diff options
author | Zhang Xiantao <xiantao.zhang@intel.com> | 2007-10-20 03:34:38 -0400 |
---|---|---|
committer | Avi Kivity <avi@qumranet.com> | 2008-01-30 10:52:54 -0500 |
commit | 34c16eecf78ed4cf01f39ac7211f5b57942ec899 (patch) | |
tree | 9a9d6192db411cc3c7ff665cc94a8797eb55aa80 /drivers/kvm/x86.h | |
parent | 8d4e1288ebb753d3140d81cb349f22b0a6829a4a (diff) |
KVM: Portability: Split kvm_vcpu into arch dependent and independent parts (part 1)
First step to split kvm_vcpu. Currently, we just use an macro to define
the common fields in kvm_vcpu for all archs, and all archs need to define
its own kvm_vcpu struct.
Signed-off-by: Zhang Xiantao <xiantao.zhang@intel.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'drivers/kvm/x86.h')
-rw-r--r-- | drivers/kvm/x86.h | 117 |
1 files changed, 117 insertions, 0 deletions
diff --git a/drivers/kvm/x86.h b/drivers/kvm/x86.h index 1e2f71bd805d..01452b552db3 100644 --- a/drivers/kvm/x86.h +++ b/drivers/kvm/x86.h | |||
@@ -13,4 +13,121 @@ | |||
13 | 13 | ||
14 | #include "kvm.h" | 14 | #include "kvm.h" |
15 | 15 | ||
16 | #include <linux/types.h> | ||
17 | #include <linux/mm.h> | ||
18 | |||
19 | #include <linux/kvm.h> | ||
20 | #include <linux/kvm_para.h> | ||
21 | |||
22 | struct kvm_vcpu { | ||
23 | KVM_VCPU_COMM; | ||
24 | u64 host_tsc; | ||
25 | int interrupt_window_open; | ||
26 | unsigned long irq_summary; /* bit vector: 1 per word in irq_pending */ | ||
27 | DECLARE_BITMAP(irq_pending, KVM_NR_INTERRUPTS); | ||
28 | unsigned long regs[NR_VCPU_REGS]; /* for rsp: vcpu_load_rsp_rip() */ | ||
29 | unsigned long rip; /* needs vcpu_load_rsp_rip() */ | ||
30 | |||
31 | unsigned long cr0; | ||
32 | unsigned long cr2; | ||
33 | unsigned long cr3; | ||
34 | unsigned long cr4; | ||
35 | unsigned long cr8; | ||
36 | u64 pdptrs[4]; /* pae */ | ||
37 | u64 shadow_efer; | ||
38 | u64 apic_base; | ||
39 | struct kvm_lapic *apic; /* kernel irqchip context */ | ||
40 | #define VCPU_MP_STATE_RUNNABLE 0 | ||
41 | #define VCPU_MP_STATE_UNINITIALIZED 1 | ||
42 | #define VCPU_MP_STATE_INIT_RECEIVED 2 | ||
43 | #define VCPU_MP_STATE_SIPI_RECEIVED 3 | ||
44 | #define VCPU_MP_STATE_HALTED 4 | ||
45 | int mp_state; | ||
46 | int sipi_vector; | ||
47 | u64 ia32_misc_enable_msr; | ||
48 | |||
49 | struct kvm_mmu mmu; | ||
50 | |||
51 | struct kvm_mmu_memory_cache mmu_pte_chain_cache; | ||
52 | struct kvm_mmu_memory_cache mmu_rmap_desc_cache; | ||
53 | struct kvm_mmu_memory_cache mmu_page_cache; | ||
54 | struct kvm_mmu_memory_cache mmu_page_header_cache; | ||
55 | |||
56 | gfn_t last_pt_write_gfn; | ||
57 | int last_pt_write_count; | ||
58 | u64 *last_pte_updated; | ||
59 | |||
60 | |||
61 | struct i387_fxsave_struct host_fx_image; | ||
62 | struct i387_fxsave_struct guest_fx_image; | ||
63 | |||
64 | gva_t mmio_fault_cr2; | ||
65 | struct kvm_pio_request pio; | ||
66 | void *pio_data; | ||
67 | |||
68 | struct { | ||
69 | int active; | ||
70 | u8 save_iopl; | ||
71 | struct kvm_save_segment { | ||
72 | u16 selector; | ||
73 | unsigned long base; | ||
74 | u32 limit; | ||
75 | u32 ar; | ||
76 | } tr, es, ds, fs, gs; | ||
77 | } rmode; | ||
78 | int halt_request; /* real mode on Intel only */ | ||
79 | |||
80 | int cpuid_nent; | ||
81 | struct kvm_cpuid_entry cpuid_entries[KVM_MAX_CPUID_ENTRIES]; | ||
82 | |||
83 | /* emulate context */ | ||
84 | |||
85 | struct x86_emulate_ctxt emulate_ctxt; | ||
86 | }; | ||
87 | |||
88 | static inline int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gva_t gva, | ||
89 | u32 error_code) | ||
90 | { | ||
91 | return vcpu->mmu.page_fault(vcpu, gva, error_code); | ||
92 | } | ||
93 | |||
94 | static inline void kvm_mmu_free_some_pages(struct kvm_vcpu *vcpu) | ||
95 | { | ||
96 | if (unlikely(vcpu->kvm->n_free_mmu_pages < KVM_MIN_FREE_MMU_PAGES)) | ||
97 | __kvm_mmu_free_some_pages(vcpu); | ||
98 | } | ||
99 | |||
100 | static inline int kvm_mmu_reload(struct kvm_vcpu *vcpu) | ||
101 | { | ||
102 | if (likely(vcpu->mmu.root_hpa != INVALID_PAGE)) | ||
103 | return 0; | ||
104 | |||
105 | return kvm_mmu_load(vcpu); | ||
106 | } | ||
107 | |||
108 | static inline int is_long_mode(struct kvm_vcpu *vcpu) | ||
109 | { | ||
110 | #ifdef CONFIG_X86_64 | ||
111 | return vcpu->shadow_efer & EFER_LME; | ||
112 | #else | ||
113 | return 0; | ||
114 | #endif | ||
115 | } | ||
116 | |||
117 | static inline int is_pae(struct kvm_vcpu *vcpu) | ||
118 | { | ||
119 | return vcpu->cr4 & X86_CR4_PAE; | ||
120 | } | ||
121 | |||
122 | static inline int is_pse(struct kvm_vcpu *vcpu) | ||
123 | { | ||
124 | return vcpu->cr4 & X86_CR4_PSE; | ||
125 | } | ||
126 | |||
127 | static inline int is_paging(struct kvm_vcpu *vcpu) | ||
128 | { | ||
129 | return vcpu->cr0 & X86_CR0_PG; | ||
130 | } | ||
131 | |||
132 | |||
16 | #endif | 133 | #endif |