11 #ifndef _ASM_X86_KVM_HOST_H
12 #define _ASM_X86_KVM_HOST_H
14 #include <linux/types.h>
22 #include <linux/kvm_para.h>
24 #include <linux/perf_event.h>
26 #include <asm/pvclock-abi.h>
32 #define KVM_MAX_VCPUS 254
33 #define KVM_SOFT_MAX_VCPUS 160
34 #define KVM_MEMORY_SLOTS 32
36 #define KVM_PRIVATE_MEM_SLOTS 4
37 #define KVM_MEM_SLOTS_NUM (KVM_MEMORY_SLOTS + KVM_PRIVATE_MEM_SLOTS)
39 #define KVM_MMIO_SIZE 16
41 #define KVM_PIO_PAGE_OFFSET 1
42 #define KVM_COALESCED_MMIO_PAGE_OFFSET 2
44 #define CR0_RESERVED_BITS \
45 (~(unsigned long)(X86_CR0_PE | X86_CR0_MP | X86_CR0_EM | X86_CR0_TS \
46 | X86_CR0_ET | X86_CR0_NE | X86_CR0_WP | X86_CR0_AM \
47 | X86_CR0_NW | X86_CR0_CD | X86_CR0_PG))
49 #define CR3_PAE_RESERVED_BITS ((X86_CR3_PWT | X86_CR3_PCD) - 1)
50 #define CR3_NONPAE_RESERVED_BITS ((PAGE_SIZE-1) & ~(X86_CR3_PWT | X86_CR3_PCD))
51 #define CR3_PCID_ENABLED_RESERVED_BITS 0xFFFFFF0000000000ULL
52 #define CR3_L_MODE_RESERVED_BITS (CR3_NONPAE_RESERVED_BITS | \
53 0xFFFFFF0000000000ULL)
54 #define CR4_RESERVED_BITS \
55 (~(unsigned long)(X86_CR4_VME | X86_CR4_PVI | X86_CR4_TSD | X86_CR4_DE\
56 | X86_CR4_PSE | X86_CR4_PAE | X86_CR4_MCE \
57 | X86_CR4_PGE | X86_CR4_PCE | X86_CR4_OSFXSR | X86_CR4_PCIDE \
58 | X86_CR4_OSXSAVE | X86_CR4_SMEP | X86_CR4_RDWRGSFS \
59 | X86_CR4_OSXMMEXCPT | X86_CR4_VMXE))
61 #define CR8_RESERVED_BITS (~(unsigned long)X86_CR8_TPR)
65 #define INVALID_PAGE (~(hpa_t)0)
66 #define VALID_PAGE(x) ((x) != INVALID_PAGE)
68 #define UNMAPPED_GVA (~(gpa_t)0)
71 #define KVM_NR_PAGE_SIZES 3
72 #define KVM_HPAGE_GFN_SHIFT(x) (((x) - 1) * 9)
73 #define KVM_HPAGE_SHIFT(x) (PAGE_SHIFT + KVM_HPAGE_GFN_SHIFT(x))
74 #define KVM_HPAGE_SIZE(x) (1UL << KVM_HPAGE_SHIFT(x))
75 #define KVM_HPAGE_MASK(x) (~(KVM_HPAGE_SIZE(x) - 1))
76 #define KVM_PAGES_PER_HPAGE(x) (KVM_HPAGE_SIZE(x) / PAGE_SIZE)
78 #define SELECTOR_TI_MASK (1 << 2)
79 #define SELECTOR_RPL_MASK 0x03
83 #define KVM_PERMILLE_MMU_PAGES 20
84 #define KVM_MIN_ALLOC_MMU_PAGES 64
85 #define KVM_MMU_HASH_SHIFT 10
86 #define KVM_NUM_MMU_PAGES (1 << KVM_MMU_HASH_SHIFT)
87 #define KVM_MIN_FREE_MMU_PAGES 5
88 #define KVM_REFILL_PAGES 25
89 #define KVM_MAX_CPUID_ENTRIES 80
90 #define KVM_NR_FIXED_MTRR_REGION 88
91 #define KVM_NR_VAR_MTRR 8
93 #define ASYNC_PF_PER_VCPU 64
146 #define KVM_NR_MEM_OBJS 40
148 #define KVM_NR_DB_REGS 4
150 #define DR6_BD (1 << 13)
151 #define DR6_BS (1 << 14)
152 #define DR6_FIXED_1 0xffff0ff0
153 #define DR6_VOLATILE 0x0000e00f
155 #define DR7_BP_EN_MASK 0x000000ff
156 #define DR7_GE (1 << 9)
157 #define DR7_GD (1 << 13)
158 #define DR7_FIXED_1 0x00000400
159 #define DR7_VOLATILE 0xffff23ff
162 #define KVM_APIC_CHECK_VAPIC 0
169 #define KVM_APIC_PV_EOI_PENDING 1
232 int clear_spte_count;
267 u64 *spte,
const void *
pte);
569 #ifdef CONFIG_KVM_MMU_AUDIT
671 unsigned char *hypercall_addr);
721 static inline void adjust_tsc_offset_guest(
struct kvm_vcpu *vcpu,
727 static inline void adjust_tsc_offset_host(
struct kvm_vcpu *vcpu,
s64 adjustment)
739 u64 dirty_mask,
u64 nx_mask,
u64 x_mask);
773 #define EMULTYPE_NO_DECODE (1 << 0)
774 #define EMULTYPE_TRAP_UD (1 << 1)
775 #define EMULTYPE_SKIP (1 << 2)
776 #define EMULTYPE_RETRY (1 << 3)
778 int emulation_type,
void *
insn,
int insn_len);
780 static inline int emulate_instruction(
struct kvm_vcpu *vcpu,
832 static inline int __kvm_irq_line_state(
unsigned long *
irq_state,
833 int irq_source_id,
int level)
841 return !!(*irq_state);
873 void *
insn,
int insn_len);
894 static inline u16 kvm_read_ldt(
void)
897 asm(
"sldt %0" :
"=g"(
ldt));
901 static inline void kvm_load_ldt(
u16 sel)
903 asm(
"lldt %0" : :
"rm"(
sel));
907 static inline unsigned long read_msr(
unsigned long msr)
916 static inline u32 get_rdx_init_val(
void)
926 #define TSS_IOPB_BASE_OFFSET 0x66
927 #define TSS_BASE_SIZE 0x68
928 #define TSS_IOPB_SIZE (65536 / 8)
929 #define TSS_REDIRECTION_SIZE (256 / 8)
930 #define RMODE_TSS_SIZE \
931 (TSS_BASE_SIZE + TSS_REDIRECTION_SIZE + TSS_IOPB_SIZE + 1)
940 #define HF_GIF_MASK (1 << 0)
941 #define HF_HIF_MASK (1 << 1)
942 #define HF_VINTR_MASK (1 << 2)
943 #define HF_NMI_MASK (1 << 3)
944 #define HF_IRET_MASK (1 << 4)
945 #define HF_GUEST_MASK (1 << 5)
955 #define ____kvm_handle_fault_on_reboot(insn, cleanup_insn) \
956 "666: " insn "\n\t" \
958 ".pushsection .fixup, \"ax\" \n" \
960 cleanup_insn "\n\t" \
961 "cmpb $0, kvm_rebooting \n\t" \
963 __ASM_SIZE(push) " $666b \n\t" \
964 "call kvm_spurious_fault \n\t" \
966 _ASM_EXTABLE(666b, 667b)
968 #define __kvm_handle_fault_on_reboot(insn) \
969 ____kvm_handle_fault_on_reboot(insn, "")
971 #define KVM_ARCH_WANT_MMU_NOTIFIER
988 struct kvm_async_pf *
work);
990 struct kvm_async_pf *
work);
992 struct kvm_async_pf *
work);