From c078552e712cd8b2a69bdca41ca6c84826a70756 Mon Sep 17 00:00:00 2001 From: Bora Guvendik Date: Mon, 2 Feb 2026 15:12:48 -0800 Subject: [PATCH] soc/intel: Replace sa_get_tseg_size() with CONFIG_SMM_TSEG_SIZE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove the sa_get_tseg_size() function and replace all its usage with CONFIG_SMM_TSEG_SIZE configuration option. The TSEG size is now obtained directly from the configuration instead of being calculated dynamically. The existing calculation assumes GSM and TSEG regions are contiguous, but there is no guarantee this is always true depending on how FSP operates. This could lead to incorrect size calculations. Using CONFIG_SMM_TSEG_SIZE is more reliable as this value is provided to the FSP during initialization. This change: - Removes sa_get_tseg_size() function declaration and implementation - Updates smm_region() to use CONFIG_SMM_TSEG_SIZE directly - Updates Alder Lake, Meteor Lake, and Panther Lake system agent code to use CONFIG_SMM_TSEG_SIZE instead of sa_get_tseg_size() Before (sa_get_tseg_size): [SPEW ] TsegBase = 0x78000000 [SPEW ] GsmBase = 0x7BC00000 [DEBUG] sa_get_tseg_size:0x3c00000 [DEBUG] New SMBASE=0x7b5ec000 IEDBASE=0x7b800000 [DEBUG] Writing SMRR. base = 0x78000006, mask=0xfc400c00 System hangs during SMM relocation After (CONFIG_SMM_TSEG_SIZE): [SPEW ] TsegBase = 0x78000000 [SPEW ] GsmBase = 0x7BC00000 [DEBUG] CONFIG_SMM_TSEG_SIZE:0x2000000 [DEBUG] New SMBASE=0x799ec000 IEDBASE=0x79c00000 [DEBUG] Writing SMRR. base = 0x78000006, mask=0xfe000c00 [DEBUG] Relocation complete. System boots successfully BUG=none Change-Id: Ie2a1f3dd68941924e056a12f01857c1182b69198 Signed-off-by: Bora Guvendik Reviewed-on: https://review.coreboot.org/c/coreboot/+/91063 Reviewed-by: Paul Menzel Reviewed-by: Kim, Wonkyu Tested-by: build bot (Jenkins) Reviewed-by: Jérémy Compostella --- src/soc/intel/alderlake/systemagent.c | 2 +- src/soc/intel/common/block/include/intelblocks/systemagent.h | 2 -- src/soc/intel/common/block/systemagent/memmap.c | 2 +- src/soc/intel/common/block/systemagent/systemagent_early.c | 5 ----- src/soc/intel/meteorlake/systemagent.c | 2 +- src/soc/intel/pantherlake/systemagent.c | 2 +- 6 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/soc/intel/alderlake/systemagent.c b/src/soc/intel/alderlake/systemagent.c index be0c6996a4..bbc421b0cb 100644 --- a/src/soc/intel/alderlake/systemagent.c +++ b/src/soc/intel/alderlake/systemagent.c @@ -116,7 +116,7 @@ void soc_add_configurable_mmio_resources(struct device *dev, int *resource_cnt) } /* TSEG */ - size = sa_get_tseg_size(); + size = CONFIG_SMM_TSEG_SIZE; tseg_base = sa_get_tseg_base(); if (size > 0) set_mmio_resource(&(cfg_rsrc[count++]), tseg_base, size, "TSEG"); diff --git a/src/soc/intel/common/block/include/intelblocks/systemagent.h b/src/soc/intel/common/block/include/intelblocks/systemagent.h index a3ae8c38bf..5047f1d9aa 100644 --- a/src/soc/intel/common/block/include/intelblocks/systemagent.h +++ b/src/soc/intel/common/block/include/intelblocks/systemagent.h @@ -91,8 +91,6 @@ uintptr_t sa_get_tolud_base(void); uintptr_t sa_get_gsm_base(void); /* API to get TSEG base address */ uintptr_t sa_get_tseg_base(void); -/* API to get TSEG size */ -size_t sa_get_tseg_size(void); /* API to lock PAM registers */ void sa_lock_pam(void); /* API to get MMIO config size */ diff --git a/src/soc/intel/common/block/systemagent/memmap.c b/src/soc/intel/common/block/systemagent/memmap.c index 3b0fb6e8ae..9a3971098f 100644 --- a/src/soc/intel/common/block/systemagent/memmap.c +++ b/src/soc/intel/common/block/systemagent/memmap.c @@ -54,7 +54,7 @@ void smm_region(uintptr_t *start, size_t *size) { *start = sa_get_tseg_base(); - *size = sa_get_tseg_size(); + *size = CONFIG_SMM_TSEG_SIZE; } void fill_postcar_frame(struct postcar_frame *pcf) diff --git a/src/soc/intel/common/block/systemagent/systemagent_early.c b/src/soc/intel/common/block/systemagent/systemagent_early.c index aecdfbb429..993d008eb6 100644 --- a/src/soc/intel/common/block/systemagent/systemagent_early.c +++ b/src/soc/intel/common/block/systemagent/systemagent_early.c @@ -146,11 +146,6 @@ uintptr_t sa_get_tseg_base(void) return ALIGN_DOWN(pci_read_config32(SA_DEV_ROOT, TSEG), 1*MiB); } -size_t sa_get_tseg_size(void) -{ - return sa_get_gsm_base() - sa_get_tseg_base(); -} - union dpr_register txt_get_chipset_dpr(void) { return (union dpr_register) { .raw = pci_read_config32(SA_DEV_ROOT, DPR) }; diff --git a/src/soc/intel/meteorlake/systemagent.c b/src/soc/intel/meteorlake/systemagent.c index bb841aa60b..9dc771f6e2 100644 --- a/src/soc/intel/meteorlake/systemagent.c +++ b/src/soc/intel/meteorlake/systemagent.c @@ -108,7 +108,7 @@ void soc_add_configurable_mmio_resources(struct device *dev, int *resource_cnt) } /* TSEG */ - size = sa_get_tseg_size(); + size = CONFIG_SMM_TSEG_SIZE; tseg_base = sa_get_tseg_base(); if (size > 0) set_mmio_resource(&(cfg_rsrc[count++]), tseg_base, size, "TSEG"); diff --git a/src/soc/intel/pantherlake/systemagent.c b/src/soc/intel/pantherlake/systemagent.c index c1a081cb1b..f88aedb95c 100644 --- a/src/soc/intel/pantherlake/systemagent.c +++ b/src/soc/intel/pantherlake/systemagent.c @@ -105,7 +105,7 @@ void soc_add_configurable_mmio_resources(struct device *dev, int *resource_cnt) } /* TSEG */ - size = sa_get_tseg_size(); + size = CONFIG_SMM_TSEG_SIZE; tseg_base = sa_get_tseg_base(); if (size > 0) set_mmio_resource(&(cfg_rsrc[count++]), tseg_base, size, "TSEG");