<p>Raul Rangel has uploaded this change for <strong>review</strong>.</p><p><a href="https://review.coreboot.org/26927">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">kahlee: Make CPU1 handle all SMIs<br><br>If CPU0 handles the ELOG_GSMI_APM_CNT SMI after the SMI handler<br>completes, the system will reboot. Forcing CPU1 to always handle the SMI<br>fixes the issue. I have not been able to find an explanation for this.<br><br>I realize this is a terrible and ugly hack but it makes it possible to<br>shutdown consistently.<br><br>BUG=b:80539294<br>TEST=built on grunt and tried `halt` a few times in a row.<br><br>Change-Id: Ibb2784648a8e827887170f34a01dcd5f411522e2<br>Signed-off-by: Raul E Rangel <rrangel@chromium.org><br>---<br>M src/cpu/x86/smm/smm_module_handler.c<br>1 file changed, 20 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/27/26927/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/cpu/x86/smm/smm_module_handler.c b/src/cpu/x86/smm/smm_module_handler.c</span><br><span>index c2001ec..46c4a7e 100644</span><br><span>--- a/src/cpu/x86/smm/smm_module_handler.c</span><br><span>+++ b/src/cpu/x86/smm/smm_module_handler.c</span><br><span>@@ -117,6 +117,13 @@</span><br><span>     return base;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+static void pause(void)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+     asm volatile (</span><br><span style="color: hsl(120, 100%, 40%);">+                ".byte 0xf3, 0x90\n" /* PAUSE */</span><br><span style="color: hsl(120, 100%, 40%);">+    );</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> asmlinkage void smm_handler_start(void *arg)</span><br><span> {</span><br><span>         const struct smm_module_params *p;</span><br><span>@@ -139,14 +146,24 @@</span><br><span>           return;</span><br><span>      }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+#if defined(CONFIG_BOARD_GOOGLE_BASEBOARD_KAHLEE)</span><br><span style="color: hsl(120, 100%, 40%);">+      /*</span><br><span style="color: hsl(120, 100%, 40%);">+     * Force CPU 1 to handle all SMIs. We need to do this because if CPU0</span><br><span style="color: hsl(120, 100%, 40%);">+  * handles an SMI for ELOG_GSMI_APM_CNT it will cause the system to</span><br><span style="color: hsl(120, 100%, 40%);">+    * reboot.</span><br><span style="color: hsl(120, 100%, 40%);">+     */</span><br><span style="color: hsl(120, 100%, 40%);">+   while (cpu == 0 && smi_handler_status == SMI_UNLOCKED) {</span><br><span style="color: hsl(120, 100%, 40%);">+              // Wait for the other CPU to get the lock</span><br><span style="color: hsl(120, 100%, 40%);">+             pause();</span><br><span style="color: hsl(120, 100%, 40%);">+      }</span><br><span style="color: hsl(120, 100%, 40%);">+#endif</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>  /* Are we ok to execute the handler? */</span><br><span>      if (!smi_obtain_lock()) {</span><br><span>            /* For security reasons we don't release the other CPUs</span><br><span>           * until the CPU with the lock is actually done */</span><br><span>           while (smi_handler_status == SMI_LOCKED) {</span><br><span style="color: hsl(0, 100%, 40%);">-                      asm volatile (</span><br><span style="color: hsl(0, 100%, 40%);">-                          ".byte 0xf3, 0x90\n" /* PAUSE */</span><br><span style="color: hsl(0, 100%, 40%);">-                      );</span><br><span style="color: hsl(120, 100%, 40%);">+                    pause();</span><br><span>             }</span><br><span>            return;</span><br><span>      }</span><br><span></span><br></pre><p>To view, visit <a href="https://review.coreboot.org/26927">change 26927</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/26927"/><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: Ibb2784648a8e827887170f34a01dcd5f411522e2 </div>
<div style="display:none"> Gerrit-Change-Number: 26927 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Raul Rangel <rrangel@chromium.org> </div>