From f8f0d0b6fa203bfa363d30f34f6fecce9e5cc2f7 Mon Sep 17 00:00:00 2001 From: Steven Price Date: Mon, 3 Feb 2020 17:36:38 -0800 Subject: mm: ptdump: reduce level numbers by 1 in note_page() Rather than having to increment the 'depth' number by 1 in ptdump_hole(), let's change the meaning of 'level' in note_page() since that makes the code simplier. Note that for x86, the level numbers were previously increased by 1 in commit 45dcd2091363 ("x86/mm/dump_pagetables: Fix printout of p4d level") and the comment "Bit 7 has a different meaning" was not updated, so this change also makes the code match the comment again. Link: http://lkml.kernel.org/r/20191218162402.45610-24-steven.price@arm.com Signed-off-by: Steven Price Reviewed-by: Catalin Marinas Cc: Albert Ou Cc: Alexandre Ghiti Cc: Andy Lutomirski Cc: Ard Biesheuvel Cc: Arnd Bergmann Cc: Benjamin Herrenschmidt Cc: Borislav Petkov Cc: Christian Borntraeger Cc: Dave Hansen Cc: David S. Miller Cc: Heiko Carstens Cc: "H. Peter Anvin" Cc: Ingo Molnar Cc: James Hogan Cc: James Morse Cc: Jerome Glisse Cc: "Liang, Kan" Cc: Mark Rutland Cc: Michael Ellerman Cc: Paul Burton Cc: Paul Mackerras Cc: Paul Walmsley Cc: Peter Zijlstra Cc: Ralf Baechle Cc: Russell King Cc: Thomas Gleixner Cc: Vasily Gorbik Cc: Vineet Gupta Cc: Will Deacon Cc: Zong Li Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- mm/ptdump.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'mm') diff --git a/mm/ptdump.c b/mm/ptdump.c index 868638b8e404..ad18a9839d6f 100644 --- a/mm/ptdump.c +++ b/mm/ptdump.c @@ -17,7 +17,7 @@ static inline int note_kasan_page_table(struct mm_walk *walk, { struct ptdump_state *st = walk->private; - st->note_page(st, addr, 5, pte_val(kasan_early_shadow_pte[0])); + st->note_page(st, addr, 4, pte_val(kasan_early_shadow_pte[0])); walk->action = ACTION_CONTINUE; @@ -37,7 +37,7 @@ static int ptdump_pgd_entry(pgd_t *pgd, unsigned long addr, #endif if (pgd_leaf(val)) - st->note_page(st, addr, 1, pgd_val(val)); + st->note_page(st, addr, 0, pgd_val(val)); return 0; } @@ -54,7 +54,7 @@ static int ptdump_p4d_entry(p4d_t *p4d, unsigned long addr, #endif if (p4d_leaf(val)) - st->note_page(st, addr, 2, p4d_val(val)); + st->note_page(st, addr, 1, p4d_val(val)); return 0; } @@ -71,7 +71,7 @@ static int ptdump_pud_entry(pud_t *pud, unsigned long addr, #endif if (pud_leaf(val)) - st->note_page(st, addr, 3, pud_val(val)); + st->note_page(st, addr, 2, pud_val(val)); return 0; } @@ -88,7 +88,7 @@ static int ptdump_pmd_entry(pmd_t *pmd, unsigned long addr, #endif if (pmd_leaf(val)) - st->note_page(st, addr, 4, pmd_val(val)); + st->note_page(st, addr, 3, pmd_val(val)); return 0; } @@ -98,7 +98,7 @@ static int ptdump_pte_entry(pte_t *pte, unsigned long addr, { struct ptdump_state *st = walk->private; - st->note_page(st, addr, 5, pte_val(READ_ONCE(*pte))); + st->note_page(st, addr, 4, pte_val(READ_ONCE(*pte))); return 0; } @@ -108,7 +108,7 @@ static int ptdump_hole(unsigned long addr, unsigned long next, { struct ptdump_state *st = walk->private; - st->note_page(st, addr, depth + 1, 0); + st->note_page(st, addr, depth, 0); return 0; } @@ -135,5 +135,5 @@ void ptdump_walk_pgd(struct ptdump_state *st, struct mm_struct *mm) up_read(&mm->mmap_sem); /* Flush out the last page */ - st->note_page(st, 0, 0, 0); + st->note_page(st, 0, -1, 0); } -- cgit v1.2.3-59-g8ed1b