Skip to content

Commit

Permalink
dump_pagetables: Avoid incorrect BUG_ON condition.
Browse files Browse the repository at this point in the history
The recursion should stop at level 0, since at this level table is not a
page table anymore. This would otherwise trigger a panic when dumping page
tables.

Signed-off-by: Johannes Wikner <[email protected]>
  • Loading branch information
sktt committed Nov 30, 2023
1 parent d1daed0 commit 99db3f5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions arch/x86/pagetables.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ static inline bool is_canon_va(const void *va) {
static void dump_pagetable(mfn_t table, int level) {
pte_t *pt;

if (level == 0)
return;

BUG_ON(mfn_invalid(table));
pt = tmp_map_mfn(table);
BUG_ON(!pt);
Expand Down
2 changes: 2 additions & 0 deletions tests/unittests.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ int unit_tests(void *_unused) {
cpu_freq_expect("Prototyp Amazing Foo One @ 1GHz", 1000000000);
cpu_freq_expect("Prototyp Amazing Foo Two @ 1.00GHz", 1000000000);

dump_pagetables(&cr3);

map_pagetables(&cr3, NULL);
map_pagetables(&cr3, &user_cr3);
pte_t *pte = get_pte(unit_tests);
Expand Down

0 comments on commit 99db3f5

Please sign in to comment.