Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1493735
| From | Laura Abbott <labbott@redhat.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 2/3] arm64: dump: Make the page table dumping seq_file optional |
| Date | 2016-09-29 23:40 +0200 |
| Message-ID | <smRdD-15L-11@gated-at.bofh.it> (permalink) |
| References | <smRdD-15L-9@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
The page table dumping code always assumes it will be dumping to a
seq_file to userspace. The dumping code is useful in other situations.
Let the seq_file be optional.
Signed-off-by: Laura Abbott <labbott@redhat.com>
---
arch/arm64/mm/dump.c | 26 +++++++++++++++++++-------
1 file changed, 19 insertions(+), 7 deletions(-)
diff --git a/arch/arm64/mm/dump.c b/arch/arm64/mm/dump.c
index 29e0838..e318f3d 100644
--- a/arch/arm64/mm/dump.c
+++ b/arch/arm64/mm/dump.c
@@ -50,6 +50,18 @@ static const struct addr_marker address_markers[] = {
{ -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
* 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,
s = bits->clear;
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,
st->level = level;
st->current_prot = prot;
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 ||
addr >= st->marker[1].start_address) {
const char *unit = units;
unsigned long delta;
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);
delta = (addr - st->start_address) >> 10;
@@ -215,17 +227,17 @@ static void note_page(struct pg_state *st, unsigned long addr, unsigned level,
delta >>= 10;
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);
if (pg_level[st->level].bits)
dump_prot(st, pg_level[st->level].bits,
pg_level[st->level].num);
- seq_puts(st->seq, "\n");
+ pt_dump_seq_puts(st->seq, "\n");
}
if (addr >= st->marker[1].start_address) {
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;
@@ -235,7 +247,7 @@ static void note_page(struct pg_state *st, unsigned long addr, unsigned level,
if (addr >= st->marker[1].start_address) {
st->marker++;
- seq_printf(st->seq, "---[ %s ]---\n", st->marker->name);
+ pt_dump_seq_printf(st->seq, "---[ %s ]---\n", st->marker->name);
}
}
--
2.10.0
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 0/3] WX Checking for arm64 Laura Abbott <labbott@redhat.com> - 2016-09-29 23:40 +0200
[PATCH 3/3] arm64: dump: Add checking for writable and exectuable pages Laura Abbott <labbott@redhat.com> - 2016-09-29 23:40 +0200
Re: [PATCH 3/3] arm64: dump: Add checking for writable and exectuable pages Mark Rutland <mark.rutland@arm.com> - 2016-09-30 04:10 +0200
Re: [PATCH 3/3] arm64: dump: Add checking for writable and exectuable pages Mark Rutland <mark.rutland@arm.com> - 2016-09-30 18:00 +0200
Re: [PATCH 3/3] arm64: dump: Add checking for writable and exectuable pages Kees Cook <keescook@chromium.org> - 2016-09-30 18:30 +0200
Re: [PATCH 3/3] arm64: dump: Add checking for writable and exectuable pages Mark Rutland <mark.rutland@arm.com> - 2016-09-30 18:50 +0200
Re: [PATCH 3/3] arm64: dump: Add checking for writable and exectuable pages Kees Cook <keescook@chromium.org> - 2016-09-30 19:20 +0200
[PATCH 2/3] arm64: dump: Make the page table dumping seq_file optional Laura Abbott <labbott@redhat.com> - 2016-09-29 23:40 +0200
Re: [PATCH 2/3] arm64: dump: Make the page table dumping seq_file optional Mark Rutland <mark.rutland@arm.com> - 2016-09-30 02:40 +0200
[PATCH 1/3] arm64: dump: Make ptdump debugfs a separate option Laura Abbott <labbott@redhat.com> - 2016-09-29 23:40 +0200
Re: [PATCH 1/3] arm64: dump: Make ptdump debugfs a separate option Mark Rutland <mark.rutland@arm.com> - 2016-09-30 02:30 +0200
Re: [PATCH 1/3] arm64: dump: Make ptdump debugfs a separate option Laura Abbott <labbott@redhat.com> - 2016-09-30 02:40 +0200
Re: [PATCH 1/3] arm64: dump: Make ptdump debugfs a separate option Mark Rutland <mark.rutland@arm.com> - 2016-09-30 02:50 +0200
Re: [PATCH 1/3] arm64: dump: Make ptdump debugfs a separate option Laura Abbott <labbott@redhat.com> - 2016-09-30 03:20 +0200
Re: [PATCH 1/3] arm64: dump: Make ptdump debugfs a separate option Mark Rutland <mark.rutland@arm.com> - 2016-09-30 03:30 +0200
Re: [kernel-hardening] [PATCH 0/3] WX Checking for arm64 Kees Cook <keescook@chromium.org> - 2016-09-30 03:30 +0200
csiph-web