cpu/x86/smm_loaderv2: Use the permanent stack top during relocation
Use the same stack location during relocation as for the permanent handler. When the number of CPUs is too large the stacks during relocation don't fit inside the default SMRAM segment at 0x30000. Currently the code would just let the CPU stack base grow downwards outside of the default SMM segment which would corrupt lower memory if S3 is implemented. Also update the comment on smm_module_setup_stub(). Change-Id: I6a0a890e8b1c2408301564c22772032cfee4d296 Signed-off-by: Arthur Heymans <arthur@aheymans.xyz> Reviewed-on: https://review.coreboot.org/c/coreboot/+/51186 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com>
This commit is contained in:
committed by
Patrick Georgi
parent
110c47699a
commit
e6c3523b1b
@@ -796,19 +796,11 @@ static void adjust_smm_apic_id_map(struct smm_loader_params *smm_params)
|
||||
}
|
||||
|
||||
static int install_relocation_handler(int num_cpus, size_t real_save_state_size,
|
||||
size_t save_state_size)
|
||||
size_t save_state_size, uintptr_t perm_smbase)
|
||||
{
|
||||
int cpus = num_cpus;
|
||||
#if CONFIG(X86_SMM_LOADER_VERSION2)
|
||||
/* Default SMRAM size is not big enough to concurrently
|
||||
* handle relocation for more than ~32 CPU threads
|
||||
* therefore, relocate 1 by 1. */
|
||||
cpus = 1;
|
||||
#endif
|
||||
|
||||
struct smm_loader_params smm_params = {
|
||||
.per_cpu_stack_size = CONFIG_SMM_STUB_STACK_SIZE,
|
||||
.num_concurrent_stacks = cpus,
|
||||
.num_concurrent_stacks = num_cpus,
|
||||
.real_cpu_save_state_size = real_save_state_size,
|
||||
.per_cpu_save_state_size = save_state_size,
|
||||
.num_concurrent_save_states = 1,
|
||||
@@ -819,7 +811,7 @@ static int install_relocation_handler(int num_cpus, size_t real_save_state_size,
|
||||
if (mp_state.ops.adjust_smm_params != NULL)
|
||||
mp_state.ops.adjust_smm_params(&smm_params, 0);
|
||||
|
||||
if (smm_setup_relocation_handler(&smm_params)) {
|
||||
if (smm_setup_relocation_handler((void *)perm_smbase, &smm_params)) {
|
||||
printk(BIOS_ERR, "%s: smm setup failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
@@ -874,9 +866,8 @@ static void load_smm_handlers(void)
|
||||
return;
|
||||
|
||||
/* Install handlers. */
|
||||
if (install_relocation_handler(mp_state.cpu_count,
|
||||
real_save_state_size,
|
||||
smm_save_state_size) < 0) {
|
||||
if (install_relocation_handler(mp_state.cpu_count, real_save_state_size,
|
||||
smm_save_state_size, mp_state.perm_smbase) < 0) {
|
||||
printk(BIOS_ERR, "Unable to install SMM relocation handler.\n");
|
||||
smm_disable();
|
||||
}
|
||||
|
Reference in New Issue
Block a user