From nobody Tue Dec 16 07:08:16 2025 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DFBAA24A061; Tue, 27 May 2025 08:26:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748334404; cv=none; b=OJjbgsI1CtBL9SUR5TMIqpodI/mFfEE6HMGMW7Tm+fLw3i2pQUPkuGENs8niJSTMreA0Da9/mcPUhaQQnQBHK/8JfGuCn263Rdrw83Xgt1ZnkuEtfolC1M/0mEoYgVihv7mz+3J5QM01+wMFsIHc7QJpOZjbnkYRdzFy+F3f1SI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748334404; c=relaxed/simple; bh=0CwsYvYwjgFsF9z8hdBk+pow10ksQ9pwAjMtH5KEl3U=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=R8DOj5dojP53yRtc43KEsepzLoAwoy8L+PD6YVLVqEEwCS2CpHMPzyNUbN5WPb4TMCoMMOpGU3TpY5LRW6Mn0BVzslcX6DlTSzUAsJ19W7A+nnTOM/cZg74GD6SQ7g0vUcxXsWBPBhN8rltGhtALqwF0DSji8mYIQdCSSrvtl34= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 6C34E14BF; Tue, 27 May 2025 01:26:25 -0700 (PDT) Received: from localhost.localdomain (unknown [10.163.85.29]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 0C2C23F5A1; Tue, 27 May 2025 01:26:37 -0700 (PDT) From: Dev Jain To: catalin.marinas@arm.com, will@kernel.org Cc: david@redhat.com, ryan.roberts@arm.com, anshuman.khandual@arm.com, mark.rutland@arm.com, yang@os.amperecomputing.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Dev Jain , stable@vger.kernel.org Subject: [PATCH v3] arm64: Restrict pagetable teardown to avoid false warning Date: Tue, 27 May 2025 13:56:33 +0530 Message-Id: <20250527082633.61073-1-dev.jain@arm.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Commit 9c006972c3fe removes the pxd_present() checks because the caller checks pxd_present(). But, in case of vmap_try_huge_pud(), the caller only checks pud_present(); pud_free_pmd_page() recurses on each pmd through pmd_free_pte_page(), wherein the pmd may be none. Thus it is possible to hit a warning in the latter, since pmd_none =3D> !pmd_table(). Thus, add a pmd_present() check in pud_free_pmd_page(). This problem was found by code inspection. Fixes: 9c006972c3fe (arm64: mmu: drop pXd_present() checks from pXd_free_pY= d_table()) Cc: Reported-by: Ryan Roberts =20 Acked-by: David Hildenbrand Signed-off-by: Dev Jain Reviewed-by: Anshuman Khandual Reviewed-by: Catalin Marinas Reviewed-by: Ryan Roberts --- This patch is based on 6.15-rc6. v2->v3: - Use pmdp_get() v1->v2: - Enforce check in caller arch/arm64/mm/mmu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index ea6695d53fb9..5a9bf291c649 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -1286,7 +1286,8 @@ int pud_free_pmd_page(pud_t *pudp, unsigned long addr) next =3D addr; end =3D addr + PUD_SIZE; do { - pmd_free_pte_page(pmdp, next); + if (pmd_present(pmdp_get(pmdp))) + pmd_free_pte_page(pmdp, next); } while (pmdp++, next +=3D PMD_SIZE, next !=3D end); =20 pud_clear(pudp); --=20 2.30.2