diff options
author | Anton Kling <anton@kling.gg> | 2024-02-22 17:28:08 +0100 |
---|---|---|
committer | Anton Kling <anton@kling.gg> | 2024-02-22 17:28:55 +0100 |
commit | a18da25e7355979d0f26cfd39dc0032172e8b135 (patch) | |
tree | 2af66bedd0dff4bbccffc8d82cd06836d7f68e0d /kernel/cpu/int_syscall.s | |
parent | 9b475d3db3275d4c34f02161ae70ced5595a0fdb (diff) |
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.
Diffstat (limited to 'kernel/cpu/int_syscall.s')
-rw-r--r-- | kernel/cpu/int_syscall.s | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/kernel/cpu/int_syscall.s b/kernel/cpu/int_syscall.s new file mode 100644 index 0000000..b2c0de9 --- /dev/null +++ b/kernel/cpu/int_syscall.s @@ -0,0 +1,35 @@ +.intel_syntax noprefix +.global int_syscall +.extern syscall_functions +int_syscall: +push ebp +mov ebp,esp +push edi +push esi +push ebx + +mov edx,DWORD PTR [ebp+0x8] # reg_t* +mov eax,DWORD PTR [edx+0x20] # syscall number +mov eax,DWORD PTR [eax*4+syscall_functions] # function pointer + +mov edi,DWORD PTR [edx+0x4] +push edi +mov edi,DWORD PTR [edx+0x8] +push edi +mov edi,DWORD PTR [edx+0x18] +push edi +mov edi,DWORD PTR [edx+0x1c] +push edi +mov edi,DWORD PTR [edx+0x14] +push edi +call eax +add esp,0x20 +mov edx,DWORD PTR [ebp+0x8] # reg_t* +mov DWORD PTR [edx+0x20],eax +lea esp,[ebp-0xc] + +pop ebx +pop esi +pop edi +pop ebp +ret |