On Wed, 29 Jul 2026 at 11:51, Harsimran Singh Tungal <[email protected]> wrote: > > Define the MM SP status values as an enum and add a runtime-safe helper > for translating MM SP notification results to U-Boot errno values. > > The FF-A notification path uses the same mapping during boot and after > ExitBootServices(), so keep the mapping table in EFI runtime rodata. > > Reviewed-by: Simon Glass <[email protected]> > Reviewed-by: Abdellatif El Khlifi <[email protected]> > Signed-off-by: Harsimran Singh Tungal <[email protected]> > --- > lib/efi_loader/efi_variable_tee.c | 50 ++++++++++++++++++++++++++----- > 1 file changed, 43 insertions(+), 7 deletions(-) > > diff --git a/lib/efi_loader/efi_variable_tee.c > b/lib/efi_loader/efi_variable_tee.c > index 6a1fa39bb6f..8a75da414f7 100644 > --- a/lib/efi_loader/efi_variable_tee.c > +++ b/lib/efi_loader/efi_variable_tee.c > @@ -4,7 +4,7 @@ > * > * Copyright (C) 2019 Linaro Ltd. <[email protected]> > * Copyright (C) 2019 Linaro Ltd. <[email protected]> > - * Copyright 2022-2023 Arm Limited and/or its affiliates > <[email protected]> > + * Copyright 2022-2026 Arm Limited and/or its affiliates > <[email protected]> > * > * Authors: > * Abdellatif El Khlifi <[email protected]> > @@ -21,18 +21,32 @@ > #include <efi_api.h> > #include <efi_loader.h> > #include <efi_variable.h> > +#include <linux/kernel.h> > #include <malloc.h> > #include <mapmem.h> > #include <mm_communication.h> > #include <tee.h> > > #if CONFIG_IS_ENABLED(ARM_FFA_TRANSPORT) > -/* MM return codes */ > -#define MM_SUCCESS (0) > -#define MM_NOT_SUPPORTED (-1) > -#define MM_INVALID_PARAMETER (-2) > -#define MM_DENIED (-3) > -#define MM_NO_MEMORY (-5) > +enum mm_sp_status { > + MM_SUCCESS = 0, > + MM_NOT_SUPPORTED = -1, > + MM_INVALID_PARAMETER = -2, > + MM_DENIED = -3, > + MM_NO_MEMORY = -5, > +}; > + > +/* > + * MM_* return codes are negative. Use -MM_* as sparse positive indices so > + * ffa_map_sp_event() can look up mm_sp_errmap[-sp_event_ret]. Unassigned > + * slots remain 0 and are treated as unmapped MM return codes. > + */ > +static const int __efi_runtime_rodata mm_sp_errmap[] = { > + [-MM_NOT_SUPPORTED] = -EINVAL, > + [-MM_INVALID_PARAMETER] = -EPERM, > + [-MM_DENIED] = -EACCES, > + [-MM_NO_MEMORY] = -EBUSY, > +}; > > static const char *mm_sp_svc_uuid = MM_SP_UUID; > static u16 mm_sp_id; > @@ -169,6 +183,28 @@ static efi_status_t optee_mm_communicate(void *comm_buf, > ulong dsize) > } > > #if CONFIG_IS_ENABLED(ARM_FFA_TRANSPORT) > +/** > + * ffa_map_sp_event() - Map MM SP response to errno > + * @sp_event_ret: MM SP return code from MM SP notification > + * > + * Convert the MM SP return code into a standard U-Boot errno. This helper > + * is marked __efi_runtime so it can be shared by both the boot and runtime > + * FF-A notification paths. > + * > + * Return: 0 on success, negative errno on failure > + */ > +static int __efi_runtime ffa_map_sp_event(int sp_event_ret) > +{ > + int idx = -sp_event_ret; > + > + if (sp_event_ret == MM_SUCCESS) > + return 0;
Instead of having the special handling here, can we add MM_SUCCESS to mm_sp_errmap and rename it? E.g, mm_sp_resp_map or something. Cheers /Ilias > + if (idx > 0 && idx < (int)ARRAY_SIZE(mm_sp_errmap) && > + mm_sp_errmap[idx]) > + return mm_sp_errmap[idx]; > + return -EACCES; > +} > + > /** > * ffa_notify_mm_sp() - Announce there is data in the shared buffer > * > -- > 2.34.1 >
