summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDino Li <dino.li@ite.com.tw>2015-12-16 18:31:07 +0800
committerchrome-bot <chrome-bot@chromium.org>2015-12-16 21:49:34 -0800
commit11c2c9223688c9d8d5833ab1d0d9dd7dfdca635d (patch)
treea6dda955821162e0847b116866468e472577cf7d
parent51811325d248b216c1d079c61a971ecead447d8c (diff)
downloadchrome-ec-11c2c9223688c9d8d5833ab1d0d9dd7dfdca635d.tar.gz
nds32: start_irq_handler() use system stack
[symptom] The 'vboot_hash_start()' always return busy error and variable 'in_progress' got a strange value(should be 0 or 1). 'start_irq_handler()' causes scratchpad overflow in first context switch. It must be called after SP switch to system stack in ISR. NOTE: The scratchpad is still also need more size even if 'start_irq_handler()' is using system stack. following is detail: 1. uint32_t scratchpad[19] 0x81d34 ~ 0x81d7f [__task_start:] 2. /* put the dummy stack pointer at the top of the stack in scratchpad */ addi $sp, $r3, 4 * 18 -> SP 0x81d7c 3. syscall push return address (-4) -> SP 0x81d78 [ISR:] 4. push r15, fp, lp, and sp (-0x10) -> SP 0x81d68 5. push r0 ~ r5 (-0x18) -> SP 0x81d50 [__switch_task:] 6. /* save ipsw, ipc, r6, r7, r8, r9, r10 on the current process stack */ (-0x1C) -> SP 0x81d34 Signed-off-by: Dino Li <dino.li@ite.com.tw> BRANCH=none BUG=none TEST=1. hash done. 2. console command 'taskinfo'. 3. the scratchpad does not overflow after first context switch. Change-Id: If5d89ff5c945a777010492fcfb54bf41f434ed69 Reviewed-on: https://chromium-review.googlesource.com/317468 Commit-Ready: Dino Li <dino.li@ite.com.tw> Tested-by: Dino Li <dino.li@ite.com.tw> Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r--core/nds32/init.S4
-rw-r--r--core/nds32/switch.S2
-rw-r--r--core/nds32/task.c4
3 files changed, 5 insertions, 5 deletions
diff --git a/core/nds32/init.S b/core/nds32/init.S
index 1f0b5c28e6..1f9c71b3c6 100644
--- a/core/nds32/init.S
+++ b/core/nds32/init.S
@@ -20,13 +20,13 @@ __entry_\()\name:
smw.adm $r15, [$sp], $r15, 0xb
/* r0-r5 are caller saved */
smw.adm $r0, [$sp], $r5, 0
- /* isr entry */
- jal start_irq_handler
/* switch to system stack if we are called from process stack */
la $r3, stack_end
mov55 $fp, $sp
slt45 $r3, $sp /* if sp > end of system stack, then r15 = 1 and */
cmovn $sp, $r3, $r15 /* point sp to the top of the system stack */
+ /* isr entry */
+ jal start_irq_handler
/* C routine handler */
jal \name\()_handler
/* check whether we need to change the scheduled task */
diff --git a/core/nds32/switch.S b/core/nds32/switch.S
index 81c0770dea..a9633782b3 100644
--- a/core/nds32/switch.S
+++ b/core/nds32/switch.S
@@ -89,7 +89,7 @@ __task_start:
movi55 $r0, 0 /* syscall 1st parameter : de-schedule nothing */
/* put the dummy stack pointer at the top of the stack in scratchpad */
- addi $sp, $r3, 4 * 16
+ addi $sp, $r3, 4 * 18
/* we are ready to re-schedule */
swi.gp $r4, [ + need_resched]
diff --git a/core/nds32/task.c b/core/nds32/task.c
index 3075fe05c6..b34e9e9f50 100644
--- a/core/nds32/task.c
+++ b/core/nds32/task.c
@@ -145,9 +145,9 @@ uint8_t task_stacks[0
/* Reserve space to discard context on first context switch. */
#ifdef CONFIG_FPU
-uint32_t scratchpad[17+18];
+uint32_t scratchpad[19+18];
#else
-uint32_t scratchpad[17];
+uint32_t scratchpad[19];
#endif
task_ *current_task = (task_ *)scratchpad;