[PATCH 2/4] powerpc/mm: map shared vmemmap tail pages as read-only

From: Muchun Song

Date: Mon Oct 19 2026 - 05:13:25 EST


PowerPC radix uses an architecture-specific vmemmap population path for
shared tail mappings, so it does not inherit the read-only protection added
to the common path.

Protect these mappings as well so illegal writes fault instead of
corrupting metadata shared by multiple tail pages.

Signed-off-by: Muchun Song <songmuchun@xxxxxxxxxxxxx>
---
arch/powerpc/mm/book3s64/radix_pgtable.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/arch/powerpc/mm/book3s64/radix_pgtable.c b/arch/powerpc/mm/book3s64/radix_pgtable.c
index 44868b62b14e..ebac5f9058f6 100644
--- a/arch/powerpc/mm/book3s64/radix_pgtable.c
+++ b/arch/powerpc/mm/book3s64/radix_pgtable.c
@@ -1059,6 +1059,9 @@ static pte_t * __meminit radix__vmemmap_pte_populate(pmd_t *pmdp, unsigned long

VM_BUG_ON(!PAGE_ALIGNED(addr));
entry = pfn_pte(__pa(p) >> PAGE_SHIFT, PAGE_KERNEL);
+ /* Map the shared tail page as read-only to catch illegal writes. */
+ if (reuse)
+ entry = pte_wrprotect(entry);
set_pte_at(&init_mm, addr, pte, entry);
asm volatile("ptesync": : :"memory");
}
--
2.54.0