summaryrefslogtreecommitdiffstats
path: root/sys/arm64
diff options
context:
space:
mode:
authorandrew <andrew@FreeBSD.org>2017-04-19 15:59:16 +0000
committerandrew <andrew@FreeBSD.org>2017-04-19 15:59:16 +0000
commitb7aef29707b4ceb8e2e598038a1b6c6bedcd075e (patch)
treebd6e3b1077a26cecbca5807f2373f5e6d8f98193 /sys/arm64
parent4b14b18364b6ec3f1121c654a7d3bf41cfff77fe (diff)
downloadFreeBSD-src-b7aef29707b4ceb8e2e598038a1b6c6bedcd075e.zip
FreeBSD-src-b7aef29707b4ceb8e2e598038a1b6c6bedcd075e.tar.gz
MFC 313772:
Load the new sp_el0 with interrupts disabled in fork_trampoline. If an interrupt arrives in fork_trampoline after sp_el0 was written we may then switch to a new thread, enter userland so change this stack pointer, then return to this code with the wrong value. This fixes this case by moving the load of sp_el0 until after interrupts have been disabled.
Diffstat (limited to 'sys/arm64')
-rw-r--r--sys/arm64/arm64/swtch.S13
1 files changed, 6 insertions, 7 deletions
diff --git a/sys/arm64/arm64/swtch.S b/sys/arm64/arm64/swtch.S
index 1b501a49..299e590 100644
--- a/sys/arm64/arm64/swtch.S
+++ b/sys/arm64/arm64/swtch.S
@@ -241,11 +241,6 @@ ENTRY(fork_trampoline)
mov fp, #0 /* Stack traceback stops here. */
bl _C_LABEL(fork_exit)
- /* Restore sp and lr */
- ldp x0, x1, [sp]
- msr sp_el0, x0
- mov lr, x1
-
/* Restore the registers other than x0 and x1 */
ldp x2, x3, [sp, #TF_X + 2 * 8]
ldp x4, x5, [sp, #TF_X + 4 * 8]
@@ -261,14 +256,18 @@ ENTRY(fork_trampoline)
ldp x24, x25, [sp, #TF_X + 24 * 8]
ldp x26, x27, [sp, #TF_X + 26 * 8]
ldp x28, x29, [sp, #TF_X + 28 * 8]
- /* Skip x30 as it was restored above as lr */
/*
* Disable interrupts to avoid
- * overwriting spsr_el1 by an IRQ exception.
+ * overwriting spsr_el1 and sp_el0 by an IRQ exception.
*/
msr daifset, #2
+ /* Restore sp and lr */
+ ldp x0, x1, [sp]
+ msr sp_el0, x0
+ mov lr, x1
+
/* Restore elr and spsr */
ldp x0, x1, [sp, #16]
msr elr_el1, x0
OpenPOWER on IntegriCloud