cpu/x86/smm: Add support for exception handling

Add an exception handler to SMM to debug crashes when a serial
console is enabled and DEBUG_SMI is set. This allows for narrowing
down issues faster than letting the machine triple fault.

Change-Id: I2ccaf8d23d508d773ce56912983884ad6832ede6
Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/87208
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Shuo Liu <shuo.liu@intel.com>
Reviewed-by: Maximilian Brune <maximilian.brune@9elements.com>
This commit is contained in:
Patrick Rudolph 2025-04-08 12:59:35 +02:00 committed by Matt DeVillier
commit 245cba6795
2 changed files with 6 additions and 0 deletions

View file

@ -665,6 +665,8 @@ asmlinkage void exception_init(void)
load_idt(idt, sizeof(idt));
#if !ENV_SMM
null_breakpoint_init();
stack_canary_breakpoint_init();
#endif
}

View file

@ -1,6 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#include <arch/io.h>
#include <arch/exception.h>
#include <commonlib/region.h>
#include <console/cbmem_console.h>
#include <console/console.h>
@ -169,6 +170,9 @@ asmlinkage void smm_handler_start(void *arg)
printk(BIOS_SPEW, "\nSMI# #%d\n", cpu);
if (CONFIG(DEBUG_SMI) && CONFIG(CONSOLE_SERIAL))
exception_init();
/* Allow drivers to initialize variables in SMM context. */
if (do_driver_init) {
#if CONFIG(SPI_FLASH_SMM)