Skip to content

Commit 3ce99bd

Browse files
Merge patch series "Improve PTDUMP and introduce new fields"
Yu Chien Peter Lin <[email protected]> says: This patchset enhances PTDUMP by providing additional information from pagetable entries. The first patch fixes the RSW field, while the second and third patches introduce the PBMT and NAPOT fields, respectively, for RV64 systems. * b4-shazam-merge: riscv: Introduce NAPOT field to PTDUMP riscv: Introduce PBMT field to PTDUMP riscv: Improve PTDUMP to show RSW with non-zero value Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
2 parents d3eabf2 + 015c3c3 commit 3ce99bd

File tree

2 files changed

+36
-21
lines changed

2 files changed

+36
-21
lines changed

arch/riscv/include/asm/pgtable-bits.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
#define _PAGE_GLOBAL (1 << 5) /* Global */
1717
#define _PAGE_ACCESSED (1 << 6) /* Set by hardware on any access */
1818
#define _PAGE_DIRTY (1 << 7) /* Set by hardware on any write */
19-
#define _PAGE_SOFT (1 << 8) /* Reserved for software */
19+
#define _PAGE_SOFT (3 << 8) /* Reserved for software */
2020

21-
#define _PAGE_SPECIAL _PAGE_SOFT
21+
#define _PAGE_SPECIAL (1 << 8) /* RSW: 0x1 */
2222
#define _PAGE_TABLE _PAGE_PRESENT
2323

2424
/*

arch/riscv/mm/ptdump.c

Lines changed: 34 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -129,55 +129,55 @@ static struct ptd_mm_info efi_ptd_info = {
129129
/* Page Table Entry */
130130
struct prot_bits {
131131
u64 mask;
132-
u64 val;
133132
const char *set;
134133
const char *clear;
135134
};
136135

137136
static const struct prot_bits pte_bits[] = {
138137
{
138+
#ifdef CONFIG_64BIT
139+
.mask = _PAGE_NAPOT,
140+
.set = "N",
141+
.clear = ".",
142+
}, {
143+
.mask = _PAGE_MTMASK_SVPBMT,
144+
.set = "MT(%s)",
145+
.clear = " .. ",
146+
}, {
147+
#endif
139148
.mask = _PAGE_SOFT,
140-
.val = _PAGE_SOFT,
141-
.set = "RSW",
142-
.clear = " ",
149+
.set = "RSW(%d)",
150+
.clear = " .. ",
143151
}, {
144152
.mask = _PAGE_DIRTY,
145-
.val = _PAGE_DIRTY,
146153
.set = "D",
147154
.clear = ".",
148155
}, {
149156
.mask = _PAGE_ACCESSED,
150-
.val = _PAGE_ACCESSED,
151157
.set = "A",
152158
.clear = ".",
153159
}, {
154160
.mask = _PAGE_GLOBAL,
155-
.val = _PAGE_GLOBAL,
156161
.set = "G",
157162
.clear = ".",
158163
}, {
159164
.mask = _PAGE_USER,
160-
.val = _PAGE_USER,
161165
.set = "U",
162166
.clear = ".",
163167
}, {
164168
.mask = _PAGE_EXEC,
165-
.val = _PAGE_EXEC,
166169
.set = "X",
167170
.clear = ".",
168171
}, {
169172
.mask = _PAGE_WRITE,
170-
.val = _PAGE_WRITE,
171173
.set = "W",
172174
.clear = ".",
173175
}, {
174176
.mask = _PAGE_READ,
175-
.val = _PAGE_READ,
176177
.set = "R",
177178
.clear = ".",
178179
}, {
179180
.mask = _PAGE_PRESENT,
180-
.val = _PAGE_PRESENT,
181181
.set = "V",
182182
.clear = ".",
183183
}
@@ -208,15 +208,30 @@ static void dump_prot(struct pg_state *st)
208208
unsigned int i;
209209

210210
for (i = 0; i < ARRAY_SIZE(pte_bits); i++) {
211-
const char *s;
211+
char s[7];
212+
unsigned long val;
212213

213-
if ((st->current_prot & pte_bits[i].mask) == pte_bits[i].val)
214-
s = pte_bits[i].set;
215-
else
216-
s = pte_bits[i].clear;
214+
val = st->current_prot & pte_bits[i].mask;
215+
if (val) {
216+
if (pte_bits[i].mask == _PAGE_SOFT)
217+
sprintf(s, pte_bits[i].set, val >> 8);
218+
#ifdef CONFIG_64BIT
219+
else if (pte_bits[i].mask == _PAGE_MTMASK_SVPBMT) {
220+
if (val == _PAGE_NOCACHE_SVPBMT)
221+
sprintf(s, pte_bits[i].set, "NC");
222+
else if (val == _PAGE_IO_SVPBMT)
223+
sprintf(s, pte_bits[i].set, "IO");
224+
else
225+
sprintf(s, pte_bits[i].set, "??");
226+
}
227+
#endif
228+
else
229+
sprintf(s, "%s", pte_bits[i].set);
230+
} else {
231+
sprintf(s, "%s", pte_bits[i].clear);
232+
}
217233

218-
if (s)
219-
pt_dump_seq_printf(st->seq, " %s", s);
234+
pt_dump_seq_printf(st->seq, " %s", s);
220235
}
221236
}
222237

0 commit comments

Comments
 (0)