From: "Huang, Kai" <kai.huang@intel.com>
To: "seanjc@google.com" <seanjc@google.com>,
"hao_zhang_kdev@163.com" <hao_zhang_kdev@163.com>
Cc: "kvm@vger.kernel.org" <kvm@vger.kernel.org>,
"pbonzini@redhat.com" <pbonzini@redhat.com>
Subject: Re: [PATCH v4 1/4] KVM: x86: ioapic: Update remote_irr only after successful delivery
Date: Tue, 11 Aug 2026 23:32:25 +0000 [thread overview]
Message-ID: <bf00c00ab342bf63af5b49fb549e00b9a5d4d2a9.camel@intel.com> (raw)
In-Reply-To: <3b3db5de497f6196ddc17558b71aa746b0adf1e7.camel@intel.com>
On Tue, 2026-08-11 at 11:11 +0000, Huang, Kai wrote:
> On Tue, 2026-08-11 at 15:34 +0800, Hao Zhang wrote:
> > From: Hao Zhang <zhanghao1@kylinos.cn>
> >
> > The I/O APIC sets remote_irr for level-triggered interrupts that have
> > been accepted by a local APIC and are waiting for an EOI.
> >
> > ioapic_service() currently treats any non-zero return from
> > kvm_irq_delivery_to_apic() as successful delivery. But
> > kvm_irq_delivery_to_apic() returns -1 when no destination is found.
> > Setting remote_irr for that failed delivery leaves the pin blocked
> > forever waiting for an EOI that will never be generated.
> >
> > Update remote_irr only when the delivery result is positive, i.e. when
> > at least one local APIC accepted the interrupt.
> >
> > Fixes: 4925663a079c ("KVM: Report IRQ injection status to userspace.")
>
> The code LGTM, but I am not sure this is the right commit for the Fixes tag.
>
> Looking at the relevant diff:
>
> +static int ioapic_service(struct kvm_ioapic *ioapic, unsigned int idx)
> {
> union ioapic_redir_entry *pent;
> + int injected = -1;
>
> pent = &ioapic->redirtbl[idx];
>
> if (!pent->fields.mask) {
> - int injected = ioapic_deliver(ioapic, idx);
> + injected = ioapic_deliver(ioapic, idx);
> if (injected && pent->fields.trig_mode == IOAPIC_LEVEL_TRIG)
> pent->fields.remote_irr = 1;
> }
>
> This commit didn't change any logic related to remote_irr, since it didn't touch
> ioapic_deliver() at all.
>
I asked the AI to double confirm what I was reading last night, and indeed I got
mixed up a bit among multiple commits in history.
Firstly, the above "it didn't touch ioapic_deliver() at all" isn't true. It
indeed introduced 'r = -1' initializer at the beginning of the function. While
I was right for "no target on destination" it returns 0 (but not -1), AI also
pointed out there are other cases such as invalid delivery_mode which can cause
ioapic_deliver() to return -1.
FWIW, AI also found it was commit
a53c17d21c46 ("KVM: ioapic/msi interrupt delivery consolidation")
which made ioapic_deliver() return -1 when "no target on destination":
if (find_first_bit(deliver_bitmask, KVM_MAX_VCPUS) >= KVM_MAX_VCPUS) {
ioapic_debug("no target on destination\n");
- return 0;
+ return r;
}
So I guess you are right, 4925663a079c is the right one to blame, but not due to
"no target on destination" case.
Anyway, IMHO we might also want to put such history digging into the changelog
to justify the Fixes tag, so people can easily see the reason behind it.
That being said:
Reviewed-by: Kai Huang <kai.huang@intel.com>
prev parent reply other threads:[~2026-08-11 23:32 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-11 7:34 [PATCH v4 1/4] KVM: x86: ioapic: Update remote_irr only after successful delivery Hao Zhang
2026-08-11 7:39 ` [PATCH v4 2/4] KVM: selftests: Verify failed IOAPIC delivery preserves state Hao Zhang
2026-08-11 7:41 ` [PATCH v4 3/4] KVM: x86: ioapic: Preserve irr_delivered for duplicate edge interrupts Hao Zhang
2026-08-11 11:27 ` Huang, Kai
2026-08-11 7:43 ` [PATCH v4 4/4] KVM: x86: ioapic: Clear irr_delivered on level-triggered RTE Hao Zhang
2026-08-11 11:43 ` Huang, Kai
2026-08-11 11:11 ` [PATCH v4 1/4] KVM: x86: ioapic: Update remote_irr only after successful delivery Huang, Kai
2026-08-11 23:32 ` Huang, Kai [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=bf00c00ab342bf63af5b49fb549e00b9a5d4d2a9.camel@intel.com \
--to=kai.huang@intel.com \
--cc=hao_zhang_kdev@163.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=seanjc@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