From: sashiko-bot@kernel.org
To: "Pratik R. Sampat" <prsampat@amd.com>, kvm@vger.kernel.org
Subject: Re: [Patch v6 1/3] KVM: SVM: Re-queue events that were never injected
Date: Sat, 05 Dec 2026 22:59:28 +0000 [thread overview]
Message-ID: <sashiko-outbox-251973@kernel.org> (raw)
In-Reply-To: <d9dbf6391daef316ece8230ce836b8b1f1c6ec03.1796503783.git.prsampat@amd.com>
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] KVM: SVM: force_immediate_exit self-IPI aborts stalled ESMTP
VMRUN in a loop
- [Low] KVM: SVM: svm_complete_interrupts() clobbers VMCB exit_int_info
and event_inj
- [Low] KVM: SVM: inaccurate EVENTINJ clear comment in
svm_complete_interrupts()
--
commit 9b4d36c2e80540d699ee7d2ba230910d0fc05661
Author: Pratik R. Sampat <prsampat@amd.com>
KVM: SVM: Re-queue events that were never injected
This commit updates svm_complete_interrupts() to migrate a non-zero
control->event_inj into control->exit_int_info so undelivered events are
re-queued on pre-entry #VMEXITs, and folds svm_cancel_injection() into it.
> diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
> index 2dd05cd6b7571..1d45bcc04112c 100644
> --- a/arch/x86/kvm/svm/svm.c
> +++ b/arch/x86/kvm/svm/svm.c
[ ... ]
> @@ -4489,6 +4490,27 @@ static void svm_complete_interrupts(struct kvm_vcpu *vcpu)
> svm->nmi_l1_to_l2 = false;
> svm->soft_int_injected = false;
>
> + /*
> + * Hardware clears EVENTINJ field when it injects an event.
> + * A non-empty EVENTINJ on #VMEXIT means the vCPU never entered guest
> + * mode, and thus that the event was never delivered. Migrate the event
> + * to EXITINTINFO so that it's requeued instead of being dropped.
[Severity: Low]
As reported by Sean Christopherson on v1 [1], is this comment accurate about
when hardware clears EVENTINJ?
Per the AMD APM and commit 69b721a86d0d ("KVM: nSVM: Clear EVENTINJ fields in
vmcb12 on nested #VMEXIT"), hardware clears EVENTINJ unconditionally on
#VMEXIT out of guest mode, not when it injects an event; pre-entry exits
leave EVENTINJ intact.
> + *
> + * An undelivered event doesn't imply a fatal VMEXIT_INVALID. With
> + * SMT Protection and Enhanced SMT Protection, VMRUN may exit with an
> + * ordinary #VMEXIT without having injected that event into the guest.
> + *
> + * Clobbering EXITINTINFO is safe precisely because the vCPU never
> + * entered guest mode.
> + */
> + if (control->event_inj) {
> + control->exit_int_info = control->event_inj;
> + control->exit_int_info_err = control->event_inj_err;
> + control->event_inj = 0;
> +
> + exitintinfo = control->exit_int_info;
> + }
[Severity: Low]
Does overwriting control->exit_int_info, control->exit_int_info_err, and
control->event_inj in place corrupt the VMCB fields before svm_handle_exit()
runs?
On a failed VMRUN (SVM_EXIT_ERR), dump_vmcb() then logs event_inj as 0 and
reports the staged event under exit_int_info, obscuring VMRUN failure
diagnosis. svm_get_exit_info() also reports the synthetic exit_int_info to
downstream callers such as trace_kvm_nested_vmexit().
Passing local exitintinfo and exitintinfo_err values to a helper, similar to
__vmx_complete_interrupts(), would avoid mutating the VMCB fields.
[Severity: Medium]
As reported by Sean Christopherson on v1 [2], how is
KVM_RUN_FORCE_IMMEDIATE_EXIT supposed to work with ESMTP?
On an SEV-SNP guest (where AVIC is inhibited), two pending injectable events
make kvm_check_and_inject_events() set *req_immediate_exit, so svm_vcpu_run()
sends a physical self-IPI via smp_send_reschedule() before VMRUN.
With ESMTP enabled, that pending self-IPI immediately aborts a stalled VMRUN
with SVM_EXIT_INTR before guest entry. svm_complete_interrupts() then
requeues control->event_inj and raises KVM_REQ_EVENT, so every retry queues
another self-IPI.
The vCPU can never wait at the ESMTP synchronization point for its sibling:
it spins firing self-IPIs while the sibling is in host mode, and if both
siblings have KVM_RUN_FORCE_IMMEDIATE_EXIT set, they livelock in repeated
SVM_EXIT_INTR exits.
[1] https://lore.kernel.org/r/arFYHRzNFT886BME@google.com
[2] https://lore.kernel.org/r/arEuMojZa_kv9VXA@google.com
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1796503783.git.prsampat@amd.com?part=1
next prev parent reply other threads:[~2026-12-05 22:59 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-05 22:34 [Patch v6 0/3] Host support for SMT and Enhanced SMT Protection Pratik R. Sampat
2026-12-05 22:34 ` [Patch v6 1/3] KVM: SVM: Re-queue events that were never injected Pratik R. Sampat
2026-12-05 22:59 ` sashiko-bot [this message]
2026-12-05 22:34 ` [Patch v6 2/3] KVM: SVM: Add host support for SMT Protection Pratik R. Sampat
2026-12-05 23:03 ` sashiko-bot
2026-12-05 22:35 ` [Patch v6 3/3] KVM: SVM: Add host support for Enhanced " Pratik R. Sampat
2026-12-05 23:00 ` sashiko-bot
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=sashiko-outbox-251973@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=prsampat@amd.com \
--cc=sashiko-reviews@lists.linux.dev \
/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