Jérémy Compostella has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/80574?usp=email )
Change subject: drivers/intel/fsp2_0/ppi: Fix FSP PPI callback calling convention ......................................................................
drivers/intel/fsp2_0/ppi: Fix FSP PPI callback calling convention
Multi Processor PEIM-to-PEIM Interface deals with pointer to function living in FSP space and which therefore need to be called with the appropriate calling convention.
By casting the callback pointer to a `void (*)(void *)' when calling `mp_run_on_all_aps' the C calling convention attribute is lost and the the code generated by the compiler does not match the FSP function calling convention.
This commit adds a function indirection to ensure FSP callbacks are invoked correctly.
TEST=verified on Lunar Lake RVP board (lnlrvp)
Change-Id: If0397f5cc8d0f4f1872bd37a001fe42e0c37ec95 Signed-off-by: Jeremy Compostella jeremy.compostella@intel.com --- M src/drivers/intel/fsp2_0/ppi/mp_service_ppi.c 1 file changed, 26 insertions(+), 4 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/74/80574/1
diff --git a/src/drivers/intel/fsp2_0/ppi/mp_service_ppi.c b/src/drivers/intel/fsp2_0/ppi/mp_service_ppi.c index a891ba0..d00a737 100644 --- a/src/drivers/intel/fsp2_0/ppi/mp_service_ppi.c +++ b/src/drivers/intel/fsp2_0/ppi/mp_service_ppi.c @@ -12,6 +12,18 @@
#define BSP_CPU_SLOT 0
+struct efi_ap_procedure_caller_params { + efi_ap_procedure procedure; + void *argument; +}; + +static void efi_ap_procedure_caller(void *arg) +{ + struct efi_ap_procedure_caller_params *params = + (struct efi_ap_procedure_caller_params *)arg; + params->procedure(params->argument); +} + efi_return_status_t mp_get_number_of_processors(efi_uintn_t *number_of_processors, efi_uintn_t *number_of_enabled_processors) { @@ -58,14 +70,19 @@ efi_return_status_t mp_startup_all_aps(efi_ap_procedure procedure, bool run_serial, efi_uintn_t timeout_usec, void *argument) { + struct efi_ap_procedure_caller_params params = { + .procedure = procedure, + .argument = argument + }; + if (!cpu_info()) return FSP_DEVICE_ERROR;
if (procedure == NULL) return FSP_INVALID_PARAMETER;
- if (mp_run_on_all_aps((void *)procedure, argument, timeout_usec, !run_serial) != - CB_SUCCESS) { + if (mp_run_on_all_aps((void *)efi_ap_procedure_caller, ¶ms, + timeout_usec, !run_serial) != CB_SUCCESS) { printk(BIOS_DEBUG, "%s: Exit with Failure\n", __func__); return FSP_NOT_STARTED; } @@ -76,6 +93,11 @@ efi_return_status_t mp_startup_all_cpus(efi_ap_procedure procedure, efi_uintn_t timeout_usec, void *argument) { + struct efi_ap_procedure_caller_params params = { + .procedure = procedure, + .argument = argument + }; + if (!cpu_info()) return FSP_DEVICE_ERROR;
@@ -99,8 +121,8 @@ * due to lack of acquiring a spin lock while accessing common data structure in * multiprocessor environment. */ - if (mp_run_on_all_aps((void *)procedure, argument, timeout_usec, false) != - CB_SUCCESS) { + if (mp_run_on_all_aps((void *)efi_ap_procedure_caller, + ¶ms, timeout_usec, false) != CB_SUCCESS) { printk(BIOS_DEBUG, "%s: Exit with Failure\n", __func__); return FSP_NOT_STARTED; }