From: Sean Christopherson <seanjc@google.com>
To: Sean Christopherson <seanjc@google.com>,
Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
Maxim Levitsky <mlevitsk@redhat.com>
Subject: [PATCH 0/2] KVM: x86: Fix RM exception injection bugs
Date: Wed, 22 Mar 2023 07:32:58 -0700 [thread overview]
Message-ID: <20230322143300.2209476-1-seanjc@google.com> (raw)
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:
diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
index bcac3efcde41..ef3bb5ab9654 100644
--- a/arch/x86/kvm/vmx/vmx.c
+++ b/arch/x86/kvm/vmx/vmx.c
@@ -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
--
2.40.0.rc2.332.ga46443480c-goog
next reply other threads:[~2023-03-22 14:33 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-22 14:32 Sean Christopherson [this message]
2023-03-22 14:32 ` [PATCH 1/2] KVM: x86: Clear "has_error_code", not "error_code", for RM exception injection Sean Christopherson
2023-03-22 14:33 ` [PATCH 2/2] KVM: nVMX: Do not report error code when synthesizing VM-Exit from Real Mode Sean Christopherson
2023-03-27 14:15 ` [PATCH 0/2] KVM: x86: Fix RM exception injection bugs Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230322143300.2209476-1-seanjc@google.com \
--to=seanjc@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mlevitsk@redhat.com \
--cc=pbonzini@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®