From 5a6e389747d37e4ed69d9261187155c83739a649 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20Neusch=C3=A4fer?= Date: Tue, 26 Sep 2017 01:44:46 +0200 Subject: arch/riscv: Use a separate trap stack MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is the lazy solution, as explained in the comment, but it works for now. Change-Id: I46e18b6d633280d6409e42462500fbe7c6823b4d Signed-off-by: Jonathan Neuschäfer Reviewed-on: https://review.coreboot.org/21689 Tested-by: build bot (Jenkins) Reviewed-by: Ronald G. Minnich --- src/arch/riscv/trap_util.S | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src') 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 -- cgit v1.2.3