Attention is currently required from: Jason Glenesk, Raul Rangel, Marshall Dawson, Fred Reitberger, Felix Held. Arthur Heymans has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/64865 )
Change subject: soc/amd/smm_relocate.c: Improve TSEG programming ......................................................................
soc/amd/smm_relocate.c: Improve TSEG programming
TSEG does not need to be aligned to 128KiB but to it's size, as the MSR work like an MTRR. 128K is a minimum TSEG size however.
Change-Id: I30854111bb47f0cb14b07f71cedacd629432e0f4 Signed-off-by: Arthur Heymans arthur@aheymans.xyz --- M src/soc/amd/common/block/cpu/smm/smm_relocate.c M src/soc/amd/common/block/include/amdblocks/smm.h 2 files changed, 24 insertions(+), 22 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/65/64865/1
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 1d7cc68..11195d8 100644 --- a/src/soc/amd/common/block/cpu/smm/smm_relocate.c +++ b/src/soc/amd/common/block/cpu/smm/smm_relocate.c @@ -9,28 +9,24 @@ #include <cpu/x86/smm.h> #include <types.h>
-static struct smm_relocation_params smm_reloc_params; - -static void fill_in_relocation_params(struct smm_relocation_params *params) +void get_smm_info(uintptr_t *perm_smbase, size_t *perm_smsize, size_t *smm_save_state_size) { + printk(BIOS_DEBUG, "Setting up SMI for CPU\n"); + uintptr_t tseg_base; size_t tseg_size;
smm_region(&tseg_base, &tseg_size);
- params->tseg_base.lo = ALIGN_DOWN(tseg_base, 128 * KiB); - params->tseg_base.hi = 0; - params->tseg_mask.lo = ALIGN_DOWN(~(tseg_size - 1), 128 * KiB); - params->tseg_mask.hi = ((1 << (cpu_phys_address_size() - 32)) - 1); + if (!IS_ALIGNED(tseg_base, tseg_size)) { + printk(BIOS_ERR, "TSEG base not aligned to TSEG size\n"); + return; + } + if (tseg_size < (1 << 17)) { + printk(BIOS_ERR, "TSEG size too small\n"); + return; + }
- params->tseg_mask.lo |= SMM_TSEG_WB; -} - -void get_smm_info(uintptr_t *perm_smbase, size_t *perm_smsize, size_t *smm_save_state_size) -{ - printk(BIOS_DEBUG, "Setting up SMI for CPU\n"); - - fill_in_relocation_params(&smm_reloc_params);
smm_subregion(SMM_SUBREGION_HANDLER, perm_smbase, perm_smsize); *smm_save_state_size = sizeof(amd64_smm_state_save_area_t); @@ -38,10 +34,21 @@
void smm_relocation_handler(int cpu, uintptr_t curr_smbase, uintptr_t staggered_smbase) { - struct smm_relocation_params *relo_params = &smm_reloc_params; amd64_smm_state_save_area_t *smm_state;
- wrmsr(SMM_ADDR_MSR, relo_params->tseg_base); + uintptr_t tseg_base; + size_t tseg_size; + + smm_region(&tseg_base, &tseg_size); + + msr_t msr; + msr.lo = tseg_base; + msr.hi = 0; + wrmsr(SMM_ADDR_MSR, msr); + + msr.lo = ~(tseg_size - 1); + msr.lo |= SMM_TSEG_WB; + msr.hi = (1 << (cpu_phys_address_size() - 32)) - 1; wrmsr(SMM_MASK_MSR, relo_params->tseg_mask);
smm_state = (void *)(SMM_AMD64_SAVE_STATE_OFFSET + curr_smbase); diff --git a/src/soc/amd/common/block/include/amdblocks/smm.h b/src/soc/amd/common/block/include/amdblocks/smm.h index 4a44203..9124607 100644 --- a/src/soc/amd/common/block/include/amdblocks/smm.h +++ b/src/soc/amd/common/block/include/amdblocks/smm.h @@ -6,11 +6,6 @@ #include <cpu/x86/msr.h> #include <types.h>
-struct smm_relocation_params { - msr_t tseg_base; - msr_t tseg_mask; -}; - void get_smm_info(uintptr_t *perm_smbase, size_t *perm_smsize, size_t *smm_save_state_size); void smm_relocation_handler(int cpu, uintptr_t curr_smbase, uintptr_t staggered_smbase); void *get_smi_source_handler(int source);