Benjamin Doron has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/80703?usp=email )
Change subject: treewide: Fix `smm_region_overlaps_handler()` ......................................................................
treewide: Fix `smm_region_overlaps_handler()`
coreboot SMI handlers must not be confused into writing over any SMRAM, not just the code subregion.
If stage cache writes were permitted, this could compromise the integrity of the S3 resume path.
Overwriting the chipset-specific area is undefined.
Change-Id: Ibd9ed34fcfd77a4236b5cf122747a6718ce9c91f Signed-off-by: Benjamin Doron benjamin.doron@9elements.com --- M src/cpu/x86/smm/smm_module_handler.c M src/mainboard/emulation/qemu-q35/Makefile.mk M src/northbridge/intel/e7505/Makefile.mk M src/northbridge/intel/gm45/Makefile.mk M src/northbridge/intel/haswell/Makefile.mk M src/northbridge/intel/i945/Makefile.mk M src/northbridge/intel/ironlake/Makefile.mk M src/northbridge/intel/pineview/Makefile.mk M src/northbridge/intel/sandybridge/Makefile.mk M src/northbridge/intel/x4x/Makefile.mk M src/soc/amd/common/block/cpu/noncar/Makefile.mk M src/soc/amd/stoneyridge/Makefile.mk M src/soc/intel/baytrail/Makefile.mk M src/soc/intel/braswell/Makefile.mk M src/soc/intel/broadwell/Makefile.mk M src/soc/intel/common/block/systemagent/Makefile.mk M src/soc/intel/denverton_ns/Makefile.mk M src/soc/intel/xeon_sp/Makefile.mk 18 files changed, 31 insertions(+), 6 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/03/80703/1
diff --git a/src/cpu/x86/smm/smm_module_handler.c b/src/cpu/x86/smm/smm_module_handler.c index 0daae00..572a459 100644 --- a/src/cpu/x86/smm/smm_module_handler.c +++ b/src/cpu/x86/smm/smm_module_handler.c @@ -118,10 +118,18 @@
bool smm_region_overlaps_handler(const struct region *r) { - const struct region r_smm = {smm_runtime.smbase, smm_runtime.smm_size}; - const struct region r_aseg = {SMM_BASE, SMM_DEFAULT_SIZE}; + struct region r_smm; + uintptr_t tseg_base;
- return region_overlap(&r_smm, r) || region_overlap(&r_aseg, r); + if (CONFIG(SMM_ASEG)) { + r_smm.offset = SMM_BASE; + r_smm.size = SMM_DEFAULT_SIZE; + } else if (CONFIG(SMM_TSEG)) { + smm_region(&tseg_base, &r_smm.size); + r_smm.offset = tseg_base; + } + + return region_overlap(&r_smm, r); }
asmlinkage void smm_handler_start(void *arg) diff --git a/src/mainboard/emulation/qemu-q35/Makefile.mk b/src/mainboard/emulation/qemu-q35/Makefile.mk index bc73edc..e53deec 100644 --- a/src/mainboard/emulation/qemu-q35/Makefile.mk +++ b/src/mainboard/emulation/qemu-q35/Makefile.mk @@ -15,9 +15,9 @@ ramstage-y += memmap.c ramstage-y += cpu.c
+smm-y += memmap.c + all-y += ../qemu-i440fx/fw_cfg.c all-y += ../qemu-i440fx/bootmode.c
ramstage-$(CONFIG_CHROMEOS) += chromeos.c - -smm-y += memmap.c diff --git a/src/northbridge/intel/e7505/Makefile.mk b/src/northbridge/intel/e7505/Makefile.mk index 44a056b..8cbd745 100644 --- a/src/northbridge/intel/e7505/Makefile.mk +++ b/src/northbridge/intel/e7505/Makefile.mk @@ -9,4 +9,6 @@ romstage-y += raminit.c romstage-y += memmap.c
+smm-y += memmap.c + endif diff --git a/src/northbridge/intel/gm45/Makefile.mk b/src/northbridge/intel/gm45/Makefile.mk index db9dc3f..9a5bfcd 100644 --- a/src/northbridge/intel/gm45/Makefile.mk +++ b/src/northbridge/intel/gm45/Makefile.mk @@ -25,5 +25,6 @@ ramstage-y += gma.c
postcar-y += memmap.c +smm-y += memmap.c
endif diff --git a/src/northbridge/intel/haswell/Makefile.mk b/src/northbridge/intel/haswell/Makefile.mk index 8da72dc..a12b3fc 100644 --- a/src/northbridge/intel/haswell/Makefile.mk +++ b/src/northbridge/intel/haswell/Makefile.mk @@ -18,6 +18,7 @@ romstage-y += report_platform.c
postcar-y += memmap.c +smm-y += memmap.c
ifeq ($(CONFIG_USE_NATIVE_RAMINIT),y) romstage-y += early_dmi.c early_pcie.c vcu_mailbox.c diff --git a/src/northbridge/intel/i945/Makefile.mk b/src/northbridge/intel/i945/Makefile.mk index e970208..d06c625 100644 --- a/src/northbridge/intel/i945/Makefile.mk +++ b/src/northbridge/intel/i945/Makefile.mk @@ -17,5 +17,6 @@ romstage-y += rcven.c
postcar-y += memmap.c +smm-y += memmap.c
endif diff --git a/src/northbridge/intel/ironlake/Makefile.mk b/src/northbridge/intel/ironlake/Makefile.mk index afca10c..409adb3 100644 --- a/src/northbridge/intel/ironlake/Makefile.mk +++ b/src/northbridge/intel/ironlake/Makefile.mk @@ -16,6 +16,7 @@ romstage-y += romstage.c romstage-y += quickpath.c
+smm-y += memmap.c smm-y += finalize.c
postcar-y += memmap.c diff --git a/src/northbridge/intel/pineview/Makefile.mk b/src/northbridge/intel/pineview/Makefile.mk index b231a3e..4a899d9 100644 --- a/src/northbridge/intel/pineview/Makefile.mk +++ b/src/northbridge/intel/pineview/Makefile.mk @@ -15,5 +15,6 @@ romstage-y += early_init.c
postcar-y += memmap.c +smm-y += memmap.c
endif diff --git a/src/northbridge/intel/sandybridge/Makefile.mk b/src/northbridge/intel/sandybridge/Makefile.mk index 6ecb17a..b172396 100644 --- a/src/northbridge/intel/sandybridge/Makefile.mk +++ b/src/northbridge/intel/sandybridge/Makefile.mk @@ -39,5 +39,6 @@ smm-y += finalize.c
postcar-y += memmap.c +smm-y += memmap.c
endif diff --git a/src/northbridge/intel/x4x/Makefile.mk b/src/northbridge/intel/x4x/Makefile.mk index 6ca0df2..0a84a8e 100644 --- a/src/northbridge/intel/x4x/Makefile.mk +++ b/src/northbridge/intel/x4x/Makefile.mk @@ -19,5 +19,6 @@ ramstage-y += northbridge.c
postcar-y += memmap.c +smm-y += memmap.c
endif diff --git a/src/soc/amd/common/block/cpu/noncar/Makefile.mk b/src/soc/amd/common/block/cpu/noncar/Makefile.mk index f3ada62..23bf08e 100644 --- a/src/soc/amd/common/block/cpu/noncar/Makefile.mk +++ b/src/soc/amd/common/block/cpu/noncar/Makefile.mk @@ -13,5 +13,6 @@ romstage-y += cpu.c ramstage-y += memmap.c ramstage-y += mpinit.c +smm-y += memmap.c
endif # CONFIG_SOC_AMD_COMMON_BLOCK_NONCAR diff --git a/src/soc/amd/stoneyridge/Makefile.mk b/src/soc/amd/stoneyridge/Makefile.mk index c1c74ea..0bcfcbd 100644 --- a/src/soc/amd/stoneyridge/Makefile.mk +++ b/src/soc/amd/stoneyridge/Makefile.mk @@ -53,6 +53,7 @@ all-y += uart.c
smm-y += pstate_util.c +smm-y += memmap.c smm-y += monotonic_timer.c smm-y += smihandler.c smm-y += tsc_freq.c diff --git a/src/soc/intel/baytrail/Makefile.mk b/src/soc/intel/baytrail/Makefile.mk index 281175c..1a5c4cc 100644 --- a/src/soc/intel/baytrail/Makefile.mk +++ b/src/soc/intel/baytrail/Makefile.mk @@ -56,6 +56,7 @@
smm-y += iosf.c smm-y += pmutil.c +smm-y += memmap.c smm-y += smihandler.c smm-y += tsc_freq.c
diff --git a/src/soc/intel/braswell/Makefile.mk b/src/soc/intel/braswell/Makefile.mk index 923ba9d..09aa292 100644 --- a/src/soc/intel/braswell/Makefile.mk +++ b/src/soc/intel/braswell/Makefile.mk @@ -54,6 +54,7 @@ ramstage-y += placeholders.c smm-y += lpc_init.c smm-y += pmutil.c +smm-y += memmap.c smm-y += smihandler.c smm-y += tsc_freq.c
diff --git a/src/soc/intel/broadwell/Makefile.mk b/src/soc/intel/broadwell/Makefile.mk index 3565cd1..95c0d84 100644 --- a/src/soc/intel/broadwell/Makefile.mk +++ b/src/soc/intel/broadwell/Makefile.mk @@ -17,6 +17,7 @@ ramstage-y += memmap.c romstage-y += memmap.c postcar-y += memmap.c +smm-y += memmap.c ramstage-y += minihd.c ramstage-y += northbridge.c ramstage-y += pei_data.c diff --git a/src/soc/intel/common/block/systemagent/Makefile.mk b/src/soc/intel/common/block/systemagent/Makefile.mk index fe7a71c..d27be89 100644 --- a/src/soc/intel/common/block/systemagent/Makefile.mk +++ b/src/soc/intel/common/block/systemagent/Makefile.mk @@ -3,7 +3,9 @@ romstage-$(CONFIG_SOC_INTEL_COMMON_BLOCK_SA) += systemagent_early.c ramstage-$(CONFIG_SOC_INTEL_COMMON_BLOCK_SA) += systemagent_early.c postcar-$(CONFIG_SOC_INTEL_COMMON_BLOCK_SA) += systemagent_early.c +smm-$(CONFIG_SOC_INTEL_COMMON_BLOCK_SA) += systemagent_early.c ramstage-$(CONFIG_SOC_INTEL_COMMON_BLOCK_SA) += systemagent.c romstage-$(CONFIG_SOC_INTEL_COMMON_BLOCK_SA) += memmap.c ramstage-$(CONFIG_SOC_INTEL_COMMON_BLOCK_SA) += memmap.c postcar-$(CONFIG_SOC_INTEL_COMMON_BLOCK_SA) += memmap.c +smm-$(CONFIG_SOC_INTEL_COMMON_BLOCK_SA) += memmap.c diff --git a/src/soc/intel/denverton_ns/Makefile.mk b/src/soc/intel/denverton_ns/Makefile.mk index 5d9b327..4f6ee56 100644 --- a/src/soc/intel/denverton_ns/Makefile.mk +++ b/src/soc/intel/denverton_ns/Makefile.mk @@ -57,6 +57,7 @@
smm-y += pmutil.c smm-y += soc_util.c +smm-y += memmap.c smm-y += smihandler.c smm-y += tsc_freq.c smm-$(CONFIG_SPI_FLASH_SMM) += spi.c diff --git a/src/soc/intel/xeon_sp/Makefile.mk b/src/soc/intel/xeon_sp/Makefile.mk index a732c78..322a0bf 100644 --- a/src/soc/intel/xeon_sp/Makefile.mk +++ b/src/soc/intel/xeon_sp/Makefile.mk @@ -15,7 +15,7 @@ ramstage-$(CONFIG_HAVE_ACPI_TABLES) += uncore_acpi.c acpi.c ramstage-$(CONFIG_SOC_INTEL_HAS_CXL) += uncore_acpi_cxl.c ramstage-$(CONFIG_HAVE_SMI_HANDLER) += smmrelocate.c -smm-y += smihandler.c pmutil.c +smm-y += memmap.c smihandler.c pmutil.c postcar-y += spi.c
subdirs-$(CONFIG_SOC_INTEL_XEON_RAS) += ras