diff options
author | mortimer <mortimer@cvs.openbsd.org> | 2020-10-16 23:39:26 +0000 |
---|---|---|
committer | mortimer <mortimer@cvs.openbsd.org> | 2020-10-16 23:39:26 +0000 |
commit | 60414b4129a9814533ab59a96e487427e0d1a93a (patch) | |
tree | 71d8707161b2dc96d13d78ec9b06652e9c5191c8 | |
parent | 04dd0ced21ac5e6c97a000efa974fb900969d813 (diff) |
Add retguard asm macros for ppc64.
ok deraadt@
-rw-r--r-- | sys/arch/powerpc64/include/asm.h | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/sys/arch/powerpc64/include/asm.h b/sys/arch/powerpc64/include/asm.h index 6c1ac47199b..d69eeaf691e 100644 --- a/sys/arch/powerpc64/include/asm.h +++ b/sys/arch/powerpc64/include/asm.h @@ -1,4 +1,4 @@ -/* $OpenBSD: asm.h,v 1.3 2020/06/25 09:03:01 kettenis Exp $ */ +/* $OpenBSD: asm.h,v 1.4 2020/10/16 23:39:25 mortimer Exp $ */ /* * Copyright (c) 2020 Dale Rahn <drahn@openbsd.org> @@ -59,4 +59,42 @@ _TMP_LABEL(y):; \ #define WEAK_ALIAS(alias,sym) \ .weak alias; .set alias,sym +#if defined(_RET_PROTECTOR) +# define RETGUARD_SETUP(x, reg) \ + RETGUARD_SYMBOL(x); \ + mflr %r0; \ + addis reg, %r2, (__retguard_ ## x)@toc@ha; \ + lwz reg, ((__retguard_ ## x)@toc@l)(reg); \ + xor reg, reg, %r0 +# define RETGUARD_CHECK(x, reg) \ + mflr %r0; \ + xor reg, reg, %r0; \ + addis %r12, %r2, (__retguard_ ## x)@toc@ha; \ + lwz %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_SYMBOL(x) \ + .ifndef __retguard_ ## x; \ + .hidden __retguard_ ## x; \ + .type __retguard_ ## x,@object; \ + .pushsection .openbsd.randomdata.retguard,"aw",@progbits; \ + .weak __retguard_ ## x; \ + .p2align 3; \ + __retguard_ ## x: ; \ + .quad 0; \ + .size __retguard_ ## x, 8; \ + .popsection; \ + .endif +#else +# define RETGUARD_SETUP(x, reg) +# define RETGUARD_CHECK(x, reg) +# define RETGUARD_SAVE(reg) +# define RETGUARD_LOAD(reg) +# define RETGUARD_SYMBOL(x) +#endif + + #endif /* !_POWERPC64_ASM_H_ */ |