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=1795172986; b=QkYunjjUJ7MO9CHq1RMeTzSBoup/mmBI95ycVMColFoZOKhNd37w40Dki+zarMW9yKbk QYKguRsrE6zP4ZTwGtJ1NDKEF3+PV7CQwTIP5DDM/mWBrmcGqSEHHgYyQ28DSgJhgAACm xBgU7Aw2rM5UZ2Ukv/fQxq8XmGugeJJtO/WP9wp4uf4AbRG/BCUq7EX7JlsChtWoJDHu0 7DQikdecxLyBUTkk4TaRua5JeCG+5G9QnjcdTB7zSQdG3e57o1NWxAQahQibDSHx2NXWU gopBkruimuVHh5iqjtiO9Y3WN2CDVxWak+7InIH5YvUfDhucB4E+N02ddGDMHcQpQ4Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795172986; 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=2RuimmOKEdckylLVvtsFC7k8j+dPt2aTJXFr5gsiNwk=; b=pda4+uy0nrCVVqansmmTK9/SBRoTlNNqisZ0Hu7tvjsZL5jzwn3LJrKQTRatxn5HTL4g 1r2Pfk3uaQqVATukrzDWd8LRbF4aOJSmnmOrVfVFKQQ2/epxmU5MuEBrrQaC3J59Uuot7 bcYA6AyQXzgDUbH9tOx3qJQENTsjXMxH5G6pUzGGr95oVm9deVXtqnHficDO60eDmx/iK eRgES8nck4ELfLPR94GTzh45AezhENaLrUWKoZHI+EbAcTS6w9KFN7RKaQF8mi7PDHnTO wVQfp28zHP87i8CYBBpZVWT2gLfeMbWpM9Ioz55PValFb7evohztprS7RgeWhxwmVOg== 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=AMikXPr3; 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)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EC111606A325; Fri, 20 Nov 2026 11:09:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=AMikXPr3 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 08D051F000C4; Fri, 20 Nov 2026 11:09:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795172985; bh=2RuimmOKEdckylLVvtsFC7k8j+dPt2aTJXFr5gsiNwk=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=AMikXPr37HdnbqD8nENh/uDeTqYDteieNAvjGhJ1zvCMDR2DGqHUYAtV/5oG6jK8M UeFx8bmTJ7V/EOoasqkHLStLmdwhiQWF/y72dJt6TYp7dtqGyY/UUW9jH4wvA+fjLx CaryP2Y4Ld6Cv5dSsGqPfucT8Puw48jyy2OSGXPuig012l6JTHfWaJcTwpEl63dn08 hbgyBHXzdPPdZgPHS4dyjiXLFfRHAPkHfQiYj5Uq8g1g32ndGfyuffKHEGmWUwC97a dXkKduKi24RxjMbYZVw0s8r9ID+2L2xBkod6s6aR5r2+Utc6lWtoSo+vEmwEwYwo1u SKUDMOC/zQEUQ== Received: from sofa.misterjones.org ([185.219.108.64] helo=lobster-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 1xUMUw-00000000wOs-3zvf; Fri, 20 Nov 2026 11:09:43 +0000 Date: Fri, 20 Nov 2026 11:13:09 +0000 Message-ID: <87cxrz92nu.wl-maz@kernel.org> From: Marc Zyngier To: Colton Lewis Cc: Oliver Upton , Wei-Lin Chang , Joey Gouly , Suzuki K Poulose , Zenghui Yu , Fuad Tabba , Steffen Eiden , kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] KVM: arm64: nv: Fix guest stage-2 mapping leak on sub-block unmap In-Reply-To: <20261119185105.626343-1-coltonlewis@google.com> References: <20261119185105.626343-1-coltonlewis@google.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: kvm@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: coltonlewis@google.com, oupton@kernel.org, weilin.chang@arm.com, joey.gouly@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, fuad.tabba@linux.dev, seiden@linux.ibm.com, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, linux-kernel@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 On Thu, 19 Nov 2026 18:51:05 +0000, Colton Lewis wrote: > > When a shadow stage-2 block mapping (for example, 2M at PMD level) is > partially invalidated by a smaller guest unmap such as a 4K TLBI > IPAS2E1IS, What does that mean? If we have a 2MB shadow mapping, then the guest cannot have something smaller in its own PTs. And how do you get a "4K TLBI IPAS2E1IS"? TTL == {4kB, L3}? If that's the case, we have every right to *ignore* this TLBI, because it cannot possibly reflect the original state of the PTs. If this is an unqualified address (no TTL), then the whole block *must* go. There is no such thing as "partial invalidation". > kvm_pgtable_stage2_unmap() shatters and clears the entire > block descriptor in mmu->pgt. Shatters? Or clears the entire block? It cannot be "and" because the two are polar opposites. > However, kvm_remove_guest_s2_mappings() > only removes a struct kvm_guest_s2_mapping node when its entire > [nested_start, nested.last] span lies within the unmap range. What do you call "the unmap range"? What we have removed from the shadow S2? What the guest gives us as part of the TLBI instruction? Something else? > As a > result, every sub-block invalidation followed by a re-fault leaks a > stale block-sized tracking node in mmu->guest_s2_mappings and > kvm->arch.mmu.guest_s2_mappings until the shadow MMU is destroyed, Leaks? A leak is something that is still allocated, but not linked to an existing data structure, and therefore not recoverable. This looks to me like exact opposite of a leak... > allowing an L1 guest to grow host kernel memory and degrade subsequent > TLBI IPAS2E1IS walks to O(N) under write_lock(&kvm->mmu_lock). Honestly, this wall of text is not an explanation. That's just a whole lot of LLM gunk that you have generously copy pasted. > > Conversely, unconditionally removing any overlapping tracking node on a > sub-block unmap would be unsafe when a shadow block mapping has been > split into a child table (such as on a page-granule fault under dirty > logging or a racing shared walk returning -EAGAIN), because sibling > sub-page PTEs outside the unmapped range remain live in mmu->pgt and > still rely on the block-sized tracking node for host MMU notifier > unmaps. -ENOPARSE. Sub-page PTEs sounds like a great idea. I stopped reading here. Please come back with an actual description of the problem that you will have produced yourself, or provide the original LLM report (it cannot be much worse than the above). M. -- Jazz isn't dead. It just smells funny.