[PATCH] arm: kirkwood: fix freeze on boot
Tom Rini
trini at konsulko.com
Mon Jun 23 15:48:30 CEST 2025
On Mon, Jun 23, 2025 at 10:08:16AM +0200, Jerome Forissier wrote:
> Commit 6fe50e395080 ("arm: asm/system.h: mrc and mcr need .arm if
> __thumb2__ is not set") is not a proper fix for the LTO link error
> mentioned in its description. It causes 32-bit arm instructions to be
> mixed with thumb instructions, which the Kirkwood SoCs do not support.
> For example, board_init_r() is mostly generated in Thumb-1 mode as
> expected since the build flags contain -mthumb -mthumb-interwork. The
> MCR instruction corresponding to writefr_extra_feature_reg() is also
> correcly emitted as a 32-bit ARM instruction (it cannot be encoded in
> Thumb-1 anyways). The problem is, the compiler inlines the MCR without
> generating the BX or BLX instruction which are needed to transition
> between the ARM and the Thumb-1 states. From the objdump output:
>
> 006186a0 <board_init_r>:
> board_init_r():
> /home/jerome/work/u-boot/common/board_r.c:799
> 6186a0: b5f0 push {r4, r5, r6, r7, lr}
> 6186a2: b0ab sub sp, #172 @ 0xac
> get_gd():
> /home/jerome/work/u-boot/./arch/arm/include/asm/global_data.h:127
> 6186a4: 464a mov r2, r9
> ...
> /home/jerome/work/u-boot/arch/arm/mach-kirkwood/cpu.c:242
> 619aae: 9b15 ldr r3, [sp, #84] @ 0x54
> writefr_extra_feature_reg():
> /home/jerome/work/u-boot/./arch/arm/include/asm/arch/cpu.h:100
> 619ab0: ee2f3f11 mcr 15, 1, r3, cr15, cr1, {0}
> ^^^^^^^^
> 32-bit ARM instruction
>
> Further investigation is needed to understand how to fix the issue so
> that the code size is minimal for all boards. In the mean time, this
> fix disables LTO for the two problematic files (common/board_f.c and
> common/board_r.c). This makes the Kirkwood-based boards bootable again.
> The binary size is increased by 1048 bytes which is perfectly
> acceptable.
>
> Fixes: 6fe50e395080 ("arm: asm/system.h: mrc and mcr need .arm if __thumb2__ is not set")
> Reported-by: Tony Dinh <mibodhi at gmail.com>
> Signed-off-by: Jerome Forissier <jerome.forissier at linaro.org>
> ---
>
> common/Makefile | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/common/Makefile b/common/Makefile
> index 35991562a12..f0b7eadf7d2 100644
> --- a/common/Makefile
> +++ b/common/Makefile
> @@ -19,6 +19,8 @@ obj-y += version.o
> # # boards
> obj-y += board_f.o
> obj-y += board_r.o
> +CFLAGS_REMOVE_board_f.o := $(LTO_CFLAGS)
> +CFLAGS_REMOVE_board_r.o := $(LTO_CFLAGS)
> obj-$(CONFIG_DISPLAY_BOARDINFO) += board_info.o
> obj-$(CONFIG_DISPLAY_BOARDINFO_LATE) += board_info.o
>
I'm sizing checking this now, but we might need a v2 with something
like:
ifeq ($(CONFIG_SYS_THUMB_BUILD),y)
... remove ...
endif
So that we don't grow *everyone* with LTO by 1KiB. I'm checking now how
bad that will go.
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20250623/2b89c9d7/attachment.sig>
More information about the U-Boot
mailing list