Kernel: Add Syscall.cpp to aarch64 build

This commit is contained in:
Timon Kruiper 2023-01-25 16:04:13 +01:00 committed by Linus Groh
parent b941bd55d9
commit 58cfd46a5a
Notes: sideshowbarker 2024-07-17 07:38:17 +09:00
2 changed files with 19 additions and 2 deletions

View File

@ -261,6 +261,7 @@ set(KERNEL_SOURCES
Scheduler.cpp
ScopedCritical.cpp
StdLib.cpp
Syscall.cpp
Syscalls/anon_create.cpp
Syscalls/alarm.cpp
Syscalls/beep.cpp
@ -402,7 +403,6 @@ if ("${SERENITY_ARCH}" STREQUAL "x86_64")
Interrupts/SpuriousInterruptHandler.cpp
kprintf.cpp
Panic.cpp
Syscall.cpp
)
set(KERNEL_SOURCES

View File

@ -7,7 +7,6 @@
#include <Kernel/API/Syscall.h>
#include <Kernel/Arch/TrapFrame.h>
#include <Kernel/Arch/x86_64/Interrupts.h>
#include <Kernel/Memory/MemoryManager.h>
#include <Kernel/Panic.h>
#include <Kernel/PerformanceManager.h>
@ -16,6 +15,10 @@
#include <Kernel/Sections.h>
#include <Kernel/ThreadTracer.h>
#if ARCH(X86_64)
# include <Kernel/Arch/x86_64/Interrupts.h>
#endif
namespace Kernel {
extern "C" void syscall_handler(TrapFrame*) __attribute__((used));
@ -61,7 +64,9 @@ static ErrorOr<FlatPtr> handle(RegisterState&, FlatPtr function, FlatPtr arg1, F
UNMAP_AFTER_INIT void initialize()
{
#if ARCH(X86_64)
register_user_callable_interrupt_handler(syscall_vector, syscall_asm_entry);
#endif
}
using Handler = auto(Process::*)(FlatPtr, FlatPtr, FlatPtr, FlatPtr) -> ErrorOr<FlatPtr>;
@ -140,8 +145,14 @@ ErrorOr<FlatPtr> handle(RegisterState& regs, FlatPtr function, FlatPtr arg1, Fla
NEVER_INLINE void syscall_handler(TrapFrame* trap)
{
#if ARCH(X86_64)
// Make sure SMAP protection is enabled on syscall entry.
clac();
#elif ARCH(AARCH64)
// FIXME: Implement the security mechanism for aarch64
#else
# error Unknown architecture
#endif
auto& regs = *trap->regs;
auto* current_thread = Thread::current();
@ -161,6 +172,7 @@ NEVER_INLINE void syscall_handler(TrapFrame* trap)
current_thread->yield_if_stopped();
#if ARCH(X86_64)
// Apply a random offset in the range 0-255 to the stack pointer,
// to make kernel stacks a bit less deterministic.
u32 lsw;
@ -177,6 +189,11 @@ NEVER_INLINE void syscall_handler(TrapFrame* trap)
if ((flags & (iopl_mask)) != 0) {
PANIC("Syscall from process with IOPL != 0");
}
#elif ARCH(AARCH64)
// FIXME: Implement the security mechanism for aarch64
#else
# error Unknown architecture
#endif
Memory::MemoryManager::validate_syscall_preconditions(process, regs);