Skip to content

KVM: x86: Fix RM exception injection bugs

Sean Christopherson kvm lkml 1 version Applied

Status from this message: Queued, thanks.

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 1 replyApplied

Patches in v1 Applied

#Subject and filesSizeRepliesApplied
1/2KVM: x86: Clear "has_error_code", not "error_code", for RM exception injectionarch/x86/kvm/x86.c+9 -20 replies
2/2KVM: nVMX: Do not report error code when synthesizing VM-Exit from Real Modearch/x86/kvm/vmx/nested.c+6 -10 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/2] KVM: x86: Fix RM exception injection bugs

Fix two bugs introduced by a semi-recent fix for AMD's Page Real Mode.

Patch 1 was tested against the syzkaller testcase that exposed the bug[*].

Patch 2 was testing by enabling the VMware backdoor in L1 to turn on #GP interception, hacking L0 KVM to passthrough MSR_IA32_VMX_BASIC to L1 and then writing the MSR from L2 while in Real Mode, thus forcing L0 KVM to emulate the WRMSR from L2 and synthesiz a #GP VM-Exit into L1. Confirmed that bad behavior in L1 with an assertion:

arch/x86/kvm/vmx/vmx.c +3 -0
index bcac3efcde41..ef3bb5ab9654 100644
@@ -5178,6 +5178,9 @@ static int handle_exception_nmi(struct kvm_vcpu *vcpu)
        vect_info = vmx->idt_vectoring_info;
        intr_info = vmx_get_intr_info(vcpu);
 
+       WARN_ONCE((intr_info & INTR_INFO_DELIVER_CODE_MASK) && !is_protmode(vcpu),
+                 "Exception VM-Exit shouldn't report error code when CPU is in Real Mode");
+
        /*
         * Machine checks are handled by handle_exception_irqoff(), or by
         * vmx_vcpu_run() if a #MC occurs on VM-Entry.  NMIs are handled by

[*] https://lkml.kernel.org/r/ZBNrWZQhMX8AHzWM%40google.com

Sean Christopherson (2):
KVM: x86: Clear "has_error_code", not "error_code", for RM exception
injection
KVM: nVMX: Do not report error code when synthesizing VM-Exit from
Real Mode

 arch/x86/kvm/vmx/nested.c |  7 ++++++-
 arch/x86/kvm/x86.c        | 11 +++++++++--
 2 files changed, 15 insertions(+), 3 deletions(-)

base-commit: 45dd9bc75d9adc9483f0c7d662ba6e73ed698a0b

Signature · 1 line
2.40.0.rc2.332.ga46443480c-goog