Skip to content

Commit

Permalink
KVM: x86: Inject #GP if guest attempts to set unsupported EFER bits
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Sean Christopherson authored and Paolo Bonzini committed Apr 16, 2019
1 parent 1198849 commit 0a62956
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions arch/x86/kvm/x86.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

}
Expand Down

0 comments on commit 0a62956

Please sign in to comment.