Arthur Heymans has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/55138 )
Change subject: mb/emulation/q35: Fix running with qemu-i386 with SMM_TSEG ......................................................................
mb/emulation/q35: Fix running with qemu-i386 with SMM_TSEG
Qemu now uses the legacy x86 SMM save state for i386, where it previously always used the amd64 save state. The smbase offsets are incompatible between those save states.
Change-Id: Ic6994c8d6e10fd06655129dbd801f1f9d5fd639f Signed-off-by: Arthur Heymans arthur@aheymans.xyz --- M src/mainboard/emulation/qemu-q35/cpu.c 1 file changed, 22 insertions(+), 6 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/38/55138/1
diff --git a/src/mainboard/emulation/qemu-q35/cpu.c b/src/mainboard/emulation/qemu-q35/cpu.c index fb31fc5..d95393b 100644 --- a/src/mainboard/emulation/qemu-q35/cpu.c +++ b/src/mainboard/emulation/qemu-q35/cpu.c @@ -1,10 +1,12 @@ /* SPDX-License-Identifier: GPL-2.0-only */
+#include "cpu/x86/smm.h" #include <console/console.h> #include <cpu/x86/mp.h> #include <stdint.h> #include <cpu/intel/smm_reloc.h> #include <cpu/amd/amd64_save_state.h> +#include <cpu/x86/legacy_save_state.h> #include <mainboard/emulation/qemu-i440fx/fw_cfg.h>
static void get_smm_info(uintptr_t *perm_smbase, size_t *perm_smsize, @@ -27,16 +29,30 @@ static void relocation_handler(int cpu, uintptr_t curr_smbase, uintptr_t staggered_smbase) { - /* The em64t101 save state is sufficiently compatible with older - save states with regards of smbase, smm_revision. */ - amd64_smm_state_save_area_t *save_state; + amd64_smm_state_save_area_t *save_state_amd64; + legacy_smm_state_save_area_t *save_state_i386; + + uint32_t smm_revision = (uint32_t)*(uint32_t *)(curr_smbase + SMM_DEFAULT_SIZE + - SMM_REVISION_OFFSET_FROM_TOP); u32 smbase = staggered_smbase;
- save_state = (void *)(curr_smbase + SMM_DEFAULT_SIZE - sizeof(*save_state)); - save_state->smbase = smbase; + switch (smm_revision) { + case 0x00020000: + save_state_i386 = (void *)(curr_smbase + SMM_DEFAULT_SIZE - sizeof(*save_state_i386)); + save_state_i386->smbase = smbase; + break; + case 0x00020064: + save_state_amd64 = + (void *)(curr_smbase + SMM_DEFAULT_SIZE - sizeof(*save_state_amd64)); + save_state_amd64->smbase = smbase; + break; + default: + printk(BIOS_DEBUG, "Unknown SMM revision 0x%08x, not relocating SMM\n", smm_revision); + return; + };
printk(BIOS_DEBUG, "In relocation handler: cpu %d\n", cpu); - printk(BIOS_DEBUG, "SMM revision: 0x%08x\n", save_state->smm_revision); + printk(BIOS_DEBUG, "SMM revision: 0x%08x\n", smm_revision); printk(BIOS_DEBUG, "New SMBASE=0x%08x\n", smbase); }