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, syzbot@google.com
Subject: [PATCH 2/2] KVM: VMX: Dedup VM-Enter error handling for VM-Fail and VM-Exit
Date: Thu, 22 Oct 2026 12:05:30 -0700 [thread overview]
Message-ID: <20261022190530.541789-3-seanjc@google.com> (raw)
In-Reply-To: <20261022190530.541789-1-seanjc@google.com>
Dedup the error handling code for failed VM-Entry as the only difference
between the VM-Fail and VM-Exit cases is the source of the failure reason.
Other than clearing vmx->fail on a VM-Exit failure, which should be a nop
absent other bugs, no functional change intended.
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
arch/x86/kvm/vmx/vmx.c | 14 +++-----------
1 file changed, 3 insertions(+), 11 deletions(-)
diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
index 29aa93cea963..a15cdad5c06a 100644
--- a/arch/x86/kvm/vmx/vmx.c
+++ b/arch/x86/kvm/vmx/vmx.c
@@ -6741,21 +6741,13 @@ int vmx_handle_exit(struct kvm_vcpu *vcpu, fastpath_t exit_fastpath)
if (vmx->vt.emulation_required)
return handle_invalid_guest_state(vcpu);
- if (exit_reason.failed_vmentry) {
+ if (exit_reason.failed_vmentry || unlikely(vmx->fail)) {
dump_vmcs(vcpu);
vcpu->run->exit_reason = KVM_EXIT_FAIL_ENTRY;
- vcpu->run->fail_entry.hardware_entry_failure_reason
- = exit_reason.full;
+ vcpu->run->fail_entry.hardware_entry_failure_reason =
+ vmx->fail ? vmcs_read32(VM_INSTRUCTION_ERROR) : exit_reason.full;
vcpu->run->fail_entry.cpu = vcpu->arch.last_vmentry_cpu;
- return 0;
- }
- if (unlikely(vmx->fail)) {
- dump_vmcs(vcpu);
- vcpu->run->exit_reason = KVM_EXIT_FAIL_ENTRY;
- vcpu->run->fail_entry.hardware_entry_failure_reason
- = vmcs_read32(VM_INSTRUCTION_ERROR);
- vcpu->run->fail_entry.cpu = vcpu->arch.last_vmentry_cpu;
vmx->fail = 0;
return 0;
}
--
2.56.0.257.gf7497c7d27-goog
prev parent reply other threads:[~2026-10-22 19:05 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-22 19:05 [PATCH 0/2] KVM: VMX: Clear vmx->fail on exit to userspace Sean Christopherson
2026-10-22 19:05 ` [PATCH 1/2] KVM: VMX: Clear vmx->fail before exiting to userspace on failed VM-Enter Sean Christopherson
2026-10-22 19:05 ` Sean Christopherson [this message]
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=20261022190530.541789-3-seanjc@google.com \
--to=seanjc@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=syzbot@google.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®