summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimon Kruiper <timonkruiper@gmail.com>2023-01-25 16:04:13 +0100
committerLinus Groh <mail@linusgroh.de>2023-01-27 20:47:08 +0000
commit58cfd46a5a7f4e41fb2da5ea253b9ff27979e5d9 (patch)
tree05f4fe77b658be8141b74297670d6ac302447c02
parentb941bd55d98413bae96d73b451d37e7fbf0f7849 (diff)
downloadserenity-58cfd46a5a7f4e41fb2da5ea253b9ff27979e5d9.zip
Kernel: Add Syscall.cpp to aarch64 build
-rw-r--r--Kernel/CMakeLists.txt2
-rw-r--r--Kernel/Syscall.cpp19
2 files changed, 19 insertions, 2 deletions
diff --git a/Kernel/CMakeLists.txt b/Kernel/CMakeLists.txt
index bc448149ba..48401971fc 100644
--- a/Kernel/CMakeLists.txt
+++ b/Kernel/CMakeLists.txt
@@ -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
diff --git a/Kernel/Syscall.cpp b/Kernel/Syscall.cpp
index bb01695bb3..37a8434d60 100644
--- a/Kernel/Syscall.cpp
+++ b/Kernel/Syscall.cpp
@@ -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);