From nobody Fri Apr 3 22:12:20 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C98161B4223 for ; Mon, 23 Mar 2026 13:03:35 +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=1774271017; cv=none; b=mG0GYeltjVOMJ0hALBugeoPeeGF29Mt9lEr53yMAQgDESyrI+iMh//cDOVSZCbwJUoRTQTtSCqGkM37T8JO0ny6TndShOzCqz87mVvxFpMKHiDseCUbpKVp+Vrm6nNd1Iqavfcn2TXwO2AHqvtbaDDW3SNgNGh5Q5SeFw8CPwpo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774271017; c=relaxed/simple; bh=yTMOCJQs9Y+qHTdo67Svr7n/ymzVKGN2wsSlLo1wCPQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pAcEIOAgbzAz2PYrDrNgj1mB6tOzzXBSVNela/VOcEB3ga/jgUJR0ZexLX0y3O5PjBBp8TFQTx55dByCtbb8XCZqVwl6/iIm+T+EIob2NH308/uZRO6Voe28W2LF+3t/XI08X1x56ndyFdSzkYztlsvVouwTZhgdM+yj336E/DM= 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 448801684; Mon, 23 Mar 2026 06:03:29 -0700 (PDT) Received: from e125769.cambridge.arm.com (e125769.cambridge.arm.com [10.1.196.27]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A60143F885; Mon, 23 Mar 2026 06:03:33 -0700 (PDT) From: Ryan Roberts To: Catalin Marinas , Will Deacon , "David Hildenbrand (Arm)" , Dev Jain , Yang Shi , Suzuki K Poulose , Jinjiang Tu , Kevin Brodsky Cc: Ryan Roberts , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 3/3] arm64: mm: Remove pmd_sect() and pud_sect() Date: Mon, 23 Mar 2026 13:03:15 +0000 Message-ID: <20260323130317.1737522-4-ryan.roberts@arm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260323130317.1737522-1-ryan.roberts@arm.com> References: <20260323130317.1737522-1-ryan.roberts@arm.com> 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" The semantics of pXd_leaf() are very similar to pXd_sect(). The only difference is that pXd_sect() only considers it a section if PTE_VALID is set, whereas pXd_leaf() permits both "valid" and "present-invalid" types. Using pXd_sect() has caused issues now that large leaf entries can be present-invalid since commit a166563e7ec37 ("arm64: mm: support large block mapping when rodata=3Dfull"), so let's just remove the API and standardize on pXd_leaf(). Signed-off-by: Ryan Roberts --- arch/arm64/include/asm/pgtable.h | 5 ----- arch/arm64/mm/mmu.c | 18 +++++++++--------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgta= ble.h index b3e58735c49bd..8aced28ba8f6e 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -779,8 +779,6 @@ extern pgprot_t phys_mem_access_prot(struct file *file,= unsigned long pfn, =20 #define pmd_table(pmd) ((pmd_val(pmd) & PMD_TYPE_MASK) =3D=3D \ PMD_TYPE_TABLE) -#define pmd_sect(pmd) ((pmd_val(pmd) & PMD_TYPE_MASK) =3D=3D \ - PMD_TYPE_SECT) #define pmd_leaf(pmd) (pmd_present(pmd) && !pmd_table(pmd)) #define pmd_bad(pmd) (!pmd_table(pmd)) =20 @@ -799,11 +797,8 @@ static inline int pmd_trans_huge(pmd_t pmd) #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ =20 #if defined(CONFIG_ARM64_64K_PAGES) || CONFIG_PGTABLE_LEVELS < 3 -static inline bool pud_sect(pud_t pud) { return false; } static inline bool pud_table(pud_t pud) { return true; } #else -#define pud_sect(pud) ((pud_val(pud) & PUD_TYPE_MASK) =3D=3D \ - PUD_TYPE_SECT) #define pud_table(pud) ((pud_val(pud) & PUD_TYPE_MASK) =3D=3D \ PUD_TYPE_TABLE) #endif diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index 5b6a8d53e64b7..7c9928c939445 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -204,7 +204,7 @@ static int alloc_init_cont_pte(pmd_t *pmdp, unsigned lo= ng addr, pmd_t pmd =3D READ_ONCE(*pmdp); pte_t *ptep; =20 - BUG_ON(pmd_sect(pmd)); + BUG_ON(pmd_leaf(pmd)); if (pmd_none(pmd)) { pmdval_t pmdval =3D PMD_TYPE_TABLE | PMD_TABLE_UXN | PMD_TABLE_AF; phys_addr_t pte_phys; @@ -303,7 +303,7 @@ static int alloc_init_cont_pmd(pud_t *pudp, unsigned lo= ng addr, /* * Check for initial section mappings in the pgd/pud. */ - BUG_ON(pud_sect(pud)); + BUG_ON(pud_leaf(pud)); if (pud_none(pud)) { pudval_t pudval =3D PUD_TYPE_TABLE | PUD_TABLE_UXN | PUD_TABLE_AF; phys_addr_t pmd_phys; @@ -1499,7 +1499,7 @@ static void unmap_hotplug_pmd_range(pud_t *pudp, unsi= gned long addr, continue; =20 WARN_ON(!pmd_present(pmd)); - if (pmd_sect(pmd)) { + if (pmd_leaf(pmd)) { pmd_clear(pmdp); =20 /* @@ -1532,7 +1532,7 @@ static void unmap_hotplug_pud_range(p4d_t *p4dp, unsi= gned long addr, continue; =20 WARN_ON(!pud_present(pud)); - if (pud_sect(pud)) { + if (pud_leaf(pud)) { pud_clear(pudp); =20 /* @@ -1646,7 +1646,7 @@ static void free_empty_pmd_table(pud_t *pudp, unsigne= d long addr, if (pmd_none(pmd)) continue; =20 - WARN_ON(!pmd_present(pmd) || !pmd_table(pmd) || pmd_sect(pmd)); + WARN_ON(!pmd_present(pmd) || !pmd_table(pmd)); free_empty_pte_table(pmdp, addr, next, floor, ceiling); } while (addr =3D next, addr < end); =20 @@ -1686,7 +1686,7 @@ static void free_empty_pud_table(p4d_t *p4dp, unsigne= d long addr, if (pud_none(pud)) continue; =20 - WARN_ON(!pud_present(pud) || !pud_table(pud) || pud_sect(pud)); + WARN_ON(!pud_present(pud) || !pud_table(pud)); free_empty_pmd_table(pudp, addr, next, floor, ceiling); } while (addr =3D next, addr < end); =20 @@ -1782,7 +1782,7 @@ int __meminit vmemmap_check_pmd(pmd_t *pmdp, int node, { vmemmap_verify((pte_t *)pmdp, node, addr, next); =20 - return pmd_sect(READ_ONCE(*pmdp)); + return pmd_leaf(READ_ONCE(*pmdp)); } =20 int __meminit vmemmap_populate(unsigned long start, unsigned long end, int= node, @@ -1846,7 +1846,7 @@ void p4d_clear_huge(p4d_t *p4dp) =20 int pud_clear_huge(pud_t *pudp) { - if (!pud_sect(READ_ONCE(*pudp))) + if (!pud_leaf(READ_ONCE(*pudp))) return 0; pud_clear(pudp); return 1; @@ -1854,7 +1854,7 @@ int pud_clear_huge(pud_t *pudp) =20 int pmd_clear_huge(pmd_t *pmdp) { - if (!pmd_sect(READ_ONCE(*pmdp))) + if (!pmd_leaf(READ_ONCE(*pmdp))) return 0; pmd_clear(pmdp); return 1; --=20 2.43.0