<p>Jonathan Neuschäfer has uploaded this change for <strong>review</strong>.</p><p><a href="https://review.coreboot.org/21689">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">arch/riscv: Use a separate trap stack<br><br>This is the lazy solution, as explained in the comment, but it works for<br>now.<br><br>Change-Id: I46e18b6d633280d6409e42462500fbe7c6823b4d<br>Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net><br>---<br>M src/arch/riscv/trap_util.S<br>1 file changed, 8 insertions(+), 4 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://review.coreboot.org:29418/coreboot refs/changes/89/21689/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/src/arch/riscv/trap_util.S b/src/arch/riscv/trap_util.S<br>index ae32379..7af4fe1 100644<br>--- a/src/arch/riscv/trap_util.S<br>+++ b/src/arch/riscv/trap_util.S<br>@@ -128,10 +128,14 @@<br> .Lsmp_hang:<br>   bnez sp, .Lsmp_hang<br> <br>-  # TODO: Use the old stack pointer (plus an offset) for exceptions in machine<br>-  # mode, to avoid overwriting stack data.<br>-    la        sp, _estack<br>-    addi sp,sp,-MENTRY_FRAME_SIZE<br>+  # Use a different stack than in the main context, to to avoid overwriting<br>+  # stack data.<br>+  # TODO: Maybe use the old stack pointer (plus an offset) instead. But only if<br>+  # the previous mode was M, because it would be a very bad idea to use a stack<br>+  # pointer provided by unprivileged code!<br>+  la sp, _estack<br>+  addi    sp, sp, -2048   # 2 KiB is half of the stack space<br>+  addi     sp, sp, -MENTRY_FRAME_SIZE<br> <br>   save_tf<br>   move  a0,sp<br></pre><p>To view, visit <a href="https://review.coreboot.org/21689">change 21689</a>. To unsubscribe, visit <a href="https://review.coreboot.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://review.coreboot.org/21689"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: coreboot </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I46e18b6d633280d6409e42462500fbe7c6823b4d </div>
<div style="display:none"> Gerrit-Change-Number: 21689 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Jonathan Neuschäfer <j.neuschaefer@gmx.net> </div>