From cb361da78fc53b7678b43026ae997af708246273 Mon Sep 17 00:00:00 2001 From: Arthur Heymans Date: Thu, 7 Apr 2022 21:20:50 +0200 Subject: cpu/x86/smm_module_loader: Add a convenient ss_top We don't want to keep track of the real smm size all the time. As a bonus now ss_start is now really the start of the save state instead of top - MAX(stub_size, save state size). Change-Id: I0981022e6c0df110d4a342ff06b1a3332911e2b7 Signed-off-by: Arthur Heymans Reviewed-on: https://review.coreboot.org/c/coreboot/+/63477 Tested-by: build bot (Jenkins) Reviewed-by: Martin L Roth --- src/cpu/x86/smm/smm_module_loader.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'src/cpu/x86/smm') diff --git a/src/cpu/x86/smm/smm_module_loader.c b/src/cpu/x86/smm/smm_module_loader.c index 071b33673d..f97f747132 100644 --- a/src/cpu/x86/smm/smm_module_loader.c +++ b/src/cpu/x86/smm/smm_module_loader.c @@ -43,6 +43,7 @@ struct cpu_smm_info { uint8_t active; uintptr_t smbase; uintptr_t ss_start; + uintptr_t ss_top; uintptr_t code_start; uintptr_t code_end; }; @@ -125,12 +126,12 @@ static int smm_create_map(const uintptr_t smbase, const unsigned int num_cpus, - needed_ss_size * (i % cpus_per_segment); cpus[i].code_start = cpus[i].smbase + SMM_ENTRY_OFFSET; cpus[i].code_end = cpus[i].code_start + stub_size; - cpus[i].ss_start = cpus[i].smbase + SMM_CODE_SEGMENT_SIZE - needed_ss_size; + cpus[i].ss_top = cpus[i].smbase + SMM_CODE_SEGMENT_SIZE; + cpus[i].ss_start = cpus[i].ss_top - params->real_cpu_save_state_size; printk(BIOS_DEBUG, " Stub [0x%lx-0x%lx[\n", cpus[i].code_start, cpus[i].code_end); - printk(BIOS_DEBUG, " Save state [0x%lx-0x%lx[\n", - cpus[i].ss_start + needed_ss_size - params->real_cpu_save_state_size, - cpus[i].ss_start + needed_ss_size); + printk(BIOS_DEBUG, " Save state [0x%lx-0x%lx[\n", cpus[i].ss_start, + cpus[i].ss_top); cpus[i].active = 1; } @@ -433,10 +434,8 @@ static void setup_smihandler_params(struct smm_runtime *mod_params, mod_params->cbmemc_size = 0; } - for (int i = 0; i < loader_params->num_cpus; i++) { - mod_params->save_state_top[i] = cpus[i].ss_start - + loader_params->per_cpu_save_state_size; - } + for (int i = 0; i < loader_params->num_cpus; i++) + mod_params->save_state_top[i] = cpus[i].ss_top; } /* -- cgit v1.2.3