Re: [PATCH] powerpc/mm: Use pte_advance_pfn() in set_huge_pte_at()

Andrew Donnellan
2026-01-12T04:23:50Z

On Thu, 2025-12-18 at 19:29 +0100, Christophe Leroy (CS GROUP) wrote:
> >    for (i = 0; i < sz / pdsize; i++, ptep++, addr += pdsize) {
> >    __set_pte_at(mm, addr, ptep, pte, 0);
> > - pte = __pte(pte_val(pte) + ((unsigned long long)pdsize /
> > PAGE_SIZE << PFN_PTE_SHIFT));
> > + pte = pte_advance_pfn(pte, pdsize / PAGE_SIZE);
>
> How can this work ?
>
> pdsize is 4M, PAGE_SIZE is 4k so pdsize/PAGE_SIZE is 0x400.
>
> PFN_PTE_SHIFT is 24.
>
> 0x400 << 24 is more than what an unsigned long can contain in
> pte_advance_pfn()

Ah, in spite of the explicit unsigned long long cast that should've reminded me
otherwise, I forgot that a long isn't 64 bits on 32 bit machines.
>

--
Andrew Donnellan OzLabs, ADL Canberra
ajd@linux.ibm.com IBM Australia Limited