mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 21:47:46 +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:
parent
04fc7d708c
commit
b5aad1c81d
4 changed files with 16 additions and 9 deletions
|
@ -115,8 +115,13 @@ u32 Processor::init_context(Thread& thread, bool leave_crit)
|
|||
iretframe.rflags = regs.rflags;
|
||||
iretframe.rip = regs.rip;
|
||||
iretframe.cs = regs.cs;
|
||||
iretframe.userspace_rsp = kernel_stack_top;
|
||||
iretframe.userspace_ss = 0;
|
||||
if (return_to_user) {
|
||||
iretframe.userspace_rsp = regs.rsp;
|
||||
iretframe.userspace_ss = GDT_SELECTOR_DATA3 | 3;
|
||||
} else {
|
||||
iretframe.userspace_rsp = kernel_stack_top;
|
||||
iretframe.userspace_ss = 0;
|
||||
}
|
||||
|
||||
// make space for a trap frame
|
||||
stack_top -= sizeof(TrapFrame);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue