mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <sha@pengutronix.de>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH master 1/3] RISC-V: cpu: request stack memory region
Date: Mon, 29 Mar 2021 09:57:06 +0200	[thread overview]
Message-ID: <20210329075706.GF609@pengutronix.de> (raw)
In-Reply-To: <20210324082304.30858-1-a.fatoum@pengutronix.de>

On Wed, Mar 24, 2021 at 09:23:02AM +0100, Ahmad Fatoum wrote:
> Now that the stack base region is determined dynamically,
> mem_malloc_resource can no longer reserve the stack space.
> Do as ARM does and add a RISC-V specific initcall to reserve
> the main thread's stack space.
> 
> Reported-by: Antony Pavlov <antonynpavlov@gmail.com>
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---

Applied, thanks

Sascha

> Fix for master as otherwise stack could be overwritten at runtime
> ---
>  arch/riscv/cpu/core.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/arch/riscv/cpu/core.c b/arch/riscv/cpu/core.c
> index bdcd500ed748..982d378eddec 100644
> --- a/arch/riscv/cpu/core.c
> +++ b/arch/riscv/cpu/core.c
> @@ -2,6 +2,9 @@
>  /*
>   * Copyright (C) 2012 Regents of the University of California
>   * Copyright (C) 2017 SiFive
> + * Copyright (C) 2021 Ahmad Fatoum, Pengutronix
> + *
> + * Common RISC-V core initcalls.
>   *
>   * All RISC-V systems have a timer attached to every hart.  These timers can
>   * either be read from the "time" and "timeh" CSRs, and can use the SBI to
> @@ -14,8 +17,17 @@
>  #include <of.h>
>  #include <linux/clk.h>
>  #include <linux/err.h>
> +#include <memory.h>
> +#include <asm-generic/memory_layout.h>
>  #include <io.h>
>  
> +static int riscv_request_stack(void)
> +{
> +	extern unsigned long riscv_stack_top;
> +	return PTR_ERR_OR_ZERO(request_sdram_region("stack", riscv_stack_top - STACK_SIZE, STACK_SIZE));
> +}
> +coredevice_initcall(riscv_request_stack);
> +
>  static struct device_d timer_dev;
>  
>  static int riscv_probe(struct device_d *parent)
> -- 
> 2.29.2
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


  parent reply	other threads:[~2021-03-29 16:43 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-24  8:23 Ahmad Fatoum
2021-03-24  8:23 ` [PATCH master 2/3] RISC-V: board-dt-2nd: ensure FDT doesn't overlap with early mem regions Ahmad Fatoum
2021-03-24  8:23 ` [PATCH master 3/3] RISC-V: boot: move stack top to very end of memory Ahmad Fatoum
2021-03-29  7:57 ` Sascha Hauer [this message]
2021-04-02  5:56 ` [PATCH master 1/3] RISC-V: cpu: request stack memory region Antony Pavlov
2021-04-02  6:34   ` Ahmad Fatoum
2021-04-02  8:13     ` Antony Pavlov
2021-04-03  7:09       ` Ahmad Fatoum
2021-04-03  9:00         ` Antony Pavlov
2021-04-04 11:26           ` Ahmad Fatoum

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=20210329075706.GF609@pengutronix.de \
    --to=sha@pengutronix.de \
    --cc=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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