Commit ae5d1cf3 authored by Laura Abbott's avatar Laura Abbott Committed by Catalin Marinas

arm64: dump: Make the page table dumping seq_file optional

The page table dumping code always assumes it will be dumping to a
seq_file to userspace. Future code will be taking advantage of
the page table dumping code but will not need the seq_file. Make
the seq_file optional for these cases.
Reviewed-by: default avatarKees Cook <keescook@chromium.org>
Reviewed-by: default avatarMark Rutland <mark.rutland@arm.com>
Tested-by: default avatarMark Rutland <mark.rutland@arm.com>
Acked-by: default avatarMark Rutland <mark.rutland@arm.com>
Signed-off-by: default avatarLaura Abbott <labbott@redhat.com>
Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
parent 4ddb9bf8
...@@ -50,6 +50,18 @@ static const struct addr_marker address_markers[] = { ...@@ -50,6 +50,18 @@ static const struct addr_marker address_markers[] = {
{ -1, NULL }, { -1, NULL },
}; };
#define pt_dump_seq_printf(m, fmt, args...) \
({ \
if (m) \
seq_printf(m, fmt, ##args); \
})
#define pt_dump_seq_puts(m, fmt) \
({ \
if (m) \
seq_printf(m, fmt); \
})
/* /*
* The page dumper groups page table entries of the same type into a single * The page dumper groups page table entries of the same type into a single
* description. It uses pg_state to track the range information while * description. It uses pg_state to track the range information while
...@@ -186,7 +198,7 @@ static void dump_prot(struct pg_state *st, const struct prot_bits *bits, ...@@ -186,7 +198,7 @@ static void dump_prot(struct pg_state *st, const struct prot_bits *bits,
s = bits->clear; s = bits->clear;
if (s) if (s)
seq_printf(st->seq, " %s", s); pt_dump_seq_printf(st->seq, " %s", s);
} }
} }
...@@ -200,14 +212,14 @@ static void note_page(struct pg_state *st, unsigned long addr, unsigned level, ...@@ -200,14 +212,14 @@ static void note_page(struct pg_state *st, unsigned long addr, unsigned level,
st->level = level; st->level = level;
st->current_prot = prot; st->current_prot = prot;
st->start_address = addr; st->start_address = addr;
seq_printf(st->seq, "---[ %s ]---\n", st->marker->name); pt_dump_seq_printf(st->seq, "---[ %s ]---\n", st->marker->name);
} else if (prot != st->current_prot || level != st->level || } else if (prot != st->current_prot || level != st->level ||
addr >= st->marker[1].start_address) { addr >= st->marker[1].start_address) {
const char *unit = units; const char *unit = units;
unsigned long delta; unsigned long delta;
if (st->current_prot) { if (st->current_prot) {
seq_printf(st->seq, "0x%016lx-0x%016lx ", pt_dump_seq_printf(st->seq, "0x%016lx-0x%016lx ",
st->start_address, addr); st->start_address, addr);
delta = (addr - st->start_address) >> 10; delta = (addr - st->start_address) >> 10;
...@@ -215,17 +227,17 @@ static void note_page(struct pg_state *st, unsigned long addr, unsigned level, ...@@ -215,17 +227,17 @@ static void note_page(struct pg_state *st, unsigned long addr, unsigned level,
delta >>= 10; delta >>= 10;
unit++; unit++;
} }
seq_printf(st->seq, "%9lu%c %s", delta, *unit, pt_dump_seq_printf(st->seq, "%9lu%c %s", delta, *unit,
pg_level[st->level].name); pg_level[st->level].name);
if (pg_level[st->level].bits) if (pg_level[st->level].bits)
dump_prot(st, pg_level[st->level].bits, dump_prot(st, pg_level[st->level].bits,
pg_level[st->level].num); pg_level[st->level].num);
seq_puts(st->seq, "\n"); pt_dump_seq_puts(st->seq, "\n");
} }
if (addr >= st->marker[1].start_address) { if (addr >= st->marker[1].start_address) {
st->marker++; st->marker++;
seq_printf(st->seq, "---[ %s ]---\n", st->marker->name); pt_dump_seq_printf(st->seq, "---[ %s ]---\n", st->marker->name);
} }
st->start_address = addr; st->start_address = addr;
...@@ -235,7 +247,7 @@ static void note_page(struct pg_state *st, unsigned long addr, unsigned level, ...@@ -235,7 +247,7 @@ static void note_page(struct pg_state *st, unsigned long addr, unsigned level,
if (addr >= st->marker[1].start_address) { if (addr >= st->marker[1].start_address) {
st->marker++; st->marker++;
seq_printf(st->seq, "---[ %s ]---\n", st->marker->name); pt_dump_seq_printf(st->seq, "---[ %s ]---\n", st->marker->name);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment