summaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/x86.c
diff options
context:
space:
mode:
authorSean Christopherson2019-04-02 17:19:16 +0200
committerPaolo Bonzini2019-04-16 15:39:07 +0200
commit0a62956312e9dcd0ce5c59be4f0a8d8292a62402 (patch)
treea9587e54b5bf3e4fe9fc70e9b9c08c47909cce41 /arch/x86/kvm/x86.c
parentKVM: x86: Skip EFER vs. guest CPUID checks for host-initiated writes (diff)
downloadkernel-qcow2-linux-0a62956312e9dcd0ce5c59be4f0a8d8292a62402.tar.gz
kernel-qcow2-linux-0a62956312e9dcd0ce5c59be4f0a8d8292a62402.tar.xz
kernel-qcow2-linux-0a62956312e9dcd0ce5c59be4f0a8d8292a62402.zip
KVM: x86: Inject #GP if guest attempts to set unsupported EFER bits
EFER.LME and EFER.NX are considered reserved if their respective feature bits are not advertised to the guest. Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'arch/x86/kvm/x86.c')
-rw-r--r--arch/x86/kvm/x86.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 5d7dcd06d08a..38440316a806 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -1266,6 +1266,13 @@ static bool __kvm_valid_efer(struct kvm_vcpu *vcpu, u64 efer)
if (efer & EFER_SVME && !guest_cpuid_has(vcpu, X86_FEATURE_SVM))
return false;
+ if (efer & (EFER_LME | EFER_LMA) &&
+ !guest_cpuid_has(vcpu, X86_FEATURE_LM))
+ return false;
+
+ if (efer & EFER_NX && !guest_cpuid_has(vcpu, X86_FEATURE_NX))
+ return false;
+
return true;
}