mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] PPC: request a consistent memory layout
@ 2017-05-08 12:56 Juergen Borleis
  2017-05-09  5:40 ` Sascha Hauer
  0 siblings, 1 reply; 3+ messages in thread
From: Juergen Borleis @ 2017-05-08 12:56 UTC (permalink / raw)
  To: barebox

Using the memory test command will crash barebox, because it tests the
area where the stack is located for the PPC architecture.

On PPC the stack is below the barebox binary. Below the stack the malloc
area is located. Until this change some routines used the macros
from memory_layout.h, some other calculated their values by their
own - which resulted into an unrequested and unprotected stack area.

Signed-off-by: Juergen Borleis <jbe@pengutronix.de>
---
 arch/ppc/mach-mpc5xxx/Kconfig       |  1 -
 arch/ppc/mach-mpc5xxx/cpu-mpc5200.c | 18 ++++++++++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/arch/ppc/mach-mpc5xxx/Kconfig b/arch/ppc/mach-mpc5xxx/Kconfig
index d0f5d78f4..fef661b0f 100644
--- a/arch/ppc/mach-mpc5xxx/Kconfig
+++ b/arch/ppc/mach-mpc5xxx/Kconfig
@@ -52,7 +52,6 @@ config ARCH_MPC5200
 config MPC5xxx
 	bool
 	depends on MACH_PHYCORE_MPC5200B_TINY || MMC12
-	select HAVE_CONFIGURABLE_MEMORY_LAYOUT
 	default y
 
 menu "Board specific settings"
diff --git a/arch/ppc/mach-mpc5xxx/cpu-mpc5200.c b/arch/ppc/mach-mpc5xxx/cpu-mpc5200.c
index 42ced9ac5..1e33eea75 100644
--- a/arch/ppc/mach-mpc5xxx/cpu-mpc5200.c
+++ b/arch/ppc/mach-mpc5xxx/cpu-mpc5200.c
@@ -33,6 +33,8 @@
 #include <of.h>
 #include <restart.h>
 #include <mach/clock.h>
+#include <asm-generic/memory_layout.h>
+#include <memory.h>
 
 int checkcpu (void)
 {
@@ -241,3 +243,19 @@ void mpc5200_setup_cs(int cs, unsigned long start, unsigned long size, u32 cfg)
 	addecr |= chipselects[cs].addecr | 1;
 	out_be32((void *)MPC5XXX_ADDECR, addecr);
 }
+
+static int mpc5200_reserve_region(void)
+{
+	struct resource *r;
+
+	/* keep this in sync with the assembler routines setting up the stack */
+	r = request_sdram_region("stack", _text_base - STACK_SIZE, STACK_SIZE);
+	if (r == NULL) {
+		pr_err("Failed to request stack region at: 0x%08lx/0x%08lx\n",
+			_text_base - STACK_SIZE, _text_base - 1);
+		return -EBUSY;
+	}
+
+	return 0;
+}
+coredevice_initcall(mpc5200_reserve_region);
-- 
2.11.0


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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] PPC: request a consistent memory layout
  2017-05-08 12:56 [PATCH] PPC: request a consistent memory layout Juergen Borleis
@ 2017-05-09  5:40 ` Sascha Hauer
  2017-05-09  7:52   ` Juergen Borleis
  0 siblings, 1 reply; 3+ messages in thread
From: Sascha Hauer @ 2017-05-09  5:40 UTC (permalink / raw)
  To: Juergen Borleis; +Cc: barebox

Hi Jürgen,

On Mon, May 08, 2017 at 02:56:07PM +0200, Juergen Borleis wrote:
> Using the memory test command will crash barebox, because it tests the
> area where the stack is located for the PPC architecture.
> 
> On PPC the stack is below the barebox binary. Below the stack the malloc
> area is located. Until this change some routines used the macros
> from memory_layout.h, some other calculated their values by their
> own - which resulted into an unrequested and unprotected stack area.
> 
> Signed-off-by: Juergen Borleis <jbe@pengutronix.de>
> ---
>  arch/ppc/mach-mpc5xxx/Kconfig       |  1 -
>  arch/ppc/mach-mpc5xxx/cpu-mpc5200.c | 18 ++++++++++++++++++
>  2 files changed, 18 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/ppc/mach-mpc5xxx/Kconfig b/arch/ppc/mach-mpc5xxx/Kconfig
> index d0f5d78f4..fef661b0f 100644
> --- a/arch/ppc/mach-mpc5xxx/Kconfig
> +++ b/arch/ppc/mach-mpc5xxx/Kconfig
> @@ -52,7 +52,6 @@ config ARCH_MPC5200
>  config MPC5xxx
>  	bool
>  	depends on MACH_PHYCORE_MPC5200B_TINY || MMC12
> -	select HAVE_CONFIGURABLE_MEMORY_LAYOUT
>  	default y
>  
>  menu "Board specific settings"
> diff --git a/arch/ppc/mach-mpc5xxx/cpu-mpc5200.c b/arch/ppc/mach-mpc5xxx/cpu-mpc5200.c

This files doesn't exist in master. Could you rebase on a current tree?

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] PPC: request a consistent memory layout
  2017-05-09  5:40 ` Sascha Hauer
@ 2017-05-09  7:52   ` Juergen Borleis
  0 siblings, 0 replies; 3+ messages in thread
From: Juergen Borleis @ 2017-05-09  7:52 UTC (permalink / raw)
  To: barebox

Hi Sascha,

On Tuesday 09 May 2017 07:40:31 Sascha Hauer wrote:
> [...]
> This files doesn't exist in master. Could you rebase on a current tree?

Arghh, sorry. V2 sent.

jb

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-05-09  7:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-08 12:56 [PATCH] PPC: request a consistent memory layout Juergen Borleis
2017-05-09  5:40 ` Sascha Hauer
2017-05-09  7:52   ` Juergen Borleis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox