diff options
author | Arthur Heymans <arthur@aheymans.xyz> | 2021-02-15 18:55:40 +0100 |
---|---|---|
committer | Patrick Georgi <pgeorgi@google.com> | 2021-03-19 11:32:59 +0000 |
commit | 64d9e8568172402d8078c2c80ba994da16f4745b (patch) | |
tree | ceeec69b2dddf5a9b60dc9eeb35a70ebabe1a06e /src/cpu/x86 | |
parent | dfff5c2d193066adff8e0bee9ed4525b622eb7c8 (diff) | |
download | coreboot-64d9e8568172402d8078c2c80ba994da16f4745b.tar.xz |
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>
Diffstat (limited to 'src/cpu/x86')
-rw-r--r-- | src/cpu/x86/smm/smm_module_handler.c | 11 | ||||
-rw-r--r-- | src/cpu/x86/smm/smm_module_loader.c | 6 | ||||
-rw-r--r-- | src/cpu/x86/smm/smm_module_loaderv2.c | 5 |
3 files changed, 14 insertions, 8 deletions
diff --git a/src/cpu/x86/smm/smm_module_handler.c b/src/cpu/x86/smm/smm_module_handler.c index dec2d6b72f..f7cf928f73 100644 --- a/src/cpu/x86/smm/smm_module_handler.c +++ b/src/cpu/x86/smm/smm_module_handler.c @@ -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) diff --git a/src/cpu/x86/smm/smm_module_loader.c b/src/cpu/x86/smm/smm_module_loader.c index de2738ab36..021d739f94 100644 --- a/src/cpu/x86/smm/smm_module_loader.c +++ b/src/cpu/x86/smm/smm_module_loader.c @@ -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); } diff --git a/src/cpu/x86/smm/smm_module_loaderv2.c b/src/cpu/x86/smm/smm_module_loaderv2.c index e0877e7fc4..886041dbba 100644 --- a/src/cpu/x86/smm/smm_module_loaderv2.c +++ b/src/cpu/x86/smm/smm_module_loaderv2.c @@ -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); } |