summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJonathan Neuschäfer <j.neuschaefer@gmx.net>2017-09-26 01:44:46 +0200
committerPatrick Georgi <pgeorgi@google.com>2017-11-07 12:30:38 +0000
commit5a6e389747d37e4ed69d9261187155c83739a649 (patch)
tree2fe954449bb7a0db759f6e532a766ebef61d9e12 /src
parentc90f1d7be0bb41e1e74b5a6f7c4ceb4a2fceada8 (diff)
downloadcoreboot-5a6e389747d37e4ed69d9261187155c83739a649.tar.xz
arch/riscv: Use a separate trap stack
This is the lazy solution, as explained in the comment, but it works for now. Change-Id: I46e18b6d633280d6409e42462500fbe7c6823b4d Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net> Reviewed-on: https://review.coreboot.org/21689 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/arch/riscv/trap_util.S12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/arch/riscv/trap_util.S b/src/arch/riscv/trap_util.S
index 44cfab7c99..5582a0770c 100644
--- a/src/arch/riscv/trap_util.S
+++ b/src/arch/riscv/trap_util.S
@@ -128,10 +128,14 @@ trap_entry:
.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.
- la sp, _estack
- addi sp,sp,-MENTRY_FRAME_SIZE
+ # Use a different stack than in the main context, to to avoid overwriting
+ # stack data.
+ # TODO: Maybe use the old stack pointer (plus an offset) instead. But only if
+ # the previous mode was M, because it would be a very bad idea to use a stack
+ # pointer provided by unprivileged code!
+ la sp, _estack
+ addi sp, sp, -2048 # 2 KiB is half of the stack space
+ addi sp, sp, -MENTRY_FRAME_SIZE
save_tf
move a0,sp