Arthur Heymans has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/63479 )
Change subject: cpu/x86/mp_init.c: Drop 'real' vs 'used' save state ......................................................................
cpu/x86/mp_init.c: Drop 'real' vs 'used' save state
Now that the save state size is handled properly inside the smm_loader there is no reason to make that distinction in the mp_init code anymore.
Change-Id: Ia0002a33b6d0f792d8d78cf625fd7e830e3e50fc Signed-off-by: Arthur Heymans arthur@aheymans.xyz --- M src/cpu/x86/mp_init.c M src/cpu/x86/smm/smm_module_loader.c M src/include/cpu/x86/smm.h 3 files changed, 14 insertions(+), 40 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/79/63479/1
diff --git a/src/cpu/x86/mp_init.c b/src/cpu/x86/mp_init.c index 81c987b..12f6cd2 100644 --- a/src/cpu/x86/mp_init.c +++ b/src/cpu/x86/mp_init.c @@ -674,9 +674,6 @@ int cpu_count; uintptr_t perm_smbase; size_t perm_smsize; - /* Size of the real CPU save state */ - size_t smm_real_save_state_size; - /* Size of allocated CPU save state, MAX(real save state size, stub size) */ size_t smm_save_state_size; uintptr_t reloc_start32_offset; int do_smm; @@ -757,13 +754,11 @@ stub_params->apic_id_to_cpu[i] = cpu_get_apic_id(i); }
-static enum cb_err install_relocation_handler(int num_cpus, size_t real_save_state_size, - size_t save_state_size) +static enum cb_err install_relocation_handler(int num_cpus, size_t save_state_size) { struct smm_loader_params smm_params = { .num_cpus = num_cpus, - .real_cpu_save_state_size = real_save_state_size, - .per_cpu_save_state_size = save_state_size, + .cpu_save_state_size = save_state_size, .num_concurrent_save_states = 1, .handler = smm_do_relocation, }; @@ -780,8 +775,7 @@ }
static enum cb_err install_permanent_handler(int num_cpus, uintptr_t smbase, - size_t smsize, size_t real_save_state_size, - size_t save_state_size) + size_t smsize, size_t save_state_size) { /* * All the CPUs will relocate to permanaent handler now. Set parameters @@ -792,8 +786,7 @@ */ struct smm_loader_params smm_params = { .num_cpus = num_cpus, - .real_cpu_save_state_size = real_save_state_size, - .per_cpu_save_state_size = save_state_size, + .cpu_save_state_size = save_state_size, .num_concurrent_save_states = num_cpus, };
@@ -810,8 +803,7 @@ /* Load SMM handlers as part of MP flight record. */ static void load_smm_handlers(void) { - size_t real_save_state_size = mp_state.smm_real_save_state_size; - size_t smm_save_state_size = mp_state.smm_save_state_size; + const size_t save_state_size = mp_state.smm_save_state_size;
/* Do nothing if SMM is disabled.*/ if (!is_smm_enabled()) @@ -824,15 +816,13 @@ }
/* Install handlers. */ - if (install_relocation_handler(mp_state.cpu_count, real_save_state_size, - smm_save_state_size) != CB_SUCCESS) { + if (install_relocation_handler(mp_state.cpu_count, save_state_size) != CB_SUCCESS) { printk(BIOS_ERR, "Unable to install SMM relocation handler.\n"); smm_disable(); }
if (install_permanent_handler(mp_state.cpu_count, mp_state.perm_smbase, - mp_state.perm_smsize, real_save_state_size, - smm_save_state_size) != CB_SUCCESS) { + mp_state.perm_smsize, save_state_size) != CB_SUCCESS) { printk(BIOS_ERR, "Unable to install SMM permanent handler.\n"); smm_disable(); } @@ -1043,26 +1033,11 @@ MP_FR_BLOCK_APS(ap_wait_for_instruction, NULL), };
-static size_t smm_stub_size(void) -{ - extern unsigned char _binary_smmstub_start[]; - struct rmodule smm_stub; - - if (rmodule_parse(&_binary_smmstub_start, &smm_stub)) { - printk(BIOS_ERR, "%s: unable to get SMM module size\n", __func__); - return 0; - } - - return rmodule_memory_size(&smm_stub); -} - static void fill_mp_state_smm(struct mp_state *state, const struct mp_ops *ops) { if (ops->get_smm_info != NULL) ops->get_smm_info(&state->perm_smbase, &state->perm_smsize, - &state->smm_real_save_state_size); - - state->smm_save_state_size = MAX(state->smm_real_save_state_size, smm_stub_size()); + &state->smm_save_state_size);
/* * Make sure there is enough room for the SMM descriptor diff --git a/src/cpu/x86/smm/smm_module_loader.c b/src/cpu/x86/smm/smm_module_loader.c index 0d99b0e..0e8df34 100644 --- a/src/cpu/x86/smm/smm_module_loader.c +++ b/src/cpu/x86/smm/smm_module_loader.c @@ -102,7 +102,7 @@
const size_t stub_size = rmodule_memory_size(&smm_stub); /* How many CPUs can fit into one 64K segment? */ - const size_t needed_ss_size = MAX(params->real_cpu_save_state_size, stub_size); + const size_t needed_ss_size = MAX(params->cpu_save_state_size, stub_size); const size_t cpus_per_segment = (SMM_CODE_SEGMENT_SIZE - SMM_ENTRY_OFFSET) / needed_ss_size;
if (cpus_per_segment == 0) { @@ -122,7 +122,7 @@ + SMM_ENTRY_OFFSET; cpus[i].smbase = cpus[i].code_start - SMM_ENTRY_OFFSET; cpus[i].ss_top = cpus[i].code_start + SMM_ENTRY_OFFSET; - cpus[i].ss_start = cpus[i].ss_top - params->real_cpu_save_state_size; + cpus[i].ss_start = cpus[i].ss_top - params->cpu_save_state_size; cpus[i].code_end = cpus[i].code_start + stub_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, cpus[i].ss_top); @@ -428,7 +428,7 @@ params->handler = rmodule_entry(&smi_handler); smihandler_params->smbase = smram_base; smihandler_params->smm_size = smram_size; - smihandler_params->save_state_size = params->real_cpu_save_state_size; + smihandler_params->save_state_size = params->cpu_save_state_size; smihandler_params->num_cpus = params->num_cpus; smihandler_params->gnvs_ptr = (uint32_t)(uintptr_t)acpi_get_gnvs(); const struct cbmem_entry *cbmemc; @@ -546,7 +546,7 @@ params->handler = rmodule_entry(&smi_handler); smihandler_params->smbase = smram_base; smihandler_params->smm_size = smram_size; - smihandler_params->save_state_size = params->real_cpu_save_state_size; + smihandler_params->save_state_size = params->cpu_save_state_size; smihandler_params->num_cpus = params->num_cpus; smihandler_params->gnvs_ptr = (uint32_t)(uintptr_t)acpi_get_gnvs(); const struct cbmem_entry *cbmemc; diff --git a/src/include/cpu/x86/smm.h b/src/include/cpu/x86/smm.h index 03b9c39..b6d778b 100644 --- a/src/include/cpu/x86/smm.h +++ b/src/include/cpu/x86/smm.h @@ -127,7 +127,7 @@ /* The smm_loader_params structure provides direction to the SMM loader: * - num_cpus - number of concurrent cpus in handler needing stack * optional for setting up relocation handler. - * - per_cpu_save_state_size - the SMM save state size per cpu + * - cpu_save_state_size - the SMM save state size per cpu * - num_concurrent_save_states - number of concurrent cpus needing save state * space * - handler - optional handler to call. Only used during SMM relocation setup. @@ -139,8 +139,7 @@ struct smm_loader_params { size_t num_cpus;
- size_t real_cpu_save_state_size; - size_t per_cpu_save_state_size; + size_t cpu_save_state_size; size_t num_concurrent_save_states;
smm_handler_t handler;