diff options
author | Sean Christopherson <sean.j.christopherson@intel.com> | 2019-04-02 18:19:16 +0300 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2019-04-16 16:39:07 +0300 |
commit | 0a62956312e9dcd0ce5c59be4f0a8d8292a62402 (patch) | |
tree | a9587e54b5bf3e4fe9fc70e9b9c08c47909cce41 /arch/x86/kvm/x86.c | |
parent | 11988499e62b310f3bf6f6d0a807a06d3f9ccc96 (diff) | |
download | linux-0a62956312e9dcd0ce5c59be4f0a8d8292a62402.tar.xz |
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.c | 7 |
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; } |