[PATCH 05/12] efi_loader: move runtime GetVariable() helpers to efi_variable.c
Harsimran Singh Tungal
harsimransingh.tungal at arm.com
Wed May 6 12:30:10 CEST 2026
On 2026-04-28 15:03 +0300, Ilias Apalodimas wrote:
> Hi Harsiman,
>
> On Fri, 24 Apr 2026 at 20:32, Harsimran Singh Tungal
> <harsimransingh.tungal at arm.com> wrote:
> >
> > Consolidate runtime GetVariable helpers to avoid duplicates
> >
> > The functions efi_get_variable_runtime() and
> > efi_get_next_variable_name_runtime() were implemented in
> > efi_variable_tee.c as part of the FF-A runtime variable handling work.
> > However, default implementations for these same runtime helpers also
> > exist in efi_var_common.c.
>
> efi_variable.c is there to deal with variables stored in the
> non-secure world and efi_variable_tee.c for the variables stored on
> the non secure world.
> You can't compile both. By moving efi_get_next_variable_name_runtime
> out of common you will break efi_variable_tee.c for example.
>
> The reason these are in common is that U-Boot exposes the memory
> backend to the kernel for get/setvariable. Then the kernel at runtime
> decides to ignore the u-boot runtime functions and rewires them to
> internal op-tee functions. If you want a variable variant for FF-A
> that belongs into efi_variable_tee.c
>
> Thanks
> /Ilias
>
>
Thanks, that is the intent here as well.
This patch is not trying to move the FF-A-specific runtime path out of
efi_variable_tee.c. The TEE/FF-A runtime variants stay in
efi_variable_tee.c.
What this patch does is relocate the generic runtime read helpers out of
efi_var_common.c, which is always built, into efi_variable.c, which is
only built for the non-TEE backend. That way the non-TEE backend keeps
the generic memory-backed runtime implementations, while the TEE/FF-A
backend can provide its own runtime read helpers in efi_variable_tee.c
without a symbol clash.
I'll reword the commit message in v2 to make that clearer.
Regards
Harsimran Singh Tungal
> > This results in duplicate symbol definitions.
> > To resolve the conflict and centralize the runtime API, this patch moves
> > the default implementations of the two runtime GetVariable() helpers
> > from efi_var_common.c to efi_variable.c. This ensures that:
> >
> > - only a single definition of each runtime helper exists,
> > - backend-specific implementations can override these cleanly,
> > - the EFI runtime variable service table continues to reference the
> > correct functions.
> >
> > No functional changes are introduced; this is a structural cleanup to
> > avoid build-time conflicts and consolidate EFI runtime variable support
> > in the appropriate file.
> >
> > Signed-off-by: Harsimran Singh Tungal <harsimransingh.tungal at arm.com>
> > ---
> > lib/efi_loader/efi_var_common.c | 24 ------------------------
> > lib/efi_loader/efi_variable.c | 24 ++++++++++++++++++++++++
> > 2 files changed, 24 insertions(+), 24 deletions(-)
> >
> > diff --git a/lib/efi_loader/efi_var_common.c b/lib/efi_loader/efi_var_common.c
> > index d63c2d1b1cd..7cbf098c64a 100644
> > --- a/lib/efi_loader/efi_var_common.c
> > +++ b/lib/efi_loader/efi_var_common.c
> > @@ -173,30 +173,6 @@ efi_status_t EFIAPI efi_query_variable_info(
> > return EFI_EXIT(ret);
> > }
> >
> > -efi_status_t __efi_runtime EFIAPI
> > -efi_get_variable_runtime(u16 *variable_name, const efi_guid_t *guid,
> > - u32 *attributes, efi_uintn_t *data_size, void *data)
> > -{
> > - efi_status_t ret;
> > -
> > - ret = efi_get_variable_mem(variable_name, guid, attributes, data_size,
> > - data, NULL, EFI_VARIABLE_RUNTIME_ACCESS);
> > -
> > - /* Remove EFI_VARIABLE_READ_ONLY flag */
> > - if (attributes)
> > - *attributes &= EFI_VARIABLE_MASK;
> > -
> > - return ret;
> > -}
> > -
> > -efi_status_t __efi_runtime EFIAPI
> > -efi_get_next_variable_name_runtime(efi_uintn_t *variable_name_size,
> > - u16 *variable_name, efi_guid_t *guid)
> > -{
> > - return efi_get_next_variable_name_mem(variable_name_size, variable_name,
> > - guid, EFI_VARIABLE_RUNTIME_ACCESS);
> > -}
> > -
> > /**
> > * efi_set_secure_state - modify secure boot state variables
> > * @secure_boot: value of SecureBoot
> > diff --git a/lib/efi_loader/efi_variable.c b/lib/efi_loader/efi_variable.c
> > index 9923936c1b5..f2e0e1ad4e2 100644
> > --- a/lib/efi_loader/efi_variable.c
> > +++ b/lib/efi_loader/efi_variable.c
> > @@ -579,6 +579,30 @@ efi_set_variable_runtime(u16 *variable_name, const efi_guid_t *vendor,
> > return EFI_SUCCESS;
> > }
> >
> > +efi_status_t __efi_runtime EFIAPI
> > +efi_get_variable_runtime(u16 *variable_name, const efi_guid_t *guid,
> > + u32 *attributes, efi_uintn_t *data_size, void *data)
> > +{
> > + efi_status_t ret;
> > +
> > + ret = efi_get_variable_mem(variable_name, guid, attributes, data_size,
> > + data, NULL, EFI_VARIABLE_RUNTIME_ACCESS);
> > +
> > + /* Remove EFI_VARIABLE_READ_ONLY flag */
> > + if (attributes)
> > + *attributes &= EFI_VARIABLE_MASK;
> > +
> > + return ret;
> > +}
> > +
> > +efi_status_t __efi_runtime EFIAPI
> > +efi_get_next_variable_name_runtime(efi_uintn_t *variable_name_size,
> > + u16 *variable_name, efi_guid_t *guid)
> > +{
> > + return efi_get_next_variable_name_mem(variable_name_size, variable_name,
> > + guid, EFI_VARIABLE_RUNTIME_ACCESS);
> > +}
> > +
> > /**
> > * efi_variables_boot_exit_notify() - notify ExitBootServices() is called
> > */
> > --
> > 2.34.1
> >
>
More information about the U-Boot
mailing list