linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: robherring2@gmail.com (Rob Herring)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/3] ARM: nommu: prevent generation of kernel unaligned memory accesses
Date: Mon, 03 Dec 2012 12:55:05 -0600	[thread overview]
Message-ID: <50BCF589.4010509@gmail.com> (raw)
In-Reply-To: <1354557403-20386-2-git-send-email-will.deacon@arm.com>

On 12/03/2012 11:56 AM, Will Deacon wrote:
> Recent ARMv7 toolchains assume that unaligned memory accesses will not
> fault and will instead be handled by the processor.
> 
> For the nommu case (without an MPU), memory will be treated as
> strongly-ordered and therefore unaligned accesses may fault regardless
> of the SCTLR.A setting.
> 
> This patch passes -mno-unaligned-access to GCC when compiling for nommu
> targets, preventing the generation of unaligned memory access in the
> kernel.

BTW, this option will not fully prevent unaligned accesses. This code
will still generate unaligned accesses:

void func(void)
{
	char array[] = { 1, 2, 3 };
}

u-boot has been fixing these up by making the arrays static.

Rob

> 
> Signed-off-by: Will Deacon <will.deacon@arm.com>
> ---
>  arch/arm/Makefile | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/arch/arm/Makefile b/arch/arm/Makefile
> index 5f914fc..03363e2 100644
> --- a/arch/arm/Makefile
> +++ b/arch/arm/Makefile
> @@ -32,6 +32,7 @@ KBUILD_DEFCONFIG := versatile_defconfig
>  # defines filename extension depending memory management type.
>  ifeq ($(CONFIG_MMU),)
>  MMUEXT		:= -nommu
> +KBUILD_CFLAGS	+= $(call cc-option,-mno-unaligned-access)
>  endif
>  
>  ifeq ($(CONFIG_FRAME_POINTER),y)
> 

  reply	other threads:[~2012-12-03 18:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-03 17:56 [PATCH 1/3] ARM: nommu: allow unaligned accesses on ARMv6+ processors Will Deacon
2012-12-03 17:56 ` [PATCH 2/3] ARM: nommu: prevent generation of kernel unaligned memory accesses Will Deacon
2012-12-03 18:55   ` Rob Herring [this message]
2012-12-03 19:27     ` Nicolas Pitre
2012-12-03 17:56 ` [PATCH 3/3] ARM: nommu: do not enable DCACHE_WORD_ACCESS when !CONFIG_MMU Will Deacon
2012-12-03 18:20 ` [PATCH 1/3] ARM: nommu: allow unaligned accesses on ARMv6+ processors Jonathan Austin
2012-12-03 19:25 ` Nicolas Pitre

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=50BCF589.4010509@gmail.com \
    --to=robherring2@gmail.com \
    --cc=linux-arm-kernel@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;
as well as URLs for NNTP newsgroup(s).