All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [PATCH 2/5] spl: Introduce spl_board_prepare_for_optee() hook
Date: Sun, 7 Feb 2021 07:37:25 -0700	[thread overview]
Message-ID: <CAPnjgZ1hN5=t7fAu=4ks2K5QaN9tfNQimtdu+9NrojVAFbCEpw@mail.gmail.com> (raw)
In-Reply-To: <20210204195556.2056956-2-mr.nuke.me@gmail.com>

Hi Alexandru,

On Thu, 4 Feb 2021 at 12:56, Alexandru Gagniuc <mr.nuke.me@gmail.com> wrote:
>
> OP-TEE requires some particular setup, which is not needed for linux
> or other payloads. Add a hook for platform-specific code to perform
> any OP-TEE related configuration and initialization.
>
> Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
> ---
>  common/spl/spl.c |  6 ++++++
>  include/spl.h    | 14 ++++++++++++++
>  2 files changed, 20 insertions(+)
>
> diff --git a/common/spl/spl.c b/common/spl/spl.c
> index cdd7b05f27..f3aaa67572 100644
> --- a/common/spl/spl.c
> +++ b/common/spl/spl.c
> @@ -160,6 +160,11 @@ __weak void spl_board_prepare_for_linux(void)
>         /* Nothing to do! */
>  }
>
> +__weak void spl_board_prepare_for_optee(void *fdt)
> +{
> +       /* Weak functions are stupid. Get rid of them! */
> +}
> +
>  __weak void spl_board_prepare_for_boot(void)
>  {
>         /* Nothing to do! */
> @@ -705,6 +710,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
>  #if CONFIG_IS_ENABLED(OPTEE)
>         case IH_OS_TEE:
>                 debug("Jumping to U-Boot via OP-TEE\n");
> +               spl_board_prepare_for_optee(spl_image.fdt_addr);
>                 spl_optee_entry(NULL, NULL, spl_image.fdt_addr,
>                                 (void *)spl_image.entry_point);
>                 break;
> diff --git a/include/spl.h b/include/spl.h
> index e172500b5f..f94e74e217 100644
> --- a/include/spl.h
> +++ b/include/spl.h
> @@ -387,6 +387,20 @@ int spl_parse_image_header(struct spl_image_info *spl_image,
>                            const struct image_header *header);
>
>  void spl_board_prepare_for_linux(void);
> +
> +/**
> + * spl_board_prepare_for_optee() - Prepare board for an OPTEE payload
> + *
> + * Prepares the board for booting an OP-TEE payload. Initialization is platform
> + * specific, and may include configuring the TrustZone memory, and other
> + * initialization steps required by OP-TEE.
> + * Note that @fdt is not used directly by OP-TEE. OP-TEE passes this @fdt to
> + * its normal world target. This target is not guaranteed to be u-boot, so @fdt
> + * changes that would normally be done by u-boot should be done in this step.
> + *
> + * @fdt: Devicetree that will be passed on, or NULL
> + */
> +void spl_board_prepare_for_optee(void *fdt);
>  void spl_board_prepare_for_boot(void);
>  int spl_board_ubi_load_image(u32 boot_device);
>  int spl_board_boot_device(u32 boot_device);
> --
> 2.26.2
>

Reviewed-by: Simon Glass <sjg@chromium.org>

One way to get rid of the weak function would be to introduce some
sort of event handler / runner or hook system. We could have an enum
of available events and allow handlers to register themselves. Then we
could do something like:

struct event ev;

ev.type = EVT_SPL_OS_PREPARE;
ev.data.spl_os_prepare = IG_OS_TEE;
ret = event_post(&ev);
(return code -ENOSYS if nothing handled the event)

Could use a ilnker_list to set up the handlers at build time. Perhaps
could allow runtime registration if useful.

Regards,
Simon

  reply	other threads:[~2021-02-07 14:37 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-04 19:55 [PATCH 1/5] spl: mmc: Support OP-TEE payloads in Falcon mode Alexandru Gagniuc
2021-02-04 19:55 ` [PATCH 2/5] spl: Introduce spl_board_prepare_for_optee() hook Alexandru Gagniuc
2021-02-07 14:37   ` Simon Glass [this message]
2021-02-04 19:55 ` [PATCH 3/5] arm: stm32mp: Implement support for TZC 400 controller Alexandru Gagniuc
2021-02-07 14:37   ` Simon Glass
2021-02-08 21:23     ` Alex G.
2021-02-04 19:55 ` [PATCH 4/5] stm32mp1: spl: Configure TrustZone controller for OP-TEE Alexandru Gagniuc
2021-02-04 19:55 ` [PATCH 5/5] ARM: dts: stm32mp: Add OP-TEE reserved memory to SPL dtb Alexandru Gagniuc
2021-02-04 19:56 ` [PATCH 1/5] spl: mmc: Support OP-TEE payloads in Falcon mode Alex G.
2021-02-07 14:37   ` Simon Glass
  -- strict thread matches above, loose matches on Subject: below --
2021-02-03 15:21 Alexandru Gagniuc
2021-02-03 15:21 ` [PATCH 2/5] spl: Introduce spl_board_prepare_for_optee() hook Alexandru Gagniuc
2021-02-03 16:30   ` Tom Rini

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='CAPnjgZ1hN5=t7fAu=4ks2K5QaN9tfNQimtdu+9NrojVAFbCEpw@mail.gmail.com' \
    --to=sjg@chromium.org \
    --cc=u-boot@lists.denx.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.