All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anup Patel <anup@brainfault.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 07/11] riscv: support SPL stack and global data relocation
Date: Mon, 29 Jul 2019 14:06:33 +0530	[thread overview]
Message-ID: <CAAhSdy2Mqk7A+_ZpchsJnQNbMe7xvSXMXrv6HFreh7jCNp3ojg@mail.gmail.com> (raw)
In-Reply-To: <20190728155723.3412-8-lukas.auer@aisec.fraunhofer.de>

On Sun, Jul 28, 2019 at 9:27 PM Lukas Auer
<lukas.auer@aisec.fraunhofer.de> wrote:
>
> To support relocation of the stack and global data on RISC-V, the
> secondary harts must be notified of the change using IPIs. We can reuse
> the hart relocation code for this purpose. It uses global data to store
> the new stack pointer and global data pointer for the secondary harts.
> This means that we cannot update the global data pointer of the main
> hart in spl_relocate_stack_gd(), because the secondary harts have not
> yet been relocated at this point. It is updated after the secondary
> harts have been notified.
>
> Signed-off-by: Lukas Auer <lukas.auer@aisec.fraunhofer.de>
> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
> Tested-by: Bin Meng <bmeng.cn@gmail.com>
> ---
>
> Changes in v2: None
>
>  arch/riscv/cpu/start.S | 35 ++++++++++++++++++++++++++++++++++-
>  common/spl/spl.c       |  2 +-
>  2 files changed, 35 insertions(+), 2 deletions(-)
>
> diff --git a/arch/riscv/cpu/start.S b/arch/riscv/cpu/start.S
> index e053197645..e8c65c887a 100644
> --- a/arch/riscv/cpu/start.S
> +++ b/arch/riscv/cpu/start.S
> @@ -170,13 +170,46 @@ wait_for_gd_init:
>  spl_clear_bss:
>         la      t0, __bss_start
>         la      t1, __bss_end
> -       beq     t0, t1, spl_call_board_init_r
> +       beq     t0, t1, spl_stack_gd_setup
>
>  spl_clear_bss_loop:
>         SREG    zero, 0(t0)
>         addi    t0, t0, REGBYTES
>         bne     t0, t1, spl_clear_bss_loop
>
> +spl_stack_gd_setup:
> +       jal     spl_relocate_stack_gd
> +
> +       /* skip setup if we did not relocate */
> +       beqz    a0, spl_call_board_init_r
> +       mv      s0, a0
> +
> +       /* setup stack on main hart */
> +#ifdef CONFIG_SMP
> +       /* tp: hart id */
> +       slli    t0, tp, CONFIG_STACK_SIZE_SHIFT
> +       sub     sp, s0, t0
> +#else
> +       mv      sp, s0
> +#endif
> +
> +       /* set new stack and global data pointer on secondary harts */
> +spl_secondary_hart_stack_gd_setup:
> +       la      a0, secondary_hart_relocate
> +       mv      a1, s0
> +       mv      a2, s0
> +       jal     smp_call_function
> +
> +       /* hang if relocation of secondary harts has failed */
> +       beqz    a0, 1f
> +       mv      a1, a0
> +       la      a0, secondary_harts_relocation_error
> +       jal     printf
> +       jal     hang
> +
> +       /* set new global data pointer on main hart */
> +1:     mv      gp, s0
> +
>  spl_call_board_init_r:
>         mv      a0, zero
>         mv      a1, zero
> diff --git a/common/spl/spl.c b/common/spl/spl.c
> index 1ed4741bdc..834f39908b 100644
> --- a/common/spl/spl.c
> +++ b/common/spl/spl.c
> @@ -756,7 +756,7 @@ ulong spl_relocate_stack_gd(void)
>  #if CONFIG_IS_ENABLED(DM)
>         dm_fixup_for_gd_move(new_gd);
>  #endif
> -#if !defined(CONFIG_ARM)
> +#if !defined(CONFIG_ARM) && !defined(CONFIG_RISCV)
>         gd = new_gd;
>  #endif
>         return ptr;
> --
> 2.21.0
>

Reviewed-by: Anup Patel <anup.patel@wdc.com>

Regards,
Anup

  reply	other threads:[~2019-07-29  8:36 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-28 15:57 [U-Boot] [PATCH v2 00/11] SPL support for RISC-V Lukas Auer
2019-07-28 15:57 ` [U-Boot] [PATCH v2 01/11] fdtdec: make CONFIG_OF_PRIOR_STAGE available in SPL Lukas Auer
2019-07-29  8:14   ` Anup Patel
2019-07-28 15:57 ` [U-Boot] [PATCH v2 02/11] Makefile: support building SPL FIT images without device trees Lukas Auer
2019-07-29  8:17   ` Anup Patel
2019-07-28 15:57 ` [U-Boot] [PATCH v2 03/11] spl: fit: use U-Boot device tree when FIT image has no device tree Lukas Auer
2019-07-29  8:20   ` Anup Patel
2019-07-28 15:57 ` [U-Boot] [PATCH v2 04/11] riscv: add run mode configuration for SPL Lukas Auer
2019-07-29  8:24   ` Anup Patel
2019-07-28 15:57 ` [U-Boot] [PATCH v2 05/11] spl: support booting via RISC-V OpenSBI Lukas Auer
2019-07-29  8:32   ` Anup Patel
2019-07-29 15:51     ` Auer, Lukas
2019-07-30  3:45       ` Anup Patel
2019-07-28 15:57 ` [U-Boot] [PATCH v2 06/11] riscv: add SPL support Lukas Auer
2019-07-29  8:34   ` Anup Patel
2019-07-28 15:57 ` [U-Boot] [PATCH v2 07/11] riscv: support SPL stack and global data relocation Lukas Auer
2019-07-29  8:36   ` Anup Patel [this message]
2019-07-28 15:57 ` [U-Boot] [PATCH v2 08/11] riscv: add a generic FIT generator script Lukas Auer
2019-07-29  8:39   ` Anup Patel
2019-07-28 15:57 ` [U-Boot] [PATCH v2 09/11] riscv: set default FIT generator script and build target for SPL builds Lukas Auer
2019-07-29  8:40   ` Anup Patel
2019-07-28 15:57 ` [U-Boot] [PATCH v2 10/11] riscv: qemu: add SPL configuration Lukas Auer
2019-07-29  8:41   ` Anup Patel
2019-07-28 15:57 ` [U-Boot] [PATCH v2 11/11] doc: update QEMU RISC-V documentation Lukas Auer
2019-07-29  8:42   ` Anup Patel
2019-07-29  8:44 ` [U-Boot] [PATCH v2 00/11] SPL support for RISC-V Anup Patel
2019-07-29 15:52   ` Auer, Lukas
     [not found] ` <752D002CFF5D0F4FA35C0100F1D73F3FA40F3AC4@ATCPCS16.andestech.com>
2019-08-01  3:32   ` Rick Chen
2019-08-01 13:51     ` Auer, Lukas
2019-08-02  8:41       ` Rick Chen
2019-08-02  8:48         ` Anup Patel
2019-08-02 10:25           ` Auer, Lukas
2019-08-08  9:49             ` Rick Chen

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=CAAhSdy2Mqk7A+_ZpchsJnQNbMe7xvSXMXrv6HFreh7jCNp3ojg@mail.gmail.com \
    --to=anup@brainfault.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.