[PATCH] ARM: Do not allow unaligned accesses when CONFIG_ALIGNMENT_TRAP
From: Russell King - ARM Linux <hidden>
Date: 2011-05-23 13:25:13
On Mon, May 23, 2011 at 01:30:43PM +0100, M?ns Rullg?rd wrote:
Catalin Marinas [off-list ref] writes:quoted
Newer versions of gcc generate unaligned accesses by default, causing kernel panics when CONFIG_ALIGNMENT_TRAP is enabled. This patch adds the -mno-unaligned-access option to gcc.Wouldn't it make more sense to disable strict alignment checking in kernel mode regardless of this option. I can't imagine why it would ever be desirable. IMO the usermode default should also be changed to allow unaligned accesses on ARMv6 and up.
We do disable strict alignment checking but only at alignment fault
handler init time:
/*
* ARMv6 and later CPUs can perform unaligned accesses for
* most single load and store instructions up to word size.
* LDM, STM, LDRD and STRD still need to be handled.
*
* Ignoring the alignment fault is not an option on these
* CPUs since we spin re-faulting the instruction without
* making any progress.
*/
if (cpu_architecture() >= CPU_ARCH_ARMv6 && (cr_alignment & CR_U)) {
cr_alignment &= ~CR_A;
cr_no_alignment &= ~CR_A;
set_cr(cr_alignment);
ai_usermode = UM_FIXUP;
}
If we need that CR bit disabled earlier, then that's what we need to do,
not bodge around it in silly ways which only _partially_ address the
issue.
I also believe the commit message to be entirely misleading and wrong.
Until we have the information on what this patch is _trying_ to address
I don't think there's much more that can be said about it.