2 * Kernel-based Virtual Machine driver for Linux
4 * This header defines architecture specific interfaces, x86 version
6 * This work is licensed under the terms of the GNU GPL, version 2. See
7 * the COPYING file in the top-level directory.
16 #include <linux/types.h>
19 #include <linux/kvm.h>
20 #include <linux/kvm_para.h>
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() */
36 u64 pdptrs
[4]; /* pae */
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
47 u64 ia32_misc_enable_msr
;
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
;
56 gfn_t last_pt_write_gfn
;
57 int last_pt_write_count
;
58 u64
*last_pte_updated
;
61 struct i387_fxsave_struct host_fx_image
;
62 struct i387_fxsave_struct guest_fx_image
;
65 struct kvm_pio_request pio
;
71 struct kvm_save_segment
{
78 int halt_request
; /* real mode on Intel only */
81 struct kvm_cpuid_entry cpuid_entries
[KVM_MAX_CPUID_ENTRIES
];
85 struct x86_emulate_ctxt emulate_ctxt
;
88 int kvm_mmu_page_fault(struct kvm_vcpu
*vcpu
, gva_t gva
, u32 error_code
);
90 static inline void kvm_mmu_free_some_pages(struct kvm_vcpu
*vcpu
)
92 if (unlikely(vcpu
->kvm
->n_free_mmu_pages
< KVM_MIN_FREE_MMU_PAGES
))
93 __kvm_mmu_free_some_pages(vcpu
);
96 static inline int kvm_mmu_reload(struct kvm_vcpu
*vcpu
)
98 if (likely(vcpu
->mmu
.root_hpa
!= INVALID_PAGE
))
101 return kvm_mmu_load(vcpu
);
104 static inline int is_long_mode(struct kvm_vcpu
*vcpu
)
107 return vcpu
->shadow_efer
& EFER_LME
;
113 static inline int is_pae(struct kvm_vcpu
*vcpu
)
115 return vcpu
->cr4
& X86_CR4_PAE
;
118 static inline int is_pse(struct kvm_vcpu
*vcpu
)
120 return vcpu
->cr4
& X86_CR4_PSE
;
123 static inline int is_paging(struct kvm_vcpu
*vcpu
)
125 return vcpu
->cr0
& X86_CR0_PG
;
128 int load_pdptrs(struct kvm_vcpu
*vcpu
, unsigned long cr3
);
129 int complete_pio(struct kvm_vcpu
*vcpu
);