summaryrefslogtreecommitdiff
path: root/src/soc
diff options
context:
space:
mode:
authorArthur Heymans <arthur@aheymans.xyz>2022-05-31 21:50:51 +0200
committerFelix Held <felix-coreboot@felixheld.de>2022-09-14 20:29:59 +0000
commit43ed5d253422425dee3908ee3158c0318a2729aa (patch)
tree78f621fc5acd998558da8ed2476ccf4bde8204b8 /src/soc
parente48dcb708c97923f39762ab60ad0423767e2b84c (diff)
cpu/amd: Move locking SMM as part of SMM init
Locking SMM as part of the AP init avoids the need for CONFIG_PARALLEL_MP_AP_WORK to lock it down. Change-Id: Ibcdfc0f9ae211644cf0911790b0b0c5d1b0b7dc9 Signed-off-by: Arthur Heymans <arthur@aheymans.xyz> Reviewed-on: https://review.coreboot.org/c/coreboot/+/64871 Reviewed-by: Paul Menzel <paulepanter@mailbox.org> Reviewed-by: Felix Held <felix-coreboot@felixheld.de> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src/soc')
-rw-r--r--src/soc/amd/common/block/cpu/smm/finalize.c22
-rw-r--r--src/soc/amd/common/block/cpu/smm/smm_helper.c14
-rw-r--r--src/soc/amd/common/block/cpu/smm/smm_relocate.c11
-rw-r--r--src/soc/amd/common/block/include/amdblocks/smm.h2
4 files changed, 11 insertions, 38 deletions
diff --git a/src/soc/amd/common/block/cpu/smm/finalize.c b/src/soc/amd/common/block/cpu/smm/finalize.c
index d0fe4bc9d6..07196d13ca 100644
--- a/src/soc/amd/common/block/cpu/smm/finalize.c
+++ b/src/soc/amd/common/block/cpu/smm/finalize.c
@@ -10,30 +10,8 @@
#include <cpu/x86/msr.h>
#include <types.h>
-static void per_core_finalize(void *unused)
-{
- /* Finalize SMM settings */
- if (is_smm_locked()) /* Skip if already locked, avoid GPF */
- return;
-
- if (CONFIG(HAVE_SMI_HANDLER))
- tseg_valid();
-
- lock_smm();
-}
-
-static void finalize_cores(void)
-{
- printk(BIOS_SPEW, "Lock SMM configuration\n");
-
- if (mp_run_on_all_cpus(per_core_finalize, NULL) != CB_SUCCESS)
- printk(BIOS_WARNING, "Failed to finalize all cores\n");
-}
-
static void soc_finalize(void *unused)
{
- finalize_cores();
-
if (!acpi_is_wakeup_s3()) {
acpi_clear_pm_gpe_status();
diff --git a/src/soc/amd/common/block/cpu/smm/smm_helper.c b/src/soc/amd/common/block/cpu/smm/smm_helper.c
index e87d12c641..a6e7d2dac5 100644
--- a/src/soc/amd/common/block/cpu/smm/smm_helper.c
+++ b/src/soc/amd/common/block/cpu/smm/smm_helper.c
@@ -30,20 +30,6 @@ void clear_tvalid(void)
wrmsr(SMM_MASK_MSR, mask);
}
-void tseg_valid(void)
-{
- msr_t mask = rdmsr(SMM_MASK_MSR);
- mask.lo |= SMM_TSEG_VALID;
-
- wrmsr(SMM_MASK_MSR, mask);
-}
-
-bool is_smm_locked(void)
-{
- msr_t hwcr = rdmsr(HWCR_MSR);
- return hwcr.lo & SMM_LOCK ? true : false;
-}
-
void lock_smm(void)
{
msr_t hwcr = rdmsr(HWCR_MSR);
diff --git a/src/soc/amd/common/block/cpu/smm/smm_relocate.c b/src/soc/amd/common/block/cpu/smm/smm_relocate.c
index e464cfca6d..87636df850 100644
--- a/src/soc/amd/common/block/cpu/smm/smm_relocate.c
+++ b/src/soc/amd/common/block/cpu/smm/smm_relocate.c
@@ -49,6 +49,14 @@ static void get_smm_info(uintptr_t *perm_smbase, size_t *perm_smsize,
*smm_save_state_size = sizeof(amd64_smm_state_save_area_t);
}
+static void tseg_valid(void)
+{
+ msr_t mask = rdmsr(SMM_MASK_MSR);
+ mask.lo |= SMM_TSEG_VALID;
+
+ wrmsr(SMM_MASK_MSR, mask);
+}
+
static void smm_relocation_handler(int cpu, uintptr_t curr_smbase, uintptr_t staggered_smbase)
{
amd64_smm_state_save_area_t *smm_state;
@@ -70,6 +78,9 @@ static void smm_relocation_handler(int cpu, uintptr_t curr_smbase, uintptr_t sta
smm_state = (void *)(SMM_AMD64_SAVE_STATE_OFFSET + curr_smbase);
smm_state->smbase = staggered_smbase;
+
+ tseg_valid();
+ lock_smm();
}
const struct mp_ops amd_mp_ops_with_smm = {
diff --git a/src/soc/amd/common/block/include/amdblocks/smm.h b/src/soc/amd/common/block/include/amdblocks/smm.h
index f0a06bf015..2218385477 100644
--- a/src/soc/amd/common/block/include/amdblocks/smm.h
+++ b/src/soc/amd/common/block/include/amdblocks/smm.h
@@ -10,8 +10,6 @@ void *get_smi_source_handler(int source);
void handle_smi_gsmi(void);
void handle_smi_store(void);
void clear_tvalid(void);
-void tseg_valid(void);
-bool is_smm_locked(void);
void lock_smm(void);
/* See SMITYPE_* for list possible of events. GEVENTS are handled with mainboard_smi_gpi. */
void mainboard_handle_smi(int event);