From 8de23ca36173cfdb3c609074496115ebd9045887 Mon Sep 17 00:00:00 2001 From: Jon Santmyer Date: Sat, 26 Sep 2026 22:07:16 -0400 Subject: x86_64: make syscall_entry compliant to SYSTEM-V ABI --- arch/x86_64/sys/syscall.c | 15 ++++----------- arch/x86_64/sys/syscall.h | 2 +- 2 files changed, 5 insertions(+), 12 deletions(-) (limited to 'arch/x86_64/sys') diff --git a/arch/x86_64/sys/syscall.c b/arch/x86_64/sys/syscall.c index a694674..7c5727f 100644 --- a/arch/x86_64/sys/syscall.c +++ b/arch/x86_64/sys/syscall.c @@ -26,35 +26,28 @@ _syscall_handle_arch(syscall_context_t *ctx) __attribute__((naked)) void _syscall_entry(void) { - __asm__ volatile(" \ + asm volatile(" \ swapgs; \ movq %%gs:%c[pcb], %%rax; \ movq %%rsp, %%rdx; \ movq %c[ksp](%%rax), %%rsp; \ - pushq %%rcx; \ pushq %%rdx; \ pushq %%r11; \ + pushq %%rcx; \ pushq %%rbp; \ callq syscall_handler; \ swapgs; \ - xorq %%r15, %%r15; \ - xorq %%r14, %%r14; \ - xorq %%r13, %%r13; \ - xorq %%r12, %%r12; \ xorq %%r10, %%r10; \ xorq %%r9, %%r9; \ xorq %%r8, %%r8; \ xorq %%rsi, %%rsi; \ xorq %%rdi, %%rdi; \ - xorq %%rbp, %%rbp; \ xorq %%rdx, %%rdx; \ - xorq %%rcx, %%rcx; \ - xorq %%rbx, %%rbx; \ popq %%rbp; \ + popq %%rcx; \ popq %%r11; \ popq %%rsp; \ - popq %%rcx; \ - sysretq;" + sysretq" :: [pcb] "i"(offsetof(processor_t, pcb)), [ksp] "i"(offsetof(pcb_t, ksp))); diff --git a/arch/x86_64/sys/syscall.h b/arch/x86_64/sys/syscall.h index 34f6a2a..32bf787 100644 --- a/arch/x86_64/sys/syscall.h +++ b/arch/x86_64/sys/syscall.h @@ -5,6 +5,6 @@ int _syscall_handle_serial(syscall_context_t *ctx); -#define SYSCALL_SERIAL_COM_WRITE 0 +#define SYSCALL_SERIAL_COM_WRITE 1 #endif -- cgit v1.2.3