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

powerpc/ptdump: Refactor update of pg_state



In note_page(), the pg_state is updated the same way in two places.

Add note_page_update_state() to do it.

Also include the display of boundary markers there as it is missing
"no level" leg, leading to a mismatch when the first two markers
are at the same address and the first displayed area uses that
address.

Signed-off-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/a284a809f01c705bbaab303b06fda216f147a99a.1593429426.git.christophe.leroy@csgroup.eu
parent 846feeac
Loading
Loading
Loading
Loading
+20 −14
Original line number Diff line number Diff line
@@ -199,20 +199,34 @@ static void note_prot_wx(struct pg_state *st, unsigned long addr)
	st->wx_pages += (addr - st->start_address) / PAGE_SIZE;
}

static void note_page(struct pg_state *st, unsigned long addr,
static void note_page_update_state(struct pg_state *st, unsigned long addr,
				   unsigned int level, u64 val, unsigned long page_size)
{
	u64 flag = val & pg_level[level].mask;
	u64 pa = val & PTE_RPN_MASK;

	/* At first no level is set */
	if (!st->level) {
	st->level = level;
	st->current_flags = flag;
	st->start_address = addr;
	st->start_pa = pa;
	st->page_size = page_size;

	while (addr >= st->marker[1].start_address) {
		st->marker++;
		pt_dump_seq_printf(st->seq, "---[ %s ]---\n", st->marker->name);
	}
}

static void note_page(struct pg_state *st, unsigned long addr,
	       unsigned int level, u64 val, unsigned long page_size)
{
	u64 flag = val & pg_level[level].mask;
	u64 pa = val & PTE_RPN_MASK;

	/* At first no level is set */
	if (!st->level) {
		pt_dump_seq_printf(st->seq, "---[ %s ]---\n", st->marker->name);
		note_page_update_state(st, addr, level, val, page_size);
	/*
	 * Dump the section of virtual memory when:
	 *   - the PTE flags from one entry to the next differs.
@@ -244,15 +258,7 @@ static void note_page(struct pg_state *st, unsigned long addr,
		 * Address indicates we have passed the end of the
		 * current section of virtual memory
		 */
		while (addr >= st->marker[1].start_address) {
			st->marker++;
			pt_dump_seq_printf(st->seq, "---[ %s ]---\n", st->marker->name);
		}
		st->start_address = addr;
		st->start_pa = pa;
		st->page_size = page_size;
		st->current_flags = flag;
		st->level = level;
		note_page_update_state(st, addr, level, val, page_size);
	}
	st->last_pa = pa;
}