Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pagetable enhancements #283

Merged
merged 2 commits into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions arch/x86/pagetables.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ cr3_t user_cr3;
static inline const char *dump_pte_flags(char *buf, size_t size, pte_t pte) {
/* clang-format off */
snprintf(buf, size, "%c %c%c%c%c%c%c%c%c%c",
pte.NX ? 'X' : '-',
pte.NX ? '-' : 'X',
pte.G ? 'G' : '-',
pte.PAT ? 'p' : '-',
pte.D ? 'D' : '-',
Expand Down Expand Up @@ -90,16 +90,14 @@ static inline void dump_page_table(void *table, int level) {
}
}

void dump_pagetables(void) {
void dump_pagetables(cr3_t cr3) {
printk("\nPage Tables:\n");

/* Map all used frames to be able to parse page tables */
map_used_memory();

paddr_t cur_cr3 = read_cr3();

printk("CR3: paddr: 0x%lx\n", cur_cr3);
dump_page_table(paddr_to_virt_kern(cur_cr3), 4);
printk("CR3: paddr: 0x%lx\n", cr3.paddr);
dump_page_table(paddr_to_virt_kern(cr3.paddr), 4);
}

static void *init_map_mfn(mfn_t mfn) {
Expand Down
2 changes: 1 addition & 1 deletion common/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ void __noreturn __text_init kernel_start(uint32_t multiboot_magic, unsigned long

WRITE_SP(get_free_pages_top(PAGE_ORDER_2M, GFP_KERNEL));
if (opt_debug)
dump_pagetables();
dump_pagetables(cr3);

if (setup_framebuffer())
display_banner();
Expand Down
2 changes: 1 addition & 1 deletion include/arch/x86/pagetable.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ extern pml4_t l4_pt_entries[L4_PT_ENTRIES];
#endif

extern void init_pagetables(void);
extern void dump_pagetables(void);
extern void dump_pagetables(cr3_t cr3);

#endif /* __ASSEMBLY__ */

Expand Down