David Hendricks has submitted this change. ( https://review.coreboot.org/c/coreboot/+/49460 )
Change subject: cpu/x86/smm: Enable setting SMM console log level from mainboard ......................................................................
cpu/x86/smm: Enable setting SMM console log level from mainboard
Add a Kconfig RUNTIME_CONFIGURABLE_SMM_LOGLEVEL that enables mainboard to override mainboard_set_smm_log_level for SMM log level. This can let SMM have different log level than other stages for more flexibility.
Another reason is that getting certain data that requires searching from flash VPD or CMOS is not very ideal to be done in SMM, so in this change the value can be passed via the member variable in struct smm_runtime and be referenced directly in SMM.
One example is that mainboard can get the desired SMM log level from VPD/CMOS, and pass SMM console log level via the variable and in SMM it can be referenced in get_console_loglevel() override function directly.
Tested=On OCP Delta Lake, verified SMM log level can be overridden.
Change-Id: I81722a4f1bf75ec942cc06e403ad702dfe938e71 Signed-off-by: Johnny Lin johnny_lin@wiwynn.com Reviewed-on: https://review.coreboot.org/c/coreboot/+/49460 Reviewed-by: David Hendricks david.hendricks@gmail.com Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Jonathan Zhang jonzhang@fb.com --- M src/cpu/x86/Kconfig M src/cpu/x86/smm/smm_module_handler.c M src/cpu/x86/smm/smm_module_loader.c M src/include/cpu/x86/smm.h 4 files changed, 57 insertions(+), 0 deletions(-)
Approvals: build bot (Jenkins): Verified David Hendricks: Looks good to me, approved Jonathan Zhang: Looks good to me, approved
diff --git a/src/cpu/x86/Kconfig b/src/cpu/x86/Kconfig index 1a7d8c6..edba27b 100644 --- a/src/cpu/x86/Kconfig +++ b/src/cpu/x86/Kconfig @@ -209,4 +209,16 @@ This is the amount of stack each AP needs. The BSP stack size can be larger and is set with STACK_SIZE.
+config RUNTIME_CONFIGURABLE_SMM_LOGLEVEL + bool + default n + depends on DEBUG_SMI && CONSOLE_OVERRIDE_LOGLEVEL + help + This enables setting the SMM console log level at runtime for more + flexibility to use different log levels for each stage. Another reason + is that reading the log level from non-volatile memory such as flash + VPD or CMOS is not very ideal to be done in SMM, with this option the + value can be passed via the member variable in struct smm_runtime and + be referenced directly in SMM. + endif # ARCH_X86 diff --git a/src/cpu/x86/smm/smm_module_handler.c b/src/cpu/x86/smm/smm_module_handler.c index a976521..1b3c93b 100644 --- a/src/cpu/x86/smm/smm_module_handler.c +++ b/src/cpu/x86/smm/smm_module_handler.c @@ -52,6 +52,13 @@ ); }
+#if CONFIG(RUNTIME_CONFIGURABLE_SMM_LOGLEVEL) +int get_console_loglevel(void) +{ + return smm_runtime.smm_log_level; +} +#endif + void smm_get_cbmemc_buffer(void **buffer_out, size_t *size_out) { *buffer_out = smm_runtime.cbmemc; diff --git a/src/cpu/x86/smm/smm_module_loader.c b/src/cpu/x86/smm/smm_module_loader.c index 6924f08..1b04e88 100644 --- a/src/cpu/x86/smm/smm_module_loader.c +++ b/src/cpu/x86/smm/smm_module_loader.c @@ -338,6 +338,11 @@
for (int i = 0; i < loader_params->num_cpus; i++) mod_params->save_state_top[i] = region_end(&cpus[i].ss); + + if (CONFIG(RUNTIME_CONFIGURABLE_SMM_LOGLEVEL)) + mod_params->smm_log_level = mainboard_set_smm_log_level(); + else + mod_params->smm_log_level = 0; }
static void print_region(const char *name, const struct region region) diff --git a/src/include/cpu/x86/smm.h b/src/include/cpu/x86/smm.h index 7914967..4ab9f21 100644 --- a/src/include/cpu/x86/smm.h +++ b/src/include/cpu/x86/smm.h @@ -49,6 +49,7 @@ int mainboard_smi_apmc(u8 data); void mainboard_smi_sleep(u8 slp_typ); void mainboard_smi_finalize(void); +int mainboard_set_smm_log_level(void);
void smm_soc_early_init(void); void smm_soc_exit(void); @@ -66,6 +67,7 @@ u32 cbmemc_size; void *cbmemc; uintptr_t save_state_top[CONFIG_MAX_CPUS]; + int smm_log_level; } __packed;
struct smm_module_params {