All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rick Chen <rickchen36@gmail.com>
To: u-boot@lists.denx.de
Subject: [PATCH 4/4] spl: opensbi: wait for ack from secondary harts before entering OpenSBI
Date: Fri, 6 Dec 2019 16:37:47 +0800	[thread overview]
Message-ID: <CAN5B=eJQZxZ8ju0keYN4w5W9OxKk7Kxqor=HAs+VHRocb3Doiw@mail.gmail.com> (raw)
In-Reply-To: <752D002CFF5D0F4FA35C0100F1D73F3FA46ABD8C@ATCPCS16.andestech.com>

Hi Lukas,

> From: Lukas Auer [mailto:lukas.auer at aisec.fraunhofer.de]
> Sent: Wednesday, December 04, 2019 5:40 AM
> To: u-boot at lists.denx.de
> Cc: Rick Jian-Zhi Chen(陳建志); Anup Patel; Bin Meng; Lukas Auer; Anup Patel
> Subject: [PATCH 4/4] spl: opensbi: wait for ack from secondary harts before entering OpenSBI
>
> At the start, OpenSBI relocates itself to its link address. If the link address ranges of U-Boot SPL and OpenSBI overlap, the relocation can lead to code corruption if a hart is still running U-Boot SPL during relocation. To avoid this problem, the main hart is specified as the preferred boot hart to perform the relocation. This fixes the code corruption problems based on the assumption that since the main hart schedules the secondary harts to enter OpenSBI, it will be the last to enter OpenSBI. However it was reported that this assumption is not always correct.
>
> To make sure the assumption always holds true, wait for all secondary harts to acknowledge the call-function request before entering OpenSBI on the main hart.
>
> Reported-by: Rick Chen <rick@andestech.com>
> Signed-off-by: Lukas Auer <lukas.auer@aisec.fraunhofer.de>
> ---

Reviewed-by: Rick Chen <rick@andestech.com>
Tested-by: Rick Chen <rick@andestech.com>

>
>  common/spl/spl_opensbi.c | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/common/spl/spl_opensbi.c b/common/spl/spl_opensbi.c index 91a411a3db..5ea59d423f 100644
> --- a/common/spl/spl_opensbi.c
> +++ b/common/spl/spl_opensbi.c
> @@ -75,9 +75,19 @@ void spl_invoke_opensbi(struct spl_image_info *spl_image)
>         invalidate_icache_all();
>
>  #ifdef CONFIG_SMP
> +       /*
> +        * Start OpenSBI on all secondary harts and wait for acknowledgment.
> +        *
> +        * OpenSBI first relocates itself to its link address. This is done by
> +        * the main hart. To make sure no hart is still running U-Boot SPL
> +        * during relocation, we wait for all secondary harts to acknowledge
> +        * the call-function request before entering OpenSBI on the main hart.
> +        * Otherwise, code corruption can occur if the link address ranges of
> +        * U-Boot SPL and OpenSBI overlap.
> +        */
>         ret = smp_call_function((ulong)spl_image->entry_point,
>                                 (ulong)spl_image->fdt_addr,
> -                               (ulong)&opensbi_info, 0);
> +                               (ulong)&opensbi_info, 1);
>         if (ret)
>                 hang();
>  #endif
> --
> 2.21.0
>

  parent reply	other threads:[~2019-12-06  8:37 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-03 21:39 [PATCH 0/4] Fixes for RISC-V U-Boot SPL / OpenSBI boot flow Lukas Auer
2019-12-03 21:39 ` [PATCH 1/4] spl: opensbi: specify main hart as preferred boot hart Lukas Auer
     [not found]   ` <752D002CFF5D0F4FA35C0100F1D73F3FA46ABD5F@ATCPCS16.andestech.com>
2019-12-06  8:29     ` Rick Chen
2019-12-06 18:01       ` Anup Patel
2019-12-03 21:39 ` [PATCH 2/4] riscv: add functions for reading the IPI status Lukas Auer
     [not found]   ` <752D002CFF5D0F4FA35C0100F1D73F3FA46ABD66@ATCPCS16.andestech.com>
2019-12-06  8:33     ` Rick Chen
2019-12-03 21:39 ` [PATCH 3/4] riscv: add option to wait for ack from secondary harts in smp functions Lukas Auer
     [not found]   ` <752D002CFF5D0F4FA35C0100F1D73F3FA46ABD85@ATCPCS16.andestech.com>
2019-12-06  8:36     ` Rick Chen
2019-12-06 18:05       ` Anup Patel
2019-12-03 21:39 ` [PATCH 4/4] spl: opensbi: wait for ack from secondary harts before entering OpenSBI Lukas Auer
     [not found]   ` <752D002CFF5D0F4FA35C0100F1D73F3FA46ABD8C@ATCPCS16.andestech.com>
2019-12-06  8:37     ` Rick Chen [this message]
2019-12-06 18:06       ` Anup Patel
     [not found] ` <752D002CFF5D0F4FA35C0100F1D73F3FA46ABD4F@ATCPCS16.andestech.com>
2019-12-06  8:26   ` [PATCH 0/4] Fixes for RISC-V U-Boot SPL / OpenSBI boot flow Rick Chen
2019-12-08 22:31     ` Auer, Lukas

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='CAN5B=eJQZxZ8ju0keYN4w5W9OxKk7Kxqor=HAs+VHRocb3Doiw@mail.gmail.com' \
    --to=rickchen36@gmail.com \
    --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.