Kernel: Rename {ss,esp}_if_crossRing to userspace_{ss,esp}
These were always so awkwardly named.
This commit is contained in:
parent
f007a63b10
commit
17ef5bc0ac
Notes:
sideshowbarker
2024-07-19 10:14:41 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/17ef5bc0ace
6 changed files with 15 additions and 15 deletions
Kernel
|
@ -135,8 +135,8 @@ static void dump(const RegisterDump& regs)
|
|||
ss = regs.ss;
|
||||
esp = regs.esp;
|
||||
} else {
|
||||
ss = regs.ss_if_crossRing;
|
||||
esp = regs.esp_if_crossRing;
|
||||
ss = regs.userspace_ss;
|
||||
esp = regs.userspace_esp;
|
||||
}
|
||||
|
||||
kprintf("exception code: %04x (isr: %04x)\n", regs.exception_code, regs.isr_number);
|
||||
|
@ -247,8 +247,8 @@ void page_fault_handler(RegisterDump regs)
|
|||
#endif
|
||||
|
||||
bool faulted_in_userspace = (regs.cs & 3) == 3;
|
||||
if (faulted_in_userspace && !MM.validate_user_stack(current->process(), VirtualAddress(regs.esp_if_crossRing))) {
|
||||
dbgprintf("Invalid stack pointer: %p\n", regs.esp_if_crossRing);
|
||||
if (faulted_in_userspace && !MM.validate_user_stack(current->process(), VirtualAddress(regs.userspace_esp))) {
|
||||
dbgprintf("Invalid stack pointer: %p\n", regs.userspace_esp);
|
||||
handle_crash(regs, "Bad stack on page fault", SIGSTKFLT);
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
|
|
@ -410,8 +410,8 @@ struct [[gnu::packed]] RegisterDump
|
|||
u32 eip;
|
||||
u32 cs;
|
||||
u32 eflags;
|
||||
u32 esp_if_crossRing;
|
||||
u32 ss_if_crossRing;
|
||||
u32 userspace_esp;
|
||||
u32 userspace_ss;
|
||||
};
|
||||
|
||||
struct [[gnu::aligned(16)]] FPUState
|
||||
|
|
|
@ -587,7 +587,7 @@ pid_t Process::sys$fork(RegisterDump& regs)
|
|||
child_tss.ecx = regs.ecx;
|
||||
child_tss.edx = regs.edx;
|
||||
child_tss.ebp = regs.ebp;
|
||||
child_tss.esp = regs.esp_if_crossRing;
|
||||
child_tss.esp = regs.userspace_esp;
|
||||
child_tss.esi = regs.esi;
|
||||
child_tss.edi = regs.edi;
|
||||
child_tss.eflags = regs.eflags;
|
||||
|
@ -597,7 +597,7 @@ pid_t Process::sys$fork(RegisterDump& regs)
|
|||
child_tss.es = regs.es;
|
||||
child_tss.fs = regs.fs;
|
||||
child_tss.gs = regs.gs;
|
||||
child_tss.ss = regs.ss_if_crossRing;
|
||||
child_tss.ss = regs.userspace_ss;
|
||||
|
||||
#ifdef FORK_DEBUG
|
||||
dbgprintf("fork: child will begin executing at %w:%x with stack %w:%x, kstack %w:%x\n", child_tss.cs, child_tss.eip, child_tss.ss, child_tss.esp, child_tss.ss0, child_tss.esp0);
|
||||
|
@ -1180,7 +1180,7 @@ int Process::sys$sigreturn(RegisterDump& registers)
|
|||
SmapDisabler disabler;
|
||||
|
||||
//Here, we restore the state pushed by dispatch signal and asm_signal_trampoline.
|
||||
u32* stack_ptr = (u32*)registers.esp_if_crossRing;
|
||||
u32* stack_ptr = (u32*)registers.userspace_esp;
|
||||
u32 smuggled_eax = *stack_ptr;
|
||||
|
||||
//pop the stored eax, ebp, return address, handler and signal code
|
||||
|
@ -1199,7 +1199,7 @@ int Process::sys$sigreturn(RegisterDump& registers)
|
|||
registers.eflags = *stack_ptr;
|
||||
stack_ptr++;
|
||||
|
||||
registers.esp_if_crossRing = registers.esp;
|
||||
registers.userspace_esp = registers.esp;
|
||||
return smuggled_eax;
|
||||
}
|
||||
|
||||
|
|
|
@ -603,8 +603,8 @@ void Scheduler::timer_tick(RegisterDump& regs)
|
|||
outgoing_tss.ss = regs.ss;
|
||||
|
||||
if ((outgoing_tss.cs & 3) != 0) {
|
||||
outgoing_tss.ss = regs.ss_if_crossRing;
|
||||
outgoing_tss.esp = regs.esp_if_crossRing;
|
||||
outgoing_tss.ss = regs.userspace_ss;
|
||||
outgoing_tss.esp = regs.userspace_esp;
|
||||
}
|
||||
prepare_for_iret_to_new_process();
|
||||
|
||||
|
|
|
@ -104,8 +104,8 @@ void syscall_handler(RegisterDump regs)
|
|||
|
||||
auto& process = current->process();
|
||||
|
||||
if (!MM.validate_user_stack(process, VirtualAddress(regs.esp_if_crossRing))) {
|
||||
dbgprintf("Invalid stack pointer: %p\n", regs.esp_if_crossRing);
|
||||
if (!MM.validate_user_stack(process, VirtualAddress(regs.userspace_esp))) {
|
||||
dbgprintf("Invalid stack pointer: %p\n", regs.userspace_esp);
|
||||
handle_crash(regs, "Bad stack on syscall entry", SIGSTKFLT);
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
|
|
@ -557,7 +557,7 @@ ShouldUnblockThread Thread::dispatch_signal(u8 signal)
|
|||
set_state(Skip1SchedulerPass);
|
||||
} else {
|
||||
auto& regs = get_register_dump_from_stack();
|
||||
u32* stack = ®s.esp_if_crossRing;
|
||||
u32* stack = ®s.userspace_esp;
|
||||
setup_stack(regs, stack);
|
||||
regs.eip = g_return_to_ring3_from_signal_trampoline.get();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue