Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

arm64/mm: add addr parameter to __set_ptes_anysz()

Patch series "Support page table check on PowerPC", v18.

Support page table check on PowerPC. Page table check tracks the usage of
of page table entries at each level to ensure that anonymous mappings have
at most one writable consumer, and likewise that file-backed mappings are
not simultaneously also anonymous mappings.

In order to support this infrastructure, a number of helpers or stubs must
be defined or updated for all powerpc platforms. Additionally, we
separate set_pte_at() and set_pte_at_unchecked(), to allow for internal,
uninstrumented mappings.

On some PowerPC platforms, implementing
{pte,pmd,pud}_user_accessible_page() requires the address. We revert
previous changes that removed the address parameter from various
interfaces, and add it to some other interfaces, in order to allow this.

For now, we don't allow page table check alongside HUGETLB_PAGE, due to
the arch-specific complexity of set_huge_page_at(). (I'm sure I could
figure this out, but I have to get this version on this list before I
leave my job.)

This series was initially written by Rohan McLure, who has left IBM and is
no longer working on powerpc.


This patch (of 18):

To provide support for page table check on powerpc, we need to reinstate
the address parameter in several functions, including
page_table_check_{ptes,pmds,puds}_set().

In preparation for this, add the addr parameter to arm64's
__set_ptes_anysz() and change its callsites accordingly.

Link: https://lkml.kernel.org/r/20251219-pgtable_check_v18rebase-v18-0-755bc151a50b@linux.ibm.com
Link: https://lkml.kernel.org/r/20251219-pgtable_check_v18rebase-v18-1-755bc151a50b@linux.ibm.com
Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com>
Reviewed-by: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Alexandre Ghiti <alex@ghiti.fr>
Cc: Alistair Popple <apopple@nvidia.com>
Cc: "Christophe Leroy (CS GROUP)" <chleroy@kernel.org>
Cc: David Hildenbrand <david@kernel.org>
Cc: Donet Tom <donettom@linux.ibm.com>
Cc: Guo Weikang <guoweikang.kernel@gmail.com>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Kevin Brodsky <kevin.brodsky@arm.com>
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Magnus Lindholm <linmag7@gmail.com>
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Nicholas Miehlbradt <nicholas@linux.ibm.com>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Paul Mackerras <paulus@ozlabs.org>
Cc: Qi Zheng <zhengqi.arch@bytedance.com>
Cc: "Ritesh Harjani (IBM)" <ritesh.list@gmail.com>
Cc: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
Cc: Thomas Huth <thuth@redhat.com>
Cc: "Vishal Moola (Oracle)" <vishal.moola@gmail.com>
Cc: Zi Yan <ziy@nvidia.com>
Cc: Alexandre Ghiti <alexghiti@rivosinc.com>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Rohan McLure <rmclure@linux.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Andrew Donnellan and committed by
Andrew Morton
9ac4941a 832d95b5

+13 -16
+8 -11
arch/arm64/include/asm/pgtable.h
··· 673 673 return __pgprot(pud_val(pfn_pud(pfn, __pgprot(0))) ^ pud_val(pud)); 674 674 } 675 675 676 - static inline void __set_ptes_anysz(struct mm_struct *mm, pte_t *ptep, 677 - pte_t pte, unsigned int nr, 676 + static inline void __set_ptes_anysz(struct mm_struct *mm, unsigned long addr, 677 + pte_t *ptep, pte_t pte, unsigned int nr, 678 678 unsigned long pgsize) 679 679 { 680 680 unsigned long stride = pgsize >> PAGE_SHIFT; ··· 709 709 __set_pte_complete(pte); 710 710 } 711 711 712 - static inline void __set_ptes(struct mm_struct *mm, 713 - unsigned long __always_unused addr, 712 + static inline void __set_ptes(struct mm_struct *mm, unsigned long addr, 714 713 pte_t *ptep, pte_t pte, unsigned int nr) 715 714 { 716 - __set_ptes_anysz(mm, ptep, pte, nr, PAGE_SIZE); 715 + __set_ptes_anysz(mm, addr, ptep, pte, nr, PAGE_SIZE); 717 716 } 718 717 719 - static inline void __set_pmds(struct mm_struct *mm, 720 - unsigned long __always_unused addr, 718 + static inline void __set_pmds(struct mm_struct *mm, unsigned long addr, 721 719 pmd_t *pmdp, pmd_t pmd, unsigned int nr) 722 720 { 723 - __set_ptes_anysz(mm, (pte_t *)pmdp, pmd_pte(pmd), nr, PMD_SIZE); 721 + __set_ptes_anysz(mm, addr, (pte_t *)pmdp, pmd_pte(pmd), nr, PMD_SIZE); 724 722 } 725 723 #define set_pmd_at(mm, addr, pmdp, pmd) __set_pmds(mm, addr, pmdp, pmd, 1) 726 724 727 - static inline void __set_puds(struct mm_struct *mm, 728 - unsigned long __always_unused addr, 725 + static inline void __set_puds(struct mm_struct *mm, unsigned long addr, 729 726 pud_t *pudp, pud_t pud, unsigned int nr) 730 727 { 731 - __set_ptes_anysz(mm, (pte_t *)pudp, pud_pte(pud), nr, PUD_SIZE); 728 + __set_ptes_anysz(mm, addr, (pte_t *)pudp, pud_pte(pud), nr, PUD_SIZE); 732 729 } 733 730 #define set_pud_at(mm, addr, pudp, pud) __set_puds(mm, addr, pudp, pud, 1) 734 731
+5 -5
arch/arm64/mm/hugetlbpage.c
··· 221 221 ncontig = num_contig_ptes(sz, &pgsize); 222 222 223 223 if (!pte_present(pte)) { 224 - for (i = 0; i < ncontig; i++, ptep++) 225 - __set_ptes_anysz(mm, ptep, pte, 1, pgsize); 224 + for (i = 0; i < ncontig; i++, ptep++, addr += pgsize) 225 + __set_ptes_anysz(mm, addr, ptep, pte, 1, pgsize); 226 226 return; 227 227 } 228 228 ··· 230 230 if (pte_cont(pte) && pte_valid(__ptep_get(ptep))) 231 231 clear_flush(mm, addr, ptep, pgsize, ncontig); 232 232 233 - __set_ptes_anysz(mm, ptep, pte, ncontig, pgsize); 233 + __set_ptes_anysz(mm, addr, ptep, pte, ncontig, pgsize); 234 234 } 235 235 236 236 pte_t *huge_pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma, ··· 445 445 if (pte_young(orig_pte)) 446 446 pte = pte_mkyoung(pte); 447 447 448 - __set_ptes_anysz(mm, ptep, pte, ncontig, pgsize); 448 + __set_ptes_anysz(mm, addr, ptep, pte, ncontig, pgsize); 449 449 return 1; 450 450 } 451 451 ··· 469 469 pte = get_clear_contig_flush(mm, addr, ptep, pgsize, ncontig); 470 470 pte = pte_wrprotect(pte); 471 471 472 - __set_ptes_anysz(mm, ptep, pte, ncontig, pgsize); 472 + __set_ptes_anysz(mm, addr, ptep, pte, ncontig, pgsize); 473 473 } 474 474 475 475 pte_t huge_ptep_clear_flush(struct vm_area_struct *vma,