Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: Chao Gao <chao.gao@intel.com>
To: Dongli Zhang <dongli.zhang@oracle.com>
Cc: <x86@kernel.org>, <kvm@vger.kernel.org>, <tglx@kernel.org>,
	<mingo@redhat.com>, <bp@alien8.de>, <dave.hansen@linux.intel.com>,
	<hpa@zytor.com>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH RFC v2 1/1] x86/irq/i8259: Ack PIC vectors in the LAPIC ISR
Date: Fri, 20 Nov 2026 16:14:31 +0800	[thread overview]
Message-ID: <awABZ_BucR628XHj@intel.com> (raw)
In-Reply-To: <20261112170604.1971438-1-dongli.zhang@oracle.com>

On Thu, Nov 12, 2026 at 05:06:04PM +0000, Dongli Zhang wrote:
>This is to fix a LAPIC ISR stall that can happen in a kdump kernel, but can
>also happen in other scenarios.
>
>The issue can be intermittently reproduced in a QEMU/KVM guest when there
>are large number of VMs on the same host.

Does your production kernel include commit 1b558e14f3c1 ("x86/apic: Make the
ISR clearing sane")? If so, can you reproduce this issue with it
reverted? It looks to me that the one-pass ISR clearing doesn't clear all
stale ISR/IRR bits.

The changelog of that commit says

  2) If interrupts are enabled, then the APIC propagates the IRR bit to the
     ISR and raises the interrupt in the CPU, which means that code _cannot_
     observe the ISR bit for any of those IRR bits.

Your analysis shows a case where this doesn't hold, since the 8259A
handler doesn't EOI the local APIC and the ISR bit stays set.

You can certainly still reproduce it by injecting an interrupt manually
after the ISR clearing. But I think the multi-pass scan may be enough for
any practical case.

>
>Device interrupts can use the PIC, IOAPIC, or MSI-X. Nowadays, most x86
>device interrupts use MSI-X or the IOAPIC. However, the PIC handler does
>not send a LAPIC EOI, even when the interrupt it handles has set a bit in
>the LAPIC ISR.
>
>For example, suppose there is a QEMU/KVM guest using virtio-net.
>
>1. virtio-net is about to deliver vector 52 to CPU 2 (APIC ID 2), but the
>guest suddenly panics on that CPU.
>
>2. The kdump kernel boots on APIC ID 2, which becomes CPU 0 in the new
>kernel.
>
>3. Suppose delivery of the interrupt is delayed, so vector 52 has not
>reached the CPU yet.
>
>4. On the new CPU 0, init_ISA_irqs() initially sets up the legacy IRQs to
>use the PIC. Vector 52 maps to IRQ4, which is normally used by the serial
>console.
>
>5. Before these legacy IRQs are handed over to the IOAPIC, suppose the
>delayed vector 52 arrives through the LAPIC and sets its ISR bit.
>
>6. The new kernel handles it as PIC IRQ4. Since mask_and_ack_8259A()
>does not send a LAPIC EOI, the ISR bit for vector 52 remains set.

      reply	other threads:[~2026-11-20  8:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-12 17:06 [PATCH RFC v2 1/1] x86/irq/i8259: Ack PIC vectors in the LAPIC ISR Dongli Zhang
2026-11-20  8:14 ` Chao Gao [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=awABZ_BucR628XHj@intel.com \
    --to=chao.gao@intel.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=dongli.zhang@oracle.com \
    --cc=hpa@zytor.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@kernel.org \
    --cc=x86@kernel.org \
    /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