public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* qemu_arm_defconfig with LTO fails due to unaligned access
@ 2023-03-08  4:12 Heinrich Schuchardt
  2023-03-08 14:03 ` Ilias Apalodimas
  2023-03-08 16:18 ` Tom Rini
  0 siblings, 2 replies; 5+ messages in thread
From: Heinrich Schuchardt @ 2023-03-08  4:12 UTC (permalink / raw)
  To: Ilias Apalodimas, Tom Rini; +Cc: U-Boot Mailing List

Hello Ilias, hello Tom,

Tom tried to run qemu_arm_defconfig with CONFIG_LTO=y in gitlab. This
failed as shown in protocol
https://source.denx.de/u-boot/u-boot/-/jobs/589913/raw

Executing 'HII database protocols'
test_hii_database_new_package_list:
data abort
pc : [<7ff39b98>]          lr : [<7ff87328>]
reloc pc : [<00000b98>]    lr : [<0004e328>]
sp : 7edf8cc0  ip : 0000000c     fp : 7ffe60ec
r10: 00000000  r9 : 7eef8eb0     r8 : 7ffe0d02
r7 : 00000000  r6 : 7ef0f8c8     r5 : 7ffe0cf0  r4 : 7ffe0cb4
r3 : 7ffe0cef  r2 : 00000000     r1 : ffffffff  r0 : 00000000
Flags: nzcv  IRQs off  FIQs off  Mode SVC_32
Code: e2403002 e3a00000 e1500001 012fff1e (e1f320b2)
UEFI image [0x00000000:0xffffffff] '/\selftest'
Resetting CPU ..

Debugging shows:

efi_hii_sibt_string_ucs2_block_next() calls u16_strnlen() for an
unaligned u16 string. Here "ldrh r2, [r3, #2]!" is executed for
unaligned r3. This should be allowable for SCTLR.A = 0.

When the crash occurs SCRLR has value 0xc5187f. SCTLR.A is bit 1 with
value 1.

The implementation of allow_unaligned() in
arch/arm/cpu/armv7 /sctlr.S should have set the flag to 0.
arch/arm/cpu/armv7/sctlr.S is compiled (as demonstrated by adding #error
to the code).

If I remove the weak implementation of allow_unaligned() in
lib/efi_loader/efi_setup.c, the error does not occur.

Shouldn't building with LTO ignore the weak implementation?

If I add a printf() statement to the weak implemenation, the printf()
command is not executed but

SCTLR 0xc5187d, SCTLR.A=0

The test passes as unaligned access is allowable.

I was building inside the Docker image with the GCC downloaded by
buildman (gcc-12.2.0-nolibc/arm-linux-gnueabi).

To me this looks like a compiler issue.

Best regards

Heinrich

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-03-08 19:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-08  4:12 qemu_arm_defconfig with LTO fails due to unaligned access Heinrich Schuchardt
2023-03-08 14:03 ` Ilias Apalodimas
2023-03-08 16:18 ` Tom Rini
2023-03-08 19:19   ` Heinrich Schuchardt
2023-03-08 19:28     ` Tom Rini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox