From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from metis.ext.pengutronix.de ([2001:6f8:1178:4:290:27ff:fe1d:cc33]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1So86Y-00013t-Cg for barebox@lists.infradead.org; Mon, 09 Jul 2012 07:10:04 +0000 From: Sascha Hauer Date: Mon, 9 Jul 2012 09:09:39 +0200 Message-Id: <1341817779-29531-1-git-send-email-s.hauer@pengutronix.de> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: barebox-bounces@lists.infradead.org Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: [PATCH] ARM: Enable unaligned accesses on armv6 and later To: barebox@lists.infradead.org Cc: Enrico Scholz We have the following in the tree: |commit af42feb9d255bc3ea3b514180f265479ea8834f9 |Author: Enrico Scholz |Date: Mon Jan 2 11:49:17 2012 +0100 | | ARM: set SCTRL[A] only when architecture does not support unaligned access | | Recent gcc generates code with unaligned access when architecture | supports it. Setting A bit unconditionally causes data-aborts on such | code rendering barebox unusable. | | Signed-off-by: Enrico Scholz | Signed-off-by: Sascha Hauer What the patch tried is correct: We should set the A bit only when the architecture does not support unaligned accesses. To figure out whether the architecture supports unaligned accesses the patch tested for the U bit which is wrong. The U bit may be 0 after a reset, so instead of testing for the U bit we have to set it. This can be done on armv6 and later. All others have the A bit set to trap unaligned accesses. Signed-off-by: Sascha Hauer --- Enrico, can you confirm this is correct? Thanks Sascha arch/arm/cpu/start.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/arch/arm/cpu/start.c b/arch/arm/cpu/start.c index 3c282ee..523179d 100644 --- a/arch/arm/cpu/start.c +++ b/arch/arm/cpu/start.c @@ -81,13 +81,11 @@ void __naked __bare_init reset(void) r &= ~(CR_M | CR_C | CR_B | CR_S | CR_R | CR_V); r |= CR_I; - if (!(r & CR_U)) - /* catch unaligned access on architectures which do not - * support unaligned access */ - r |= CR_A; - else - r &= ~CR_A; - +#if __LINUX_ARM_ARCH__ >= 6 + r |= CR_U; +#else + r |= CR_A; +#endif #ifdef __ARMEB__ r |= CR_B; -- 1.7.10 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox