From: Tom Rini <trini@konsulko.com>
To: Heinrich Schuchardt <xypron.glpk@gmx.de>
Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>,
U-Boot Mailing List <u-boot@lists.denx.de>
Subject: Re: qemu_arm_defconfig with LTO fails due to unaligned access
Date: Wed, 8 Mar 2023 11:18:32 -0500 [thread overview]
Message-ID: <20230308161832.GF968799@bill-the-cat> (raw)
In-Reply-To: <783cfab5-feb0-1148-f4be-125195275c98@gmx.de>
[-- Attachment #1: Type: text/plain, Size: 2310 bytes --]
On Wed, Mar 08, 2023 at 05:12:26AM +0100, Heinrich Schuchardt wrote:
> 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.
Interesting, yes. It seems like it shouldn't be too hard to come up with
a condensed example where the assembly function isn't used but instead
the weak C function is.
And as a work-around, re-doing the code so that path_to_uefi() just
checks for ARM && !ARM64 before calling allow_unaligned() and not doing
the weak function trick should also be fine.
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
next prev parent reply other threads:[~2023-03-08 16:18 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2023-03-08 19:19 ` Heinrich Schuchardt
2023-03-08 19:28 ` 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=20230308161832.GF968799@bill-the-cat \
--to=trini@konsulko.com \
--cc=ilias.apalodimas@linaro.org \
--cc=u-boot@lists.denx.de \
--cc=xypron.glpk@gmx.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox