diff options
author | mortimer <mortimer@cvs.openbsd.org> | 2020-10-22 23:35:44 +0000 |
---|---|---|
committer | mortimer <mortimer@cvs.openbsd.org> | 2020-10-22 23:35:44 +0000 |
commit | d5ae03425e2868889c1a181be4607b21707fa79f (patch) | |
tree | 0d084c773b575cd368009146077a5d024ec6f78e /sys | |
parent | ac30548bf03cf4280a3976edf2de470abfd8a0c9 (diff) |
Add retguard to OPAL functions in powerpc64 locore.
ok deraadt@ kettenis@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/powerpc64/include/asm.h | 14 | ||||
-rw-r--r-- | sys/arch/powerpc64/powerpc64/locore.S | 10 |
2 files changed, 14 insertions, 10 deletions
diff --git a/sys/arch/powerpc64/include/asm.h b/sys/arch/powerpc64/include/asm.h index 9f4c122fe99..8b9b6e4ee61 100644 --- a/sys/arch/powerpc64/include/asm.h +++ b/sys/arch/powerpc64/include/asm.h @@ -1,4 +1,4 @@ -/* $OpenBSD: asm.h,v 1.5 2020/10/17 15:26:05 deraadt Exp $ */ +/* $OpenBSD: asm.h,v 1.6 2020/10/22 23:35:43 mortimer Exp $ */ /* * Copyright (c) 2020 Dale Rahn <drahn@openbsd.org> @@ -72,10 +72,10 @@ _TMP_LABEL(y):; \ addis %r12, %r2, (__retguard_ ## x)@toc@ha; \ ld %r12, ((__retguard_ ## x)@toc@l)(%r12); \ tdne reg, %r12 -# define RETGUARD_SAVE(reg, off) \ - std reg, off(%r31) -# define RETGUARD_LOAD(reg, off) \ - ld reg, off(%r31) +# define RETGUARD_SAVE(reg, loc) \ + std reg, loc +# define RETGUARD_LOAD(reg, loc) \ + ld reg, loc # define RETGUARD_SYMBOL(x) \ .ifndef __retguard_ ## x; \ .hidden __retguard_ ## x; \ @@ -91,8 +91,8 @@ _TMP_LABEL(y):; \ #else # define RETGUARD_SETUP(x, reg) # define RETGUARD_CHECK(x, reg) -# define RETGUARD_SAVE(reg) -# define RETGUARD_LOAD(reg) +# define RETGUARD_SAVE(reg, loc) +# define RETGUARD_LOAD(reg, loc) # define RETGUARD_SYMBOL(x) #endif diff --git a/sys/arch/powerpc64/powerpc64/locore.S b/sys/arch/powerpc64/powerpc64/locore.S index 1ca5aa2c969..56e73e806f0 100644 --- a/sys/arch/powerpc64/powerpc64/locore.S +++ b/sys/arch/powerpc64/powerpc64/locore.S @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.S,v 1.40 2020/10/21 23:53:22 mortimer Exp $ */ +/* $OpenBSD: locore.S,v 1.41 2020/10/22 23:35:43 mortimer Exp $ */ /* * Copyright (c) 2020 Mark Kettenis <kettenis@openbsd.org> @@ -312,6 +312,7 @@ opal_entry: #define OPAL_CALL(opal_token, name) \ .globl name; \ name: \ + RETGUARD_SETUP(opal_call, %r12); \ li %r0, opal_token; \ b opal_call @@ -359,8 +360,9 @@ OPAL_CALL(OPAL_SENSOR_READ_U64, opal_sensor_read_u64) opal_call: mflr %r11 std %r11, 16(%r1) - stdu %r1, -32(%r1) + stdu %r1, -40(%r1) std %r2, 24(%r1) + RETGUARD_SAVE(%r12, 32(%r1)) addis %r11, %r2, opal_base@toc@ha addi %r11, %r11, opal_base@toc@l @@ -387,10 +389,12 @@ opal_call: isync ld %r31, 12(%r1) + RETGUARD_LOAD(%r11, 32(%r1)) ld %r2, 24(%r1) - addi %r1, %r1, 32 + addi %r1, %r1, 40 ld %r0, 16(%r1) mtlr %r0 + RETGUARD_CHECK(opal_call, %r11) blr /* |