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/x86.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/x86.h')
-rw-r--r-- | drivers/kvm/x86.h | 102 |
1 files changed, 95 insertions, 7 deletions
diff --git a/drivers/kvm/x86.h b/drivers/kvm/x86.h index 0da4be9b0bad..a0dd4473b8f8 100644 --- a/drivers/kvm/x86.h +++ b/drivers/kvm/x86.h | |||
@@ -11,8 +11,6 @@ | |||
11 | #ifndef KVM_X86_H | 11 | #ifndef KVM_X86_H |
12 | #define KVM_X86_H | 12 | #define KVM_X86_H |
13 | 13 | ||
14 | #include "kvm.h" | ||
15 | |||
16 | #include <linux/types.h> | 14 | #include <linux/types.h> |
17 | #include <linux/mm.h> | 15 | #include <linux/mm.h> |
18 | 16 | ||
@@ -21,6 +19,8 @@ | |||
21 | 19 | ||
22 | #include <asm/desc.h> | 20 | #include <asm/desc.h> |
23 | 21 | ||
22 | #include "types.h" | ||
23 | |||
24 | #define CR3_PAE_RESERVED_BITS ((X86_CR3_PWT | X86_CR3_PCD) - 1) | 24 | #define CR3_PAE_RESERVED_BITS ((X86_CR3_PWT | X86_CR3_PCD) - 1) |
25 | #define CR3_NONPAE_RESERVED_BITS ((PAGE_SIZE-1) & ~(X86_CR3_PWT | X86_CR3_PCD)) | 25 | #define CR3_NONPAE_RESERVED_BITS ((PAGE_SIZE-1) & ~(X86_CR3_PWT | X86_CR3_PCD)) |
26 | #define CR3_L_MODE_RESERVED_BITS (CR3_NONPAE_RESERVED_BITS|0xFFFFFF0000000000ULL) | 26 | #define CR3_L_MODE_RESERVED_BITS (CR3_NONPAE_RESERVED_BITS|0xFFFFFF0000000000ULL) |
@@ -54,9 +54,19 @@ | |||
54 | 54 | ||
55 | #define IOPL_SHIFT 12 | 55 | #define IOPL_SHIFT 12 |
56 | 56 | ||
57 | #define KVM_PERMILLE_MMU_PAGES 20 | ||
58 | #define KVM_MIN_ALLOC_MMU_PAGES 64 | ||
59 | #define KVM_NUM_MMU_PAGES 1024 | ||
60 | #define KVM_MIN_FREE_MMU_PAGES 5 | ||
61 | #define KVM_REFILL_PAGES 25 | ||
62 | #define KVM_MAX_CPUID_ENTRIES 40 | ||
63 | |||
57 | extern spinlock_t kvm_lock; | 64 | extern spinlock_t kvm_lock; |
58 | extern struct list_head vm_list; | 65 | extern struct list_head vm_list; |
59 | 66 | ||
67 | struct kvm_vcpu; | ||
68 | struct kvm; | ||
69 | |||
60 | enum { | 70 | enum { |
61 | VCPU_REGS_RAX = 0, | 71 | VCPU_REGS_RAX = 0, |
62 | VCPU_REGS_RCX = 1, | 72 | VCPU_REGS_RCX = 1, |
@@ -92,6 +102,89 @@ enum { | |||
92 | 102 | ||
93 | #include "x86_emulate.h" | 103 | #include "x86_emulate.h" |
94 | 104 | ||
105 | #define KVM_NR_MEM_OBJS 40 | ||
106 | |||
107 | /* | ||
108 | * We don't want allocation failures within the mmu code, so we preallocate | ||
109 | * enough memory for a single page fault in a cache. | ||
110 | */ | ||
111 | struct kvm_mmu_memory_cache { | ||
112 | int nobjs; | ||
113 | void *objects[KVM_NR_MEM_OBJS]; | ||
114 | }; | ||
115 | |||
116 | #define NR_PTE_CHAIN_ENTRIES 5 | ||
117 | |||
118 | struct kvm_pte_chain { | ||
119 | u64 *parent_ptes[NR_PTE_CHAIN_ENTRIES]; | ||
120 | struct hlist_node link; | ||
121 | }; | ||
122 | |||
123 | /* | ||
124 | * kvm_mmu_page_role, below, is defined as: | ||
125 | * | ||
126 | * bits 0:3 - total guest paging levels (2-4, or zero for real mode) | ||
127 | * bits 4:7 - page table level for this shadow (1-4) | ||
128 | * bits 8:9 - page table quadrant for 2-level guests | ||
129 | * bit 16 - "metaphysical" - gfn is not a real page (huge page/real mode) | ||
130 | * bits 17:19 - common access permissions for all ptes in this shadow page | ||
131 | */ | ||
132 | union kvm_mmu_page_role { | ||
133 | unsigned word; | ||
134 | struct { | ||
135 | unsigned glevels : 4; | ||
136 | unsigned level : 4; | ||
137 | unsigned quadrant : 2; | ||
138 | unsigned pad_for_nice_hex_output : 6; | ||
139 | unsigned metaphysical : 1; | ||
140 | unsigned access : 3; | ||
141 | }; | ||
142 | }; | ||
143 | |||
144 | struct kvm_mmu_page { | ||
145 | struct list_head link; | ||
146 | struct hlist_node hash_link; | ||
147 | |||
148 | /* | ||
149 | * The following two entries are used to key the shadow page in the | ||
150 | * hash table. | ||
151 | */ | ||
152 | gfn_t gfn; | ||
153 | union kvm_mmu_page_role role; | ||
154 | |||
155 | u64 *spt; | ||
156 | /* hold the gfn of each spte inside spt */ | ||
157 | gfn_t *gfns; | ||
158 | unsigned long slot_bitmap; /* One bit set per slot which has memory | ||
159 | * in this shadow page. | ||
160 | */ | ||
161 | int multimapped; /* More than one parent_pte? */ | ||
162 | int root_count; /* Currently serving as active root */ | ||
163 | union { | ||
164 | u64 *parent_pte; /* !multimapped */ | ||
165 | struct hlist_head parent_ptes; /* multimapped, kvm_pte_chain */ | ||
166 | }; | ||
167 | }; | ||
168 | |||
169 | /* | ||
170 | * x86 supports 3 paging modes (4-level 64-bit, 3-level 64-bit, and 2-level | ||
171 | * 32-bit). The kvm_mmu structure abstracts the details of the current mmu | ||
172 | * mode. | ||
173 | */ | ||
174 | struct kvm_mmu { | ||
175 | void (*new_cr3)(struct kvm_vcpu *vcpu); | ||
176 | int (*page_fault)(struct kvm_vcpu *vcpu, gva_t gva, u32 err); | ||
177 | void (*free)(struct kvm_vcpu *vcpu); | ||
178 | gpa_t (*gva_to_gpa)(struct kvm_vcpu *vcpu, gva_t gva); | ||
179 | void (*prefetch_page)(struct kvm_vcpu *vcpu, | ||
180 | struct kvm_mmu_page *page); | ||
181 | hpa_t root_hpa; | ||
182 | int root_level; | ||
183 | int shadow_root_level; | ||
184 | |||
185 | u64 *pae_root; | ||
186 | }; | ||
187 | |||
95 | struct kvm_vcpu_arch { | 188 | struct kvm_vcpu_arch { |
96 | u64 host_tsc; | 189 | u64 host_tsc; |
97 | int interrupt_window_open; | 190 | int interrupt_window_open; |
@@ -162,11 +255,6 @@ struct kvm_vcpu_arch { | |||
162 | struct x86_emulate_ctxt emulate_ctxt; | 255 | struct x86_emulate_ctxt emulate_ctxt; |
163 | }; | 256 | }; |
164 | 257 | ||
165 | struct kvm_vcpu { | ||
166 | KVM_VCPU_COMM; | ||
167 | |||
168 | struct kvm_vcpu_arch arch; | ||
169 | }; | ||
170 | 258 | ||
171 | struct descriptor_table { | 259 | struct descriptor_table { |
172 | u16 limit; | 260 | u16 limit; |