[PATCH] KVM: arm64: GICv3: Keep active LPIs in the LRs
Brad Fitzpatrick
bradfitz at tailscale.com
Thu Nov 26 15:15:55 PST 2026
On Thu, Nov 26, 2026 at 12:45 AM Marc Zyngier <maz at kernel.org> wrote:
>
> Hi Brad,
>
> On Thu, 26 Nov 2026 01:42:04 +0000,
> Brad Fitzpatrick via B4 Relay <devnull+bradfitz.tailscale.com at kernel.org> wrote:
> >
> > From: Brad Fitzpatrick <bradfitz at 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.
Thanks! That works great. It's indeed a bit slower (12% fewer IOPS, 5
to 10% less disk throughput, 5% less networking throughput), but the
absolute numbers are still so ridiculously fast compared to the host's
actual hardware, that it's a drop in the bucket for us. And even with
the trap enabled on a recent kernel, it's still faster than the old
6.17 kernel.
I whipped up a workaround at the Proxmox layer instead that probes
whether macOS is still busted and conditionally sets the trap flag:
https://github.com/bradfitz/pve-on-macos-nested-virt-fix
We'll use that in the meantime. Maybe others will find it useful too.
>
> Feel free to additionally report the issue to Apple (once more).
I'll poke some contacts at Apple and make sure they're aware.
Thanks again!
- Brad
More information about the linux-arm-kernel
mailing list