mirror of
https://github.com/SerenityOS/serenity
synced 2024-07-22 18:46:18 +00:00
![Sönke Holz](/assets/img/avatar_default.png)
This removes the allocate_tls syscall and adds an archctl option to set the fs_base for the current thread on x86-64, since you can't set that register from userspace. enter_thread_context loads the fs_base for the next thread on each context switch. This also moves tpidr_el0 (the thread pointer register on AArch64) to the register state, so it gets properly saved/restored on context switches. The userspace TLS allocation code is kept pretty similar to the original kernel TLS code, aside from a couple of style changes. We also have to add a new argument "tls_pointer" to SC_create_thread_params, as we otherwise can't prevent race conditions between setting the thread pointer register and signal handling code that might be triggered before the thread pointer was set, which could use TLS.
28 lines
562 B
C++
28 lines
562 B
C++
/*
|
|
* Copyright (c) 2024, Sönke Holz <sholz8530@gmail.com>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <Kernel/API/archctl_numbers.h>
|
|
#include <Kernel/Tasks/Process.h>
|
|
|
|
namespace Kernel {
|
|
|
|
ErrorOr<FlatPtr> Process::sys$archctl(int option, FlatPtr arg1)
|
|
{
|
|
VERIFY_NO_PROCESS_BIG_LOCK(this);
|
|
switch (option) {
|
|
case ARCHCTL_X86_64_SET_FS_BASE_FOR_CURRENT_THREAD: {
|
|
Thread::current()->arch_specific_data().fs_base = arg1;
|
|
Processor::set_fs_base(arg1);
|
|
return 0;
|
|
}
|
|
|
|
default:
|
|
return EINVAL;
|
|
}
|
|
}
|
|
|
|
}
|