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

powerpc/ptdump: Display size of BATs



Display the size of areas mapped with BATs.

For that, the size display for pages is refactorised.

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/acf764eee231f0358e66ca9e819f052804055acc.1589866984.git.christophe.leroy@csgroup.eu
parent 3af4786e
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -10,6 +10,8 @@
#include <asm/pgtable.h>
#include <asm/cpu_has_feature.h>

#include "ptdump.h"

static char *pp_601(int k, int pp)
{
	if (pp == 0)
@@ -42,6 +44,7 @@ static void bat_show_601(struct seq_file *m, int idx, u32 lower, u32 upper)
#else
	seq_printf(m, "0x%08x ", pbn);
#endif
	pt_dump_size(m, size);

	seq_printf(m, "Kernel %s User %s", pp_601(k & 2, pp), pp_601(k & 1, pp));

@@ -88,6 +91,7 @@ static void bat_show_603(struct seq_file *m, int idx, u32 lower, u32 upper, bool
#else
	seq_printf(m, "0x%08x ", brpn);
#endif
	pt_dump_size(m, size);

	if (k == 1)
		seq_puts(m, "User ");
+14 −9
Original line number Diff line number Diff line
@@ -112,6 +112,19 @@ static struct addr_marker address_markers[] = {
		seq_putc(m, c);		\
})

void pt_dump_size(struct seq_file *m, unsigned long size)
{
	static const char units[] = "KMGTPE";
	const char *unit = units;

	/* Work out what appropriate unit to use */
	while (!(size & 1023) && unit[1]) {
		size >>= 10;
		unit++;
	}
	pt_dump_seq_printf(m, "%9lu%c ", size, *unit);
}

static void dump_flag_info(struct pg_state *st, const struct flag_info
		*flag, u64 pte, int num)
{
@@ -146,8 +159,6 @@ static void dump_flag_info(struct pg_state *st, const struct flag_info

static void dump_addr(struct pg_state *st, unsigned long addr)
{
	static const char units[] = "KMGTPE";
	const char *unit = units;
	unsigned long delta;

#ifdef CONFIG_PPC64
@@ -164,13 +175,7 @@ static void dump_addr(struct pg_state *st, unsigned long addr)
		pt_dump_seq_printf(st->seq, " " REG " ", st->start_pa);
		delta = (addr - st->start_address) >> 10;
	}
	/* Work out what appropriate unit to use */
	while (!(delta & 1023) && unit[1]) {
		delta >>= 10;
		unit++;
	}
	pt_dump_seq_printf(st->seq, "%9lu%c", delta, *unit);

	pt_dump_size(st->seq, delta);
}

static void note_prot_wx(struct pg_state *st, unsigned long addr)
+3 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 */
#include <linux/types.h>
#include <linux/seq_file.h>

struct flag_info {
	u64		mask;
@@ -17,3 +18,5 @@ struct pgtable_level {
};

extern struct pgtable_level pg_level[5];

void pt_dump_size(struct seq_file *m, unsigned long delta);