-/* $OpenBSD: cpuswitch.S,v 1.3 2018/03/29 19:25:39 patrick Exp $ */
+/* $OpenBSD: cpuswitch.S,v 1.4 2018/09/07 01:32:01 mortimer Exp $ */
/*
* Copyright (c) 2015 Dale Rahn <drahn@dalerahn.com>
*
mov x1, x19
1:
+ RETGUARD_SYMBOL(cpu_switchto)
+ RETGUARD_LOAD_RANDOM(cpu_switchto, x20)
mrs x2, tpidr_el1 // load curcpu
mov w5, #SONPROC
mov x0, x1
bl pmap_setttb
mov x3, x19
+ mov x15, x20
mov sp, x3
ldp x25, x26, [x3, #(SF_X25)]
ldp x27, x28, [x3, #(SF_X27)]
ldp x29, x30, [x3, #(SF_X29)]
+ RETGUARD_CALC_COOKIE(x15)
add sp, sp, #(SWITCHFRAME_SZ)
+ RETGUARD_CHECK(cpu_switchto, x15)
ret
ENTRY(proc_trampoline)
-/* $OpenBSD: support.S,v 1.7 2018/08/12 17:15:10 mortimer Exp $ */
+/* $OpenBSD: support.S,v 1.8 2018/09/07 01:32:01 mortimer Exp $ */
/*-
* Copyright (c) 2014 Andrew Turner
* Copyright (c) 2014-2015 The FreeBSD Foundation
#ifdef DDB
ENTRY(setjmp)
+ RETGUARD_SETUP(setjmp, x15)
/* Store the stack pointer */
mov x8, sp
str x8, [x0], #8
/* Return zero */
mov x0, #0
+ RETGUARD_CHECK(setjmp, x15)
ret
END(setjmp)
ENTRY(longjmp)
+ RETGUARD_SYMBOL(longjmp)
+ RETGUARD_LOAD_RANDOM(longjmp, x15)
/* Restore the stack pointer */
ldr x8, [x0], #8
mov sp, x8
ldp x25, x26, [x0], #16
ldp x27, x28, [x0], #16
ldp x29, lr, [x0], #16
+ RETGUARD_CALC_COOKIE(x15)
/* Return nonzero */
mov x0, #1
+ RETGUARD_CHECK(longjmp, x15)
ret
END(longjmp)
#endif
-/* $OpenBSD: asm.h,v 1.4 2018/08/12 17:15:10 mortimer Exp $ */
+/* $OpenBSD: asm.h,v 1.5 2018/09/07 01:32:01 mortimer Exp $ */
/* $NetBSD: asm.h,v 1.4 2001/07/16 05:43:32 matt Exp $ */
/*
#endif
#if defined(_RET_PROTECTOR)
+# define RETGUARD_CALC_COOKIE(reg) \
+ eor reg, reg, x30
+
+# define RETGUARD_LOAD_RANDOM(x, reg) \
+ adrp reg, __CONCAT(__retguard_, x); \
+ ldr reg, [reg, :lo12:__CONCAT(__retguard_, x)]
+
# define RETGUARD_SETUP(x, reg) \
RETGUARD_SYMBOL(x); \
- adrp reg, __CONCAT(__retguard_, x); \
- ldr reg, [reg, :lo12:__CONCAT(__retguard_, x)]; \
- eor reg, reg, x30
+ RETGUARD_LOAD_RANDOM(x, reg); \
+ RETGUARD_CALC_COOKIE(reg)
+
# define RETGUARD_CHECK(x, reg) \
- eor reg, reg, x30; \
- adrp x9, __CONCAT(__retguard_, x); \
- ldr x9, [x9, :lo12:__CONCAT(__retguard_, x)]; \
+ RETGUARD_CALC_COOKIE(reg); \
+ RETGUARD_LOAD_RANDOM(x, x9); \
subs reg, reg, x9; \
cbz reg, 66f; \
brk #0x1; \
66:
+
# define RETGUARD_PUSH(reg) \
str reg, [sp, #-16]!
+
# define RETGUARD_POP(reg) \
ldr reg, [sp, #16]!
+
# define RETGUARD_SYMBOL(x) \
.ifndef __CONCAT(__retguard_, x); \
.hidden __CONCAT(__retguard_, x); \
.popsection; \
.endif
#else
+# define RETGUARD_CALC_COOKIE(reg)
+# define RETGUARD_LOAD_RANDOM(x, reg)
# define RETGUARD_SETUP(x, reg)
# define RETGUARD_CHECK(x, reg)
# define RETGUARD_PUSH(reg)