1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 20:28:11 +00:00

Kernel: Move kernel above the 3GB virtual address mark

The kernel and its static data structures are no longer identity-mapped
in the bottom 8MB of the address space, but instead move above 3GB.

The first 8MB above 3GB are pseudo-identity-mapped to the bottom 8MB of
the physical address space. But things don't have to stay this way!

Thanks to Jesse who made an earlier attempt at this, it was really easy
to get device drivers working once the page tables were in place! :^)

Fixes #734.
This commit is contained in:
Andreas Kling 2020-01-17 19:59:20 +01:00
parent cee597a728
commit e362b56b4f
17 changed files with 325 additions and 125 deletions

View file

@ -146,6 +146,20 @@ static void dump(const RegisterDump& regs)
kprintf("eax=%08x ebx=%08x ecx=%08x edx=%08x\n", regs.eax, regs.ebx, regs.ecx, regs.edx);
kprintf("ebp=%08x esp=%08x esi=%08x edi=%08x\n", regs.ebp, esp, regs.esi, regs.edi);
u32 cr0;
asm("movl %%cr0, %%eax"
: "=a"(cr0));
u32 cr2;
asm("movl %%cr2, %%eax"
: "=a"(cr2));
u32 cr3;
asm("movl %%cr3, %%eax"
: "=a"(cr3));
u32 cr4;
asm("movl %%cr4, %%eax"
: "=a"(cr4));
kprintf("cr0=%08x cr2=%08x cr3=%08x cr4=%08x\n", cr0, cr2, cr3, cr4);
if (current && current->process().validate_read((void*)regs.eip, 8)) {
SmapDisabler disabler;
u8* codeptr = (u8*)regs.eip;
@ -221,7 +235,7 @@ EH_ENTRY(14, page_fault);
void page_fault_handler(RegisterDump regs)
{
clac();
ASSERT(current);
//ASSERT(current);
u32 fault_address;
asm("movl %%cr2, %%eax"
@ -232,12 +246,13 @@ void page_fault_handler(RegisterDump regs)
: "=a"(fault_page_directory));
#ifdef PAGE_FAULT_DEBUG
dbgprintf("%s(%u): ring%u %s page fault in PD=%x, %s V%08x\n",
dbgprintf("%s(%u): ring%u %s page fault in PD=%x, %s%s V%08x\n",
current ? current->process().name().characters() : "(none)",
current ? current->pid() : 0,
regs.cs & 3,
regs.exception_code & 1 ? "PV" : "NP",
fault_page_directory,
regs.exception_code & 8 ? "reserved-bit " : "",
regs.exception_code & 2 ? "write" : "read",
fault_address);
#endif