Commit 6bf9a639 authored by Heiko Carstens's avatar Heiko Carstens Committed by Vasily Gorbik

s390/mm,ptdump: make page table dumping seq_file optional

s390 version of ae5d1cf3 ("arm64: dump: Make the page table
dumping seq_file optional").
Tested-by: default avatarVasily Gorbik <gor@linux.ibm.com>
Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
parent 6c6687a4
...@@ -51,18 +51,34 @@ struct pg_state { ...@@ -51,18 +51,34 @@ struct pg_state {
const struct addr_marker *marker; const struct addr_marker *marker;
}; };
#define pt_dump_seq_printf(m, fmt, args...) \
({ \
struct seq_file *__m = (m); \
\
if (__m) \
seq_printf(__m, fmt, ##args); \
})
#define pt_dump_seq_puts(m, fmt) \
({ \
struct seq_file *__m = (m); \
\
if (__m) \
seq_printf(__m, fmt); \
})
static void print_prot(struct seq_file *m, unsigned int pr, int level) static void print_prot(struct seq_file *m, unsigned int pr, int level)
{ {
static const char * const level_name[] = static const char * const level_name[] =
{ "ASCE", "PGD", "PUD", "PMD", "PTE" }; { "ASCE", "PGD", "PUD", "PMD", "PTE" };
seq_printf(m, "%s ", level_name[level]); pt_dump_seq_printf(m, "%s ", level_name[level]);
if (pr & _PAGE_INVALID) { if (pr & _PAGE_INVALID) {
seq_printf(m, "I\n"); pt_dump_seq_printf(m, "I\n");
return; return;
} }
seq_puts(m, (pr & _PAGE_PROTECT) ? "RO " : "RW "); pt_dump_seq_puts(m, (pr & _PAGE_PROTECT) ? "RO " : "RW ");
seq_puts(m, (pr & _PAGE_NOEXEC) ? "NX\n" : "X\n"); pt_dump_seq_puts(m, (pr & _PAGE_NOEXEC) ? "NX\n" : "X\n");
} }
static void note_page(struct ptdump_state *pt_st, unsigned long addr, int level, u64 val) static void note_page(struct ptdump_state *pt_st, unsigned long addr, int level, u64 val)
...@@ -87,13 +103,13 @@ static void note_page(struct ptdump_state *pt_st, unsigned long addr, int level, ...@@ -87,13 +103,13 @@ static void note_page(struct ptdump_state *pt_st, unsigned long addr, int level,
if (level == -1) if (level == -1)
addr = max_addr; addr = max_addr;
if (st->level == -1) { if (st->level == -1) {
seq_printf(m, "---[ %s ]---\n", st->marker->name); pt_dump_seq_printf(m, "---[ %s ]---\n", st->marker->name);
st->start_address = addr; st->start_address = addr;
st->current_prot = prot; st->current_prot = prot;
st->level = level; st->level = level;
} 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) {
seq_printf(m, "0x%0*lx-0x%0*lx ", pt_dump_seq_printf(m, "0x%0*lx-0x%0*lx ",
width, st->start_address, width, st->start_address,
width, addr); width, addr);
delta = (addr - st->start_address) >> 10; delta = (addr - st->start_address) >> 10;
...@@ -101,11 +117,11 @@ static void note_page(struct ptdump_state *pt_st, unsigned long addr, int level, ...@@ -101,11 +117,11 @@ static void note_page(struct ptdump_state *pt_st, unsigned long addr, int level,
delta >>= 10; delta >>= 10;
unit++; unit++;
} }
seq_printf(m, "%9lu%c ", delta, *unit); pt_dump_seq_printf(m, "%9lu%c ", delta, *unit);
print_prot(m, st->current_prot, st->level); print_prot(m, st->current_prot, st->level);
while (addr >= st->marker[1].start_address) { while (addr >= st->marker[1].start_address) {
st->marker++; st->marker++;
seq_printf(m, "---[ %s ]---\n", st->marker->name); pt_dump_seq_printf(m, "---[ %s ]---\n", st->marker->name);
} }
st->start_address = addr; st->start_address = addr;
st->current_prot = prot; st->current_prot = prot;
......
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