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 0B562606A339 for ; Fri, 20 Nov 2026 11:10:12 +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=cAqIXv8Z; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=AMikXPr3 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=2RuimmOKEdckylLVvtsFC7k8j+dPt2aTJXFr5gsiNwk=; b=cAqIXv8ZTRgCgHX/rAgCNzcEo5 hzs1xKWp60moaXFie+xVXJIUcoWUAATrWgh6QHrN0457Q0OGUe4SVW4BsinvLmZ6yxM9Per1ujXeI wUQ0rtEWszGXHzMz955UU07EfKvQL+E/v+UbbRK8AB+GISd5lgcUgvpStXl7209fddUKKopwUVo8p 1nRFJ7cDmfqb21W021tQJGBGHY6yOas/mykAHffJq3VjW9i2LwmjF1BQhsd8e6povARcZLKnBJKDL 3rW35kYqhz3Sancky6/2yqFulxdot3A7wYDF1F8TrPOpmsitg2U8IJ6kLBkpQmSy58QwYjiqajb/g hCiaMtAg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xUMV9-0000000Ej8g-3YDV; Fri, 20 Nov 2026 11:09:55 +0000 Received: from tor.source.kernel.org ([2600:3c04:e001:324:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xUMV0-0000000Ej26-3Tpc for linux-arm-kernel@lists.infradead.org; Fri, 20 Nov 2026 11:09:46 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id DDD116283E; Fri, 20 Nov 2026 11:09:45 +0000 (UTC) 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-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: 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 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 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.