From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795682749; b=c9oVFD/JLTet0tAnuj/YB3Bn/efKkcR5FDDO43deiM58nN39SjwpNJhy4sS6a/0JEknT Myywk4jRnQErKz/ClVDq87RS6iCYWrfiPZWB8GE7nGU7U2RqgnR/eDC0bOFxMC/8BV7ff P4+/92c4K+0W2ipffQABcpa/96ZwBAsZ56QzOkDdOtT4q+v9JZ8242p4fCOJcU+7kCXG8 DtBtvbmbsKhJ4CNV8vyo9uOQ2MWqBP9bBrX/3L7JVh20pSd5u2egUMNrZn0w04o4NZvCg JM88Io+Wolsz2oU+c1sJo8NdJFjrX1vMCujMDYIuOXwZ3dMR/mxSgQEOqje0j3VWf2w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795682749; h=Received:DKIM-Signature:Received:Date:Message-ID:From:To:Cc:Subject: In-Reply-To:References:User-Agent:MIME-Version:Content-Type: X-SA-Exim-Connect-IP:X-SA-Exim-Rcpt-To:X-SA-Exim-Mail-From: X-SA-Exim-Scanned; bh=7zcR/ikWclJnhYs2fKp9HLMsUdRTdij9sxjOELYqmY8=; b=sxj86i2B4lKV2PxUmIfm+3XXAOCdNMnQOHVS3sa0uC/w/qxyU0F7Ln9dSk0Og6Uoqqjy Vq6wYzr75m4sG9nKnc9pUu06rQhdrS7garlmpHjDIeGWgQp9g2Kbqo2E9Y/E6eDLibwe7 9fqSTXif0qZ1Pwp4s9T+uqWw9YvWvYoD1zTT28VnyWI+z1Gfz4sJMeRrZRFBqjZo/BHxK f92hlKUUZODYGk2MSsiQQ2pLyc9XW0jkb/hfOe/U6lvxsZjN5dlypOZnkCAf/yqL+DvwS G4BmgRyCFokatg+i2NroQrJXtIBoriNxkHu6jRkpfEmoXfXQQfEF8Jiz9q5sfIMwQAA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=nO+mJC6O; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2DC8A606A33A; Thu, 26 Nov 2026 08:45:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=nO+mJC6O Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7DFE01F000D1; Thu, 26 Nov 2026 08:45:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795682748; bh=7zcR/ikWclJnhYs2fKp9HLMsUdRTdij9sxjOELYqmY8=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=nO+mJC6O09ovshzuOQZxxg4pao4iwqiW4gHuAG7wOjvMuj4lZ4bXC1908+elx66Vi 5sCXwGBOJw3QRbfiNxAsM3foforxsN2p9RWWWht9OlUTODk/rkYgUWmP1bARv5bIai xnLRBqrXB7KiQMPtrh2b2rDm0MrxsStEAAorDvoRoBahqtwYY9X+CtieVZicGfMIPc B97r+EIbTcKGHpsrc6paC33t7EjDoDnDzmoLjXVD+hyZ0Zdye3oQYiFapMJZvWTJd6 vz12eB7uyEbO3dIXabqPzI7G5EJAS90xJ6zvts1azI6yaueq61Dlo+B2N9j0cSm4wE pnDTX6cGtlxnA== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xWV6w-00000003WhU-0V6l; Thu, 26 Nov 2026 08:45:46 +0000 Date: Thu, 26 Nov 2026 08:45:45 +0000 Message-ID: <86y0agx9om.wl-maz@kernel.org> From: Marc Zyngier To: bradfitz@tailscale.com Cc: Oliver Upton , Fuad Tabba , Joey Gouly , Steffen Eiden , Suzuki K Poulose , Zenghui Yu , Catalin Marinas , Will Deacon , Mark Rutland , 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 In-Reply-To: <20261126-bradfitz-kvm_lpi_active-v1-1-9ff28176bf66@tailscale.com> References: <20261126-bradfitz-kvm_lpi_active-v1-1-9ff28176bf66@tailscale.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/30.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: bradfitz@tailscale.com, oupton@kernel.org, fuad.tabba@linux.dev, joey.gouly@arm.com, seiden@linux.ibm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, mark.rutland@arm.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, stable@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Hi Brad, On Thu, 26 Nov 2026 01:42:04 +0000, Brad Fitzpatrick via B4 Relay wrote: > > From: Brad Fitzpatrick > > 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.