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/isr.s | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'kernel/cpu/isr.s') diff --git a/kernel/cpu/isr.s b/kernel/cpu/isr.s index 1bb2fff..8032485 100644 --- a/kernel/cpu/isr.s +++ b/kernel/cpu/isr.s @@ -270,12 +270,12 @@ ISR_NOERRCODE 254 ISR_NOERRCODE 255 isr_common_stub: - pusha # Pushes edi,esi,ebp,esp,ebx,edx,ecx,eax + pusha # Pushes edi,esi,ebp,esp,ebx,edx,ecx,eax - mov ax, ds # Lower 16-bits of eax = ds. - push eax # save the data segment descriptor + mov ax, ds # Lower 16-bits of eax = ds. + push eax # save the data segment descriptor - mov ax, 0x10 # load the kernel data segment descriptor + mov ax, 0x10 # load the kernel data segment descriptor mov ds, ax mov es, ax mov fs, ax @@ -285,13 +285,13 @@ isr_common_stub: call int_handler add esp, 4 - pop ebx # reload the original data segment descriptor + pop ebx # reload the original data segment descriptor mov ds, bx mov es, bx mov fs, bx mov gs, bx - popa # Pops edi,esi,ebp... - add esp, 8 # Cleans up the pushed error code and pushed ISR number + popa # Pops edi,esi,ebp... + add esp, 8 # Cleans up the pushed error code and pushed ISR number sti - iret # pops 5 things at once: CS, EIP, EFLAGS, SS, and ESP + iret # pops 5 things at once: CS, EIP, EFLAGS, SS, and ESP -- cgit v1.2.3