All of lore.kernel.org
 help / color / mirror / Atom feed
From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
To: Simon Glass <sjg@chromium.org>, harsimransingh.tungal@arm.com
Cc: hugues.kambampiana@arm.com, ilias.apalodimas@linaro.org,
	trini@konsulko.com, u-boot@lists.denx.de, xypron.glpk@gmx.de
Subject: Re: [PATCH 12/12] efi_loader: align FF-A cache maintenance with runtime path
Date: Fri, 8 May 2026 11:34:25 +0100	[thread overview]
Message-ID: <af28MYL97NMcvsFz@e130802.arm.com> (raw)
In-Reply-To: <CAFLszTjVEhDxLN0btbo=Uczr7QMQpJF-T_7Sp78vvft-FYTPZQ@mail.gmail.com>

Hi Harsimran,

> On 2026-04-24T17:31:50, Harsimran Singh Tungal
> <harsimransingh.tungal@arm.com> wrote:
> > efi_loader: align FF-A cache maintenance with runtime path
> >
> > Match boot-time FF-A cache handling to runtime behavior
> >
> > The boot-time FF-A MM communication path used invalidate_dcache_all()
> > after copying the message into the shared buffer. This differs from the
> > runtime path, which performs range-based maintenance to avoid global cache
> > operations.
> >
> > Update ffa_mm_communicate() to use the same pattern as the runtime helper:
> > clean the shared buffer range before the SMC and invalidate the same range
> > after the response. This keeps boot-time and runtime behavior consistent
> > and avoids whole-cache invalidation.
> >
> > Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
> > Signed-off-by: Harsimran Singh Tungal <harsimransingh.tungal@arm.com>
> >
> > lib/efi_loader/efi_variable_tee.c | 33 ++++++++++++++++++++++++++-------
> >  1 file changed, 26 insertions(+), 7 deletions(-)
> 
> > diff --git a/lib/efi_loader/efi_variable_tee.c b/lib/efi_loader/efi_variable_tee.c
> > @@ -389,19 +389,38 @@ static efi_status_t ffa_mm_communicate(void *comm_buf, ulong comm_buf_size)
> >       memcpy(virt_shared_buf, comm_buf, tx_data_size);
> >
> >       /*
> > -      * The secure world might have cache disabled for
> > -      * the device region used for shared buffer (which is the case for Optee).
> > -      * In this case, the secure world reads the data from DRAM.
> > -      * Let's flush the cache so the DRAM is updated with the latest data.
> > +      * Shared buffer cache maintenance for FF-A / OP-TEE communication:
> > +      *
> > +      * NS -> S (request path):
> > +      *
> > +      * The non-secure side populates the shared buffer. If the buffer is cached
> > +      * in NS, the updated bytes may reside in dirty D-cache lines and not yet be
> > +      * visible in DDR. Since the secure world typically reads the shared buffer
> > +      * directly from DDR (e.g. with caches disabled / non-coherent mapping), we
> > +      * must clean the corresponding cache lines to the Point of Coherency (PoC)
> > +      * before entering secure world.
> > +      *
> > +      * S -> NS (response path):
> > +      *
> > +      * The secure world may update the same shared buffer in DDR. After returning
> > +      * to non-secure, any cached copies of that region in NS may be stale. We
> > +      * therefore invalidate the shared buffer range after the FF-A call to drop
> > +      * those lines and force subsequent reads to fetch the latest data from DDR.
> >        */
> 
> This 20-line comment is now duplicated verbatim with the one in
> ffa_mm_communicate_runtime() introduced earlier in the series. Please
> factor the clean-before / invalidate-after sequence into a small
> helper (e.g. ffa_mm_buf_pre_call() / ffa_mm_buf_post_call()) so the
> commentary lives in one place and the two paths cannot drift. The
> runtime helper would add the extra 'no whole-cache invalidation after
> ExitBootServices()' note at the call site.
> 
> > diff --git a/lib/efi_loader/efi_variable_tee.c b/lib/efi_loader/efi_variable_tee.c
> > @@ -389,19 +389,38 @@ static efi_status_t ffa_mm_communicate(void *comm_buf, ulong comm_buf_size)
> > -#ifdef CONFIG_ARM64
> > -     invalidate_dcache_all();
> > -#endif
> > +     if (IS_ENABLED(CONFIG_ARM64))
> > +             flush_dcache_range((unsigned long)virt_shared_buf,
> > +                                (unsigned long)virt_shared_buf +
> > +                                CONFIG_FFA_SHARED_MM_BUF_SIZE);
> 
> Just to check - flush_dcache_range() and invalidate_dcache_range() on
> arm64 require start and end to be cache-line aligned, otherwise the
> arch code warns and falls back to clean+invalidate of the partial
> lines. CONFIG_FFA_SHARED_MM_BUF_ADDR and _SIZE need to be at least
> CONFIG_SYS_CACHELINE_SIZE aligned - is that documented or enforced
> anywhere? You could use BUILD_BUG_ON() near the call, perhaps?

Let's make sure the CONFIG_FFA_SHARED_MM_BUF_ADDR and _SIZE
are CONFIG_SYS_CACHELINE_SIZE aligned and document that in the Kconfig file.
It is also a good idea to add the BUILD_BUG_ON() check.

Regards,
Abdellatif

  reply	other threads:[~2026-05-08 10:34 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
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 [this message]
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=af28MYL97NMcvsFz@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.