Attention is currently required from: Felix Held, Fred Reitberger, Jason Glenesk, Matt DeVillier.
Arthur Heymans has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/83066?usp=email )
Change subject: cpu/x86: Move SMI GSMI calls entry to a common place ......................................................................
cpu/x86: Move SMI GSMI calls entry to a common place
Now that SMM save states are handled in a common place so can the GSMI calls entry.
Change-Id: I93639d8d0fde2e874eb9b963c449be1b754ca63d Signed-off-by: Arthur Heymans arthur@aheymans.xyz --- M src/drivers/elog/gsmi.c M src/include/elog.h M src/soc/amd/common/block/cpu/smm/smi_apmc.c M src/soc/amd/common/block/include/amdblocks/smm.h M src/soc/amd/stoneyridge/smihandler.c M src/soc/intel/baytrail/smihandler.c M src/soc/intel/braswell/smihandler.c M src/soc/intel/broadwell/pch/smihandler.c M src/soc/intel/common/block/smm/smihandler.c M src/southbridge/intel/common/smihandler.c M src/southbridge/intel/lynxpoint/smihandler.c 11 files changed, 36 insertions(+), 154 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/66/83066/1
diff --git a/src/drivers/elog/gsmi.c b/src/drivers/elog/gsmi.c index 36940f1..06fb246 100644 --- a/src/drivers/elog/gsmi.c +++ b/src/drivers/elog/gsmi.c @@ -3,6 +3,8 @@ #include <console/console.h> #include <elog.h> #include <stdint.h> +#include <cpu/x86/smm.h> +#include <cpu/x86/save_state.h>
#define GSMI_RET_SUCCESS 0x00 #define GSMI_RET_INVALID_PARAMETER 0x82 @@ -44,7 +46,7 @@ }
/* Param is usually EBX, ret in EAX */ -u32 gsmi_exec(u8 command, u32 *param) +static u32 gsmi_exec(u8 command, u32 *param) { struct gsmi_set_eventlog_param *sel; struct gsmi_set_eventlog_type1 *type1; @@ -122,3 +124,27 @@
return ret; } + +void apmc_smi_gsmi(void) +{ + u8 sub_command; + u16 ax; + u32 ret, param; + const int apmc_node = get_apmc_node(APM_CNT_ELOG_GSMI); + + if (apmc_node < 0) + return; + + /* Command and return value in EAX */ + if (get_save_state_reg(RAX, apmc_node, &ax, sizeof(ax))) + return; + + sub_command = (ax >> 8); + + /* Parameter buffer in EBX */ + if (get_save_state_reg(RBX, apmc_node, ¶m, sizeof(param))) + return; + + ret = gsmi_exec(sub_command, ¶m); + set_save_state_reg(RAX, apmc_node, &ret, sizeof(ret)); +} diff --git a/src/include/elog.h b/src/include/elog.h index db59b76..fad8ccc 100644 --- a/src/include/elog.h +++ b/src/include/elog.h @@ -47,7 +47,7 @@ static inline int elog_gsmi_add_event_word(u8 event_type, u16 data) { return 0; } #endif
-u32 gsmi_exec(u8 command, u32 *param); +void apmc_smi_gsmi(void);
#if CONFIG(ELOG_BOOT_COUNT) u32 boot_count_read(void); diff --git a/src/soc/amd/common/block/cpu/smm/smi_apmc.c b/src/soc/amd/common/block/cpu/smm/smi_apmc.c index 9df6ae3..63bc398 100644 --- a/src/soc/amd/common/block/cpu/smm/smi_apmc.c +++ b/src/soc/amd/common/block/cpu/smm/smi_apmc.c @@ -51,25 +51,6 @@ return NULL; }
-void handle_smi_gsmi(void) -{ - u8 sub_command; - amd64_smm_state_save_area_t *io_smi; - u32 reg_ebx; - - io_smi = find_save_state(APM_CNT_ELOG_GSMI); - if (!io_smi) - return; - /* Command and return value in EAX */ - sub_command = (io_smi->rax >> 8) & 0xff; - - /* Parameter buffer in EBX */ - reg_ebx = io_smi->rbx; - - /* drivers/elog/gsmi.c */ - io_smi->rax = gsmi_exec(sub_command, ®_ebx); -} - void handle_smi_store(void) { u8 sub_command; @@ -103,7 +84,7 @@ break; case APM_CNT_ELOG_GSMI: if (CONFIG(ELOG_GSMI)) - handle_smi_gsmi(); + apmc_smi_gsmi(); break; case APM_CNT_SMMSTORE: if (CONFIG(SMMSTORE)) diff --git a/src/soc/amd/common/block/include/amdblocks/smm.h b/src/soc/amd/common/block/include/amdblocks/smm.h index bcd30f8..d84a980 100644 --- a/src/soc/amd/common/block/include/amdblocks/smm.h +++ b/src/soc/amd/common/block/include/amdblocks/smm.h @@ -7,7 +7,6 @@ #include <types.h>
void *get_smi_source_handler(int source); -void handle_smi_gsmi(void); void handle_smi_store(void); void fch_apmc_smi_handler(void); void clear_tvalid(void); diff --git a/src/soc/amd/stoneyridge/smihandler.c b/src/soc/amd/stoneyridge/smihandler.c index f962fa0..5c13a57 100644 --- a/src/soc/amd/stoneyridge/smihandler.c +++ b/src/soc/amd/stoneyridge/smihandler.c @@ -33,7 +33,7 @@ break; case APM_CNT_ELOG_GSMI: if (CONFIG(ELOG_GSMI)) - handle_smi_gsmi(); + apmc_smi_gsmi(); break; case APM_CNT_SMMSTORE: if (CONFIG(SMMSTORE)) diff --git a/src/soc/intel/baytrail/smihandler.c b/src/soc/intel/baytrail/smihandler.c index 9a47843..7a5d222 100644 --- a/src/soc/intel/baytrail/smihandler.c +++ b/src/soc/intel/baytrail/smihandler.c @@ -168,25 +168,6 @@ return NULL; }
-static void southbridge_smi_gsmi(void) -{ - u32 *ret, *param; - uint8_t sub_command; - em64t100_smm_state_save_area_t *io_smi = smi_apmc_find_state_save(APM_CNT_ELOG_GSMI); - - if (!io_smi) - return; - - /* Command and return value in EAX */ - ret = (u32 *)&io_smi->rax; - sub_command = (uint8_t)(*ret >> 8); - - /* Parameter buffer in EBX */ - param = (u32 *)&io_smi->rbx; - - /* drivers/elog/gsmi.c */ - *ret = gsmi_exec(sub_command, param); -}
void *acpi_get_device_nvs(void) { @@ -281,7 +262,7 @@ break; case APM_CNT_ELOG_GSMI: if (CONFIG(ELOG_GSMI)) - southbridge_smi_gsmi(); + apmc_smi_gsmi(); break; case APM_CNT_LEGACY: soc_legacy(); diff --git a/src/soc/intel/braswell/smihandler.c b/src/soc/intel/braswell/smihandler.c index d2588cf..940c66d 100644 --- a/src/soc/intel/braswell/smihandler.c +++ b/src/soc/intel/braswell/smihandler.c @@ -199,26 +199,6 @@ return NULL; }
-static void southbridge_smi_gsmi(void) -{ - u32 *ret, *param; - uint8_t sub_command; - em64t100_smm_state_save_area_t *io_smi = smi_apmc_find_state_save(APM_CNT_ELOG_GSMI); - - if (!io_smi) - return; - - /* Command and return value in EAX */ - ret = (u32 *)&io_smi->rax; - sub_command = (uint8_t)(*ret >> 8); - - /* Parameter buffer in EBX */ - param = (u32 *)&io_smi->rbx; - - /* drivers/elog/gsmi.c */ - *ret = gsmi_exec(sub_command, param); -} - static void southbridge_smi_store(void) { u8 sub_command, ret; @@ -252,7 +232,7 @@ break; case APM_CNT_ELOG_GSMI: if (CONFIG(ELOG_GSMI)) - southbridge_smi_gsmi(); + apmc_smi_gsmi(); break; case APM_CNT_SMMSTORE: if (CONFIG(SMMSTORE)) diff --git a/src/soc/intel/broadwell/pch/smihandler.c b/src/soc/intel/broadwell/pch/smihandler.c index 99906d9..632775b 100644 --- a/src/soc/intel/broadwell/pch/smihandler.c +++ b/src/soc/intel/broadwell/pch/smihandler.c @@ -251,27 +251,6 @@ return NULL; }
-static void southbridge_smi_gsmi(void) -{ - u32 *ret, *param; - u8 sub_command; - em64t101_smm_state_save_area_t *io_smi = - smi_apmc_find_state_save(APM_CNT_ELOG_GSMI); - - if (!io_smi) - return; - - /* Command and return value in EAX */ - ret = (u32 *)&io_smi->rax; - sub_command = (u8)(*ret >> 8); - - /* Parameter buffer in EBX */ - param = (u32 *)&io_smi->rbx; - - /* drivers/elog/gsmi.c */ - *ret = gsmi_exec(sub_command, param); -} - static void southbridge_smi_store(void) { u8 sub_command, ret; @@ -306,7 +285,7 @@ break; case APM_CNT_ELOG_GSMI: if (CONFIG(ELOG_GSMI)) - southbridge_smi_gsmi(); + apmc_smi_gsmi(); break; case APM_CNT_SMMSTORE: if (CONFIG(SMMSTORE)) diff --git a/src/soc/intel/common/block/smm/smihandler.c b/src/soc/intel/common/block/smm/smihandler.c index 59489a4..fc26dc4 100644 --- a/src/soc/intel/common/block/smm/smihandler.c +++ b/src/soc/intel/common/block/smm/smihandler.c @@ -242,28 +242,6 @@ } }
-static void southbridge_smi_gsmi( - const struct smm_save_state_ops *save_state_ops) -{ - u8 sub_command, ret; - void *io_smi = NULL; - uint32_t reg_ebx; - - io_smi = find_save_state(save_state_ops, APM_CNT_ELOG_GSMI); - if (!io_smi) - return; - /* Command and return value in EAX */ - sub_command = (save_state_ops->get_reg(io_smi, RAX) >> 8) - & 0xff; - - /* Parameter buffer in EBX */ - reg_ebx = save_state_ops->get_reg(io_smi, RBX); - - /* drivers/elog/gsmi.c */ - ret = gsmi_exec(sub_command, ®_ebx); - save_state_ops->set_reg(io_smi, RAX, ret); -} - static void set_insmm_sts(const bool enable_writes) { msr_t msr = { @@ -384,7 +362,7 @@ break; case APM_CNT_ELOG_GSMI: if (CONFIG(ELOG_GSMI)) - southbridge_smi_gsmi(save_state_ops); + apmc_smi_gsmi(); break; case APM_CNT_SMMSTORE: if (CONFIG(SMMSTORE)) diff --git a/src/southbridge/intel/common/smihandler.c b/src/southbridge/intel/common/smihandler.c index 798f2f1..42351b0 100644 --- a/src/southbridge/intel/common/smihandler.c +++ b/src/southbridge/intel/common/smihandler.c @@ -228,27 +228,6 @@ return NULL; }
-static void southbridge_smi_gsmi(void) -{ - u32 *ret, *param; - u8 sub_command; - em64t101_smm_state_save_area_t *io_smi = - smi_apmc_find_state_save(APM_CNT_ELOG_GSMI); - - if (!io_smi) - return; - - /* Command and return value in EAX */ - ret = (u32*)&io_smi->rax; - sub_command = (u8)(*ret >> 8); - - /* Parameter buffer in EBX */ - param = (u32*)&io_smi->rbx; - - /* drivers/elog/gsmi.c */ - *ret = gsmi_exec(sub_command, param); -} - static void southbridge_smi_store(void) { u8 sub_command, ret; @@ -294,7 +273,7 @@ break; case APM_CNT_ELOG_GSMI: if (CONFIG(ELOG_GSMI)) - southbridge_smi_gsmi(); + apmc_smi_gsmi(); break; case APM_CNT_SMMSTORE: if (CONFIG(SMMSTORE)) diff --git a/src/southbridge/intel/lynxpoint/smihandler.c b/src/southbridge/intel/lynxpoint/smihandler.c index 8caafb7..8f2b5a3 100644 --- a/src/southbridge/intel/lynxpoint/smihandler.c +++ b/src/southbridge/intel/lynxpoint/smihandler.c @@ -200,27 +200,6 @@ return NULL; }
-static void southbridge_smi_gsmi(void) -{ - u32 *ret, *param; - u8 sub_command; - em64t101_smm_state_save_area_t *io_smi = - smi_apmc_find_state_save(APM_CNT_ELOG_GSMI); - - if (!io_smi) - return; - - /* Command and return value in EAX */ - ret = (u32 *)&io_smi->rax; - sub_command = (u8)(*ret >> 8); - - /* Parameter buffer in EBX */ - param = (u32 *)&io_smi->rbx; - - /* drivers/elog/gsmi.c */ - *ret = gsmi_exec(sub_command, param); -} - static void southbridge_smi_store(void) { u8 sub_command, ret; @@ -270,7 +249,7 @@ break; case APM_CNT_ELOG_GSMI: if (CONFIG(ELOG_GSMI)) - southbridge_smi_gsmi(); + apmc_smi_gsmi(); break; case APM_CNT_SMMSTORE: if (CONFIG(SMMSTORE))