From nobody Fri Dec 19 18:42:55 2025 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7C21D15624D; Sun, 18 May 2025 09:55:01 +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=1747562104; cv=none; b=RmI2bLedo3CHkK9u56L2PWsKTDe1LZXcmzEBD7HrCjankAGBPRqFA1/SbxsW6rZ0hBRNo9IMZWLKrWy+VJbhJSLtU1rD/vSp0VEuE0bDbdsp07palqMYfA8Vc4DM3xJyOn0NHCuNa4am68GS3HKKFaAH6keDCC8kBf4AcmlCPwg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747562104; c=relaxed/simple; bh=GPXt7yrDAXgUzVEqDKWM6kasfQ42+eP9tdA1xqv6jRg=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=bRdHZYK1jW4bzQYym8ATZ6yqgv6YYpSSMI0m7bKEPixwglbXTGJhTw8vSOh0L2VaUuEdZ8Ba8xuEW63F+5LTRWYoUliF+I3rvFUkdg+gcemm0axkkyZ8rikfr3g5T9uBrpathdpgeCIecu2RtxbbFnuY69Q1knWe2Nofbid7s+E= 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 C250E169C; Sun, 18 May 2025 02:54:47 -0700 (PDT) Received: from K4MQJ0H1H2.arm.com (unknown [10.163.82.43]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id DF0613F5A1; Sun, 18 May 2025 02:54:56 -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 v2] arm64: Restrict pagetable teardown to avoid false warning Date: Sun, 18 May 2025 15:24:45 +0530 Message-Id: <20250518095445.31044-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. This patch is based on 6.15-rc6. Fixes: 9c006972c3fe (arm64: mmu: drop pXd_present() checks from pXd_free_pY= d_table()) Cc: Reported-by: Ryan Roberts =20 Signed-off-by: Dev Jain Acked-by: David Hildenbrand --- 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..5b1f4cd238ca 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)) + pmd_free_pte_page(pmdp, next); } while (pmdp++, next +=3D PMD_SIZE, next !=3D end); =20 pud_clear(pudp); --=20 2.30.2