Eugene Myers has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/78889?usp=email )
Change subject: cpu/x86/smm: Fix get_save_state calculation ......................................................................
cpu/x86/smm: Fix get_save_state calculation
When the STM is configured, get_save_state returns an incorrect pointer to the cpu save state because the size (rounded up to 0x100) of the processor SMM descriptor needs to be subtracted out in this case.
This patch addresses the issue identified in CB:76601 and bug #511.
Change-Id: I0233c6d13bdffb3853845ac6ef25c066deaab747 Signed-off-by: Eugene D. Myers edmyers@cyberpackventures.com --- M src/cpu/x86/smm/smm_module_handler.c 1 file changed, 10 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/89/78889/1
diff --git a/src/cpu/x86/smm/smm_module_handler.c b/src/cpu/x86/smm/smm_module_handler.c index 3415b02..dfa4bd2f 100644 --- a/src/cpu/x86/smm/smm_module_handler.c +++ b/src/cpu/x86/smm/smm_module_handler.c @@ -9,6 +9,7 @@ #include <cpu/x86/smm.h> #include <rmodule.h> #include <types.h> +#include <security/intel/stm/SmmStm.h>
#if CONFIG(SPI_FLASH_SMM) #include <spi-generic.h> @@ -100,10 +101,18 @@
void *smm_get_save_state(int cpu) { + size_t stm_psd_size = 0; + if (cpu > smm_runtime.num_cpus) return NULL;
- return (void *)(smm_runtime.save_state_top[cpu] - smm_runtime.save_state_size); + if (CONFIG(STM)) { + stm_psd_size = ALIGN_UP(sizeof(TXT_PROCESSOR_SMM_DESCRIPTOR), + 0x100); + } + + return (void *)(smm_runtime.save_state_top[cpu] - + (smm_runtime.save_state_size - stm_psd_size)); }
uint32_t smm_revision(void)