Skip to contentSkip to conversation

KVM: SVM: Remove bogus WARN and emulation if guest #GPs with EFER.SVME=1

PATCH In review Sean Christopherson 2 participants 2 messages Feb 4, 2021

Subsystems (3)
lore
Share & tools
lore

Sean Christopherson

author maintainer
#0 lore raw

PATCH 1/1 KVM: SVM: Remove bogus WARN and emulation if guest #GPs with EFER.SVME=1

Immediately reinject #GP (if intercepted) if the VMware backdoor is disabled and the instruction is not affected by the erratum that causes bogus #GPs on SVM instructions. It is completely reasonable for the guest to take a #GP(0) with EFER.SVME=1, e.g. when probing an MSR, and attempting emulation on an unknown instruction is obviously not good.

Fixes b3f4e11adc7d ("KVM: SVM: Add emulation support for #GP triggered by SVM instructions")
Cc Bandan Das <[email protected]>
Cc Maxim Levitsky <[email protected]>
---
 arch/x86/kvm/svm/svm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/kvm/svm/svm.c +2 -1
index f53e6377a933..707a2f85bcc6 100644
@@ -2263,7 +2263,8 @@ static int gp_interception(struct vcpu_svm *svm)
 	opcode = svm_instr_opcode(vcpu);
 
 	if (opcode == NONE_SVM_INSTR) {
-		WARN_ON_ONCE(!enable_vmware_backdoor);
+		if (!enable_vmware_backdoor)
+			goto reinject;
 
 		/*
 		 * VMware backdoor emulation on #GP interception only handles
Signature · 1 line
2.30.0.365.g02bc693789-goog
maintainer
#1 lore raw
Quoted 20 lines · Sean Christopherson

Immediately reinject #GP (if intercepted) if the VMware backdoor is disabled and the instruction is not affected by the erratum that causes bogus #GPs on SVM instructions. It is completely reasonable for the guest to take a #GP(0) with EFER.SVME=1, e.g. when probing an MSR, and attempting emulation on an unknown instruction is obviously not good.

Fixes b3f4e11adc7d ("KVM: SVM: Add emulation support for #GP triggered by SVM instructions")
Cc Bandan Das <[email protected]>
Cc Maxim Levitsky <[email protected]>
---
  arch/x86/kvm/svm/svm.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/kvm/svm/svm.c +0 -0
index f53e6377a933..707a2f85bcc6 100644

arch/x86/kvm/svm/svm.c static int gp_interception(struct vcpu_svm *svm) · line 2270

Quoted 9 lines
arch/x86/kvm/svm/svm.c +2 -1
@@ -2263,7 +2263,8 @@ static int gp_interception(struct vcpu_svm *svm)
  	opcode = svm_instr_opcode(vcpu);
 
  	if (opcode == NONE_SVM_INSTR) {
-		WARN_ON_ONCE(!enable_vmware_backdoor);
+		if (!enable_vmware_backdoor)
+			goto reinject;
 
  		/*
  		 * VMware backdoor emulation on #GP interception only handles

Squashed, thanks.

Paolo