cpu/x86/smm_module_hander: Set up a save state map

With the smm_module_loaderv2 the save state map is not linear so copy
a map from ramstage into the smihandler.

TESTED on QEMU q35: Both SMMLOADER V1 and V2 handle save states properly.

Change-Id: I31c57b59559ad4ee98500d83969424e5345881ee
Signed-off-by: Arthur Heymans <arthur@aheymans.xyz>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/50769
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
This commit is contained in:
Arthur Heymans 2021-02-15 18:55:40 +01:00 committed by Patrick Georgi
parent dfff5c2d19
commit 64d9e85681
4 changed files with 15 additions and 8 deletions

View File

@ -94,15 +94,10 @@ struct global_nvs *gnvs;
void *smm_get_save_state(int cpu)
{
char *base;
if (cpu > smm_runtime.num_cpus)
return NULL;
/* This function assumes all save states start at top of default
* SMRAM size space and are staggered down by save state size. */
base = (void *)(uintptr_t)smm_runtime.smbase;
base += SMM_DEFAULT_SIZE;
base -= (cpu + 1) * smm_runtime.save_state_size;
return base;
return (void *)(smm_runtime.save_state_top[cpu] - smm_runtime.save_state_size);
}
uint32_t smm_revision(void)

View File

@ -1,5 +1,6 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#include <stdint.h>
#include <string.h>
#include <acpi/acpi_gnvs.h>
#include <rmodule.h>
@ -392,5 +393,10 @@ int smm_load_module(void *smram, size_t size, struct smm_loader_params *params)
handler_mod_params->num_cpus = params->num_concurrent_stacks;
handler_mod_params->gnvs_ptr = (uintptr_t)acpi_get_gnvs();
for (int i = 0; i < CONFIG_MAX_CPUS; i++) {
handler_mod_params->save_state_top[i] = (uintptr_t)smram + SMM_DEFAULT_SIZE
- params->per_cpu_save_state_size * i;
}
return smm_module_setup_stub(smram, size, params, fxsave_area);
}

View File

@ -641,5 +641,10 @@ int smm_load_module(void *smram, size_t size, struct smm_loader_params *params)
return -1;
}
for (int i = 0; i < params->num_concurrent_stacks; i++) {
handler_mod_params->save_state_top[i] =
cpus[i].ss_start + params->per_cpu_save_state_size;
}
return smm_module_setup_stub(base, size, params, fxsave_area);
}

View File

@ -60,6 +60,7 @@ struct smm_runtime {
u32 save_state_size;
u32 num_cpus;
u32 gnvs_ptr;
uintptr_t save_state_top[CONFIG_MAX_CPUS];
} __packed;
struct smm_module_params {