public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Leo Liang <ycliang@andestech.com>
To: Bo Gan <ganboing@gmail.com>
Cc: <u-boot@lists.denx.de>, Rick Chen <rick@andestech.com>,
	Sean Anderson <seanga2@gmail.com>, Bin Meng <bmeng.cn@gmail.com>,
	Lukas Auer <lukas.auer@aisec.fraunhofer.de>
Subject: Re: [RESEND PATCH v2] riscv: setup per-hart stack earlier
Date: Mon, 24 Jul 2023 03:07:07 +0000	[thread overview]
Message-ID: <ZL3q2zr0Rij+cmRa@ubuntu01> (raw)
In-Reply-To: <1686527657-366116-1-git-send-email-ganboing@gmail.com>

On Sun, Jun 11, 2023 at 04:54:17PM -0700, Bo Gan wrote:
> Harts need to use per-hart stack before any function call, even if that
> function is a simple one. When the callee uses stack for register save/
> restore, especially RA, if nested call, concurrent access by multiple
> harts on the same stack will cause data-race.
> 
> This patch sets up SP before `board_init_f_alloc_reserve`. A side effect
> of this is that the memory layout has changed as the following:
> 
> +----------------+        +----------------+ <----- SPL_STACK/
> |  ......        |        |  hart 0 stack  |        SYS_INIT_SP_ADDR
> |  malloc_base   |        +----------------+
> +----------------+        |  hart 1 stack  |
> |  GD            |        +----------------+ If not SMP, N=1
> +----------------+        |  ......        |
> |  hart 0 stack  |        +----------------+
> +----------------+   ==>  |  hart N-1 stack|
> |  hart 1 stack  |        +----------------+
> +----------------+        |  ......        |
> |  ......        |        |  malloc_base   |
> +----------------+        +----------------+
> |  hart N-1 stack|        |  GD            |
> +----------------+        +----------------+
> |                |        |                |
> 
> Signed-off-by: Bo Gan <ganboing@gmail.com>
> Cc: Rick Chen <rick@andestech.com>
> Cc: Leo <ycliang@andestech.com>
> Cc: Sean Anderson <seanga2@gmail.com>
> Cc: Bin Meng <bmeng.cn@gmail.com>
> Cc: Lukas Auer <lukas.auer@aisec.fraunhofer.de>
> Reviewed-by: Rick Chen <rick@andestech.com>
> ---
> 
> v2:
> - Fixed macro CONFIG_SYS_INIT_SP_ADDR -> SYS_INIT_SP_ADDR
> - Tested SPL with VisionFive 2 board
> ---
>  arch/riscv/cpu/start.S | 37 ++++++++++++++++++++++++-------------
>  1 file changed, 24 insertions(+), 13 deletions(-)

Reviewed-by: Leo Yu-Chi Liang <ycliang@andestech.com>

      parent reply	other threads:[~2023-07-24  3:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-11 23:54 [RESEND PATCH v2] riscv: setup per-hart stack earlier Bo Gan
     [not found] ` <SEZPR03MB8064071D92E63D7A4C631359C154A@SEZPR03MB8064.apcprd03.prod.outlook.com>
2023-06-12  0:39   ` Rick Chen
2023-07-24  3:07 ` Leo Liang [this message]

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=ZL3q2zr0Rij+cmRa@ubuntu01 \
    --to=ycliang@andestech.com \
    --cc=bmeng.cn@gmail.com \
    --cc=ganboing@gmail.com \
    --cc=lukas.auer@aisec.fraunhofer.de \
    --cc=rick@andestech.com \
    --cc=seanga2@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox