cpu/x86/smm: Fix smm_get_save_state() returning invalid pointer

The smm_get_save_state() function returns an invalid pointer (negative
pointer) when the cpu variable is equal to the number of CPUs. This
leads to a hang when the pointer is used to access the save state.

TEST=No unexpected hangs in System Management Mode (SMM) were detected
     on fatcat.

Change-Id: I09f969105190a004372c43cb1542f5b716da1eda
Signed-off-by: Jeremy Compostella <jeremy.compostella@intel.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/86038
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Elyes Haouas <ehaouas@noos.fr>
Reviewed-by: Jamie Ryu <jamie.m.ryu@intel.com>
This commit is contained in:
Jeremy Compostella 2025-01-17 12:45:00 -08:00 committed by Elyes Haouas
commit 0cf6a4d702

View file

@ -106,7 +106,7 @@ struct global_nvs *gnvs;
void *smm_get_save_state(int cpu)
{
if (cpu > smm_runtime.num_cpus)
if (cpu >= smm_runtime.num_cpus)
return NULL;
return (void *)(smm_runtime.save_state_top[cpu] -