From: Sean Christopherson <seanjc@google.com>
To: "Pratik R. Sampat" <prsampat@amd.com>
Cc: sashiko-reviews@lists.linux.dev, kvm@vger.kernel.org
Subject: Re: [PATCH 1/3] KVM: SVM: Re-queue events that were never injected
Date: Mon, 21 Sep 2026 09:15:25 -0700 [thread overview]
Message-ID: <arFYHRzNFT886BME@google.com> (raw)
In-Reply-To: <ecbb6fb8-fe61-4028-880b-245f94db0f9f@amd.com>
On Thu, Sep 17, 2026, Pratik R. Sampat wrote:
>
>
> On 9/14/26 1:16 PM, sashiko-bot@kernel.org wrote:
> > [You don't often get email from sashiko-bot@kernel.org. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
> >
> > Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> > - [High] svm_complete_interrupts() incorrectly checks if (control->event_inj) instead of the SVM_EVTINJ_VALID bit, which can silently drop valid hardware-reported events (like guest page faults) by clobbering EXITINTINFO.
> > --
> >
> > commit 50716e3ba11eb9d000a0186ffad984ac08df1dcb
> > Author: Pratik R. Sampat <prsampat@amd.com>
> >
> > KVM: SVM: Re-queue events that were never injected
> >
> > When injecting an event into the guest via the event_inj field, a non-zero
> > event_inj value on #VMEXIT means the hardware was unable to inject it.
> > This commit adds a check to recover potentially lost interrupts by detecting
> > an undelivered injected event and re-queuing it.
> >
> >> diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
> >> index d0971685034b9..e2be2cd86c320 100644
> >> --- a/arch/x86/kvm/svm/svm.c
> >> +++ b/arch/x86/kvm/svm/svm.c
> > [ ... ]
> >> @@ -4323,6 +4324,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.
> >> + *
> >> + * An undelivered event doesn't imply a fatal VMEXIT_INVALID. With
> >> + * 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) {
> > [Severity: High]
> > Does this code silently drop valid hardware-reported events?
> >
> > If an L1 hypervisor sets event_inj to a non-zero value but leaves the
> > SVM_EVTINJ_VALID bit clear, hardware will ignore the injection and won't
> > clear EVENTINJ.
>
>
> The first half is right, nested_svm_check_event_inj() intentionally returns
> true when V is clear, so vmcb02->control.event_inj can be non-zero with V=0.
>
> The second half isn't. Clearing EVENTINJ is not part of injection, it's part of
> #VMEXIT, and it's unconditional.
So that doesn't mesh with the above comment, which says:
Hardware clears EVENTINJ field when it injects an event.
And it begs the question of how this patch is at all useful. Because all this
fancy new paranoia is clearly generating #VMEXITs, and if #VMEXIT unconditionally
clears control->event_inj, I don't see how control->event_inj can be non-zero if
KVM attempted VMRUN.
I.e. either this is all broken, or the APM is buggy.
next prev parent reply other threads:[~2026-09-21 16:15 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-14 16:55 [PATCH 0/3] Introduce Enhanced SMT Protection for SEV-SNP Pratik R. Sampat
2026-09-14 16:55 ` [PATCH 1/3] KVM: SVM: Re-queue events that were never injected Pratik R. Sampat
2026-09-14 17:16 ` sashiko-bot
2026-09-17 15:07 ` Pratik R. Sampat
2026-09-21 16:15 ` Sean Christopherson [this message]
2026-09-22 20:45 ` Pratik R. Sampat
2026-09-21 13:16 ` Sean Christopherson
2026-09-22 20:45 ` Pratik R. Sampat
2026-09-14 16:55 ` [PATCH 2/3] KVM: SVM: Add host support for Enhanced SMT Protection Pratik R. Sampat
2026-09-14 17:13 ` sashiko-bot
2026-09-17 15:07 ` Pratik R. Sampat
2026-09-16 19:56 ` Borislav Petkov
2026-09-17 15:07 ` Pratik R. Sampat
2026-09-14 16:55 ` [PATCH 3/3] x86/sev: Add guest " Pratik R. Sampat
2026-09-14 17:11 ` sashiko-bot
2026-09-17 15:07 ` Pratik R. Sampat
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=arFYHRzNFT886BME@google.com \
--to=seanjc@google.com \
--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