summaryrefslogtreecommitdiff
path: root/sys/arch/powerpc
diff options
context:
space:
mode:
Diffstat (limited to 'sys/arch/powerpc')
-rw-r--r--sys/arch/powerpc/include/asm.h31
-rw-r--r--sys/arch/powerpc/powerpc/setjmp.S17
2 files changed, 31 insertions, 17 deletions
diff --git a/sys/arch/powerpc/include/asm.h b/sys/arch/powerpc/include/asm.h
index 60fbac38f17..2e0a7707730 100644
--- a/sys/arch/powerpc/include/asm.h
+++ b/sys/arch/powerpc/include/asm.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: asm.h,v 1.15 2020/10/26 22:07:06 gkoehler Exp $ */
+/* $OpenBSD: asm.h,v 1.16 2020/11/28 19:49:30 gkoehler Exp $ */
/* $NetBSD: asm.h,v 1.1 1996/09/30 16:34:20 ws Exp $ */
/*
@@ -109,16 +109,22 @@ _TMP_LABEL(y):; \
lis reg, (__retguard_ ## x)@ha; \
lwz reg, ((__retguard_ ## x)@l)(reg)
# endif
-# define RETGUARD_SETUP(x) \
+# define RETGUARD_SETUP(x, reg, retreg) \
+ mflr retreg; \
+ RETGUARD_SETUP_LATE(x, reg, retreg)
+# define RETGUARD_SETUP_LATE(x, reg, retreg) \
RETGUARD_SYMBOL(x); \
- mflr %r12; \
- RETGUARD_LOAD_RANDOM(x, %r11); \
- xor %r11, %r11, %r12
-# define RETGUARD_CHECK(x) \
- xor %r11, %r11, %r12; \
+ RETGUARD_LOAD_RANDOM(x, reg); \
+ xor reg, reg, retreg
+# define RETGUARD_CHECK(x, reg, retreg) \
+ xor reg, reg, retreg; \
RETGUARD_LOAD_RANDOM(x, %r10); \
- mtlr %r12; \
- twne %r11, %r10
+ mtlr retreg; \
+ twne reg, %r10
+# define RETGUARD_SAVE(reg, loc) \
+ stw reg, loc
+# define RETGUARD_LOAD(reg, loc) \
+ lwz reg, loc
# define RETGUARD_SYMBOL(x) \
.ifndef __retguard_ ## x; \
.hidden __retguard_ ## x; \
@@ -133,8 +139,11 @@ _TMP_LABEL(y):; \
.endif
#else
# define RETGUARD_LOAD_RANDOM(x, reg)
-# define RETGUARD_SETUP(x)
-# define RETGUARD_CHECK(x)
+# define RETGUARD_SETUP(x, reg, retreg)
+# define RETGUARD_SETUP_LATE(x, reg, retreg)
+# define RETGUARD_CHECK(x, reg, retreg)
+# define RETGUARD_SAVE(reg, loc)
+# define RETGUARD_LOAD(reg, loc)
# define RETGUARD_SYMBOL(x)
#endif
diff --git a/sys/arch/powerpc/powerpc/setjmp.S b/sys/arch/powerpc/powerpc/setjmp.S
index c8f067c1254..b3fa03d0b90 100644
--- a/sys/arch/powerpc/powerpc/setjmp.S
+++ b/sys/arch/powerpc/powerpc/setjmp.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: setjmp.S,v 1.9 2008/05/21 19:42:07 miod Exp $ */
+/* $OpenBSD: setjmp.S,v 1.10 2020/11/28 19:49:30 gkoehler Exp $ */
/* kernel version of this file, does not have signal goop */
/* int setjmp(jmp_buf env) */
@@ -56,6 +56,8 @@
ENTRY(_C_LABEL(setjmp))
+ mflr %r12
+ RETGUARD_SETUP_LATE(setjmp, %r11, %r12)
stw %r31, JMP_r31(%r3)
/* r1, r14-r30 */
stw %r1, JMP_r1 (%r3)
@@ -79,18 +81,22 @@ ENTRY(_C_LABEL(setjmp))
/* cr, lr, ctr, xer */
mfcr %r0
stw %r0, JMP_cr(%r3)
- mflr %r0
- stw %r0, JMP_lr(%r3)
+ stw %r12, JMP_lr(%r3)
mfctr %r0
stw %r0, JMP_ctr(%r3)
mfxer %r0
stw %r0, JMP_xer(%r3)
/* f14-f31, fpscr */
li %r3, 0
+ RETGUARD_CHECK(setjmp, %r11, %r12)
blr
ENTRY(_C_LABEL(longjmp))
+ /* lr, r31 */
+ lwz %r12, JMP_lr(%r3)
+ RETGUARD_SETUP_LATE(longjmp, %r11, %r12)
+ mtlr %r12
lwz %r31, JMP_r31(%r3)
/* r1, r14-r30 */
lwz %r1, JMP_r1 (%r3)
@@ -111,15 +117,14 @@ ENTRY(_C_LABEL(longjmp))
lwz %r28, JMP_r28(%r3)
lwz %r29, JMP_r29(%r3)
lwz %r30, JMP_r30(%r3)
- /* cr, lr, ctr, xer */
+ /* cr, ctr, xer */
lwz %r0, JMP_cr(%r3)
mtcr %r0
- lwz %r0, JMP_lr(%r3)
- mtlr %r0
lwz %r0, JMP_ctr(%r3)
mtctr %r0
lwz %r0, JMP_xer(%r3)
mtxer %r0
/* f14-f31, fpscr */
li %r3, 1
+ RETGUARD_CHECK(longjmp, %r11, %r12)
blr