<p>Marshall Dawson has uploaded this change for <strong>review</strong>.</p><p><a href="https://review.coreboot.org/23437">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">amd/stoneyridge: Move SmmLock to end of POST<br><br>Relocate locking of the SMM settings from the CPU initialization to<br>the end of POST (or just before resuming).<br><br>Change-Id: I70b7e33e7045d397e41f571caff6a2acbb64eaab<br>Signed-off-by: Marshall Dawson <marshalldawson3rd@gmail.com><br>---<br>M src/soc/amd/stoneyridge/Makefile.inc<br>A src/soc/amd/stoneyridge/finalize.c<br>M src/soc/amd/stoneyridge/model_15_init.c<br>3 files changed, 53 insertions(+), 5 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://review.coreboot.org:29418/coreboot refs/changes/37/23437/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/soc/amd/stoneyridge/Makefile.inc b/src/soc/amd/stoneyridge/Makefile.inc</span><br><span>index 3401808..da0b22a 100644</span><br><span>--- a/src/soc/amd/stoneyridge/Makefile.inc</span><br><span>+++ b/src/soc/amd/stoneyridge/Makefile.inc</span><br><span>@@ -101,6 +101,7 @@</span><br><span> ramstage-y += usb.c</span><br><span> ramstage-y += tsc_freq.c</span><br><span> ramstage-$(CONFIG_SPI_FLASH) += spi.c</span><br><span style="color: hsl(120, 100%, 40%);">+ramstage-y += finalize.c</span><br><span> </span><br><span> smm-y += smihandler.c</span><br><span> smm-y += smi_util.c</span><br><span>diff --git a/src/soc/amd/stoneyridge/finalize.c b/src/soc/amd/stoneyridge/finalize.c</span><br><span>new file mode 100644</span><br><span>index 0000000..7de9315</span><br><span>--- /dev/null</span><br><span>+++ b/src/soc/amd/stoneyridge/finalize.c</span><br><span>@@ -0,0 +1,52 @@</span><br><span style="color: hsl(120, 100%, 40%);">+/*</span><br><span style="color: hsl(120, 100%, 40%);">+ * This file is part of the coreboot project.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * Copyright (C) 2018 Advanced Micro Devices, Inc.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This program is free software; you can redistribute it and/or modify</span><br><span style="color: hsl(120, 100%, 40%);">+ * it under the terms of the GNU General Public License as published by</span><br><span style="color: hsl(120, 100%, 40%);">+ * the Free Software Foundation; version 2 of the License.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This program is distributed in the hope that it will be useful,</span><br><span style="color: hsl(120, 100%, 40%);">+ * but WITHOUT ANY WARRANTY; without even the implied warranty of</span><br><span style="color: hsl(120, 100%, 40%);">+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span><br><span style="color: hsl(120, 100%, 40%);">+ * GNU General Public License for more details.</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%);">+#include <cpu/x86/mp.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <cpu/x86/msr.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <cpu/amd/amdfam15.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <bootstate.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <timer.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <console/console.h></span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+static void per_core_finalize(void)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+    msr_t msr;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+  /* Lock down SMM settings */</span><br><span style="color: hsl(120, 100%, 40%);">+  msr = rdmsr(HWCR_MSR);</span><br><span style="color: hsl(120, 100%, 40%);">+        msr.lo |= SMM_LOCK;</span><br><span style="color: hsl(120, 100%, 40%);">+   wrmsr(HWCR_MSR, msr);</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%);">+static void finalize_cores(void)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+       int r;</span><br><span style="color: hsl(120, 100%, 40%);">+        printk(BIOS_SPEW, "Lock SMM configuration\n");</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+    r = mp_run_on_all_cpus(per_core_finalize, 10 * USECS_PER_MSEC);</span><br><span style="color: hsl(120, 100%, 40%);">+       if (r)</span><br><span style="color: hsl(120, 100%, 40%);">+                printk(BIOS_DEBUG, "Failed to finalize all cores\n");</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%);">+static void soc_finalize(void *unused)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+       finalize_cores();</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   post_code(POST_OS_BOOT);</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%);">+BOOT_STATE_INIT_ENTRY(BS_OS_RESUME, BS_ON_ENTRY, soc_finalize, NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+BOOT_STATE_INIT_ENTRY(BS_PAYLOAD_LOAD, BS_ON_EXIT, soc_finalize, NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>diff --git a/src/soc/amd/stoneyridge/model_15_init.c b/src/soc/amd/stoneyridge/model_15_init.c</span><br><span>index 930e395..56f747c 100644</span><br><span>--- a/src/soc/amd/stoneyridge/model_15_init.c</span><br><span>+++ b/src/soc/amd/stoneyridge/model_15_init.c</span><br><span>@@ -76,11 +76,6 @@</span><br><span>        msr.hi = 0;</span><br><span>  for (i = 0 ; i < 6 ; i++)</span><br><span>                 wrmsr(MCI_STATUS + (i * 4), msr);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-       /* Write protect SMM space with SMMLOCK. */</span><br><span style="color: hsl(0, 100%, 40%);">-     msr = rdmsr(HWCR_MSR);</span><br><span style="color: hsl(0, 100%, 40%);">-  msr.lo |= (1 << 0);</span><br><span style="color: hsl(0, 100%, 40%);">-       wrmsr(HWCR_MSR, msr);</span><br><span> }</span><br><span> </span><br><span> static struct device_operations cpu_dev_ops = {</span><br><span></span><br></pre><p>To view, visit <a href="https://review.coreboot.org/23437">change 23437</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/23437"/><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: I70b7e33e7045d397e41f571caff6a2acbb64eaab </div>
<div style="display:none"> Gerrit-Change-Number: 23437 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Marshall Dawson <marshalldawson3rd@gmail.com> </div>