From: Sean Christopherson Date: Tue, 2 Apr 2019 15:19:16 +0000 (-0700) Subject: KVM: x86: Inject #GP if guest attempts to set unsupported EFER bits X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=0a62956312e9dcd0ce5c59be4f0a8d8292a62402;p=openwrt%2Fstaging%2Fblogic.git 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 Signed-off-by: Paolo Bonzini --- 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; }