diff options
author | Nadav Har'El <nyh@il.ibm.com> | 2011-05-25 16:03:24 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2011-07-12 04:45:10 -0400 |
commit | 5e1746d6205d1efa3193cc0c67aa2d15e54799bd (patch) | |
tree | 9234ab8fddb5e7a8d86b506a19d7697566d51cfb /arch/x86/kvm/x86.c | |
parent | ec378aeef9dfc7c4ba72e9bd6cd4bd6f7d5fd0cc (diff) |
KVM: nVMX: Allow setting the VMXE bit in CR4
This patch allows the guest to enable the VMXE bit in CR4, which is a
prerequisite to running VMXON.
Whether to allow setting the VMXE bit now depends on the architecture (svm
or vmx), so its checking has moved to kvm_x86_ops->set_cr4(). This function
now returns an int: If kvm_x86_ops->set_cr4() returns 1, __kvm_set_cr4()
will also return 1, and this will cause kvm_set_cr4() will throw a #GP.
Turning on the VMXE bit is allowed only when the nested VMX feature is
enabled, and turning it off is forbidden after a vmxon.
Signed-off-by: Nadav Har'El <nyh@il.ibm.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Diffstat (limited to 'arch/x86/kvm/x86.c')
-rw-r--r-- | arch/x86/kvm/x86.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index d88de565d0c0..460932b62c5b 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c | |||
@@ -615,11 +615,9 @@ int kvm_set_cr4(struct kvm_vcpu *vcpu, unsigned long cr4) | |||
615 | kvm_read_cr3(vcpu))) | 615 | kvm_read_cr3(vcpu))) |
616 | return 1; | 616 | return 1; |
617 | 617 | ||
618 | if (cr4 & X86_CR4_VMXE) | 618 | if (kvm_x86_ops->set_cr4(vcpu, cr4)) |
619 | return 1; | 619 | return 1; |
620 | 620 | ||
621 | kvm_x86_ops->set_cr4(vcpu, cr4); | ||
622 | |||
623 | if ((cr4 ^ old_cr4) & pdptr_bits) | 621 | if ((cr4 ^ old_cr4) & pdptr_bits) |
624 | kvm_mmu_reset_context(vcpu); | 622 | kvm_mmu_reset_context(vcpu); |
625 | 623 | ||