Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e033829d authored by Christophe Leroy's avatar Christophe Leroy Committed by Michael Ellerman
Browse files

powerpc/ptdump: fix walk_pagetables() address mismatch



walk_pagetables() always walk the entire pgdir from address 0
but considers PAGE_OFFSET or KERN_VIRT_START as the starting
address of the walk, resulting in a possible mismatch in the
displayed addresses.

Ex: on PPC32, when KERN_VIRT_START was locally defined as
PAGE_OFFSET, ptdump displayed 0x80000000
instead of 0xc0000000 for the first kernel page,
because 0xc0000000 + 0xc0000000 = 0x80000000

Start the walk at st->start_address instead of starting at 0.

Signed-off-by: default avatarChristophe Leroy <christophe.leroy@c-s.fr>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/5aa2ac513295f594cce8ddb1c649f61947bd063d.1565786091.git.christophe.leroy@c-s.fr
parent 7c7a532b
Loading
Loading
Loading
Loading
+3 −5
Original line number Original line Diff line number Diff line
@@ -299,17 +299,15 @@ static void walk_pud(struct pg_state *st, pgd_t *pgd, unsigned long start)


static void walk_pagetables(struct pg_state *st)
static void walk_pagetables(struct pg_state *st)
{
{
	pgd_t *pgd = pgd_offset_k(0UL);
	unsigned int i;
	unsigned int i;
	unsigned long addr;
	unsigned long addr = st->start_address & PGDIR_MASK;

	pgd_t *pgd = pgd_offset_k(addr);
	addr = st->start_address;


	/*
	/*
	 * Traverse the linux pagetable structure and dump pages that are in
	 * Traverse the linux pagetable structure and dump pages that are in
	 * the hash pagetable.
	 * the hash pagetable.
	 */
	 */
	for (i = 0; i < PTRS_PER_PGD; i++, pgd++, addr += PGDIR_SIZE) {
	for (i = pgd_index(addr); i < PTRS_PER_PGD; i++, pgd++, addr += PGDIR_SIZE) {
		if (!pgd_none(*pgd) && !pgd_is_leaf(*pgd))
		if (!pgd_none(*pgd) && !pgd_is_leaf(*pgd))
			/* pgd exists */
			/* pgd exists */
			walk_pud(st, pgd, addr);
			walk_pud(st, pgd, addr);