ecomaikgolf / alma

toy kernel written in C++ for x86-64 machines with the mere purpose of learning OS development
8 stars 1 forks source link

Page Table Manager #54

Closed ecomaikgolf closed 2 years ago

ecomaikgolf commented 2 years ago

Already implemented, just a milestone issue

ecomaikgolf commented 2 years ago

Demonstration

This code gives a page fault CPU exception without the Page Table Manager Activated

//asm("mov %0, %%cr3" : : "r"(page_table.get_PGDT()));
uint16_t *a = (uint16_t *)UINT64_MAX;
*a = 0x1231;

2021-07-28-020820_683x368_scrot

If we remove the code everything works

//asm("mov %0, %%cr3" : : "r"(page_table.get_PGDT()));
//uint16_t *a = (uint16_t *)UINT64_MAX;
//*a = 0x1231;

2021-07-28-020912_924x563_scrot

If we activate the code and the Page Table Manager, and map the address we don't get the page fault

page_table.map(UINT64_MAX, fbbase); //when we request the UINT64_MAX virtual address, access fbbase physical addr (in range)
asm("mov %0, %%cr3" : : "r"(page_table.get_PGDT()));
uint16_t *a = (uint16_t *)UINT64_MAX;
*a = 0x1231;

2021-07-28-021026_897x506_scrot