1
0
mirror of https://github.com/SerenityOS/serenity synced 2024-07-09 08:20:44 +00:00

Kernel: Add a Thread member for arch-specific data

This will be used to store the fs_base value on x86-64, which is needed
for thread-local storage.
This commit is contained in:
Sönke Holz 2024-04-13 10:26:50 +02:00 committed by Andrew Kaster
parent 57f4f8caf8
commit 216089c7a1
6 changed files with 72 additions and 0 deletions

View File

@ -0,0 +1,19 @@
/*
* Copyright (c) 2024, Sönke Holz <sholz8530@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Platform.h>
#if ARCH(X86_64)
# include <Kernel/Arch/x86_64/ArchSpecificThreadData.h>
#elif ARCH(AARCH64)
# include <Kernel/Arch/aarch64/ArchSpecificThreadData.h>
#elif ARCH(RISCV64)
# include <Kernel/Arch/riscv64/ArchSpecificThreadData.h>
#else
# error Unknown architecture
#endif

View File

@ -0,0 +1,16 @@
/*
* Copyright (c) 2024, Sönke Holz <sholz8530@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Types.h>
namespace Kernel {
struct ArchSpecificThreadData {
};
}

View File

@ -0,0 +1,16 @@
/*
* Copyright (c) 2024, Sönke Holz <sholz8530@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Types.h>
namespace Kernel {
struct ArchSpecificThreadData {
};
}

View File

@ -0,0 +1,16 @@
/*
* Copyright (c) 2024, Sönke Holz <sholz8530@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Types.h>
namespace Kernel {
struct ArchSpecificThreadData {
};
}

View File

@ -1210,6 +1210,7 @@ ErrorOr<NonnullRefPtr<Thread>> Thread::clone(NonnullRefPtr<Process> process)
clone->m_signal_mask = m_signal_mask;
clone->m_fpu_state = m_fpu_state;
clone->m_thread_specific_data = m_thread_specific_data;
clone->m_arch_specific_data = m_arch_specific_data;
return clone;
}

View File

@ -20,6 +20,7 @@
#include <Kernel/API/POSIX/sched.h>
#include <Kernel/API/POSIX/select.h>
#include <Kernel/API/POSIX/signal_numbers.h>
#include <Kernel/Arch/ArchSpecificThreadData.h>
#include <Kernel/Arch/RegisterState.h>
#include <Kernel/Arch/ThreadRegisters.h>
#include <Kernel/Debug.h>
@ -790,6 +791,8 @@ public:
StringView state_string() const;
VirtualAddress thread_specific_data() const { return m_thread_specific_data; }
ArchSpecificThreadData& arch_specific_data() { return m_arch_specific_data; }
ArchSpecificThreadData const& arch_specific_data() const { return m_arch_specific_data; }
ALWAYS_INLINE void yield_if_should_be_stopped()
{
@ -1193,6 +1196,7 @@ private:
IntrusiveListNode<Thread> m_blocked_threads_list_node;
LockRank m_lock_rank_mask {};
bool m_allocation_enabled { true };
ArchSpecificThreadData m_arch_specific_data;
// FIXME: remove this after annihilating Process::m_big_lock
IntrusiveListNode<Thread> m_big_lock_blocked_threads_list_node;