Skip to content

Commit 9182301

Browse files
Sebastian EneMarc Zyngier
authored andcommitted
arm64: ptdump: Use the ptdump description from a local context
Rename the attributes description array to allow the parsing method to use the description from a local context. To be able to do this, store a pointer to the description array in the state structure. This will allow for the later introduced callers (stage_2 ptdump) to specify their own page table description format to the ptdump parser. Signed-off-by: Sebastian Ene <[email protected]> Acked-by: Will Deacon <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Marc Zyngier <[email protected]>
1 parent acc3d3a commit 9182301

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

arch/arm64/include/asm/ptdump.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ struct ptdump_pg_level {
4545
*/
4646
struct ptdump_pg_state {
4747
struct ptdump_state ptdump;
48+
struct ptdump_pg_level *pg_level;
4849
struct seq_file *seq;
4950
const struct addr_marker *marker;
5051
const struct mm_struct *mm;

arch/arm64/mm/ptdump.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ static const struct ptdump_prot_bits pte_bits[] = {
117117
}
118118
};
119119

120-
static struct ptdump_pg_level pg_level[] __ro_after_init = {
120+
static struct ptdump_pg_level kernel_pg_levels[] __ro_after_init = {
121121
{ /* pgd */
122122
.name = "PGD",
123123
.bits = pte_bits,
@@ -192,6 +192,7 @@ void note_page(struct ptdump_state *pt_st, unsigned long addr, int level,
192192
u64 val)
193193
{
194194
struct ptdump_pg_state *st = container_of(pt_st, struct ptdump_pg_state, ptdump);
195+
struct ptdump_pg_level *pg_level = st->pg_level;
195196
static const char units[] = "KMGTPE";
196197
u64 prot = 0;
197198

@@ -262,6 +263,7 @@ void ptdump_walk(struct seq_file *s, struct ptdump_info *info)
262263
.seq = s,
263264
.marker = info->markers,
264265
.mm = info->mm,
266+
.pg_level = &kernel_pg_levels[0],
265267
.level = -1,
266268
.ptdump = {
267269
.note_page = note_page,
@@ -279,10 +281,10 @@ static void __init ptdump_initialize(void)
279281
{
280282
unsigned i, j;
281283

282-
for (i = 0; i < ARRAY_SIZE(pg_level); i++)
283-
if (pg_level[i].bits)
284-
for (j = 0; j < pg_level[i].num; j++)
285-
pg_level[i].mask |= pg_level[i].bits[j].mask;
284+
for (i = 0; i < ARRAY_SIZE(kernel_pg_levels); i++)
285+
if (kernel_pg_levels[i].bits)
286+
for (j = 0; j < kernel_pg_levels[i].num; j++)
287+
kernel_pg_levels[i].mask |= kernel_pg_levels[i].bits[j].mask;
286288
}
287289

288290
static struct ptdump_info kernel_ptdump_info __ro_after_init = {
@@ -297,6 +299,7 @@ bool ptdump_check_wx(void)
297299
{ 0, NULL},
298300
{ -1, NULL},
299301
},
302+
.pg_level = &kernel_pg_levels[0],
300303
.level = -1,
301304
.check_wx = true,
302305
.ptdump = {

0 commit comments

Comments
 (0)