cpu/x86/smm,lib/cbmem_console: Enable CBMEMC when using DEBUG_SMI

This change will allow the SMI handler to write to the cbmem console
buffer. Normally SMIs can only be debugged using some kind of serial
port (UART). By storing the SMI logs into cbmem we can debug SMIs using
`cbmem -1`. Now that these logs are available to the OS we could also
verify there were no errors in the SMI handler.

Since SMM can write to all of DRAM, we can't trust any pointers
provided by cbmem after the OS has booted. For this reason we store the
cbmem console pointer as part of the SMM runtime parameters. The cbmem
console is implemented as a circular buffer so it will never write
outside of this area.

BUG=b:221231786
TEST=Boot non-serial FW with DEBUG_SMI and verified SMI messages are
visible when running `cbmem -1`. Perform a suspend/resume cycle and
verify new SMI events are written to the cbmem console log.

Signed-off-by: Raul E Rangel <rrangel@chromium.org>
Change-Id: Ia1e310a12ca2f54210ccfaee58807cb808cfff79
Reviewed-on: https://review.coreboot.org/c/coreboot/+/62355
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Karthik Ramasubramanian <kramasub@google.com>
This commit is contained in:
Raul E Rangel
2022-02-24 16:02:49 -07:00
committed by Felix Held
parent ef44779726
commit c5160986cf
6 changed files with 36 additions and 1 deletions

View File

@@ -10,7 +10,8 @@ void cbmemc_tx_byte(unsigned char data);
#define __CBMEM_CONSOLE_ENABLE__ (CONFIG(CONSOLE_CBMEM) && \
(ENV_RAMSTAGE || ENV_SEPARATE_VERSTAGE || ENV_POSTCAR || \
ENV_ROMSTAGE || (ENV_BOOTBLOCK && CONFIG(BOOTBLOCK_CONSOLE))))
ENV_ROMSTAGE || (ENV_BOOTBLOCK && CONFIG(BOOTBLOCK_CONSOLE)) || \
(ENV_SMM && CONFIG(DEBUG_SMI))))
#if __CBMEM_CONSOLE_ENABLE__
static inline void __cbmemc_init(void) { cbmemc_init(); }
@@ -28,3 +29,6 @@ void cbmemc_copy_in(void *buffer, size_t size);
void cbmem_dump_console_to_uart(void);
void cbmem_dump_console(void);
#endif
/* Retrieves the location of the CBMEM Console buffer in SMM mode */
void smm_get_cbmemc_buffer(void **buffer_out, size_t *size_out);

View File

@@ -61,6 +61,8 @@ struct smm_runtime {
u32 save_state_size;
u32 num_cpus;
u32 gnvs_ptr;
u32 cbmemc_size;
void *cbmemc;
uintptr_t save_state_top[CONFIG_MAX_CPUS];
} __packed;