Skip to content

Commit ae5d1cf

Browse files
labbottctmarinas
authored andcommitted
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: Kees Cook <keescook@chromium.org> Reviewed-by: Mark Rutland <mark.rutland@arm.com> Tested-by: Mark Rutland <mark.rutland@arm.com> Acked-by: Mark Rutland <mark.rutland@arm.com> Signed-off-by: Laura Abbott <labbott@redhat.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
1 parent 4ddb9bf commit ae5d1cf

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

arch/arm64/mm/dump.c

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,18 @@ static const struct addr_marker address_markers[] = {
5050
{ -1, NULL },
5151
};
5252

53+
#define pt_dump_seq_printf(m, fmt, args...) \
54+
({ \
55+
if (m) \
56+
seq_printf(m, fmt, ##args); \
57+
})
58+
59+
#define pt_dump_seq_puts(m, fmt) \
60+
({ \
61+
if (m) \
62+
seq_printf(m, fmt); \
63+
})
64+
5365
/*
5466
* The page dumper groups page table entries of the same type into a single
5567
* 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,
186198
s = bits->clear;
187199

188200
if (s)
189-
seq_printf(st->seq, " %s", s);
201+
pt_dump_seq_printf(st->seq, " %s", s);
190202
}
191203
}
192204

@@ -200,32 +212,32 @@ static void note_page(struct pg_state *st, unsigned long addr, unsigned level,
200212
st->level = level;
201213
st->current_prot = prot;
202214
st->start_address = addr;
203-
seq_printf(st->seq, "---[ %s ]---\n", st->marker->name);
215+
pt_dump_seq_printf(st->seq, "---[ %s ]---\n", st->marker->name);
204216
} else if (prot != st->current_prot || level != st->level ||
205217
addr >= st->marker[1].start_address) {
206218
const char *unit = units;
207219
unsigned long delta;
208220

209221
if (st->current_prot) {
210-
seq_printf(st->seq, "0x%016lx-0x%016lx ",
222+
pt_dump_seq_printf(st->seq, "0x%016lx-0x%016lx ",
211223
st->start_address, addr);
212224

213225
delta = (addr - st->start_address) >> 10;
214226
while (!(delta & 1023) && unit[1]) {
215227
delta >>= 10;
216228
unit++;
217229
}
218-
seq_printf(st->seq, "%9lu%c %s", delta, *unit,
230+
pt_dump_seq_printf(st->seq, "%9lu%c %s", delta, *unit,
219231
pg_level[st->level].name);
220232
if (pg_level[st->level].bits)
221233
dump_prot(st, pg_level[st->level].bits,
222234
pg_level[st->level].num);
223-
seq_puts(st->seq, "\n");
235+
pt_dump_seq_puts(st->seq, "\n");
224236
}
225237

226238
if (addr >= st->marker[1].start_address) {
227239
st->marker++;
228-
seq_printf(st->seq, "---[ %s ]---\n", st->marker->name);
240+
pt_dump_seq_printf(st->seq, "---[ %s ]---\n", st->marker->name);
229241
}
230242

231243
st->start_address = addr;
@@ -235,7 +247,7 @@ static void note_page(struct pg_state *st, unsigned long addr, unsigned level,
235247

236248
if (addr >= st->marker[1].start_address) {
237249
st->marker++;
238-
seq_printf(st->seq, "---[ %s ]---\n", st->marker->name);
250+
pt_dump_seq_printf(st->seq, "---[ %s ]---\n", st->marker->name);
239251
}
240252

241253
}

0 commit comments

Comments
 (0)