mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 10:17:35 +00:00
Kernel: Add Syscall.cpp to aarch64 build
This commit is contained in:
parent
b941bd55d9
commit
58cfd46a5a
2 changed files with 19 additions and 2 deletions
|
@ -261,6 +261,7 @@ set(KERNEL_SOURCES
|
||||||
Scheduler.cpp
|
Scheduler.cpp
|
||||||
ScopedCritical.cpp
|
ScopedCritical.cpp
|
||||||
StdLib.cpp
|
StdLib.cpp
|
||||||
|
Syscall.cpp
|
||||||
Syscalls/anon_create.cpp
|
Syscalls/anon_create.cpp
|
||||||
Syscalls/alarm.cpp
|
Syscalls/alarm.cpp
|
||||||
Syscalls/beep.cpp
|
Syscalls/beep.cpp
|
||||||
|
@ -402,7 +403,6 @@ if ("${SERENITY_ARCH}" STREQUAL "x86_64")
|
||||||
Interrupts/SpuriousInterruptHandler.cpp
|
Interrupts/SpuriousInterruptHandler.cpp
|
||||||
kprintf.cpp
|
kprintf.cpp
|
||||||
Panic.cpp
|
Panic.cpp
|
||||||
Syscall.cpp
|
|
||||||
)
|
)
|
||||||
|
|
||||||
set(KERNEL_SOURCES
|
set(KERNEL_SOURCES
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
|
|
||||||
#include <Kernel/API/Syscall.h>
|
#include <Kernel/API/Syscall.h>
|
||||||
#include <Kernel/Arch/TrapFrame.h>
|
#include <Kernel/Arch/TrapFrame.h>
|
||||||
#include <Kernel/Arch/x86_64/Interrupts.h>
|
|
||||||
#include <Kernel/Memory/MemoryManager.h>
|
#include <Kernel/Memory/MemoryManager.h>
|
||||||
#include <Kernel/Panic.h>
|
#include <Kernel/Panic.h>
|
||||||
#include <Kernel/PerformanceManager.h>
|
#include <Kernel/PerformanceManager.h>
|
||||||
|
@ -16,6 +15,10 @@
|
||||||
#include <Kernel/Sections.h>
|
#include <Kernel/Sections.h>
|
||||||
#include <Kernel/ThreadTracer.h>
|
#include <Kernel/ThreadTracer.h>
|
||||||
|
|
||||||
|
#if ARCH(X86_64)
|
||||||
|
# include <Kernel/Arch/x86_64/Interrupts.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
|
|
||||||
extern "C" void syscall_handler(TrapFrame*) __attribute__((used));
|
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()
|
UNMAP_AFTER_INIT void initialize()
|
||||||
{
|
{
|
||||||
|
#if ARCH(X86_64)
|
||||||
register_user_callable_interrupt_handler(syscall_vector, syscall_asm_entry);
|
register_user_callable_interrupt_handler(syscall_vector, syscall_asm_entry);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
using Handler = auto(Process::*)(FlatPtr, FlatPtr, FlatPtr, FlatPtr) -> ErrorOr<FlatPtr>;
|
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)
|
NEVER_INLINE void syscall_handler(TrapFrame* trap)
|
||||||
{
|
{
|
||||||
|
#if ARCH(X86_64)
|
||||||
// Make sure SMAP protection is enabled on syscall entry.
|
// Make sure SMAP protection is enabled on syscall entry.
|
||||||
clac();
|
clac();
|
||||||
|
#elif ARCH(AARCH64)
|
||||||
|
// FIXME: Implement the security mechanism for aarch64
|
||||||
|
#else
|
||||||
|
# error Unknown architecture
|
||||||
|
#endif
|
||||||
|
|
||||||
auto& regs = *trap->regs;
|
auto& regs = *trap->regs;
|
||||||
auto* current_thread = Thread::current();
|
auto* current_thread = Thread::current();
|
||||||
|
@ -161,6 +172,7 @@ NEVER_INLINE void syscall_handler(TrapFrame* trap)
|
||||||
|
|
||||||
current_thread->yield_if_stopped();
|
current_thread->yield_if_stopped();
|
||||||
|
|
||||||
|
#if ARCH(X86_64)
|
||||||
// Apply a random offset in the range 0-255 to the stack pointer,
|
// Apply a random offset in the range 0-255 to the stack pointer,
|
||||||
// to make kernel stacks a bit less deterministic.
|
// to make kernel stacks a bit less deterministic.
|
||||||
u32 lsw;
|
u32 lsw;
|
||||||
|
@ -177,6 +189,11 @@ NEVER_INLINE void syscall_handler(TrapFrame* trap)
|
||||||
if ((flags & (iopl_mask)) != 0) {
|
if ((flags & (iopl_mask)) != 0) {
|
||||||
PANIC("Syscall from process with IOPL != 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);
|
Memory::MemoryManager::validate_syscall_preconditions(process, regs);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue