* [PATCH] powerpc/mm: Use pte_advance_pfn() in set_huge_pte_at()
@ 2025-12-18 16:21 Andrew Donnellan
2025-12-18 18:29 ` Christophe Leroy (CS GROUP)
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Donnellan @ 2025-12-18 16:21 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Christophe Leroy (CS GROUP)
In set_huge_pte_at(), replace the existing open coded pte value
calculation with the new helper pte_advance_pfn().
Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com>
---
arch/powerpc/mm/pgtable.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/powerpc/mm/pgtable.c b/arch/powerpc/mm/pgtable.c
index 56d7e8960e77d877390d6bcbf0d8a305cc222101..9073e373e1e8a88f904cae592e1e8c34707545e6 100644
--- a/arch/powerpc/mm/pgtable.c
+++ b/arch/powerpc/mm/pgtable.c
@@ -365,7 +365,7 @@ void set_huge_pte_at(struct mm_struct *mm, unsigned long addr, pte_t *ptep,
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);
}
}
#endif
---
base-commit: ea1013c1539270e372fc99854bc6e4d94eaeff66
change-id: 20251219-set_huge_pte_at_pte_advance_pfn-0ae18078fcca
--
Andrew Donnellan OzLabs, ADL Canberra
ajd@linux.ibm.com IBM Australia Limited
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] powerpc/mm: Use pte_advance_pfn() in set_huge_pte_at()
2025-12-18 16:21 [PATCH] powerpc/mm: Use pte_advance_pfn() in set_huge_pte_at() Andrew Donnellan
@ 2025-12-18 18:29 ` Christophe Leroy (CS GROUP)
2026-01-12 4:23 ` Andrew Donnellan
0 siblings, 1 reply; 3+ messages in thread
From: Christophe Leroy (CS GROUP) @ 2025-12-18 18:29 UTC (permalink / raw)
To: Andrew Donnellan, linuxppc-dev
Hi Andrew,
Le 18/12/2025 à 17:21, Andrew Donnellan a écrit :
> In set_huge_pte_at(), replace the existing open coded pte value
> calculation with the new helper pte_advance_pfn().
>
> Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com>
> ---
> arch/powerpc/mm/pgtable.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/powerpc/mm/pgtable.c b/arch/powerpc/mm/pgtable.c
> index 56d7e8960e77d877390d6bcbf0d8a305cc222101..9073e373e1e8a88f904cae592e1e8c34707545e6 100644
> --- a/arch/powerpc/mm/pgtable.c
> +++ b/arch/powerpc/mm/pgtable.c
> @@ -365,7 +365,7 @@ void set_huge_pte_at(struct mm_struct *mm, unsigned long addr, pte_t *ptep,
>
> 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()
Christophe
> }
> }
> #endif
>
> ---
> base-commit: ea1013c1539270e372fc99854bc6e4d94eaeff66
> change-id: 20251219-set_huge_pte_at_pte_advance_pfn-0ae18078fcca
>
>
> --
> Andrew Donnellan OzLabs, ADL Canberra
> ajd@linux.ibm.com IBM Australia Limited
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] powerpc/mm: Use pte_advance_pfn() in set_huge_pte_at()
2025-12-18 18:29 ` Christophe Leroy (CS GROUP)
@ 2026-01-12 4:23 ` Andrew Donnellan
0 siblings, 0 replies; 3+ messages in thread
From: Andrew Donnellan @ 2026-01-12 4:23 UTC (permalink / raw)
To: Christophe Leroy (CS GROUP), linuxppc-dev
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-01-12 4:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-18 16:21 [PATCH] powerpc/mm: Use pte_advance_pfn() in set_huge_pte_at() Andrew Donnellan
2025-12-18 18:29 ` Christophe Leroy (CS GROUP)
2026-01-12 4:23 ` Andrew Donnellan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox