diff options
author | Zhang Xiantao <xiantao.zhang@intel.com> | 2007-12-13 20:41:22 -0500 |
---|---|---|
committer | Avi Kivity <avi@qumranet.com> | 2008-01-30 10:58:09 -0500 |
commit | d657a98e3c20537d8b4d44aef51cf4311d96f2b0 (patch) | |
tree | cf1e1e2e3c0d05617ab6baf5c017987708a55d41 /drivers/kvm/kvm.h | |
parent | 1d737c8a68736db36e0aa502ace9da240704c5ae (diff) |
KVM: Portability: Move kvm_vcpu definition back to kvm.h
This patches moves kvm_vcpu definition to kvm.h, and finally
kvm.h includes x86.h.
Signed-off-by: Zhang Xiantao <xiantao.zhang@intel.com>
Acked-by: Carsten Otte <cotte@de.ibm.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'drivers/kvm/kvm.h')
-rw-r--r-- | drivers/kvm/kvm.h | 113 |
1 files changed, 8 insertions, 105 deletions
diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h index c040bb3ac819..53717be80bbe 100644 --- a/drivers/kvm/kvm.h +++ b/drivers/kvm/kvm.h | |||
@@ -22,17 +22,13 @@ | |||
22 | 22 | ||
23 | #include "types.h" | 23 | #include "types.h" |
24 | 24 | ||
25 | #include "x86.h" | ||
26 | |||
25 | #define KVM_MAX_VCPUS 4 | 27 | #define KVM_MAX_VCPUS 4 |
26 | #define KVM_ALIAS_SLOTS 4 | 28 | #define KVM_ALIAS_SLOTS 4 |
27 | #define KVM_MEMORY_SLOTS 8 | 29 | #define KVM_MEMORY_SLOTS 8 |
28 | /* memory slots that does not exposed to userspace */ | 30 | /* memory slots that does not exposed to userspace */ |
29 | #define KVM_PRIVATE_MEM_SLOTS 4 | 31 | #define KVM_PRIVATE_MEM_SLOTS 4 |
30 | #define KVM_PERMILLE_MMU_PAGES 20 | ||
31 | #define KVM_MIN_ALLOC_MMU_PAGES 64 | ||
32 | #define KVM_NUM_MMU_PAGES 1024 | ||
33 | #define KVM_MIN_FREE_MMU_PAGES 5 | ||
34 | #define KVM_REFILL_PAGES 25 | ||
35 | #define KVM_MAX_CPUID_ENTRIES 40 | ||
36 | 32 | ||
37 | #define KVM_PIO_PAGE_OFFSET 1 | 33 | #define KVM_PIO_PAGE_OFFSET 1 |
38 | 34 | ||
@@ -41,111 +37,16 @@ | |||
41 | */ | 37 | */ |
42 | #define KVM_REQ_TLB_FLUSH 0 | 38 | #define KVM_REQ_TLB_FLUSH 0 |
43 | 39 | ||
44 | #define NR_PTE_CHAIN_ENTRIES 5 | ||
45 | |||
46 | struct kvm_pte_chain { | ||
47 | u64 *parent_ptes[NR_PTE_CHAIN_ENTRIES]; | ||
48 | struct hlist_node link; | ||
49 | }; | ||
50 | |||
51 | /* | ||
52 | * kvm_mmu_page_role, below, is defined as: | ||
53 | * | ||
54 | * bits 0:3 - total guest paging levels (2-4, or zero for real mode) | ||
55 | * bits 4:7 - page table level for this shadow (1-4) | ||
56 | * bits 8:9 - page table quadrant for 2-level guests | ||
57 | * bit 16 - "metaphysical" - gfn is not a real page (huge page/real mode) | ||
58 | * bits 17:19 - common access permissions for all ptes in this shadow page | ||
59 | */ | ||
60 | union kvm_mmu_page_role { | ||
61 | unsigned word; | ||
62 | struct { | ||
63 | unsigned glevels : 4; | ||
64 | unsigned level : 4; | ||
65 | unsigned quadrant : 2; | ||
66 | unsigned pad_for_nice_hex_output : 6; | ||
67 | unsigned metaphysical : 1; | ||
68 | unsigned access : 3; | ||
69 | }; | ||
70 | }; | ||
71 | |||
72 | struct kvm_mmu_page { | ||
73 | struct list_head link; | ||
74 | struct hlist_node hash_link; | ||
75 | |||
76 | /* | ||
77 | * The following two entries are used to key the shadow page in the | ||
78 | * hash table. | ||
79 | */ | ||
80 | gfn_t gfn; | ||
81 | union kvm_mmu_page_role role; | ||
82 | |||
83 | u64 *spt; | ||
84 | /* hold the gfn of each spte inside spt */ | ||
85 | gfn_t *gfns; | ||
86 | unsigned long slot_bitmap; /* One bit set per slot which has memory | ||
87 | * in this shadow page. | ||
88 | */ | ||
89 | int multimapped; /* More than one parent_pte? */ | ||
90 | int root_count; /* Currently serving as active root */ | ||
91 | union { | ||
92 | u64 *parent_pte; /* !multimapped */ | ||
93 | struct hlist_head parent_ptes; /* multimapped, kvm_pte_chain */ | ||
94 | }; | ||
95 | }; | ||
96 | 40 | ||
97 | struct kvm_vcpu; | 41 | struct kvm_vcpu; |
98 | extern struct kmem_cache *kvm_vcpu_cache; | 42 | extern struct kmem_cache *kvm_vcpu_cache; |
99 | 43 | ||
100 | /* | ||
101 | * x86 supports 3 paging modes (4-level 64-bit, 3-level 64-bit, and 2-level | ||
102 | * 32-bit). The kvm_mmu structure abstracts the details of the current mmu | ||
103 | * mode. | ||
104 | */ | ||
105 | struct kvm_mmu { | ||
106 | void (*new_cr3)(struct kvm_vcpu *vcpu); | ||
107 | int (*page_fault)(struct kvm_vcpu *vcpu, gva_t gva, u32 err); | ||
108 | void (*free)(struct kvm_vcpu *vcpu); | ||
109 | gpa_t (*gva_to_gpa)(struct kvm_vcpu *vcpu, gva_t gva); | ||
110 | void (*prefetch_page)(struct kvm_vcpu *vcpu, | ||
111 | struct kvm_mmu_page *page); | ||
112 | hpa_t root_hpa; | ||
113 | int root_level; | ||
114 | int shadow_root_level; | ||
115 | |||
116 | u64 *pae_root; | ||
117 | }; | ||
118 | |||
119 | #define KVM_NR_MEM_OBJS 40 | ||
120 | |||
121 | /* | ||
122 | * We don't want allocation failures within the mmu code, so we preallocate | ||
123 | * enough memory for a single page fault in a cache. | ||
124 | */ | ||
125 | struct kvm_mmu_memory_cache { | ||
126 | int nobjs; | ||
127 | void *objects[KVM_NR_MEM_OBJS]; | ||
128 | }; | ||
129 | |||
130 | struct kvm_guest_debug { | 44 | struct kvm_guest_debug { |
131 | int enabled; | 45 | int enabled; |
132 | unsigned long bp[4]; | 46 | unsigned long bp[4]; |
133 | int singlestep; | 47 | int singlestep; |
134 | }; | 48 | }; |
135 | 49 | ||
136 | struct kvm_pio_request { | ||
137 | unsigned long count; | ||
138 | int cur_count; | ||
139 | struct page *guest_pages[2]; | ||
140 | unsigned guest_page_offset; | ||
141 | int in; | ||
142 | int port; | ||
143 | int size; | ||
144 | int string; | ||
145 | int down; | ||
146 | int rep; | ||
147 | }; | ||
148 | |||
149 | struct kvm_vcpu_stat { | 50 | struct kvm_vcpu_stat { |
150 | u32 pf_fixed; | 51 | u32 pf_fixed; |
151 | u32 pf_guest; | 52 | u32 pf_guest; |
@@ -218,6 +119,12 @@ void kvm_io_bus_register_dev(struct kvm_io_bus *bus, | |||
218 | struct kvm_vcpu_stat stat; \ | 119 | struct kvm_vcpu_stat stat; \ |
219 | KVM_VCPU_MMIO | 120 | KVM_VCPU_MMIO |
220 | 121 | ||
122 | struct kvm_vcpu { | ||
123 | KVM_VCPU_COMM; | ||
124 | |||
125 | struct kvm_vcpu_arch arch; | ||
126 | }; | ||
127 | |||
221 | struct kvm_mem_alias { | 128 | struct kvm_mem_alias { |
222 | gfn_t base_gfn; | 129 | gfn_t base_gfn; |
223 | unsigned long npages; | 130 | unsigned long npages; |
@@ -441,8 +348,4 @@ struct kvm_stats_debugfs_item { | |||
441 | }; | 348 | }; |
442 | extern struct kvm_stats_debugfs_item debugfs_entries[]; | 349 | extern struct kvm_stats_debugfs_item debugfs_entries[]; |
443 | 350 | ||
444 | #if defined(CONFIG_X86) | ||
445 | #include "x86.h" | ||
446 | #endif | ||
447 | |||
448 | #endif | 351 | #endif |