Re: [PATCH mm-unstable RFC v4 2/7] arm64/mm: use PTE-level pgprot for huge PFN helpers
From: Will Deacon <will@kernel.org>
Date: 2026-07-16 14:35:13
Also in:
linux-mm, linux-pm, lkml
On Tue, May 26, 2026 at 10:49:58PM +0800, Yin Tirui wrote:
quoted hunk ↗ jump to hunk
Make the arm64 PMD/PUD PFN helpers use PTE-level pgprot_t as the basic format. pfn_pmd() and pfn_pud() now translate PTE-level attributes into block entries. pmd_pgprot() and pud_pgprot() translate block descriptor attributes back into PTE-level attributes. Remove mk_pmd_sect_prot() and mk_pud_sect_prot(). Signed-off-by: Yin Tirui <redacted> --- arch/arm64/include/asm/pgtable.h | 48 ++++++++++++++++++++++---------- arch/arm64/mm/mmu.c | 4 +-- 2 files changed, 36 insertions(+), 16 deletions(-)diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index 4dfa42b7d053..c3ee12e14f86 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h@@ -511,16 +511,6 @@ static inline pmd_t pte_pmd(pte_t pte) return __pmd(pte_val(pte)); } -static inline pgprot_t mk_pud_sect_prot(pgprot_t prot) -{ - return __pgprot((pgprot_val(prot) & ~PUD_TYPE_MASK) | PUD_TYPE_SECT); -} - -static inline pgprot_t mk_pmd_sect_prot(pgprot_t prot) -{ - return __pgprot((pgprot_val(prot) & ~PMD_TYPE_MASK) | PMD_TYPE_SECT); -} - static inline pte_t pte_swp_mkexclusive(pte_t pte) { return set_pte_bit(pte, __pgprot(PTE_SWP_EXCLUSIVE));@@ -628,7 +618,13 @@ static inline pmd_t pmd_mkspecial(pmd_t pmd) #define __pmd_to_phys(pmd) __pte_to_phys(pmd_pte(pmd)) #define __phys_to_pmd_val(phys) __phys_to_pte_val(phys) #define pmd_pfn(pmd) ((__pmd_to_phys(pmd) & PMD_MASK) >> PAGE_SHIFT) -#define pfn_pmd(pfn,prot) __pmd(__phys_to_pmd_val((phys_addr_t)(pfn) << PAGE_SHIFT) | pgprot_val(prot)) +static inline pmd_t pfn_pmd(unsigned long pfn, pgprot_t prot) +{ + pmd_t pmd = __pmd(__phys_to_pmd_val((phys_addr_t)pfn << PAGE_SHIFT) | + pgprot_val(prot)); + + return pmd_mkhuge(pmd); +}
There's a slight potential difference in behaviour here, in that the old mk_pXd_sect_prot() helpers would always return a pgprot_t with the valid bit set, whereas pXd_mkhuge() preserve it from the input prot. I couldn't find any places that cared about this, though, so: Acked-by: Will Deacon <will@kernel.org> Will