Kernel: Save fpu state and flags in signal handler

This was causing some weird crashes :D
This commit is contained in:
2025-06-27 21:51:13 +03:00
parent 9e895e5286
commit f73bb242f3
3 changed files with 15 additions and 4 deletions

View File

@@ -7,9 +7,6 @@
.global signal_trampoline
signal_trampoline:
pushl %ebp
movl %esp, %ebp
pusha
movl 40(%esp), %edi
@@ -19,16 +16,22 @@ signal_trampoline:
movl %esp, %ebp
andl $-16, %esp
subl $512, %esp
fxsave (%esp)
subl $12, %esp
pushl %edi
call *%eax
addl $16, %esp
fxrstor (%esp)
addl $512, %esp
// restore stack
movl %ebp, %esp
popa
leave
addl $8, %esp
popf
ret

View File

@@ -30,8 +30,14 @@ signal_trampoline:
movq %rsp, %rbp
andq $-16, %rsp
subq $512, %rsp
fxsave64 (%rsp)
call *%rax
fxrstor64 (%rsp)
addq $512, %rsp
// restore stack
movq %rbp, %rsp
popq %r15
@@ -51,6 +57,7 @@ signal_trampoline:
popq %rax
addq $16, %rsp
popfq
// return over red-zone
ret $128