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.

mm/ptdump: split effective_prot() into level specific callbacks

Last argument in effective_prot() is u64 assuming pxd_val() returned value
(all page table levels) is 64 bit. pxd_val() is very platform specific
and its type should not be assumed in generic MM.

Split effective_prot() into individual page table level specific callbacks
which accepts corresponding pxd_t argument instead and then the
subscribing platform (only x86) just derive pxd_val() from the entries as
required and proceed as earlier.

Link: https://lkml.kernel.org/r/20250407053113.746295-3-anshuman.khandual@arm.com
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
Cc: Paul Walmsley <paul.walmsley@sifive.com>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Cc: Will Deacon <will@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Anshuman Khandual and committed by
Andrew Morton
08978fc3 e064e738

+46 -12
+31 -1
arch/x86/mm/dump_pagetables.c
··· 266 266 st->prot_levels[level] = effective; 267 267 } 268 268 269 + static void effective_prot_pte(struct ptdump_state *st, pte_t pte) 270 + { 271 + effective_prot(st, 4, pte_val(pte)); 272 + } 273 + 274 + static void effective_prot_pmd(struct ptdump_state *st, pmd_t pmd) 275 + { 276 + effective_prot(st, 3, pmd_val(pmd)); 277 + } 278 + 279 + static void effective_prot_pud(struct ptdump_state *st, pud_t pud) 280 + { 281 + effective_prot(st, 2, pud_val(pud)); 282 + } 283 + 284 + static void effective_prot_p4d(struct ptdump_state *st, p4d_t p4d) 285 + { 286 + effective_prot(st, 1, p4d_val(p4d)); 287 + } 288 + 289 + static void effective_prot_pgd(struct ptdump_state *st, pgd_t pgd) 290 + { 291 + effective_prot(st, 0, pgd_val(pgd)); 292 + } 293 + 294 + 269 295 /* 270 296 * This function gets called on a break in a continuous series 271 297 * of PTE entries; the next one is different so we need to ··· 442 416 .note_page_p4d = note_page_p4d, 443 417 .note_page_pgd = note_page_pgd, 444 418 .note_page_flush = note_page_flush, 445 - .effective_prot = effective_prot, 419 + .effective_prot_pte = effective_prot_pte, 420 + .effective_prot_pmd = effective_prot_pmd, 421 + .effective_prot_pud = effective_prot_pud, 422 + .effective_prot_p4d = effective_prot_p4d, 423 + .effective_prot_pgd = effective_prot_pgd, 446 424 .range = ptdump_ranges 447 425 }, 448 426 .level = -1,
+5 -1
include/linux/ptdump.h
··· 17 17 void (*note_page_p4d)(struct ptdump_state *st, unsigned long addr, p4d_t p4d); 18 18 void (*note_page_pgd)(struct ptdump_state *st, unsigned long addr, pgd_t pgd); 19 19 void (*note_page_flush)(struct ptdump_state *st); 20 - void (*effective_prot)(struct ptdump_state *st, int level, u64 val); 20 + void (*effective_prot_pte)(struct ptdump_state *st, pte_t pte); 21 + void (*effective_prot_pmd)(struct ptdump_state *st, pmd_t pmd); 22 + void (*effective_prot_pud)(struct ptdump_state *st, pud_t pud); 23 + void (*effective_prot_p4d)(struct ptdump_state *st, p4d_t p4d); 24 + void (*effective_prot_pgd)(struct ptdump_state *st, pgd_t pgd); 21 25 const struct ptdump_range *range; 22 26 }; 23 27
+10 -10
mm/ptdump.c
··· 38 38 return note_kasan_page_table(walk, addr); 39 39 #endif 40 40 41 - if (st->effective_prot) 42 - st->effective_prot(st, 0, pgd_val(val)); 41 + if (st->effective_prot_pgd) 42 + st->effective_prot_pgd(st, val); 43 43 44 44 if (pgd_leaf(val)) { 45 45 st->note_page_pgd(st, addr, val); ··· 61 61 return note_kasan_page_table(walk, addr); 62 62 #endif 63 63 64 - if (st->effective_prot) 65 - st->effective_prot(st, 1, p4d_val(val)); 64 + if (st->effective_prot_p4d) 65 + st->effective_prot_p4d(st, val); 66 66 67 67 if (p4d_leaf(val)) { 68 68 st->note_page_p4d(st, addr, val); ··· 84 84 return note_kasan_page_table(walk, addr); 85 85 #endif 86 86 87 - if (st->effective_prot) 88 - st->effective_prot(st, 2, pud_val(val)); 87 + if (st->effective_prot_pud) 88 + st->effective_prot_pud(st, val); 89 89 90 90 if (pud_leaf(val)) { 91 91 st->note_page_pud(st, addr, val); ··· 106 106 return note_kasan_page_table(walk, addr); 107 107 #endif 108 108 109 - if (st->effective_prot) 110 - st->effective_prot(st, 3, pmd_val(val)); 109 + if (st->effective_prot_pmd) 110 + st->effective_prot_pmd(st, val); 111 111 if (pmd_leaf(val)) { 112 112 st->note_page_pmd(st, addr, val); 113 113 walk->action = ACTION_CONTINUE; ··· 122 122 struct ptdump_state *st = walk->private; 123 123 pte_t val = ptep_get_lockless(pte); 124 124 125 - if (st->effective_prot) 126 - st->effective_prot(st, 4, pte_val(val)); 125 + if (st->effective_prot_pte) 126 + st->effective_prot_pte(st, val); 127 127 128 128 st->note_page_pte(st, addr, val); 129 129