From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
To: Ilias Apalodimas <ilias.apalodimas@linaro.org>,
harsimransingh.tungal@arm.com
Cc: u-boot@lists.denx.de, trini@konsulko.com, xypron.glpk@gmx.de,
hugues.kambampiana@arm.com, sjg@chromium.org
Subject: Re: [PATCH 03/12] efi_loader: add FF-A runtime support in EFI variable TEE driver
Date: Fri, 8 May 2026 11:23:52 +0100 [thread overview]
Message-ID: <af25uGoE7BBQpGhj@e130802.arm.com> (raw)
In-Reply-To: <CAC_iWj+TMCCMkRmAV3x2gh0LoxBt3pvkJgnojq48fCkJBFro+w@mail.gmail.com>
Hi Harsimran,
> On Fri, 24 Apr 2026 at 20:32, Harsimran Singh Tungal
> <harsimransingh.tungal@arm.com> wrote:
> >
> > Enable MM variable services over FF-A after ExitBootServices
> >
> > This patch extends lib/efi_loader/efi_variable_tee.c to support FF-A
> > communication with the secure world during EFI runtime. It enables EFI
> > runtime variable access and MM communication using FF-A transport when
> > ExitBootServices() has already been called.
> >
> > Key changes:
> > ------------
> > - Introduce runtime-safe implementations for MM communication,
> > notification, and variable access using FF-A driver.
> > - Introduce communication-buffer helper (get_comm_buf()) that switches
> > between dynamic allocation (boot phase) and the fixed FF-A shared
> > buffer (runtime phase).
> > - Mark persistent data and code with __efi_runtime and
> > __efi_runtime_data attributes.
> > - Use direct physical address mapping for shared buffers since
> > U-Boot operates with 1:1 physical-to-virtual mapping.
> > - Only per-buffer cache maintenance is performed at runtime,
> > as whole D-cache invalidation would violate the OS coherency model
> > after ExitBootServices().
> > - Add runtime-phase tracking (efi_runtime_enabled).
>
> Why is this needed? For the memory allocations?
>
> [...]
>
> > *
> > * Authors:
> > * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
> > @@ -14,6 +14,7 @@
> >
> > #if CONFIG_IS_ENABLED(ARM_FFA_TRANSPORT)
> > #include <arm_ffa.h>
> > +#include <arm_ffa_runtime.h>
> > #endif
> > #include <cpu_func.h>
> > #include <dm.h>
> > @@ -34,20 +35,47 @@
> > #define MM_DENIED (-3)
> > #define MM_NO_MEMORY (-5)
> >
> > +static const int __efi_runtime_rodata mm_sp_errmap[] = {
> > + [-MM_NOT_SUPPORTED] = -EINVAL,
> > + [-MM_INVALID_PARAMETER] = -EPERM,
> > + [-MM_DENIED] = -EACCES,
> > + [-MM_NO_MEMORY] = -EBUSY,
> > +};
> > +
>
> These are already defined above and used in ffa_notify_mm_sp(). If you
> plan to convert them, do it for the entire file.
>
> [...]
>
> > +/**
> > + * efi_is_runtime_enabled() - Indicate whether the system is in the UEFI runtime phase
> > + *
> > + * This helper returns whether the firmware has transitioned into the
> > + * UEFI runtime phase, meaning that ExitBootServices() has been invoked.
> > + *
> > + * Return:
> > + * true - The system is operating in UEFI runtime mode.
> > + * false - The system is still in the boot services phase.
> > + */
> > +static bool __efi_runtime efi_is_runtime_enabled(void)
> > +{
> > + return efi_runtime_enabled;
> > +}
>
> Enabled is a bit confusing. efi_at_runtime() should be enough. The
> efi_tcg.c code calls this 'ebs_called'
>
> > +
> > /**
> > * get_connection() - Retrieve OP-TEE session for a specific UUID.
> > *
> > @@ -169,6 +197,28 @@ static efi_status_t optee_mm_communicate(void *comm_buf, ulong dsize)
> > }
> >
> > #if CONFIG_IS_ENABLED(ARM_FFA_TRANSPORT)
> > +/**
> > + * ffa_map_sp_event_runtime() - Map MM SP response to errno (runtime-safe)
> > + * @sp_event_ret: MM SP return code from ffa_notify_mm_sp_runtime()
> > + *
> > + * Convert the MM SP return code into a standard U-Boot errno. This helper
> > + * is marked __efi_runtime to ensure it is safe to call after
> > + * ExitBootServices().
> > + *
> > + * Return: 0 on success, negative errno on failure
> > + */
> > +static __efi_runtime int ffa_map_sp_event_runtime(int sp_event_ret)
> > +{
> > + int idx = -sp_event_ret;
> > +
> > + if (sp_event_ret == MM_SUCCESS)
> > + return 0;
> > + 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
> > *
> > @@ -225,6 +275,35 @@ static int ffa_notify_mm_sp(void)
> > return ret;
> > }
> >
> > +/**
> > + * ffa_notify_mm_sp_runtime() - Runtime implementation of
> > + * ffa_notify_mm_sp()
> > + *
> > + * Notify the MM partition in the trusted world that
> > + * data is available in the shared buffer.
> > + * This is a blocking call during which trusted world has exclusive access
> > + * to the MM shared buffer.
> > + *
> > + * Return:
> > + *
> > + * 0 on success
> > + */
> > +static int __efi_runtime ffa_notify_mm_sp_runtime(void)
> > +{
> > + struct ffa_send_direct_data msg = {0};
> > + int ret;
> > + int sp_event_ret;
> > +
> > + msg.data0 = CONFIG_FFA_SHARED_MM_BUF_OFFSET;
> > +
> > + ret = ffa_sync_send_receive_runtime(mm_sp_id, &msg, 1);
> > + if (ret)
> > + return ret;
> > +
> > + ret = ffa_map_sp_event_runtime(sp_event_ret);
> > + return ret;
> > +}
> > +
> > /**
> > * ffa_discover_mm_sp_id() - Query the MM partition ID
> > *
> > @@ -360,6 +439,116 @@ static efi_status_t ffa_mm_communicate(void *comm_buf, ulong comm_buf_size)
> > return efi_ret;
> > }
> >
> > +/**
> > + * ffa_mm_communicate_runtime() - Runtime implementation of ffa_mm_communicate()
> > + * @comm_buf: locally allocated communication buffer used for rx/tx
> > + * @comm_buf_size: communication buffer size
> > + *
> > + * Issue a door bell event to notify the MM partition (SP) running in OP-TEE
> > + * that there is data to read from the shared buffer.
> > + * Communication with the MM SP is performed using FF-A transport.
> > + * On the event, MM SP can read the data from the buffer and
> > + * update the MM shared buffer with response data.
> > + * The response data is copied back to the communication buffer.
> > + *
> > + * Return:
> > + *
> > + * EFI status code
> > + */
> > +static efi_status_t __efi_runtime ffa_mm_communicate_runtime(void *comm_buf,
> > + ulong comm_buf_size)
> > +{
>
> There's a lot of code duplication between the boottime and runtime
> variants, but I don;t see why we need it. Can't we have a single
> function that works both boottime and runtime?
Ilias suggestion makes sense to me. Please address that.
Regards,
Abdellatif
next prev parent reply other threads:[~2026-05-08 10:24 UTC|newest]
Thread overview: 84+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-24 17:31 [PATCH 00/12] arm64: FF-A runtime transport for EFI variables Harsimran Singh Tungal
2026-04-24 17:31 ` [PATCH 01/12] efi_loader: add runtime memset helper Harsimran Singh Tungal
2026-04-27 7:54 ` Ilias Apalodimas
2026-04-28 18:08 ` Simon Glass
2026-05-04 20:03 ` Harsimran Singh Tungal
2026-04-24 17:31 ` [PATCH 02/12] arm-ffa: add FF-A bus runtime support Harsimran Singh Tungal
2026-04-28 18:10 ` Simon Glass
2026-05-04 20:25 ` Harsimran Singh Tungal
2026-05-08 10:18 ` Abdellatif El Khlifi
2026-04-24 17:31 ` [PATCH 03/12] efi_loader: add FF-A runtime support in EFI variable TEE driver Harsimran Singh Tungal
2026-04-27 16:21 ` Ilias Apalodimas
2026-05-04 20:40 ` Harsimran Singh Tungal
2026-05-08 10:23 ` Abdellatif El Khlifi [this message]
2026-04-28 18:12 ` Simon Glass
2026-05-05 8:55 ` Harsimran Singh Tungal
2026-04-24 17:31 ` [PATCH 04/12] efi_loader: enable EFI runtime SetVariable()/GetVariable() using FF-A transport Harsimran Singh Tungal
2026-04-28 18:16 ` Simon Glass
2026-05-05 14:30 ` Harsimran Singh Tungal
2026-05-07 15:31 ` Simon Glass
2026-04-24 17:31 ` [PATCH 05/12] efi_loader: move runtime GetVariable() helpers to efi_variable.c Harsimran Singh Tungal
2026-04-28 12:03 ` Ilias Apalodimas
2026-05-06 10:30 ` Harsimran Singh Tungal
2026-04-28 18:25 ` Simon Glass
2026-04-24 17:31 ` [PATCH 06/12] corstone1000: enable bootefi selftest Harsimran Singh Tungal
2026-04-27 7:56 ` Ilias Apalodimas
2026-04-28 18:01 ` Simon Glass
2026-05-06 12:20 ` Harsimran Singh Tungal
2026-05-07 15:32 ` Simon Glass
2026-04-24 17:31 ` [PATCH 07/12] efi: selftest: add runtime variable tests with non-volatile storage Harsimran Singh Tungal
2026-04-28 18:04 ` Simon Glass
2026-05-06 15:14 ` Harsimran Singh Tungal
2026-05-07 15:32 ` Simon Glass
2026-04-24 17:31 ` [PATCH 08/12] test: dm: add sandbox FF-A runtime transport tests Harsimran Singh Tungal
2026-04-28 18:05 ` Simon Glass
2026-05-14 14:58 ` Harsimran Singh Tungal
2026-04-24 17:31 ` [PATCH 09/12] sandbox: ffa: share synthetic partition metadata via macros Harsimran Singh Tungal
2026-04-28 18:07 ` Simon Glass
2026-05-14 15:00 ` Harsimran Singh Tungal
2026-05-15 18:28 ` Simon Glass
2026-04-24 17:31 ` [PATCH 10/12] doc: arm64: document FF-A runtime path for EFI variables Harsimran Singh Tungal
2026-04-28 18:08 ` Simon Glass
2026-05-14 15:05 ` Harsimran Singh Tungal
2026-05-08 10:40 ` Abdellatif El Khlifi
2026-04-24 17:31 ` [PATCH 11/12] doc: bootefi: note two-phase runtime variables selftest Harsimran Singh Tungal
2026-04-28 18:14 ` Simon Glass
2026-05-14 15:07 ` Harsimran Singh Tungal
2026-04-24 17:31 ` [PATCH 12/12] efi_loader: align FF-A cache maintenance with runtime path Harsimran Singh Tungal
2026-04-28 18:14 ` Simon Glass
2026-05-08 10:34 ` Abdellatif El Khlifi
2026-05-14 15:11 ` Harsimran Singh Tungal
2026-04-24 22:18 ` [PATCH 00/12] arm64: FF-A runtime transport for EFI variables Heinrich Schuchardt
2026-05-05 14:37 ` Harsimran Singh Tungal
2026-04-28 18:16 ` [00/12] " Simon Glass
2026-05-14 15:37 ` Harsimran Singh Tungal
2026-05-14 12:49 ` [PATCH v2 00/11] " Harsimran Singh Tungal
2026-05-14 12:49 ` [PATCH v2 01/11] efi_loader: add runtime memset helper Harsimran Singh Tungal
2026-05-15 18:14 ` Simon Glass
2026-05-14 12:49 ` [PATCH v2 02/11] arm-ffa: add FF-A bus runtime support Harsimran Singh Tungal
2026-05-15 18:25 ` Simon Glass
2026-05-26 9:16 ` Harsimran Singh Tungal
2026-05-14 12:49 ` [PATCH v2 03/11] efi_loader: add FF-A runtime support in EFI variable TEE driver Harsimran Singh Tungal
2026-05-15 18:35 ` Simon Glass
2026-06-05 10:46 ` Ilias Apalodimas
2026-05-14 12:49 ` [PATCH v2 04/11] efi_loader: enable EFI runtime SetVariable()/GetVariable() using FF-A transport Harsimran Singh Tungal
2026-05-15 18:26 ` Simon Glass
2026-05-26 14:25 ` Harsimran Singh Tungal
2026-05-14 12:49 ` [PATCH v2 05/11] charset: mark u16_strsize() as __efi_runtime Harsimran Singh Tungal
2026-05-15 18:21 ` Simon Glass
2026-05-14 12:49 ` [PATCH v2 06/11] efi_loader: move runtime variable read helpers to efi_variable.c Harsimran Singh Tungal
2026-05-15 18:21 ` Simon Glass
2026-06-05 11:04 ` Ilias Apalodimas
2026-05-14 12:49 ` [PATCH v2 07/11] corstone1000: enable bootefi selftest Harsimran Singh Tungal
2026-05-15 18:22 ` Simon Glass
2026-05-14 12:49 ` [PATCH v2 08/11] efi: selftest: add runtime variable tests with non-volatile storage Harsimran Singh Tungal
2026-05-15 18:35 ` Simon Glass
2026-05-14 12:49 ` [PATCH v2 09/11] test: dm: add sandbox FF-A runtime transport tests Harsimran Singh Tungal
2026-05-15 18:27 ` Simon Glass
2026-05-26 14:50 ` Harsimran Singh Tungal
2026-05-27 4:45 ` Simon Glass
2026-05-27 8:39 ` Harsimran Singh Tungal
2026-05-14 12:49 ` [PATCH v2 10/11] doc: arm64: document FF-A runtime path for EFI variables Harsimran Singh Tungal
2026-05-15 18:30 ` Simon Glass
2026-05-14 12:49 ` [PATCH v2 11/11] doc: bootefi: note two-phase runtime variables selftest Harsimran Singh Tungal
2026-05-15 18:30 ` Simon Glass
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=af25uGoE7BBQpGhj@e130802.arm.com \
--to=abdellatif.elkhlifi@arm.com \
--cc=harsimransingh.tungal@arm.com \
--cc=hugues.kambampiana@arm.com \
--cc=ilias.apalodimas@linaro.org \
--cc=sjg@chromium.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
--cc=xypron.glpk@gmx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.