powerpc/mm: Fix page table dump to work on Radix
authorMichael Ellerman <mpe@ellerman.id.au>
Wed, 15 Aug 2018 11:29:45 +0000 (21:29 +1000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 21 Nov 2018 08:24:02 +0000 (09:24 +0100)
[ Upstream commit 0d923962ab69c27cca664a2d535e90ef655110ca ]

When we're running on Book3S with the Radix MMU enabled the page table
dump currently prints the wrong addresses because it uses the wrong
start address.

Fix it to use PAGE_OFFSET rather than KERN_VIRT_START.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/powerpc/mm/dump_linuxpagetables.c

index c9282d27b2037122577e7966601d70914e794bbc..31c1c61afaa429edb6e4667d16be035f6b32dbdb 100644 (file)
@@ -422,12 +422,13 @@ static void walk_pagetables(struct pg_state *st)
        unsigned int i;
        unsigned long addr;
 
+       addr = st->start_address;
+
        /*
         * Traverse the linux pagetable structure and dump pages that are in
         * the hash pagetable.
         */
-       for (i = 0; i < PTRS_PER_PGD; i++, pgd++) {
-               addr = KERN_VIRT_START + i * PGDIR_SIZE;
+       for (i = 0; i < PTRS_PER_PGD; i++, pgd++, addr += PGDIR_SIZE) {
                if (!pgd_none(*pgd) && !pgd_huge(*pgd))
                        /* pgd exists */
                        walk_pud(st, pgd, addr);
@@ -476,9 +477,14 @@ static int ptdump_show(struct seq_file *m, void *v)
 {
        struct pg_state st = {
                .seq = m,
-               .start_address = KERN_VIRT_START,
                .marker = address_markers,
        };
+
+       if (radix_enabled())
+               st.start_address = PAGE_OFFSET;
+       else
+               st.start_address = KERN_VIRT_START;
+
        /* Traverse kernel page tables */
        walk_pagetables(&st);
        note_page(&st, 0, 0, 0);