From: Heinrich Schuchardt <xypron.glpk@gmx.de>
To: Sam Edwards <cfsworks@gmail.com>
Cc: Marek Vasut <marek.vasut+renesas@mailbox.org>,
Sumit Garg <sumit.garg@linaro.org>,
Peter Robinson <pbrobinson@gmail.com>,
Richard Henderson <richard.henderson@linaro.org>,
u-boot@lists.denx.de, Tom Rini <trini@konsulko.com>,
Ilias Apalodimas <ilias.apalodimas@linaro.org>,
Simon Glass <sjg@chromium.org>, Bin Meng <bmeng.cn@gmail.com>
Subject: Re: [PATCH 06/17] arm: Use -mstrict-align when the MMU is off
Date: Mon, 24 Feb 2025 09:20:36 +0100 [thread overview]
Message-ID: <fe6585a0-e0e5-4686-97b5-aee51b5cdd00@gmx.de> (raw)
In-Reply-To: <20250224055524.1334929-7-CFSworks@gmail.com>
On 2/24/25 06:55, Sam Edwards wrote:
> On ARM, enabling the MMU is a prerequisite to enabling caching, which
> allows unaligned memory accesses by consolidating them into aligned
> accesses. When the MMU is disabled, however, all accesses must strictly
> adhere to the alignment rules.
>
> Some compilers (e.g. Clang) contain optimizations that may break these
> rules on the assumption that misaligned accesses merely incur a
> performance penalty. We do not necessarily want to prevent the compiler
> from applying these optimizations where it believes there may be net
> gains, but we do need to tell it to respect the alignment requirements
> when the MMU is disabled.
>
> Therefore, add the `-mstrict-align` compiler flag when SYS_ARM_MMU is
> not set.
>
> Signed-off-by: Sam Edwards <CFSworks@gmail.com>
> ---
> arch/arm/config.mk | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/arch/arm/config.mk b/arch/arm/config.mk
> index e0045e22271..98237b251f1 100644
> --- a/arch/arm/config.mk
> +++ b/arch/arm/config.mk
> @@ -33,6 +33,10 @@ PLATFORM_RELFLAGS += $(LLVM_RELFLAGS)
>
> PLATFORM_CPPFLAGS += -D__ARM__
>
> +ifneq ($(CONFIG_SYS_ARM_MMU),y)
> +PLATFORM_RELFLAGS += -mstrict-align
We don't set CONFIG_SYS_ARM_MMU on armv8 though we initialize the MMU.
The flag -mstrict-align seems only to exist for 64bit ARM and is already
set in arch/arm/cpu/armv8/config.mk.
On 32-bit ARM there is a flag -mno-unaligned-access which we set in
arch/arm/cpu/armv7/config.mk and arch/arm/cpu/armv7m/config.mk.
Here are some places we forbid unaligned access irrespective of
CONFIG_SYS_ARM_MMU:
arch/arm/cpu/arm1136/start.S:80: orr r0, r0, #0x00000002
@ set bit 1 (A) Align
arch/arm/cpu/arm1176/start.S:82: orr r0, r0, #0x00000002
@ set bit 1 (A) Align
arch/arm/cpu/arm920t/start.S:81: orr r0, r0, #0x00000002
@ set bit 1 (A) Align
arch/arm/cpu/arm926ejs/start.S:102: orr r0, r0, #0x00000002
/* set bit 1 (A) Align */
arch/arm/cpu/arm946es/start.S:88: orr r0, r0, #0x00000002
/* set bit 1 (A) Align */
arch/arm/cpu/armv7/start.S:229: orr r0, r0, #0x00000002 @ set
bit 1 (--A-) Align
Best regards
Heinrich
> +endif
> +
> ifdef CONFIG_ARM64
> PLATFORM_ELFFLAGS += -B aarch64 -O elf64-littleaarch64
> else
next prev parent reply other threads:[~2025-02-24 8:20 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-24 5:55 [PATCH 00/17] Various toolchain compatibility fixes/improvements Sam Edwards
2025-02-24 5:55 ` [PATCH 01/17] arm: Remove stray .mmutable reference in linker script Sam Edwards
2025-02-26 14:44 ` Ilias Apalodimas
2025-02-24 5:55 ` [PATCH 02/17] arm: Exclude eabi_compat from LTO Sam Edwards
2025-03-09 8:47 ` Ilias Apalodimas
2025-02-24 5:55 ` [PATCH 03/17] arm: Add __aeabi_memclr in eabi_compat Sam Edwards
2025-03-09 8:45 ` Ilias Apalodimas
2025-02-24 5:55 ` [PATCH 04/17] arm: Add aligned-memory aliases to eabi_compat Sam Edwards
2025-03-09 8:51 ` Ilias Apalodimas
2025-02-24 5:55 ` [PATCH 05/17] arm: Discard unwanted sections in linker script Sam Edwards
2025-02-24 5:55 ` [PATCH 06/17] arm: Use -mstrict-align when the MMU is off Sam Edwards
2025-02-24 8:20 ` Heinrich Schuchardt [this message]
2025-02-24 11:21 ` Mark Kettenis
2025-02-24 5:55 ` [PATCH 07/17] arm: Replace 'adrl' in EFI crt0 Sam Edwards
2025-02-24 8:42 ` Heinrich Schuchardt
2025-02-25 2:16 ` Sam Edwards
2025-02-24 5:55 ` [PATCH 08/17] x86: Fix call64's section flags Sam Edwards
2025-02-24 5:55 ` [PATCH 09/17] spl: riscv: opensbi: Error on misaligned FDT Sam Edwards
2025-02-24 8:54 ` Heinrich Schuchardt
2025-02-24 14:54 ` Tom Rini
2025-02-25 2:29 ` Sam Edwards
2025-02-24 5:55 ` [PATCH 10/17] spl: Align FDT load address Sam Edwards
2025-02-24 8:59 ` Heinrich Schuchardt
2025-02-24 14:56 ` Tom Rini
2025-02-24 15:54 ` Heinrich Schuchardt
2025-02-24 16:03 ` Tom Rini
2025-02-25 2:48 ` Sam Edwards
2025-02-24 5:55 ` [PATCH 11/17] makefile: Fix symbol typo in binary_size_check Sam Edwards
2025-02-24 9:17 ` Heinrich Schuchardt
2025-02-25 13:04 ` Simon Glass
2025-02-24 5:55 ` [PATCH 12/17] makefile: Avoid objcopy --gap-fill for .hex/.srec Sam Edwards
2025-02-24 5:55 ` [PATCH 13/17] makefile: Add `norelro` linker option Sam Edwards
2025-03-11 14:31 ` Ilias Apalodimas
2025-02-24 5:55 ` [PATCH 14/17] makefile: Add READELF command variable Sam Edwards
2025-02-24 9:20 ` Heinrich Schuchardt
2025-02-26 9:51 ` Ilias Apalodimas
2025-02-24 5:55 ` [PATCH 15/17] efi_loader: Remove ENTRY(_start) from linker script Sam Edwards
2025-02-24 9:36 ` Heinrich Schuchardt
2025-02-25 2:21 ` Sam Edwards
2025-02-24 5:55 ` [PATCH 16/17] efi_loader: Move .dynamic out of .text in EFI Sam Edwards
2025-02-24 7:34 ` Heinrich Schuchardt
2025-03-04 2:37 ` Sam Edwards
2025-02-24 5:55 ` [PATCH 17/17] scripts/Makefile.lib: efi: Preserve the .dynstr section as well Sam Edwards
2025-02-24 9:46 ` Heinrich Schuchardt
2025-03-06 3:46 ` [PATCH 00/17] Various toolchain compatibility fixes/improvements Sam Edwards
2025-03-06 13:15 ` Ilias Apalodimas
2025-03-06 15:47 ` Tom Rini
2025-03-08 6:48 ` Sam Edwards
2025-03-10 14:07 ` Tom Rini
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=fe6585a0-e0e5-4686-97b5-aee51b5cdd00@gmx.de \
--to=xypron.glpk@gmx.de \
--cc=bmeng.cn@gmail.com \
--cc=cfsworks@gmail.com \
--cc=ilias.apalodimas@linaro.org \
--cc=marek.vasut+renesas@mailbox.org \
--cc=pbrobinson@gmail.com \
--cc=richard.henderson@linaro.org \
--cc=sjg@chromium.org \
--cc=sumit.garg@linaro.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.