[PATCH v8 02/10] powerpc/8xx: add pte_set_huge()

Christophe Leroy (CS GROUP) chleroy at kernel.org
Thu Sep 17 23:14:31 PDT 2026



Le 17/09/2026 à 07:29, Wen Jiang a écrit :
> From: Wen Jiang <jiangwen6 at xiaomi.com>
> 
> vmap installs PTE-level block mappings (SZ_16K/SZ_512K on powerpc/8xx)
> by reusing set_huge_pte_at(), a HugeTLB helper gated by
> CONFIG_HUGETLB_PAGE. This makes the feature silently unavailable on
> CONFIG_HUGETLB_PAGE=n kernels and couples mm/vmalloc.c to HugeTLB
> internals it does not otherwise need.
> 
> Add pte_set_huge() to powerpc/8xx, next to the existing
> pmd_clear_huge()/pud_clear_huge() in mm/nohash/8xx.c. It builds the huge
> PTE and writes it into the backing cells directly, without going through
> set_huge_pte_at(), so it does not depend on CONFIG_HUGETLB_PAGE.
> 
> No pte_clear_huge() is needed: 8xx does not implement
> arch_vmap_pte_range_unmap_size(), so the vmap unmap path never takes the
> block-mapping branch.
> 
> In practice PPC_8xx selects HUGETLBFS unconditionally, so
> CONFIG_HUGETLB_PAGE=n does not occur there today; this is a decoupling
> cleanup rather than a new configuration.

8xx selects CONFIG_HUGETLB_PAGE because it uses set_huge_pte_at() to map 
kernel text with large pages. That was added by commit 34536d780683 
("powerpc/8xx: Add a function to early map kernel via huge pages")

But now pte_set_huge() could be used instead in 
__early_map_kernel_hugepage() and then CONFIG_HUGETLB_PAGE could be removed.

> 
> There is no caller yet: mm/vmalloc.c is converted later in this series,
> once the generic fallbacks are in place.
> 
> Signed-off-by: Wen Jiang <jiangwen6 at xiaomi.com>

Reviewed-by: Christophe Leroy (CS GROUP) <chleroy at kernel.org>

> ---
>   arch/powerpc/include/asm/nohash/32/pte-8xx.h |  4 +++
>   arch/powerpc/mm/nohash/8xx.c                 | 29 ++++++++++++++++++++
>   2 files changed, 33 insertions(+)
> 
> diff --git a/arch/powerpc/include/asm/nohash/32/pte-8xx.h b/arch/powerpc/include/asm/nohash/32/pte-8xx.h
> index e2ea8ba9f8cae..1ee3f8f0de974 100644
> --- a/arch/powerpc/include/asm/nohash/32/pte-8xx.h
> +++ b/arch/powerpc/include/asm/nohash/32/pte-8xx.h
> @@ -235,6 +235,10 @@ static inline pte_t ptep_get(pte_t *ptep)
>   }
>   #endif /* CONFIG_PPC_16K_PAGES */
>   
> +#define __HAVE_ARCH_PTE_SET_HUGE
> +void pte_set_huge(pte_t *ptep, unsigned long addr, phys_addr_t phys,
> +		  pgprot_t prot, unsigned long size);
> +
>   #endif
>   
>   #endif /* __KERNEL__ */
> diff --git a/arch/powerpc/mm/nohash/8xx.c b/arch/powerpc/mm/nohash/8xx.c
> index a9d3f4729eada..2518d2a6bdb41 100644
> --- a/arch/powerpc/mm/nohash/8xx.c
> +++ b/arch/powerpc/mm/nohash/8xx.c
> @@ -220,3 +220,32 @@ int pmd_clear_huge(pmd_t *pmd)
>   {
>   	 return 0;
>   }
> +
> +/*
> + * vmap PTE-level block mapping. Sets a present kernel mapping directly,
> + * so unlike set_huge_pte_at() it needs neither CONFIG_HUGETLB_PAGE nor
> + * set_pte_filter() (a no-op for non-exec kernel mappings).
> + */
> +void pte_set_huge(pte_t *ptep, unsigned long addr, phys_addr_t phys,
> +		  pgprot_t prot, unsigned long size)
> +{
> +	pmd_t *pmdp = pmd_off(&init_mm, addr);
> +	pte_t pte = pfn_pte(PHYS_PFN(phys), prot);
> +	pte_basic_t val;
> +	pte_basic_t *entry = (pte_basic_t *)ptep;
> +	int num, i;
> +
> +	pte = arch_make_huge_pte(pte, ilog2(size), 0);
> +	val = pte_val(pte);
> +
> +	/*
> +	 * Make sure hardware valid bit is not set. We don't do
> +	 * tlb flush for this update.
> +	 */
> +	VM_WARN_ON(pte_hw_valid(*ptep) && !pte_protnone(*ptep));
> +
> +	num = number_of_cells_per_pte(pmdp, val, 1);
> +
> +	for (i = 0; i < num; i++, entry++, val += SZ_4K)
> +		*entry = val;
> +}




More information about the linux-arm-kernel mailing list