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 459F7606A322 for ; Fri, 4 Dec 2026 13:40:29 +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=sHe1xb0d; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=foss header.b=pdgA+3F9 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-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc: To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Unsubscribe-Post: List-Owner; bh=2AmiFLnzfhuySQMt64ZrwysblJeq2X2j1i3P2A15rjE=; b=sHe1xb0ds0vvX1 N0Tc0xOoVN9zrH3W0N4vWocH5D1r6v+WA7eX4NgmeZ5V0GKibbyP38tnMhEhDhM+rgDvvwUreeQP3 BeLk7h3DWAiyg6TmSJwwz9HQEFJ2GEw1TO2lrLub5MaGvYmrnDQfz1Kfd0Sg4HMXN9RsLRtQ6sGH+ qmZ9iVeWSzVApmbfHy65x8Bope/Ii6y+eLYhAC0J0/8pm0teyDLPqk5hufMVBLxqxmBO7xZmCInzt wrc9NPCi4g1D9i6N9z+KEdQwd/jA5WK/5DCQZwlXhAH14tSwEfNM4ZxBeYTzMuZPwCXulRBN96D+B h7FNyW1yLKJF+iJYfqGA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZTWT-00000000R5p-1Rrv; Fri, 04 Dec 2026 13:40:25 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZTWO-00000000R4t-3xZM for linux-arm-kernel@lists.infradead.org; Fri, 04 Dec 2026 13:40:23 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E548214BF; Fri, 4 Dec 2026 05:40:16 -0800 (PST) Received: from LeoBrasDK.cambridge.arm.com (LeoBrasDK.cambridge.arm.com [10.2.212.21]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 643CD3F632; Fri, 4 Dec 2026 05:40:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1796391619; bh=7MYI+PbDH5Cg7CAMuQ6SzNyKPe7W8H4bQFzyP/cUKYY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pdgA+3F9A1CtLYVzWNKu9LjlYkekhBONLIRw900ufQULZ090q+HscvEC8Gtngi+u9 HCwbiZmWkFulK9zvsY8eEKLZiCwVEDH6I+mXCmhY5+tYzNpuhaQ7cVPaHycOtoqiMK gZBW890POWZGI+MBuiCIVcdleSE1eFKNE3CtYCZo= From: Leonardo Bras To: "Lorenzo Stoakes (ARM)" Cc: Leonardo Bras , Marc Zyngier , Oliver Upton , Fuad Tabba , Joey Gouly , Steffen Eiden , Suzuki K Poulose , Zenghui Yu , Catalin Marinas , Will Deacon , Mark Rutland , Christoffer Dall , Jintack Lim , Wei-Lin Chang , Yanan Wang , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org, Usama Arif , stable@vger.kernel.org Subject: Re: [PATCH v2] KVM: arm64: Unconditionally top up the mmu memcache on user fault Date: Fri, 4 Dec 2026 13:39:59 +0000 Message-ID: X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261203-fix-nv-cache-topup-v2-1-afc8fc1f87a2@kernel.org> References: <20261203-fix-nv-cache-topup-v2-1-afc8fc1f87a2@kernel.org> X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261204_054021_743698_1BF80942 X-CRM114-Status: GOOD ( 22.95 ) X-Spam-Score: -4.4 (----) 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=-9.3 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,USER_AGENT_GIT autolearn=ham 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, Dec 03, 2026 at 06:45:24PM +0000, Lorenzo Stoakes (ARM) wrote: > The S2 user fault path tops up the MMU memcache (used for page table > pre-allocation as the point at which page tables are installed may not > allocate) except when: > > * It's a permission fault AND > * dirty page logging is disabled AND > * pKVM is disabled > > At which point it is assumed no page table will be allocated. > > However this is not safe - if the mapping size differs from that at which > the permission fault was taken, we must install a new mapping, which may > require a page table. This can happen when: > > * A guest hypervisor replaces a block in its own S2 with a table without > issuing a TLBI (likely due to a bug) - the shadow S2 mapping size is > clamped to that of the guest's S2, so the shadow block has to be > collapsed. > > * A guest hypervisor does issue the TLBI, but races with another vCPU > which has already taken a permission fault on the shadow block. > > * Nested virtualisation isn't in use at all, but the VMM replaces a THP > with 64K hugetlb pages while a permission fault on it is in flight. > > With the memcache empty, kvm_mmu_memory_cache_alloc() hits its > guest-triggerable WARN_ON(!nobjs) and falls back to a GFP_ATOMIC allocation > under mmu_lock, with a BUG_ON() if that fails. > > Therefore, top up the memcache unconditionally. This is cheap, as the top > up does nothing if the cache already holds enough objects. > > Note that dirty logging had a similar issue, addressed in > commit 56fd1fc526e6 ("KVM: arm64: Top up stage-2 memcache for dirty > logging faults"). > > Local testing with dirty logging disabled indicated no performance > impact. > > kvm_page_table_test was modified to take 65,536 permission faults with > dirty logging disabled, and run on an Apple M2 with the kernel under test > running as an NV guest. The median time across ~70 runs was 1.059s without > this patch and 1.062s with it. Cool! I wonder how that will impact with Usama's patch prepended. Thanks! Leo