Commit cf98d2b6 authored by Christophe Leroy's avatar Christophe Leroy Committed by Michael Ellerman

powerpc/ptdump: Reduce level numbers by 1 in note_page() and add p4d level

Do the same as commit f8f0d0b6 ("mm: ptdump: reduce level numbers
by 1 in note_page()") and add missing p4d level.

This will align powerpc to the users of generic ptdump.
Signed-off-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/d76495c574132b197b445a1f133755cca4b912a4.1625762906.git.christophe.leroy@csgroup.eu
parent 64b87b0c
...@@ -75,8 +75,10 @@ static const struct flag_info flag_array[] = { ...@@ -75,8 +75,10 @@ static const struct flag_info flag_array[] = {
}; };
struct pgtable_level pg_level[5] = { struct pgtable_level pg_level[5] = {
{ { /* pgd */
}, { /* pgd */ .flag = flag_array,
.num = ARRAY_SIZE(flag_array),
}, { /* p4d */
.flag = flag_array, .flag = flag_array,
.num = ARRAY_SIZE(flag_array), .num = ARRAY_SIZE(flag_array),
}, { /* pud */ }, { /* pud */
......
...@@ -103,8 +103,10 @@ static const struct flag_info flag_array[] = { ...@@ -103,8 +103,10 @@ static const struct flag_info flag_array[] = {
}; };
struct pgtable_level pg_level[5] = { struct pgtable_level pg_level[5] = {
{ { /* pgd */
}, { /* pgd */ .flag = flag_array,
.num = ARRAY_SIZE(flag_array),
}, { /* p4d */
.flag = flag_array, .flag = flag_array,
.num = ARRAY_SIZE(flag_array), .num = ARRAY_SIZE(flag_array),
}, { /* pud */ }, { /* pud */
......
...@@ -58,7 +58,7 @@ struct pg_state { ...@@ -58,7 +58,7 @@ struct pg_state {
const struct addr_marker *marker; const struct addr_marker *marker;
unsigned long start_address; unsigned long start_address;
unsigned long start_pa; unsigned long start_pa;
unsigned int level; int level;
u64 current_flags; u64 current_flags;
bool check_wx; bool check_wx;
unsigned long wx_pages; unsigned long wx_pages;
...@@ -188,10 +188,9 @@ static void note_prot_wx(struct pg_state *st, unsigned long addr) ...@@ -188,10 +188,9 @@ static void note_prot_wx(struct pg_state *st, unsigned long addr)
st->wx_pages += (addr - st->start_address) / PAGE_SIZE; st->wx_pages += (addr - st->start_address) / PAGE_SIZE;
} }
static void note_page_update_state(struct pg_state *st, unsigned long addr, static void note_page_update_state(struct pg_state *st, unsigned long addr, int level, u64 val)
unsigned int level, u64 val)
{ {
u64 flag = val & pg_level[level].mask; u64 flag = level >= 0 ? val & pg_level[level].mask : 0;
u64 pa = val & PTE_RPN_MASK; u64 pa = val & PTE_RPN_MASK;
st->level = level; st->level = level;
...@@ -206,12 +205,12 @@ static void note_page_update_state(struct pg_state *st, unsigned long addr, ...@@ -206,12 +205,12 @@ static void note_page_update_state(struct pg_state *st, unsigned long addr,
} }
static void note_page(struct pg_state *st, unsigned long addr, static void note_page(struct pg_state *st, unsigned long addr,
unsigned int level, u64 val, unsigned long page_size) int level, u64 val, unsigned long page_size)
{ {
u64 flag = val & pg_level[level].mask; u64 flag = level >= 0 ? val & pg_level[level].mask : 0;
/* At first no level is set */ /* At first no level is set */
if (!st->level) { if (st->level == -1) {
pt_dump_seq_printf(st->seq, "---[ %s ]---\n", st->marker->name); pt_dump_seq_printf(st->seq, "---[ %s ]---\n", st->marker->name);
note_page_update_state(st, addr, level, val); note_page_update_state(st, addr, level, val);
/* /*
...@@ -383,6 +382,7 @@ static int ptdump_show(struct seq_file *m, void *v) ...@@ -383,6 +382,7 @@ static int ptdump_show(struct seq_file *m, void *v)
struct pg_state st = { struct pg_state st = {
.seq = m, .seq = m,
.marker = address_markers, .marker = address_markers,
.level = -1,
.start_address = IS_ENABLED(CONFIG_PPC64) ? PAGE_OFFSET : TASK_SIZE, .start_address = IS_ENABLED(CONFIG_PPC64) ? PAGE_OFFSET : TASK_SIZE,
}; };
...@@ -393,7 +393,7 @@ static int ptdump_show(struct seq_file *m, void *v) ...@@ -393,7 +393,7 @@ static int ptdump_show(struct seq_file *m, void *v)
/* Traverse kernel page tables */ /* Traverse kernel page tables */
walk_pagetables(&st); walk_pagetables(&st);
note_page(&st, 0, 0, 0, 0); note_page(&st, 0, -1, 0, 0);
return 0; return 0;
} }
...@@ -415,6 +415,7 @@ void ptdump_check_wx(void) ...@@ -415,6 +415,7 @@ void ptdump_check_wx(void)
struct pg_state st = { struct pg_state st = {
.seq = NULL, .seq = NULL,
.marker = address_markers, .marker = address_markers,
.level = -1,
.check_wx = true, .check_wx = true,
.start_address = IS_ENABLED(CONFIG_PPC64) ? PAGE_OFFSET : TASK_SIZE, .start_address = IS_ENABLED(CONFIG_PPC64) ? PAGE_OFFSET : TASK_SIZE,
}; };
......
...@@ -68,8 +68,10 @@ static const struct flag_info flag_array[] = { ...@@ -68,8 +68,10 @@ static const struct flag_info flag_array[] = {
}; };
struct pgtable_level pg_level[5] = { struct pgtable_level pg_level[5] = {
{ { /* pgd */
}, { /* pgd */ .flag = flag_array,
.num = ARRAY_SIZE(flag_array),
}, { /* p4d */
.flag = flag_array, .flag = flag_array,
.num = ARRAY_SIZE(flag_array), .num = ARRAY_SIZE(flag_array),
}, { /* pud */ }, { /* pud */
......
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