summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2020-10-19 08:47:29 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2020-10-19 08:47:29 +0000
commit912db85ca1d2550e054ed66102a1ffc78a74a0d8 (patch)
tree8a09bb549f5558d298abb1532ba1e3938183cec7
parent182cd58bd85aa0a1c57d9ca89b58b119d42d9eb0 (diff)
Save and restore the FPCR register such that floating-point control modes
are properly restored by longjmp(3).
-rw-r--r--lib/libc/arch/aarch64/gen/_setjmp.S10
-rw-r--r--lib/libc/arch/aarch64/gen/setjmp.S10
2 files changed, 14 insertions, 6 deletions
diff --git a/lib/libc/arch/aarch64/gen/_setjmp.S b/lib/libc/arch/aarch64/gen/_setjmp.S
index 23149acba1e..9410a7451e5 100644
--- a/lib/libc/arch/aarch64/gen/_setjmp.S
+++ b/lib/libc/arch/aarch64/gen/_setjmp.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: _setjmp.S,v 1.3 2018/10/01 22:49:50 mortimer Exp $ */
+/* $OpenBSD: _setjmp.S,v 1.4 2020/10/19 08:47:28 kettenis Exp $ */
/*-
* Copyright (c) 2014 Andrew Turner
* Copyright (c) 2014 The FreeBSD Foundation
@@ -53,7 +53,9 @@ ENTRY(_setjmp)
stp d8, d9, [x0], #16
stp d10, d11, [x0], #16
stp d12, d13, [x0], #16
- stp d14, d15, [x0]
+ stp d14, d15, [x0], #16
+ mrs x1, fpcr
+ str x1, [x0]
#endif
/* Return value */
@@ -92,7 +94,9 @@ ENTRY(_longjmp)
ldp d8, d9, [x0], #16
ldp d10, d11, [x0], #16
ldp d12, d13, [x0], #16
- ldp d14, d15, [x0]
+ ldp d14, d15, [x0], #16
+ ldr x2, [x0]
+ msr fpcr, x2
#endif
/* Load the return value */
diff --git a/lib/libc/arch/aarch64/gen/setjmp.S b/lib/libc/arch/aarch64/gen/setjmp.S
index ddbfe12039b..c64e84f3c83 100644
--- a/lib/libc/arch/aarch64/gen/setjmp.S
+++ b/lib/libc/arch/aarch64/gen/setjmp.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: setjmp.S,v 1.3 2018/10/01 22:49:50 mortimer Exp $ */
+/* $OpenBSD: setjmp.S,v 1.4 2020/10/19 08:47:28 kettenis Exp $ */
/*-
* Copyright (c) 2014 Andrew Turner
* Copyright (c) 2014 The FreeBSD Foundation
@@ -61,7 +61,9 @@ ENTRY(setjmp)
stp d8, d9, [x0], #16
stp d10, d11, [x0], #16
stp d12, d13, [x0], #16
- stp d14, d15, [x0]
+ stp d14, d15, [x0], #16
+ mrs x1, fpcr
+ str x1, [x0]
/* Return value */
mov x0, #0
@@ -108,7 +110,9 @@ ENTRY(longjmp)
ldp d8, d9, [x0], #16
ldp d10, d11, [x0], #16
ldp d12, d13, [x0], #16
- ldp d14, d15, [x0]
+ ldp d14, d15, [x0], #16
+ ldr x1, [x0]
+ msr fpcr, x1
/* Load the return value */
cmp w3, #0