From: "Pratik R. Sampat" <prsampat@amd.com>
To: sashiko-reviews@lists.linux.dev
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH 1/3] KVM: SVM: Re-queue events that were never injected
Date: Thu, 17 Sep 2026 11:07:23 -0400 [thread overview]
Message-ID: <ecbb6fb8-fe61-4028-880b-245f94db0f9f@amd.com> (raw)
In-Reply-To: <20260914171628.8A4631F00893@smtp.kernel.org>
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. APM vol 3, VMRUN:
Upon #VMEXIT, the processor performs the following actions in order to
return to the host execution context:
...
EXITINTINFO
clear EVENTINJ field in VMCB
KVM already relies on this, nested_svm_vmexit_update_vmcb12() zeroes vmcb12's
EVENTINJ rather than propagating vmcb02's, citing the same thing.
>
> If a genuine exception occurs in the L2 guest that populates EXITINTINFO,
> this check incorrectly evaluates to true since event_inj is non-zero.
>
> This causes EXITINTINFO to be clobbered with the L1's invalid event_inj
> data. Because the clobbered value lacks the VALID bit, KVM will then ignore
> it and drop the event.
>
> Should this code check the SVM_EVTINJ_VALID bit instead of checking for a
> non-zero event_inj value?
I believe we don't need to since the valid check is made later below.
-- Pratik
>
>> + 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;
>> + }
>> +
>
> --
> Sashiko AI review · https://sashiko.dev/#/patchset/cover.1789399214.git.prsampat@amd.com?part=1
next prev parent reply other threads:[~2026-09-17 15:07 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 [this message]
2026-09-21 16:15 ` Sean Christopherson
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=ecbb6fb8-fe61-4028-880b-245f94db0f9f@amd.com \
--to=prsampat@amd.com \
--cc=kvm@vger.kernel.org \
--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