From a18da25e7355979d0f26cfd39dc0032172e8b135 Mon Sep 17 00:00:00 2001 From: Anton Kling Date: Thu, 22 Feb 2024 17:28:08 +0100 Subject: Kernel: Fix undefined behavior and cleanup functions. The int_syscall caused crashes for higher level of optimizations. To fix this I rewrote the function in assembly as I deemed it to be simpler. --- kernel/cpu/syscall.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'kernel/cpu/syscall.c') diff --git a/kernel/cpu/syscall.c b/kernel/cpu/syscall.c index e2ea7e3..193367e 100644 --- a/kernel/cpu/syscall.c +++ b/kernel/cpu/syscall.c @@ -182,18 +182,13 @@ int (*syscall_functions[])() = { (void(*))syscall_tmp_handle_packet, }; +void int_syscall(reg_t *r); void syscall_function_handler(u32 eax, u32 arg1, u32 arg2, u32 arg3, u32 arg4, u32 arg5, u32 ebp, u32 esp) { assert(eax < sizeof(syscall_functions) / sizeof(syscall_functions[0])); syscall_functions[eax](arg1, arg2, arg3, arg4, arg5); } -void int_syscall(reg_t *r) { - u32 syscall = r->eax; - assert(syscall < sizeof(syscall_functions) / sizeof(syscall_functions[0])); - r->eax = syscall_functions[syscall](r->ebx, r->ecx, r->edx, r->esi, r->edi); -} - void syscalls_init(void) { install_handler(int_syscall, INT_32_INTERRUPT_GATE(0x3), 0x80); } -- cgit v1.2.3