arm64: Preserve FPU registers in setjmp/longjmp and arch_context_swap.

Change-Id: If0ca2ecbfa45b663dab39d1e9cb2562f071c3b27
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5268
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: David Karoly <karolyd577@gmail.com>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
This commit is contained in:
milek7 2022-04-06 20:46:13 +02:00 committed by waddlesplash
parent 444980deb1
commit d5f2742d1f
4 changed files with 29 additions and 5 deletions

View File

@ -10,7 +10,8 @@
struct arch_thread {
uint64 regs[13]; // x19-x30, sp
uint64 regs[13]; // x19-x30, sp
uint64 fp_regs[8]; // d8-d15
};
struct arch_team {

View File

@ -241,6 +241,7 @@ FUNCTION(_fp_restore):
FUNCTION_END(_fp_restore)
FUNCTION(_arch_context_swap):
// save
stp x19, x20, [x0], #16
stp x21, x22, [x0], #16
stp x23, x24, [x0], #16
@ -249,8 +250,14 @@ FUNCTION(_arch_context_swap):
stp x29, x30, [x0], #16
mov x2, sp
str x2, [x0]
str x2, [x0], #8
stp d8, d9, [x0], #16
stp d10, d11, [x0], #16
stp d12, d13, [x0], #16
stp d14, d15, [x0], #16
// restore
ldp x19, x20, [x1], #16
ldp x21, x22, [x1], #16
ldp x23, x24, [x1], #16
@ -258,9 +265,15 @@ FUNCTION(_arch_context_swap):
ldp x27, x28, [x1], #16
ldp x29, x30, [x1], #16
ldr x2, [x1]
ldr x2, [x1], #8
mov sp, x2
ldp d8, d9, [x1], #16
ldp d10, d11, [x1], #16
ldp d12, d13, [x1], #16
ldp d14, d15, [x1], #16
// pass x29 as argument to thread entry function
mov x0, x29
ret
FUNCTION_END(_arch_context_swap)

View File

@ -18,9 +18,14 @@ FUNCTION(_longjmp):
ldp x27, x28, [x0], #16
ldp x29, x30, [x0], #16
ldr x2, [x0]
ldr x2, [x0], #8
mov sp, x2
ldp d8, d9, [x0], #16
ldp d10, d11, [x0], #16
ldp d12, d13, [x0], #16
ldp d14, d15, [x0], #16
b __longjmp_return
FUNCTION_END(siglongjmp)
FUNCTION_END(longjmp)

View File

@ -16,7 +16,12 @@ FUNCTION(sigsetjmp):
stp x29, x30, [x0], #16
mov x2, sp
str x2, [x0]
str x2, [x0], #8
stp d8, d9, [x0], #16
stp d10, d11, [x0], #16
stp d12, d13, [x0], #16
stp d14, d15, [x0], #16
b __setjmp_save_sigs
FUNCTION_END(sigsetjmp)