All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: sashiko-reviews@lists.linux.dev
Cc: Nicholas Dudar <main.kalliope@gmail.com>, kvm@vger.kernel.org
Subject: Re: [PATCH v2 6.1.y 1/3] KVM: nVMX: Add a helper to get highest pending from Posted Interrupt vector
Date: Mon, 22 Jun 2026 18:47:15 -0700	[thread overview]
Message-ID: <ajnlo3vf-Qcai0jz@google.com> (raw)
In-Reply-To: <20260619204642.F1A691F000E9@smtp.kernel.org>

On Fri, Jun 19, 2026, sashiko-bot@kernel.org wrote:
> > diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
> > index bdc462944cb08..7d8e18dbe8531 100644
> > --- a/arch/x86/kvm/vmx/nested.c
> > +++ b/arch/x86/kvm/vmx/nested.c
> [ ... ]
> > @@ -3818,8 +3819,8 @@ static int vmx_complete_nested_posted_interrupt(struct kvm_vcpu *vcpu)
> >  	if (!pi_test_and_clear_on(vmx->nested.pi_desc))
> >  		return 0;
> >  
> > -	max_irr = find_last_bit((unsigned long *)vmx->nested.pi_desc->pir, 256);
> > -	if (max_irr != 256) {
> > +	max_irr = pi_find_highest_vector(vmx->nested.pi_desc);
> > +	if (max_irr > 0) {
> 
> [Severity: Medium]
> Does this condition inadvertently skip vector 0?

No, it deliberately skips vector 0.

> The commit message states that pi_find_highest_vector() returns -1 to indicate
> no interrupt pending, so max_irr can be -1 or 0-255. By checking max_irr > 0,
> the code skips processing if vector 0 is the highest pending interrupt.
> 
> While vector 0 is an invalid APIC interrupt that hardware typically ignores,
> skipping it here means KVM does not call __kvm_apic_update_irr(). As a result,
> vector 0 could remain stuck in the PIR array instead of being cleared, which
> diverges from the lockless PIR/ON protocol.
> 
> Should this condition check for max_irr >= 0 or max_irr != -1 instead?

Nah, because vmcs.GUEST_INTR_STATUS's RVI will never satisfy:

  RVI[7:4] > VPPR[7:4]

and so the interrupt (that shouldn't/can't exist) will never be delivered, even
if the KVM check were "fixed".  If anything KVM could do "max_irr > 15", probably
with a #define of some kind instead of an open coded literally.

Regardless, that's something to tweak in upstream, not in LTS backports.

  reply	other threads:[~2026-06-23  1:47 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-19 20:31 [PATCH v2 6.1.y 0/3] KVM: nVMX: backport virtual-APIC host NULL-deref fix Nicholas Dudar
2026-06-19 20:31 ` [PATCH v2 6.1.y 1/3] KVM: nVMX: Add a helper to get highest pending from Posted Interrupt vector Nicholas Dudar
2026-06-19 20:46   ` sashiko-bot
2026-06-23  1:47     ` Sean Christopherson [this message]
2026-06-23  2:01   ` Sean Christopherson
2026-06-23  3:03     ` Admin
2026-06-19 20:31 ` [PATCH v2 6.1.y 2/3] KVM: nVMX: Check for pending posted interrupts when looking for nested events Nicholas Dudar
2026-06-19 20:31 ` [PATCH v2 6.1.y 3/3] KVM: nVMX: Fold requested virtual interrupt check into has_nested_events() Nicholas Dudar
2026-06-21 13:47 ` [PATCH v2 6.1.y 0/3] KVM: nVMX: backport virtual-APIC host NULL-deref fix Sasha Levin
2026-06-23  2:07   ` Sean Christopherson

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=ajnlo3vf-Qcai0jz@google.com \
    --to=seanjc@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=main.kalliope@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.