From 1b8e65dee16c083849a0cf0dc61b0e6ecf64c118 Mon Sep 17 00:00:00 2001 From: Angel Pons Date: Fri, 19 Feb 2021 18:29:58 +0100 Subject: [PATCH] soc/intel/{skl,cnl}: Move smm_lock() to cpu.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Looks like smmrelocate.c is nearly identical across multiple platforms. This is done to be able to deduplicate smmrelocate.c in the follow-ups. Change-Id: I2edc64c9eabc3815b12a2e3cffb03cba2228eea0 Signed-off-by: Angel Pons Reviewed-on: https://review.coreboot.org/c/coreboot/+/50933 Reviewed-by: Michael Niewöhner Reviewed-by: Arthur Heymans Tested-by: build bot (Jenkins) --- src/soc/intel/cannonlake/cpu.c | 12 ++++++++++++ src/soc/intel/cannonlake/smmrelocate.c | 13 ------------- src/soc/intel/skylake/cpu.c | 12 ++++++++++++ src/soc/intel/skylake/smmrelocate.c | 13 ------------- 4 files changed, 24 insertions(+), 26 deletions(-) diff --git a/src/soc/intel/cannonlake/cpu.c b/src/soc/intel/cannonlake/cpu.c index 2520559cdc..5b39156292 100644 --- a/src/soc/intel/cannonlake/cpu.c +++ b/src/soc/intel/cannonlake/cpu.c @@ -134,6 +134,18 @@ static void per_cpu_smm_trigger(void) smm_relocate(); } +void smm_lock(void) +{ + struct device *sa_dev = pcidev_path_on_root(SA_DEVFN_ROOT); + /* + * LOCK the SMM memory window and enable normal SMM. + * After running this function, only a full reset can + * make the SMM registers writable again. + */ + printk(BIOS_DEBUG, "Locking SMM.\n"); + pci_write_config8(sa_dev, SMRAM, D_LCK | G_SMRAME | C_BASE_SEG); +} + static void post_mp_init(void) { /* Set Max Ratio */ diff --git a/src/soc/intel/cannonlake/smmrelocate.c b/src/soc/intel/cannonlake/smmrelocate.c index 7d189eadf2..1acb184410 100644 --- a/src/soc/intel/cannonlake/smmrelocate.c +++ b/src/soc/intel/cannonlake/smmrelocate.c @@ -16,7 +16,6 @@ #include #include #include -#include #include "chip.h" static void update_save_state(int cpu, uintptr_t curr_smbase, @@ -232,15 +231,3 @@ void smm_relocate(void) else if (!boot_cpu()) smm_initiate_relocation(); } - -void smm_lock(void) -{ - struct device *sa_dev = pcidev_path_on_root(SA_DEVFN_ROOT); - /* - * LOCK the SMM memory window and enable normal SMM. - * After running this function, only a full reset can - * make the SMM registers writable again. - */ - printk(BIOS_DEBUG, "Locking SMM.\n"); - pci_write_config8(sa_dev, SMRAM, D_LCK | G_SMRAME | C_BASE_SEG); -} diff --git a/src/soc/intel/skylake/cpu.c b/src/soc/intel/skylake/cpu.c index 4cadb7f9ee..19f2e3a0bf 100644 --- a/src/soc/intel/skylake/cpu.c +++ b/src/soc/intel/skylake/cpu.c @@ -138,6 +138,18 @@ static void per_cpu_smm_trigger(void) smm_relocate(); } +void smm_lock(void) +{ + struct device *sa_dev = pcidev_path_on_root(SA_DEVFN_ROOT); + /* + * LOCK the SMM memory window and enable normal SMM. + * After running this function, only a full reset can + * make the SMM registers writable again. + */ + printk(BIOS_DEBUG, "Locking SMM.\n"); + pci_write_config8(sa_dev, SMRAM, D_LCK | G_SMRAME | C_BASE_SEG); +} + static void vmx_configure(void *unused) { set_feature_ctrl_vmx(); diff --git a/src/soc/intel/skylake/smmrelocate.c b/src/soc/intel/skylake/smmrelocate.c index 7d189eadf2..1acb184410 100644 --- a/src/soc/intel/skylake/smmrelocate.c +++ b/src/soc/intel/skylake/smmrelocate.c @@ -16,7 +16,6 @@ #include #include #include -#include #include "chip.h" static void update_save_state(int cpu, uintptr_t curr_smbase, @@ -232,15 +231,3 @@ void smm_relocate(void) else if (!boot_cpu()) smm_initiate_relocation(); } - -void smm_lock(void) -{ - struct device *sa_dev = pcidev_path_on_root(SA_DEVFN_ROOT); - /* - * LOCK the SMM memory window and enable normal SMM. - * After running this function, only a full reset can - * make the SMM registers writable again. - */ - printk(BIOS_DEBUG, "Locking SMM.\n"); - pci_write_config8(sa_dev, SMRAM, D_LCK | G_SMRAME | C_BASE_SEG); -}