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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A8941C433F5 for ; Wed, 9 Mar 2022 18:27:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date: Message-ID:From:References:Cc:To:Subject:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=iQCFSLzuSIAXIj+Zr7yuJaNZGOFjuqJOLlMxbXqa5+I=; b=OKiAI5zPk4Fo4lB4UGBWt38ZBB EvQNX/phbyJAxrZwlZuySjrhekEF2DdRKYU5xydOQxddTPpwPqwuVJaKwwmYDRlBzCMPUTdp9iBqF 2dQbABGQ7x0ro0bms+HZOYVVpPDRbamxl0IahPSdIEq0+o16fhnT2IEbVd4yds4sWmucBBnB9eypN GOSd2LUi8XMIa63ssUw7fX/IA3LdJ9VTp9jFQPXBLJZrDDJMpS+fjr5AWRdNR24wBYVC/rAdZ1mvg 9xbtQ7oXHwCgBxPQlqtylRishFwOLnP5/jdNPK8ATslxL4a1zCATR97BpI8fxvsM7wKasKA+6F2Rt jeiroakw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nS10s-00A4UJ-OV; Wed, 09 Mar 2022 18:26:18 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nS10o-00A4So-Pf for linux-arm-kernel@lists.infradead.org; Wed, 09 Mar 2022 18:26:16 +0000 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 A28801691; Wed, 9 Mar 2022 10:26:12 -0800 (PST) Received: from [10.1.196.218] (eglon.cambridge.arm.com [10.1.196.218]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A44453F7F5; Wed, 9 Mar 2022 10:26:11 -0800 (PST) Subject: Re: [PATCH] arm64: Paper over ARM_SMCCC_ARCH_WORKAROUND_3 Clang issue To: Nathan Chancellor , Marc Zyngier Cc: linux-arm-kernel@lists.infradead.org, kernel-team@android.com, Nick Desaulniers , Will Deacon , Catalin Marinas , llvm@lists.linux.dev References: <20220309155716.3988480-1-maz@kernel.org> From: James Morse Message-ID: <70b5df18-efd3-4fca-7f08-a2de0ebae060@arm.com> Date: Wed, 9 Mar 2022 18:26:07 +0000 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-GB X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220309_102614_921171_6A1FB245 X-CRM114-Status: GOOD ( 19.46 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Nathan, On 09/03/2022 17:50, Nathan Chancellor wrote: > On Wed, Mar 09, 2022 at 10:11:18AM -0700, Nathan Chancellor wrote: >> On Wed, Mar 09, 2022 at 03:57:16PM +0000, Marc Zyngier wrote: >>> Compiling the arm64 kernel with the BHB workarounds and Clang+LTO >>> results in a bunch of: >>> >>> :4:2: error: invalid fixup for movz/movk instruction >>> mov w0, #ARM_SMCCC_ARCH_WORKAROUND_3 >>> >>> when compiling arch/arm64/kernel/entry.S, and makes no sense at all. >>> >>> As it turns out, moving a single include line around makes the >>> problem disappear. Why, you'd ask? Well, I don't have the faintest >>> idea, and I'm running out of patience. So make of that what you want. [...] > CONFIG_LTO=y causes the following include chain: > > include/linux/arm-smccc.h > include/linux/init.h > include/linux/compiler.h > arch/arm64/include/asm/rwonce.h Gah, a header file that does something completely different under LTO! > arch/arm64/include/asm/alternative-macros.h > arch/arm64/include/asm/assembler.h > > assembler.h has the use of ARM_SMCCC_ARCH_WORKAROUND_3 but the init.h > include in arm-smccc.h happens before the definition, so it does not get > expanded. Thanks for getting to the bottom of this! The error message had me stumped. ... > This diff seems like a somewhat proper solution, as __READ_ONCE() cannot > be used in assembly, but I am open to other suggestions. > > diff --git a/arch/arm64/include/asm/rwonce.h b/arch/arm64/include/asm/rwonce.h > index 1bce62fa908a..56f7b1d4d54b 100644 > --- a/arch/arm64/include/asm/rwonce.h > +++ b/arch/arm64/include/asm/rwonce.h > @@ -5,7 +5,7 @@ > #ifndef __ASM_RWONCE_H > #define __ASM_RWONCE_H > > -#ifdef CONFIG_LTO > +#if defined(CONFIG_LTO) && !defined(__ASSEMBLY__) > > #include > #include > @@ -66,7 +66,7 @@ > }) > > #endif /* !BUILD_VDSO */ > -#endif /* CONFIG_LTO */ > +#endif /* CONFIG_LTO && !__ASSEMBLY__ */ > > #include This looks like the smallest/cleanest fix. Acked-by: James Morse I guess ultimately we should split things like arm-smccc.h into multiple files... Thanks, James _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel