Skip to content

Commit

Permalink
arch,pt: add PT_LEVELS macro defining page table levels
Browse files Browse the repository at this point in the history
Signed-off-by: Pawel Wieczorkiewicz <[email protected]>
  • Loading branch information
wipawel committed Nov 21, 2023
1 parent 93893ad commit f942ed3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
13 changes: 2 additions & 11 deletions arch/x86/pagetables.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,6 @@ static void dump_pagetable(mfn_t table, int level) {
}

void dump_pagetables(cr3_t *cr3_ptr) {
#if defined(__x86_64__)
int level = 4;
#else
int level = 3;
#endif
ASSERT(cr3_ptr);
if (mfn_invalid(cr3_ptr->mfn)) {
warning("CR3: 0x%lx is invalid", cr3.paddr);
Expand All @@ -134,18 +129,14 @@ void dump_pagetables(cr3_t *cr3_ptr) {

printk("Page Tables: CR3 paddr: 0x%lx\n", cr3.paddr);
spin_lock(&vmap_lock);
dump_pagetable(cr3_ptr->mfn, level);
dump_pagetable(cr3_ptr->mfn, PT_LEVELS);
spin_unlock(&vmap_lock);
}

static void dump_pagetable_va(cr3_t *cr3_ptr, void *va) {
paddr_t tab_paddr;
pgentry_t *tab;
#if defined(__x86_64__)
int level = 4;
#else
int level = 3;
#endif
int level = PT_LEVELS;

ASSERT(cr3_ptr);
if (mfn_invalid(cr3_ptr->mfn)) {
Expand Down
6 changes: 6 additions & 0 deletions include/arch/x86/page.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,12 @@ typedef unsigned long mfn_t;
#define VA_BITS 32
#endif

#ifdef __i386__
#define PT_LEVELS 3 /* assumes PAE */
#else
#define PT_LEVELS (la57_enabled() ? 5 : 4)
#endif

#define _paddr(addr) ((paddr_t) _ul(addr))

#define PADDR_INVALID (~0x0UL)
Expand Down

0 comments on commit f942ed3

Please sign in to comment.