mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Juergen Borleis <jbe@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH v2] PPC: request a consistent memory layout
Date: Tue,  9 May 2017 09:51:15 +0200	[thread overview]
Message-ID: <20170509075115.15702-1-jbe@pengutronix.de> (raw)

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.c   | 18 ++++++++++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/arch/ppc/mach-mpc5xxx/Kconfig b/arch/ppc/mach-mpc5xxx/Kconfig
index 1ecce3a56..180aa32ad 100644
--- a/arch/ppc/mach-mpc5xxx/Kconfig
+++ b/arch/ppc/mach-mpc5xxx/Kconfig
@@ -32,7 +32,6 @@ config ARCH_MPC5200
 config MPC5xxx
 	bool
 	depends on MACH_PHYCORE_MPC5200B_TINY
-	select HAVE_CONFIGURABLE_MEMORY_LAYOUT
 	default y
 
 menu "Board specific settings"
diff --git a/arch/ppc/mach-mpc5xxx/cpu.c b/arch/ppc/mach-mpc5xxx/cpu.c
index 42ced9ac5..ab58967aa 100644
--- a/arch/ppc/mach-mpc5xxx/cpu.c
+++ b/arch/ppc/mach-mpc5xxx/cpu.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)
 {
@@ -60,6 +62,22 @@ int checkcpu (void)
 
 /* ------------------------------------------------------------------------- */
 
+static int mpc5xxx_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(mpc5xxx_reserve_region);
+
 static void __noreturn mpc5xxx_restart_soc(struct restart_handler *rst)
 {
 	ulong msr;
-- 
2.11.0


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

             reply	other threads:[~2017-05-09  7:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-09  7:51 Juergen Borleis [this message]
2017-05-11  6:17 ` Sascha Hauer

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=20170509075115.15702-1-jbe@pengutronix.de \
    --to=jbe@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