Skip to content

Commit

Permalink
Kernel: Remove special-casing of sys$gettid() in syscall entry
Browse files Browse the repository at this point in the history
We had a fast-path for the gettid syscall that was useful before
we started caching the thread ID in LibC. Just get rid of it. :^)
  • Loading branch information
awesomekling committed Jul 17, 2020
1 parent 485d1fa commit 8ec8ec8
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions Kernel/Syscall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,7 @@ int handle(RegisterState& regs, u32 function, u32 arg1, u32 arg2, u32 arg3)
void syscall_handler(TrapFrame* trap)
{
auto& regs = *trap->regs;
// Special handling of the "gettid" syscall since it's extremely hot.
// FIXME: Remove this hack once userspace locks stop calling it so damn much.
auto current_thread = Thread::current();
auto& process = current_thread->process();
if (regs.eax == SC_gettid) {
regs.eax = process.sys$gettid();
current_thread->did_syscall();
return;
}

if (current_thread->tracer() && current_thread->tracer()->is_tracing_syscalls()) {
current_thread->tracer()->set_trace_syscalls(false);
Expand All @@ -149,6 +141,7 @@ void syscall_handler(TrapFrame* trap)
asm volatile(""
: "=m"(*ptr));

auto& process = current_thread->process();
if (!MM.validate_user_stack(process, VirtualAddress(regs.userspace_esp))) {
dbg() << "Invalid stack pointer: " << String::format("%p", regs.userspace_esp);
handle_crash(regs, "Bad stack on syscall entry", SIGSTKFLT);
Expand Down

0 comments on commit 8ec8ec8

Please sign in to comment.