From 5579d86c8f453c37628d7492a8708d3df9a74edb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20Neusch=C3=A4fer?= Date: Thu, 11 Aug 2016 22:49:10 +0200 Subject: [PATCH] UPSTREAM: arch/riscv: Set the stack pointer upon trap entry BUG=None BRANCH=None TEST=None Signed-off-by: Jonathan Neuschfer Reviewed-on: https://review.coreboot.org/16017 Reviewed-by: Ronald G. Minnich Change-Id: I52fae62bc6cf775179963720fbcfaa9e07f6a717 Reviewed-on: https://chromium-review.googlesource.com/370706 Commit-Ready: Furquan Shaikh Tested-by: Furquan Shaikh Reviewed-by: Aaron Durbin --- src/arch/riscv/trap_util.S | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/arch/riscv/trap_util.S b/src/arch/riscv/trap_util.S index 82a5629f4c..5ee0fddc53 100644 --- a/src/arch/riscv/trap_util.S +++ b/src/arch/riscv/trap_util.S @@ -116,7 +116,17 @@ supervisor_trap_entry: .global trap_entry trap_entry: csrw mscratch, sp - 1:addi sp,sp,-320 + + # SMP isn't supported yet, to avoid overwriting the same stack with different + # harts that handle traps at the same time. + csrr sp, mhartid +.Lsmp_hang: + bnez sp, .Lsmp_hang + + # TODO: Use the old stack pointer (plus an offset) for exceptions in machine + # mode, to avoid overwriting stack data. + li sp, 0x8000fff0 + save_tf move a0,sp jal trap_handler