You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I realized that 13ac000 belongs to GDT, I created my GDT and can now unmap that address.
But what is mapped in the first two addresses? Can I safely unmap them?
If it turns out not to be context switch function, then I suppose I can safely unmap these addresses anyway? Why does the bootloader leave these things mapped?
For example, GDT could be safely unmapped by bootloader.
If it turns out not to be context switch function, then I suppose I can safely unmap these addresses anyway?
I'm pretty sure it's the context switch function. If it's not the context switch function, then it depends on the memory for whether it's safe to unmap.
Why does the bootloader leave these things mapped?
The context switch function needs to do two things:
Switch to the kernel's page tables.
Jump to the kernel's entry point.
It needs to do these steps in that order. The problem is that if we don't map the context switch function into the kernel's page tables, we can't do the second step after switching the page tables.
For example, GDT could be safely unmapped by bootloader.
The GDT can't be safely unmapped before switching to a new one. Some instructions like iret read from the GDT and if the GDT is no longer mapped, this causes a page fault.
Activity
Freax13 commentedon Nov 1, 2024
That's probably the context switch function of the boot loader:
bootloader/common/src/lib.rs
Lines 235 to 260 in ea3f61a
These pages contain a function that switches to the kernel page tables and jumps to its entry point. You can safely unmap it.
See also #240
mrjbom commentedon Nov 1, 2024
If it turns out not to be context switch function, then I suppose I can safely unmap these addresses anyway? Why does the bootloader leave these things mapped?
For example, GDT could be safely unmapped by bootloader.
Freax13 commentedon Nov 1, 2024
I'm pretty sure it's the context switch function. If it's not the context switch function, then it depends on the memory for whether it's safe to unmap.
The context switch function needs to do two things:
It needs to do these steps in that order. The problem is that if we don't map the context switch function into the kernel's page tables, we can't do the second step after switching the page tables.
The GDT can't be safely unmapped before switching to a new one. Some instructions like
iretread from the GDT and if the GDT is no longer mapped, this causes a page fault.