mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Andrey Smirnov <andrew.smirnov@gmail.com>
To: barebox@lists.infradead.org
Cc: Andrey Smirnov <andrew.smirnov@gmail.com>
Subject: [PATCH] arm: Disable unaligned access if MMU is switched off
Date: Wed, 23 Sep 2015 20:17:25 -0700	[thread overview]
Message-ID: <1443064645-4007-1-git-send-email-andrew.smirnov@gmail.com> (raw)

Form reading ARM architecture related documentation if appears that
while unaligned memory access is supported by the processor in general
it is not supported if MMU is disabled.

The problem in question can be easilty reproduced by building the code
without this patch, MMU disabled and trying to run 'memtest'
command. Which would in turn call mem_test() which would eventually
call show_progress(). That last function, if build without
-mno-unaligned-access would result in unaligned memory access which
would result in Barebox hanging.

This patch is a very conservative attempt to make sure that any code
that can potentially be executed with MMU disabled is built with
unaligned memory accesses disabled.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 arch/arm/Makefile      | 14 ++++++++++++++
 scripts/Makefile.build |  2 +-
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 721aa9b..9af4f3b 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -13,6 +13,20 @@ AS		+= -EL
 LD		+= -EL
 endif
 
+#
+# Unaligned access is not supported when MMU is disabled, so if MMU is
+# enabled early on, only PBL, part of which will be executed with MMU
+# diabled, would have to be build with -mno-unaligned-accesses,
+# otherwise set this flag globally
+#
+ifeq ($(CONFIG_MMU_EARLY),y)
+ifneq ($(CONFIG_PBL_IMAGE),y)
+PBL_CFLAGS += -mno-unaligned-access
+endif
+else
+CFLAGS += -mno-unaligned-access
+endif
+
 # This selects which instruction set is used.
 # Note that GCC does not numerically define an architecture version
 # macro, but instead defines a whole series of macros which makes
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 56ee072..1624a7a 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -188,7 +188,7 @@ quiet_cmd_pbl_cc_o_c = PBLCC   $@
 
 ifndef CONFIG_MODVERSIONS
 cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
-cmd_pbl_cc_o_c = $(CC) -D__PBL__ $(c_flags) $(PBL_CPPFLAGS) -c -o $@ $<
+cmd_pbl_cc_o_c = $(CC) -D__PBL__ $(c_flags) $(PBL_CFLAGS) $(PBL_CPPFLAGS) -c -o $@ $<
 
 else
 # When module versioning is enabled the following steps are executed:
-- 
2.1.4


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

             reply	other threads:[~2015-09-24  3:17 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-24  3:17 Andrey Smirnov [this message]
2015-09-24  9:20 ` Lucas Stach
2015-09-29  7:32   ` Sascha Hauer
2015-09-29 17:53     ` Andrey Smirnov

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=1443064645-4007-1-git-send-email-andrew.smirnov@gmail.com \
    --to=andrew.smirnov@gmail.com \
    --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