Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_2 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8E87FC4338F for ; Mon, 16 Aug 2021 11:34:22 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id EC4EC61CF3 for ; Mon, 16 Aug 2021 11:34:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org EC4EC61CF3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2553882F2B; Mon, 16 Aug 2021 13:34:20 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id AFA3382F2B; Mon, 16 Aug 2021 13:34:18 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id 8675882E7D for ; Mon, 16 Aug 2021 13:34:13 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=andre.przywara@arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E0D4E6D; Mon, 16 Aug 2021 04:34:12 -0700 (PDT) Received: from slackpad.fritz.box (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 494AA3F40C; Mon, 16 Aug 2021 04:34:12 -0700 (PDT) Date: Mon, 16 Aug 2021 12:34:06 +0100 From: Andre Przywara To: Samuel Holland Cc: Tom Rini , u-boot@lists.denx.de, Jagan Teki Subject: Re: [PATCH] ARM: Prevent the compiler from using NEON registers Message-ID: <20210816123406.7f02b1cd@slackpad.fritz.box> In-Reply-To: <20210816031437.15856-1-samuel@sholland.org> References: <20210816031437.15856-1-samuel@sholland.org> Organization: Arm Ltd. X-Mailer: Claws Mail 3.17.1 (GTK+ 2.24.31; x86_64-slackware-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.2 at phobos.denx.de X-Virus-Status: Clean On Sun, 15 Aug 2021 22:14:37 -0500 Samuel Holland wrote: Hi, in general I think the patch makes sense, and we should use that option since we also specify -msoft-float. > For ARMv8-A, NEON is standard, It should be noted that the ARMv8-A architecture itself treats FP and AdvSIMD as optional, and little cores like Cortex-A53 make this even an integration option [1]. This also gives another reason for this patch, as we cannot assume NEON support for *every* core we are compiling for (even though most A53s out there seem to include NEON). Anyway GCC decides to include both +fp and +simd when the basic (and probably default) "armv8-a" is used for -march [2], so we must indeed restrict it explicitly, when we want to avoid it. [1]https://developer.arm.com/documentation/ddi0500/j/Introduction/Implementation-options [2]https://gcc.gnu.org/onlinedocs/gcc/AArch64-Options.html -march=name > so the compiler can use it even when no > special target flags are provided. For example, it can use stores from > NEON registers to zero-initialize large structures. GCC 11 decides to > do this inside the DRAM init code for the Allwinner H6, which breaks > boot on that platform, as NEON is not available in SPL. And that brings up the question: why? The Cortex cores in all Allwinner SoCs support NEON, and we always clear CPTR_EL3 in start.S, so it should be usable. So I did some experiments, and I guess it's our old friend "unaligned access" again, because SIMD instructions themselves work (movi, str q0). But the SPL runs with the MMU off, so everything is device memory, and natural alignment is mandatory, even with SCTLR.A cleared. "stp q0, q0, [x0]" worked when x0 was 16 bytes aligned, but hang when it was not. The same applied to "stur q0, [x0]", which is used with an unaligned offset in the generated code (https://tpaste.us/qPEw). So this deserves some more research, for instance to find out if GCC ignores -mstrict-align here? Cheers, Andre > Fix this by > restricting the compiler to using GPRs only, not vector registers. > > Signed-off-by: Samuel Holland > --- > arch/arm/config.mk | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/arch/arm/config.mk b/arch/arm/config.mk > index 16c63e12667..964c6b026ec 100644 > --- a/arch/arm/config.mk > +++ b/arch/arm/config.mk > @@ -25,6 +25,7 @@ endif > > PLATFORM_RELFLAGS += -fno-common -ffixed-r9 > PLATFORM_RELFLAGS += $(call cc-option, -msoft-float) \ > + $(call cc-option,-mgeneral-regs-only) \ > $(call cc-option,-mshort-load-bytes,$(call cc-option,-malignment-traps,)) > > # LLVM support