From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 7ED09606A31C for ; Thu, 26 Nov 2026 08:46:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=zWcG2+bW; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=nO+mJC6O DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: References:In-Reply-To:Subject:Cc:To:From:Message-ID:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=7zcR/ikWclJnhYs2fKp9HLMsUdRTdij9sxjOELYqmY8=; b=zWcG2+bWNTuZG7IL8IdIvA434q ruVRKQKSj5Vo3wCG0rM+dlhCfRU6o5apLGN7hDsXCTt/a8D8NYleuVSvTDjIez4s759gxfEwV+92b qXNatACzSZmrxzQ/b364jlJR7FJKD8i4qmP5twmloJ3mvb3AFD+Q/XG6Y7Li9rOjuT7e4rCeCAUMT mVmzNniueWIsxOg23/wkBpfYzKXQN7PYIrt6TXjZ4VXCvztIZW29DHYoZiVELdpo30wtdcCZK4X00 iUr0xTPs73IYGscwlQTK7sPfFb5amKIAeKGewZrTu3gHgiatKiEDPxBpuawSOCFL3lrzX2CGqqyLN x/REdTqQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xWV70-0000000CQap-3TEg; Thu, 26 Nov 2026 08:45:50 +0000 Received: from sea.source.kernel.org ([172.234.252.31]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xWV6z-0000000CQai-1CMh for linux-arm-kernel@lists.infradead.org; Thu, 26 Nov 2026 08:45:49 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id ADA7B40994; Thu, 26 Nov 2026 08:45:48 +0000 (UTC) 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-Archived-By: 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 X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-5.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 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.