U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Ilias Apalodimas" <ilias.apalodimas@linaro.org>
To: "Harsimran Singh Tungal" <harsimransingh.tungal@arm.com>,
	<u-boot@lists.u-boot-project.org>
Cc: "Abdellatif El Khlifi" <abdellatif.elkhlifi@arm.com>,
	"Tom Rini" <trini@konsulko.com>,
	"Heinrich Schuchardt" <xypron.glpk@gmx.de>,
	"Simon Glass" <sjg@chromium.org>,
	"Devaraj Ranganna" <Devaraj.Ranganna@arm.com>
Subject: Re: [PATCH v5 08/22] efi_loader: add MM SP status mapping for FF-A variables
Date: Fri, 18 Sep 2026 20:19:05 +0300	[thread overview]
Message-ID: <DLIM4554THB3.26ORA4HIE4U3S@linaro.org> (raw)
In-Reply-To: <20260914110106.1974894-9-harsimransingh.tungal@arm.com>

On Mon Sep 14, 2026 at 2:00 PM EEST, Harsimran Singh Tungal 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 <sjg@chromium.org>
> Reviewed-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
> Signed-off-by: Harsimran Singh Tungal <harsimransingh.tungal@arm.com>
>

Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>

> ---
> Changelog:
> ===============
>
> v5:
>
> Ilias:
>
> - Include MM_SUCCESS in the MM SP response map
>
> v4:
>
> Ilias:
>
> - Replace MM status macros with an enum
>
> v3:
>
> Simon:
>
> - Add a comment explaining the sparse MM SP error map indexing
>
> v2:
>
> Ilias, Simon:
>
> - Reuse common MM SP error mapping
> ---
>  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..bc15795e94f 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. <sughosh.ganu@linaro.org>
>   *  Copyright (C) 2019 Linaro Ltd. <ilias.apalodimas@linaro.org>
> - *  Copyright 2022-2023 Arm Limited and/or its affiliates <open-source-office@arm.com>
> + *  Copyright 2022-2026 Arm Limited and/or its affiliates <open-source-office@arm.com>
>   *
>   *  Authors:
>   *    Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
> @@ -21,18 +21,34 @@
>  #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_* failure codes are negative. Use -MM_* as sparse positive indices so
> + * ffa_map_sp_event() can look up mm_sp_resp_map[-sp_event_ret]. The
> + * unassigned gap between MM_DENIED and MM_NO_MEMORY maps to -EACCES.
> + */
> +static const int __efi_runtime_rodata mm_sp_resp_map[] = {
> +	[MM_SUCCESS]		 = 0,
> +	[-MM_NOT_SUPPORTED]	 = -EINVAL,
> +	[-MM_INVALID_PARAMETER]	 = -EPERM,
> +	[-MM_DENIED]		 = -EACCES,
> +	[-MM_NO_MEMORY - 1]	 = -EACCES,
> +	[-MM_NO_MEMORY]		 = -EBUSY,
> +};
>
>  static const char *mm_sp_svc_uuid = MM_SP_UUID;
>  static u16 mm_sp_id;
> @@ -169,6 +185,26 @@ 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 (idx >= 0 && idx < (int)ARRAY_SIZE(mm_sp_resp_map))
> +		return mm_sp_resp_map[idx];
> +
> +	return -EACCES;
> +}
> +
>  /**
>   * ffa_notify_mm_sp() - Announce there is data in the shared buffer
>   *


  reply	other threads:[~2026-09-18 17:19 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-14 11:00 [PATCH v5 00/22] arm64: FF-A runtime transport for EFI variables Harsimran Singh Tungal
2026-09-14 11:00 ` [PATCH v5 01/22] efi_loader: add runtime memset helper Harsimran Singh Tungal
2026-09-14 11:00 ` [PATCH v5 02/22] arm-ffa: store boot-discovered runtime data separately Harsimran Singh Tungal
2026-09-14 11:00 ` [PATCH v5 03/22] arm-ffa: add runtime-safe FF-A SMC wrapper Harsimran Singh Tungal
2026-09-14 11:00 ` [PATCH v5 04/22] arm-ffa: add runtime direct-message support Harsimran Singh Tungal
2026-09-14 11:00 ` [PATCH v5 05/22] arm-ffa: reuse direct-message helper at boot time Harsimran Singh Tungal
2026-09-14 11:00 ` [PATCH v5 06/22] arm-ffa: enable runtime context at ExitBootServices Harsimran Singh Tungal
2026-09-14 11:00 ` [PATCH v5 07/22] arm: cache: keep range maintenance available at EFI runtime Harsimran Singh Tungal
2026-09-14 11:00 ` [PATCH v5 08/22] efi_loader: add MM SP status mapping for FF-A variables Harsimran Singh Tungal
2026-09-18 17:19   ` Ilias Apalodimas [this message]
2026-09-14 11:00 ` [PATCH v5 09/22] efi_loader: make MM transport selection runtime-safe Harsimran Singh Tungal
2026-09-14 11:00 ` [PATCH v5 10/22] efi_loader: make FF-A MM SP notification runtime-safe Harsimran Singh Tungal
2026-09-14 11:00 ` [PATCH v5 11/22] efi_loader: make FF-A MM communication runtime-safe Harsimran Singh Tungal
2026-09-14 11:00 ` [PATCH v5 12/22] efi_loader: reserve FF-A shared buffer for runtime variables Harsimran Singh Tungal
2026-09-18 18:30   ` Ilias Apalodimas
2026-10-05 11:12     ` Harsimran Singh Tungal
2026-10-05 11:51       ` Ilias Apalodimas
2026-09-14 11:00 ` [PATCH v5 13/22] efi_loader: enable TEE runtime SetVariable() over FF-A Harsimran Singh Tungal
2026-09-18 18:20   ` Ilias Apalodimas
2026-10-05 13:06     ` Harsimran Singh Tungal
2026-10-05 13:15       ` Ilias Apalodimas
2026-10-08 17:32         ` Harsimran Singh Tungal
2026-10-09  8:19           ` Ilias Apalodimas
2026-10-09 11:08             ` Harsimran Singh Tungal
2026-10-09 11:15               ` Ilias Apalodimas
2026-10-09 13:25                 ` Harsimran Singh Tungal
2026-09-14 11:00 ` [PATCH v5 14/22] efi_loader: enable TEE runtime GetVariable() " Harsimran Singh Tungal
2026-09-14 11:00 ` [PATCH v5 15/22] efi_loader: enable TEE runtime GetNextVariableName() " Harsimran Singh Tungal
2026-09-14 11:01 ` [PATCH v5 16/22] efi_loader: enable TEE runtime QueryVariableInfo() " Harsimran Singh Tungal
2026-09-14 11:01 ` [PATCH v5 17/22] charset: mark u16_strsize() as __efi_runtime Harsimran Singh Tungal
2026-09-14 11:01 ` [PATCH v5 18/22] corstone1000: enable bootefi selftest Harsimran Singh Tungal
2026-09-14 11:01 ` [PATCH v5 19/22] efi: selftest: add runtime variable tests with non-volatile storage Harsimran Singh Tungal
2026-09-14 11:01 ` [PATCH v5 20/22] test: dm: add sandbox FF-A runtime transport tests Harsimran Singh Tungal
2026-09-14 11:01 ` [PATCH v5 21/22] doc: arm64: document FF-A runtime path for EFI variables Harsimran Singh Tungal
2026-09-14 11:01 ` [PATCH v5 22/22] doc: bootefi: note two-phase runtime variables selftest Harsimran Singh Tungal

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=DLIM4554THB3.26ORA4HIE4U3S@linaro.org \
    --to=ilias.apalodimas@linaro.org \
    --cc=Devaraj.Ranganna@arm.com \
    --cc=abdellatif.elkhlifi@arm.com \
    --cc=harsimransingh.tungal@arm.com \
    --cc=sjg@chromium.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.u-boot-project.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox