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> Reviewed-on: https://review.coreboot.org/c/coreboot/+/63479 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Martin L Roth <gaumless@tutanota.com>
This commit is contained in:
parent
d7c371619a
commit
1684b0aa67
|
@ -673,9 +673,6 @@ struct mp_state {
|
|||
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;
|
||||
|
@ -756,13 +753,11 @@ static void adjust_smm_apic_id_map(struct smm_loader_params *smm_params)
|
|||
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,
|
||||
};
|
||||
|
@ -779,8 +774,7 @@ static enum cb_err install_relocation_handler(int num_cpus, size_t real_save_sta
|
|||
}
|
||||
|
||||
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
|
||||
|
@ -791,8 +785,7 @@ static enum cb_err install_permanent_handler(int num_cpus, uintptr_t smbase,
|
|||
*/
|
||||
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,
|
||||
};
|
||||
|
||||
|
@ -809,8 +802,7 @@ static enum cb_err install_permanent_handler(int num_cpus, uintptr_t smbase,
|
|||
/* 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())
|
||||
|
@ -823,15 +815,13 @@ static void load_smm_handlers(void)
|
|||
}
|
||||
|
||||
/* 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();
|
||||
}
|
||||
|
@ -1090,26 +1080,11 @@ static struct mp_flight_record mp_steps[] = {
|
|||
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
|
||||
|
|
|
@ -106,7 +106,7 @@ static int smm_create_map(const uintptr_t smbase, const unsigned int num_cpus,
|
|||
* Make sure that the first stub does not overlap with the last save state of a segment.
|
||||
*/
|
||||
const size_t stub_size = rmodule_memory_size(&smm_stub);
|
||||
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 - stub_size) / needed_ss_size;
|
||||
|
||||
|
@ -127,7 +127,7 @@ static int smm_create_map(const uintptr_t smbase, const unsigned int num_cpus,
|
|||
cpus[i].code_start = cpus[i].smbase + SMM_ENTRY_OFFSET;
|
||||
cpus[i].code_end = cpus[i].code_start + stub_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;
|
||||
cpus[i].ss_start = cpus[i].ss_top - params->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,
|
||||
|
@ -372,7 +372,7 @@ static void setup_smihandler_params(struct smm_runtime *mod_params,
|
|||
{
|
||||
mod_params->smbase = smram_base;
|
||||
mod_params->smm_size = smram_size;
|
||||
mod_params->save_state_size = loader_params->real_cpu_save_state_size;
|
||||
mod_params->save_state_size = loader_params->cpu_save_state_size;
|
||||
mod_params->num_cpus = loader_params->num_cpus;
|
||||
mod_params->gnvs_ptr = (uint32_t)(uintptr_t)acpi_get_gnvs();
|
||||
const struct cbmem_entry *cbmemc;
|
||||
|
|
|
@ -127,7 +127,7 @@ static inline bool smm_points_to_smram(const void *ptr, const size_t len)
|
|||
/* 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 @@ static inline bool smm_points_to_smram(const void *ptr, const size_t len)
|
|||
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;
|
||||
|
|
Loading…
Reference in New Issue