From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D3CB0C64EC4 for ; Wed, 8 Mar 2023 19:28:19 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2043385E7B; Wed, 8 Mar 2023 20:28:16 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=konsulko.com header.i=@konsulko.com header.b="Wd99nZ2p"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 44CDE85E7B; Wed, 8 Mar 2023 20:28:14 +0100 (CET) Received: from mail-qt1-x829.google.com (mail-qt1-x829.google.com [IPv6:2607:f8b0:4864:20::829]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id D5DF885E7A for ; Wed, 8 Mar 2023 20:28:10 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=trini@konsulko.com Received: by mail-qt1-x829.google.com with SMTP id c19so19266089qtn.13 for ; Wed, 08 Mar 2023 11:28:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; t=1678303689; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=IfnM9EAWxL34eorqqQ43QroUEIrSoc4UZYDkoJgYh5Q=; b=Wd99nZ2p3CVu8agnsvKnKR+hG1MhZbnck/Gf8DB9WhcJKHwzm2NoJNs7kdmGBsPT3E 1T+zbCdR99J9OtAot8kxmMf0qLQr17Clvnk76qmHLIADNnw4lpPFJYP0xkQf1pk6TWcR Ya46YUjh7zIZWRLgZwGpDbnLTzRTWzMSV4y4E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678303689; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=IfnM9EAWxL34eorqqQ43QroUEIrSoc4UZYDkoJgYh5Q=; b=gQoy6AzR9uduwDVt91XMOCXSsrzfpAIAhJvcLMsuACefipbm/g8LFZRXwED0MRdsJ0 on/Ap5Y3HdyUYfc6YlAkezZCWlSL2ZHp/NWYCu5aNkoJzVBvvv8L0+lH88/bOWfz6u+7 WogD5b/k8q1ifwX0hZGLRuRSePCG69UpZu0lZLfI0EujOhBSvM4M/w9ax2rYWYW3WCD3 LORfr40Dj3Q4pnFeWFhQAf0S6cS6YNkknDjHGz6soTAE+Un4bFdzPUJctZBp2+KCXy9T KuknTx1NZho13oc/V1BzDZnkGYBCtwL9p22Q5Yv2aHgs4MH6nWE9dBpb5YA8H5vmLl/h jazQ== X-Gm-Message-State: AO0yUKVQYK6wEd/XBmPqFgxcajzwAUGPAa8U0MZf7fudILrtc8kMr4LR Reu3V02lREVYHDVhSzQfeHbxsw== X-Google-Smtp-Source: AK7set/Exgkb8s2pMVFbHG1AAG/DFOx1CWrk+tDEaJpvF9lRWGcr/e19GYapYUBuc0SDi5vhuKlFZw== X-Received: by 2002:a05:622a:c:b0:3b9:bc8c:c207 with SMTP id x12-20020a05622a000c00b003b9bc8cc207mr40996576qtw.18.1678303689568; Wed, 08 Mar 2023 11:28:09 -0800 (PST) Received: from bill-the-cat (2603-6081-7b00-6400-0000-0000-0000-036b.res6.spectrum.com. [2603:6081:7b00:6400::36b]) by smtp.gmail.com with ESMTPSA id w25-20020a05620a129900b0073ba211e765sm11911183qki.19.2023.03.08.11.28.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Mar 2023 11:28:09 -0800 (PST) Date: Wed, 8 Mar 2023 14:28:07 -0500 From: Tom Rini To: Heinrich Schuchardt Cc: Ilias Apalodimas , U-Boot Mailing List Subject: Re: qemu_arm_defconfig with LTO fails due to unaligned access Message-ID: <20230308192807.GI968799@bill-the-cat> References: <783cfab5-feb0-1148-f4be-125195275c98@gmx.de> <20230308161832.GF968799@bill-the-cat> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="ZbxTmPE6oVWeeQDh" Content-Disposition: inline In-Reply-To: X-Clacks-Overhead: GNU Terry Pratchett X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean --ZbxTmPE6oVWeeQDh Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Mar 08, 2023 at 08:19:32PM +0100, Heinrich Schuchardt wrote: >=20 >=20 > Am 8. M=E4rz 2023 17:18:32 MEZ schrieb Tom Rini : > >On Wed, Mar 08, 2023 at 05:12:26AM +0100, Heinrich Schuchardt wrote: > >> Hello Ilias, hello Tom, > >>=20 > >> Tom tried to run qemu_arm_defconfig with CONFIG_LTO=3Dy in gitlab. This > >> failed as shown in protocol > >> https://source.denx.de/u-boot/u-boot/-/jobs/589913/raw > >>=20 > >> 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 .. > >>=20 > >> Debugging shows: > >>=20 > >> 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 =3D 0. > >>=20 > >> When the crash occurs SCRLR has value 0xc5187f. SCTLR.A is bit 1 with > >> value 1. > >>=20 > >> 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 #err= or > >> to the code). > >>=20 > >> If I remove the weak implementation of allow_unaligned() in > >> lib/efi_loader/efi_setup.c, the error does not occur. > >>=20 > >> Shouldn't building with LTO ignore the weak implementation? > >>=20 > >> If I add a printf() statement to the weak implemenation, the printf() > >> command is not executed but > >>=20 > >> SCTLR 0xc5187d, SCTLR.A=3D0 > >>=20 > >> The test passes as unaligned access is allowable. > >>=20 > >> I was building inside the Docker image with the GCC downloaded by > >> buildman (gcc-12.2.0-nolibc/arm-linux-gnueabi). > >>=20 > >> 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. > > >=20 > We have more places in our code using weak functions. There many cases no= t covered by CI. >=20 > Just looking at EFI may not be adequate. Yes, there's a more general issue with weak functions where the non-weak version is in assembly rather than C. I think we've addressed those already, however, but it's good to note and should probably get documented. --=20 Tom --ZbxTmPE6oVWeeQDh Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQGzBAABCgAdFiEEGjx/cOCPqxcHgJu/FHw5/5Y0tywFAmQI4b0ACgkQFHw5/5Y0 tyxpMgwAkbOvzxfd90MPMg9PAsuXl7QNA+RTNj645f/m31fDMfnThAN0h1jL06CA 6RzHLNnnG2HS32udNtj0gpl/qOZjZhGcnoN3MOAwmHhDo5bLv2ZmGSGNR9jKeCmO JVLKExypDgl6vMWykUsPrGLXOox2H2AQ54/YBAQ7N5KDXSChpUmbiAQixUxcSTcZ qBTXtRSRSwXRNzxXswUd4KOcziWQlntSytvR9/3mi4tEHK4vSYLlSfNHuaE+a9Le vZ8Y3KUY06JZVHj1BYmh2jB5Uq8M+FVT/pQvrRhCim7OKrE5UhBHgLRERw6l+xBA 3z1M1b/jPCCKGFfgkSLAIeQP7ClIMEoiVXcn2ipf9gnVgtpad9+hfj6P2iF7olMq xNRqDUNO/z/tg5WpiAlkyOnRAVkbwfXSXOJNu4DpfBQOQWYBbBLawfQTzZHC4LFZ DfLg2Ol5bg5C0eVaHU9jDX7yNDwW/snZEToVKpQDnywtAmhFNXVlI+2WYopbL5+3 5aaayzFH =zVGa -----END PGP SIGNATURE----- --ZbxTmPE6oVWeeQDh--