Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: bradfitz@tailscale.com
Cc: Oliver Upton <oupton@kernel.org>,
	Fuad Tabba <fuad.tabba@linux.dev>,
	Joey Gouly <joey.gouly@arm.com>,
	Steffen Eiden <seiden@linux.ibm.com>,
	Suzuki K Poulose <suzuki.poulose@arm.com>,
	Zenghui Yu <yuzenghui@huawei.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev,
	stable@vger.kernel.org
Subject: Re: [PATCH] KVM: arm64: GICv3: Keep active LPIs in the LRs
Date: Thu, 26 Nov 2026 08:45:45 +0000	[thread overview]
Message-ID: <86y0agx9om.wl-maz@kernel.org> (raw)
In-Reply-To: <20261126-bradfitz-kvm_lpi_active-v1-1-9ff28176bf66@tailscale.com>

Hi Brad,

On Thu, 26 Nov 2026 01:42:04 +0000,
Brad Fitzpatrick via B4 Relay <devnull+bradfitz.tailscale.com@kernel.org> wrote:
> 
> From: Brad Fitzpatrick <bradfitz@tailscale.com>
> 
> Since commit 73c9726975af ("KVM: arm64: GICv3: Drop LPI active state
> when folding LRs"), the active state of a virtual LPI is discarded on
> every exit. If the guest has acknowledged an LPI but not yet EOI'd it
> when an exit happens, the LPI is then pruned from the ap_list, and the
> guest's subsequent EOI targets an INTID that is not in any LR. KVM then
> relies on the virtual CPU interface performing the priority drop
> regardless.
> 
> That doesn't hold for Apple's emulated GICv3 interface, as exposed by
> macOS Virtualization.framework to a Linux guest running with nested
> virtualization (M3 and later, e.g. "tart run --nested"). There, an EOI
> of a vLPI that has no LR leaves the corresponding ICH_AP1R0_EL2 bit set.
> The running priority of the vCPU stays at the LPI's priority forever,
> and since Linux uses the same priority for all of its interrupts,
> nothing is ever delivered to that vCPU again. The nested guest's CPU
> spins on WFI, with KVM seeing pending interrupts and waking it up over
> and over (about 30k WFI exits per second), while the guest itself
> reports a hard lockup on that CPU. With a 2-vCPU Debian guest, this
> happens within the first minute of boot, every time.

[...]

This is a known bug on Apple HW running MacOS, which has been reported
a number of times to Apple (both directly and through hypervisor
vendors), and resulted in a deafening silence.

The nature of the bug is unclear: either the host hypervisor is buggy,
and it needs to be fixed, or the HW is buggy, and the host hypervisor
needs to work around the bug (working around that bug in each and
every guest is not an acceptable outcome).

The other bug is of course in the spec, where the provided pseudocode
for aarch64/support/VirtualWriteEOIR1 is remarkably buggy. But for
that generation of older ARM specification, the pseudocode is not
authoritative, and it is the text that matters. Dozen of
implementations got it right, and it is surprising that Apple didn't.

The proposed fix breaks all sorts of other things, and can prevent
pending interrupts from making it into the LRs, as we now have active
LPIs occupying LRs for no good reasons. And to be brutally honest,
carrying hacks that make the vgic even harder to maintain is not
something I want to entertain anymore. If this problem is to be
solved, it must be done on the host hypervisor, and nowhere else.

The workaround I can offer is to set "kvm-arm.vgic_v3_group1_trap=1"
on the Linux kernel command line. This will ask the L0 hypervisor to
forward ICC_IAR1_EL1/ICC_EOIR1_EL1 traps to KVM, which will itself
emulate the HW. This is expensive (each interrupt will result in about
4 extra full context switches in MacOS), but your guest will hopefully
work reliably (assuming that MacOS implements trap forwarding
correctly). This is exactly what the host hypervisor should implement
if the HW is buggy.

Feel free to additionally report the issue to Apple (once more).

Thanks,

	M.

-- 
Without deviation from the norm, progress is not possible.


      reply	other threads:[~2026-11-26  8:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26  1:42 [PATCH] KVM: arm64: GICv3: Keep active LPIs in the LRs Brad Fitzpatrick via B4 Relay
2026-11-26  8:45 ` Marc Zyngier [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=86y0agx9om.wl-maz@kernel.org \
    --to=maz@kernel.org \
    --cc=bradfitz@tailscale.com \
    --cc=catalin.marinas@arm.com \
    --cc=fuad.tabba@linux.dev \
    --cc=joey.gouly@arm.com \
    --cc=kvmarm@lists.linux.dev \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=mark.rutland@arm.com \
    --cc=oupton@kernel.org \
    --cc=seiden@linux.ibm.com \
    --cc=stable@vger.kernel.org \
    --cc=suzuki.poulose@arm.com \
    --cc=will@kernel.org \
    --cc=yuzenghui@huawei.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