KVM: Use standard CR4 flags, tighten checking
On this machine (Intel), writing to the CR4 bits 0x00000800 and 0x00001000 cause a GPF. The Intel manual is a little unclear, but AFIACT they're reserved, too. Also fix spelling of CR4_RESEVED_BITS. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Signed-off-by: Avi Kivity <avi@qumranet.com>
This commit is contained in:
committed by
Avi Kivity
parent
f802a307cb
commit
66aee91aaa
@ -23,12 +23,6 @@
|
||||
#define CR3_NONPAE_RESERVED_BITS ((PAGE_SIZE-1) & ~(X86_CR3_PWT | X86_CR3_PCD))
|
||||
#define CR3_L_MODE_RESERVED_BITS (CR3_NONPAE_RESERVED_BITS|0xFFFFFF0000000000ULL)
|
||||
|
||||
#define CR4_VME_MASK (1ULL << 0)
|
||||
#define CR4_PSE_MASK (1ULL << 4)
|
||||
#define CR4_PAE_MASK (1ULL << 5)
|
||||
#define CR4_PGE_MASK (1ULL << 7)
|
||||
#define CR4_VMXE_MASK (1ULL << 13)
|
||||
|
||||
#define KVM_GUEST_CR0_MASK \
|
||||
(X86_CR0_PG | X86_CR0_PE | X86_CR0_WP | X86_CR0_NE \
|
||||
| X86_CR0_NW | X86_CR0_CD)
|
||||
@ -36,9 +30,9 @@
|
||||
(X86_CR0_PG | X86_CR0_PE | X86_CR0_WP | X86_CR0_NE | X86_CR0_TS \
|
||||
| X86_CR0_MP)
|
||||
#define KVM_GUEST_CR4_MASK \
|
||||
(CR4_PSE_MASK | CR4_PAE_MASK | CR4_PGE_MASK | CR4_VMXE_MASK | CR4_VME_MASK)
|
||||
#define KVM_PMODE_VM_CR4_ALWAYS_ON (CR4_VMXE_MASK | CR4_PAE_MASK)
|
||||
#define KVM_RMODE_VM_CR4_ALWAYS_ON (CR4_VMXE_MASK | CR4_PAE_MASK | CR4_VME_MASK)
|
||||
(X86_CR4_VME | X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE | X86_CR4_VMXE)
|
||||
#define KVM_PMODE_VM_CR4_ALWAYS_ON (X86_CR4_PAE | X86_CR4_VMXE)
|
||||
#define KVM_RMODE_VM_CR4_ALWAYS_ON (X86_CR4_VME | X86_CR4_PAE | X86_CR4_VMXE)
|
||||
|
||||
#define INVALID_PAGE (~(hpa_t)0)
|
||||
#define UNMAPPED_GVA (~(gpa_t)0)
|
||||
@ -645,12 +639,12 @@ static inline int is_long_mode(struct kvm_vcpu *vcpu)
|
||||
|
||||
static inline int is_pae(struct kvm_vcpu *vcpu)
|
||||
{
|
||||
return vcpu->cr4 & CR4_PAE_MASK;
|
||||
return vcpu->cr4 & X86_CR4_PAE;
|
||||
}
|
||||
|
||||
static inline int is_pse(struct kvm_vcpu *vcpu)
|
||||
{
|
||||
return vcpu->cr4 & CR4_PSE_MASK;
|
||||
return vcpu->cr4 & X86_CR4_PSE;
|
||||
}
|
||||
|
||||
static inline int is_paging(struct kvm_vcpu *vcpu)
|
||||
|
Reference in New Issue
Block a user