1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:07:35 +00:00

Kernel: Fix GDT and segment selectors to make userland work on x86_64

Userland faulted on the very first instruction before because the
PML4T/PDPT/etc. weren't marked as user-accessible. For some reason
x86 doesn't care about that.

Also, we need to provide an appropriate userspace stack segment
selector to iretq.
This commit is contained in:
Gunnar Beutner 2021-06-28 17:03:08 +02:00 committed by Andreas Kling
parent 04fc7d708c
commit b5aad1c81d
4 changed files with 16 additions and 9 deletions

View file

@ -1070,6 +1070,7 @@ UNMAP_AFTER_INIT void Processor::gdt_init()
#else
write_raw_gdt_entry(GDT_SELECTOR_CODE0, 0x0000ffff, 0x00af9a00); // code0
write_raw_gdt_entry(GDT_SELECTOR_CODE3, 0x0000ffff, 0x00affa00); // code3
write_raw_gdt_entry(GDT_SELECTOR_DATA3, 0x0000ffff, 0x008ff200); // data3
#endif
#if ARCH(I386)