* [PATCH 1/3] ARM: nommu: allow unaligned accesses on ARMv6+ processors
@ 2012-12-03 17:56 Will Deacon
2012-12-03 17:56 ` [PATCH 2/3] ARM: nommu: prevent generation of kernel unaligned memory accesses Will Deacon
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Will Deacon @ 2012-12-03 17:56 UTC (permalink / raw)
To: linux-arm-kernel
Commit 8428e84d ("ARM: 7150/1: Allow kernel unaligned accesses on ARMv6+
processors") unconditionally clears SCTLR.A for ARMv6+ processors, since
newer toolchains assume that unaligned memory accesses will not fault
for these cores.
This patch adds the corresponding change for nommu kernel builds.
Signed-off-by: Will Deacon <will.deacon@arm.com>
---
Identical to Armando's recent patch but included here for completeness.
arch/arm/kernel/head-nommu.S | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm/kernel/head-nommu.S b/arch/arm/kernel/head-nommu.S
index 278cfc1..2c228a0 100644
--- a/arch/arm/kernel/head-nommu.S
+++ b/arch/arm/kernel/head-nommu.S
@@ -68,7 +68,7 @@ __after_proc_init:
* CP15 system control register value returned in r0 from
* the CPU init function.
*/
-#ifdef CONFIG_ALIGNMENT_TRAP
+#if defined(CONFIG_ALIGNMENT_TRAP) && __LINUX_ARM_ARCH__ < 6
orr r0, r0, #CR_A
#else
bic r0, r0, #CR_A
--
1.8.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/3] ARM: nommu: prevent generation of kernel unaligned memory accesses
2012-12-03 17:56 [PATCH 1/3] ARM: nommu: allow unaligned accesses on ARMv6+ processors Will Deacon
@ 2012-12-03 17:56 ` Will Deacon
2012-12-03 18:55 ` Rob Herring
2012-12-03 17:56 ` [PATCH 3/3] ARM: nommu: do not enable DCACHE_WORD_ACCESS when !CONFIG_MMU Will Deacon
` (2 subsequent siblings)
3 siblings, 1 reply; 7+ messages in thread
From: Will Deacon @ 2012-12-03 17:56 UTC (permalink / raw)
To: linux-arm-kernel
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.
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)
--
1.8.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/3] ARM: nommu: do not enable DCACHE_WORD_ACCESS when !CONFIG_MMU
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 17:56 ` 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
3 siblings, 0 replies; 7+ messages in thread
From: Will Deacon @ 2012-12-03 17:56 UTC (permalink / raw)
To: linux-arm-kernel
Commit b9a50f74905a ("ARM: 7450/1: dcache: select DCACHE_WORD_ACCESS for
little-endian ARMv6+ CPUs") added support for word-at-time path
comparisons, relying on the ability to perform unaligned loads with
negligible performance impact in hardware.
For nommu configurations without MPU support, this is unpredictable and
so we should fall back to the byte-by-byte routines.
Signed-off-by: Will Deacon <will.deacon@arm.com>
---
arch/arm/Kconfig | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index ade7e92..3388431 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -6,7 +6,7 @@ config ARM
select ARCH_HAVE_CUSTOM_GPIO_H
select ARCH_WANT_IPC_PARSE_VERSION
select CPU_PM if (SUSPEND || CPU_IDLE)
- select DCACHE_WORD_ACCESS if (CPU_V6 || CPU_V6K || CPU_V7) && !CPU_BIG_ENDIAN
+ select DCACHE_WORD_ACCESS if (CPU_V6 || CPU_V6K || CPU_V7) && !CPU_BIG_ENDIAN && MMU
select GENERIC_ATOMIC64 if (CPU_V6 || !CPU_32v6K || !AEABI)
select GENERIC_CLOCKEVENTS_BROADCAST if SMP
select GENERIC_IRQ_PROBE
--
1.8.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 1/3] ARM: nommu: allow unaligned accesses on ARMv6+ processors
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 17:56 ` [PATCH 3/3] ARM: nommu: do not enable DCACHE_WORD_ACCESS when !CONFIG_MMU Will Deacon
@ 2012-12-03 18:20 ` Jonathan Austin
2012-12-03 19:25 ` Nicolas Pitre
3 siblings, 0 replies; 7+ messages in thread
From: Jonathan Austin @ 2012-12-03 18:20 UTC (permalink / raw)
To: linux-arm-kernel
On 03/12/12 17:56, Will Deacon wrote:
> Commit 8428e84d ("ARM: 7150/1: Allow kernel unaligned accesses on ARMv6+
> processors") unconditionally clears SCTLR.A for ARMv6+ processors, since
> newer toolchains assume that unaligned memory accesses will not fault
> for these cores.
>
> This patch adds the corresponding change for nommu kernel builds.
>
> Signed-off-by: Will Deacon <will.deacon@arm.com>
For the series:
Tested-by: Jonathan Austin <jonathan.austin@arm.com>
(Tested on Cortex-R Series models)
Jonny
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 2/3] ARM: nommu: prevent generation of kernel unaligned memory accesses
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
2012-12-03 19:27 ` Nicolas Pitre
0 siblings, 1 reply; 7+ messages in thread
From: Rob Herring @ 2012-12-03 18:55 UTC (permalink / raw)
To: linux-arm-kernel
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)
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/3] ARM: nommu: allow unaligned accesses on ARMv6+ processors
2012-12-03 17:56 [PATCH 1/3] ARM: nommu: allow unaligned accesses on ARMv6+ processors Will Deacon
` (2 preceding siblings ...)
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
3 siblings, 0 replies; 7+ messages in thread
From: Nicolas Pitre @ 2012-12-03 19:25 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, 3 Dec 2012, Will Deacon wrote:
> Commit 8428e84d ("ARM: 7150/1: Allow kernel unaligned accesses on ARMv6+
> processors") unconditionally clears SCTLR.A for ARMv6+ processors, since
> newer toolchains assume that unaligned memory accesses will not fault
> for these cores.
>
> This patch adds the corresponding change for nommu kernel builds.
>
> Signed-off-by: Will Deacon <will.deacon@arm.com>
> ---
>
> Identical to Armando's recent patch but included here for completeness.
For patches 1 to 3:
Acked-by: Nicolas Pitre <nico@linaro.org>
>
> arch/arm/kernel/head-nommu.S | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/arm/kernel/head-nommu.S b/arch/arm/kernel/head-nommu.S
> index 278cfc1..2c228a0 100644
> --- a/arch/arm/kernel/head-nommu.S
> +++ b/arch/arm/kernel/head-nommu.S
> @@ -68,7 +68,7 @@ __after_proc_init:
> * CP15 system control register value returned in r0 from
> * the CPU init function.
> */
> -#ifdef CONFIG_ALIGNMENT_TRAP
> +#if defined(CONFIG_ALIGNMENT_TRAP) && __LINUX_ARM_ARCH__ < 6
> orr r0, r0, #CR_A
> #else
> bic r0, r0, #CR_A
> --
> 1.8.0
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 2/3] ARM: nommu: prevent generation of kernel unaligned memory accesses
2012-12-03 18:55 ` Rob Herring
@ 2012-12-03 19:27 ` Nicolas Pitre
0 siblings, 0 replies; 7+ messages in thread
From: Nicolas Pitre @ 2012-12-03 19:27 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, 3 Dec 2012, Rob Herring wrote:
> 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 };
> }
Isn't that a gcc bug?
Nicolas
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2012-12-03 19:27 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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
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).