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
@@ -764,7 +764,7 @@ static void hardware_enable(void *garbage)
|
||||
if ((old & 5) != 5)
|
||||
/* enable and lock */
|
||||
wrmsrl(MSR_IA32_FEATURE_CONTROL, old | 5);
|
||||
write_cr4(read_cr4() | CR4_VMXE); /* FIXME: not cpu hotplug safe */
|
||||
write_cr4(read_cr4() | X86_CR4_VMXE); /* FIXME: not cpu hotplug safe */
|
||||
asm volatile (ASM_VMX_VMXON_RAX : : "a"(&phys_addr), "m"(phys_addr)
|
||||
: "memory", "cc");
|
||||
}
|
||||
@@ -879,8 +879,8 @@ static void enter_pmode(struct kvm_vcpu *vcpu)
|
||||
flags |= (vcpu->rmode.save_iopl << IOPL_SHIFT);
|
||||
vmcs_writel(GUEST_RFLAGS, flags);
|
||||
|
||||
vmcs_writel(GUEST_CR4, (vmcs_readl(GUEST_CR4) & ~CR4_VME_MASK) |
|
||||
(vmcs_readl(CR4_READ_SHADOW) & CR4_VME_MASK));
|
||||
vmcs_writel(GUEST_CR4, (vmcs_readl(GUEST_CR4) & ~X86_CR4_VME) |
|
||||
(vmcs_readl(CR4_READ_SHADOW) & X86_CR4_VME));
|
||||
|
||||
update_exception_bitmap(vcpu);
|
||||
|
||||
@@ -937,7 +937,7 @@ static void enter_rmode(struct kvm_vcpu *vcpu)
|
||||
flags |= IOPL_MASK | X86_EFLAGS_VM;
|
||||
|
||||
vmcs_writel(GUEST_RFLAGS, flags);
|
||||
vmcs_writel(GUEST_CR4, vmcs_readl(GUEST_CR4) | CR4_VME_MASK);
|
||||
vmcs_writel(GUEST_CR4, vmcs_readl(GUEST_CR4) | X86_CR4_VME);
|
||||
update_exception_bitmap(vcpu);
|
||||
|
||||
vmcs_write16(GUEST_SS_SELECTOR, vmcs_readl(GUEST_SS_BASE) >> 4);
|
||||
|
Reference in New Issue
Block a user