cpu/x86/smm: Check that the stub size is < save state size

If the stub size would be larger than the save state size, the stagger
points would overlap with the stub.

The check is placed in the stub placement code. The stub placement
code is called twice. Once for the initial SMM relocatation and for
the permanent handler in TSEG. So the check is done twice, which is
not really needed.

Change-Id: I253e1a7112cd8f7496cb1a826311f4dd5ccfc73a
Signed-off-by: Arthur Heymans <arthur@aheymans.xyz>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/47069
Reviewed-by: David Hendricks <david.hendricks@gmail.com>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Arthur Heymans 2020-11-01 12:37:40 +01:00 committed by Patrick Georgi
parent bf13ef0738
commit fd8619e665
2 changed files with 12 additions and 0 deletions

View File

@ -209,6 +209,12 @@ static int smm_module_setup_stub(void *smbase, size_t smm_size,
smm_stub_size = rmodule_memory_size(&smm_stub);
stub_entry_offset = rmodule_entry_offset(&smm_stub);
if (smm_stub_size > params->per_cpu_save_state_size) {
printk(BIOS_ERR, "SMM Module: SMM stub size larger than save state size\n");
printk(BIOS_ERR, "SMM Module: Staggered entry points will overlap stub\n");
return -1;
}
/* Assume the stub is always small enough to live within upper half of
* SMRAM region after the save state space has been allocated. */
smm_stub_loc = &base[SMM_ENTRY_OFFSET];

View File

@ -134,6 +134,12 @@ static int smm_create_map(uintptr_t smbase, unsigned int num_cpus,
return 0;
}
if (stub_size > ss_size) {
printk(BIOS_ERR, "%s: Save state larger than SMM stub size\n", __func__);
printk(BIOS_ERR, " Decrease stub size or increase the size allocated for the save state\n");
return 0;
}
for (i = 0; i < num_cpus; i++) {
cpus[i].smbase = base;
cpus[i].entry = base + smm_entry_offset;