Add FF-A runtime annotations and expose invoke_ffa_fn_runtime() for code that must remain available after ExitBootServices().
Provide implementations for the Arm FF-A driver and sandbox emulator so later runtime direct-message helpers can use the same SMC entry point in both environments. Reviewed-by: Simon Glass <[email protected]> Acked-by: Abdellatif El Khlifi <[email protected]> Signed-off-by: Harsimran Singh Tungal <[email protected]> --- drivers/firmware/arm-ffa/arm-ffa.c | 16 ++++++++- drivers/firmware/arm-ffa/ffa-emul-uclass.c | 12 +++++++ include/arm_ffa_runtime.h | 41 ++++++++++++++++++++++ 3 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 include/arm_ffa_runtime.h diff --git a/drivers/firmware/arm-ffa/arm-ffa.c b/drivers/firmware/arm-ffa/arm-ffa.c index 9e6b5dcc542..241ef018817 100644 --- a/drivers/firmware/arm-ffa/arm-ffa.c +++ b/drivers/firmware/arm-ffa/arm-ffa.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0+ /* - * Copyright 2022-2023 Arm Limited and/or its affiliates <[email protected]> + * Copyright 2022-2023, 2026 Arm Limited and/or its affiliates <[email protected]> * * Authors: * Abdellatif El Khlifi <[email protected]> @@ -8,6 +8,7 @@ #include <arm_ffa.h> #include <arm_ffa_priv.h> +#include <arm_ffa_runtime.h> #include <dm.h> #include <log.h> #include <dm/device-internal.h> @@ -25,6 +26,19 @@ void invoke_ffa_fn(ffa_value_t args, ffa_value_t *res) arm_smccc_1_2_smc(&args, res); } +/** + * invoke_ffa_fn_runtime() - Runtime-safe SMC wrapper + * @args: FF-A ABI arguments to be copied to Xn registers + * @res: FF-A ABI return values copied from Xn registers + * + * Calls the SMCCC SMC 1.2 helper from EFI runtime context. This wrapper + * is marked __ffa_runtime so it remains available after ExitBootServices(). + */ +void __ffa_runtime invoke_ffa_fn_runtime(ffa_value_t *args, ffa_value_t *res) +{ + arm_smccc_1_2_smc(args, res); +} + /** * arm_ffa_discover() - perform FF-A discovery * @dev: The Arm FF-A bus device (arm_ffa) diff --git a/drivers/firmware/arm-ffa/ffa-emul-uclass.c b/drivers/firmware/arm-ffa/ffa-emul-uclass.c index 6198d687354..d270f7b614e 100644 --- a/drivers/firmware/arm-ffa/ffa-emul-uclass.c +++ b/drivers/firmware/arm-ffa/ffa-emul-uclass.c @@ -671,6 +671,18 @@ void invoke_ffa_fn(ffa_value_t args, ffa_value_t *res) sandbox_arm_ffa_smccc_smc(&args, res); } +/** + * invoke_ffa_fn_runtime() - Runtime-safe SMC wrapper + * @args: FF-A ABI arguments to be copied to Xn registers + * @res: FF-A ABI return data to be copied from Xn registers + * + * Calls the emulated SMC call. + */ +void invoke_ffa_fn_runtime(ffa_value_t *args, ffa_value_t *res) +{ + sandbox_arm_ffa_smccc_smc(args, res); +} + /** * ffa_emul_find() - Find the FF-A emulator * @dev: the sandbox FF-A device (sandbox-arm-ffa) diff --git a/include/arm_ffa_runtime.h b/include/arm_ffa_runtime.h new file mode 100644 index 00000000000..66096db3d24 --- /dev/null +++ b/include/arm_ffa_runtime.h @@ -0,0 +1,41 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright 2026 Arm Limited and/or its affiliates <[email protected]> + * + * Authors: + * Harsimran Singh Tungal <[email protected]> + * Abdellatif El Khlifi <[email protected]> + */ + +#ifndef __ARM_FFA_RUNTIME_H +#define __ARM_FFA_RUNTIME_H + +#include <linux/types.h> +#include <arm_ffa.h> +#include <efi_loader.h> + +/** + * __ffa_runtime - controls whether functions are + * available after calling the EFI ExitBootServices service. + * Functions tagged with these keywords are resident (available at boot time and + * at runtime) + */ +#if IS_ENABLED(CONFIG_ARM_FFA_RT_MODE) +#define __ffa_runtime_data __efi_runtime_data +#define __ffa_runtime __efi_runtime +#else +#define __ffa_runtime_data +#define __ffa_runtime +#endif + +/** + * invoke_ffa_fn_runtime() - Runtime-safe SMC wrapper + * @args: FF-A ABI arguments to be copied to Xn registers + * @res: FF-A ABI return values copied from Xn registers + * + * Calls low level SMC implementation. This wrapper + * is marked __ffa_runtime so it remains available after ExitBootServices(). + */ +void __ffa_runtime invoke_ffa_fn_runtime(ffa_value_t *args, ffa_value_t *res); + +#endif -- 2.34.1
