<p>Marshall Dawson has uploaded this change for <strong>review</strong>.</p><p><a href="https://review.coreboot.org/22949">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">x86/smm: Preserve local variables whan aligning stack<br><br>Align the stack earlier and account for all local variables.<br><br>Ensure %edi, containing the fxsave/fxrstor location, can be properly<br>retrieved from the stack prior to the rsm instruction.<br><br>This corrects an observed bug where the stack had a 16-byte alignment,<br>%edi was pushed, then the stack was realigned for the call to<br>c_handler.  After returning, garbage was popped into %edi and the<br>system rebooted as a result of the fxrstor instruction.<br><br>BUG=b:70027919<br>TEST=Boot Kahlee to the OS<br><br>Change-Id: Ic06cdf8bd95d9aaa9634ecf3546a5033150fe82b<br>Signed-off-by: Marshall Dawson <marshalldawson3rd@gmail.com><br>---<br>M src/cpu/x86/smm/smm_stub.S<br>1 file changed, 8 insertions(+), 3 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://review.coreboot.org:29418/coreboot refs/changes/49/22949/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/cpu/x86/smm/smm_stub.S b/src/cpu/x86/smm/smm_stub.S</span><br><span>index 32435a0..f5a30d4 100644</span><br><span>--- a/src/cpu/x86/smm/smm_stub.S</span><br><span>+++ b/src/cpu/x86/smm/smm_stub.S</span><br><span>@@ -145,6 +145,14 @@</span><br><span>         add     %eax, %edi</span><br><span> </span><br><span> 2:</span><br><span style="color: hsl(120, 100%, 40%);">+  /* Align the stack before saving any local information.  This takes</span><br><span style="color: hsl(120, 100%, 40%);">+    * into account that the stack must be in proper alignment at the time</span><br><span style="color: hsl(120, 100%, 40%);">+         * the call to c_handler is made.  That is, c_handler's stack must be</span><br><span style="color: hsl(120, 100%, 40%);">+      * aligned so that %esp+4 (or %rsp+8) is a multiple of 16.</span><br><span style="color: hsl(120, 100%, 40%);">+     */</span><br><span style="color: hsl(120, 100%, 40%);">+   andl    $0xfffffff0, %esp</span><br><span style="color: hsl(120, 100%, 40%);">+     sub     $12, %esp</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>  /* Save location of fxsave area. */</span><br><span>  push    %edi</span><br><span>         mov     %esp, %ebp</span><br><span>@@ -160,9 +168,6 @@</span><br><span>     fxsave  (%edi)</span><br><span> </span><br><span> 1:</span><br><span style="color: hsl(0, 100%, 40%);">-        /* Align stack to 16 bytes. Another 16 bytes are pushed below. */</span><br><span style="color: hsl(0, 100%, 40%);">-       andl    $0xfffffff0, %esp</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span>    /* Call into the c-based SMM relocation function with the platform</span><br><span>    * parameters. Equivalent to:</span><br><span>         *   struct arg = { c_handler_params, cpu_num, smm_runtime {;</span><br><span></span><br></pre><p>To view, visit <a href="https://review.coreboot.org/22949">change 22949</a>. To unsubscribe, or for help writing mail filters, 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/22949"/><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: Ic06cdf8bd95d9aaa9634ecf3546a5033150fe82b </div>
<div style="display:none"> Gerrit-Change-Number: 22949 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Marshall Dawson <marshalldawson3rd@gmail.com> </div>