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 65522C433FE for ; Thu, 29 Sep 2022 17:34:30 +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-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=kuxrbc/EQGcvFKtIKX+O/Jepf1pr3lPdYzAZ38m6cOI=; b=U9/tTzDFnp6u6q UJCHnIVy2UT58u/fgpy9wT4SNTZUgGCd77Xbxjo1ps04x7INDY/NHDCL2wn0ZfRIi/GVAP+PCjyPe nhZ1tr2xETQXHFS36B3zFkBqIL4Vdohb4byodcwA2R5DTE45U8yIU14LtlKcBHnDlhYhyQxTUjAi6 xOfpUO5VyvTHIIjwx+27AhW/j/m1oSR3R3cRm9eVfSwnNkLvPtbPgpJ0flrQgtneoGoWO0/4jmibl HorIiZtQyYNX3ylRxhnrlsjArgkWeczGJfJ97jAuHVKbpv7TwlF7r3rtyD2lWm1zhuhlxMElTNg14 fK6d4dtbrsh4wY744AVw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1odxPa-004drV-Ng; Thu, 29 Sep 2022 17:33:26 +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 1odxPW-004dps-SG for linux-arm-kernel@lists.infradead.org; Thu, 29 Sep 2022 17:33:25 +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 9E31615BF; Thu, 29 Sep 2022 10:33:25 -0700 (PDT) Received: from [10.57.65.170] (unknown [10.57.65.170]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E5BFE3F73B; Thu, 29 Sep 2022 10:33:17 -0700 (PDT) Message-ID: <9fc378c7-2d0b-9716-9067-0e87e9ca4cd8@arm.com> Date: Thu, 29 Sep 2022 18:33:05 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:102.0) Gecko/20100101 Thunderbird/102.3.0 Subject: Re: [PATCH] arm64: fix the build with binutils 2.27 Content-Language: en-GB To: Mark Rutland , linux-arm-kernel@lists.infradead.org Cc: ardb@kernel.org, catalin.marinas@arm.com, jonathanh@nvidia.com, will@kernel.org References: <20220929150227.1028556-1-mark.rutland@arm.com> From: Robin Murphy In-Reply-To: <20220929150227.1028556-1-mark.rutland@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220929_103323_035308_90011A2D X-CRM114-Status: GOOD ( 25.44 ) 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-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 2022-09-29 16:02, Mark Rutland wrote: > Jon Hunter reports that for some toolchains the build has been broken > since commit: > > 4c0bd995d73ed889 ("arm64: alternatives: have callbacks take a cap") > > ... with a stream of build-time splats of the form: > > | CC arch/arm64/kvm/hyp/vhe/debug-sr.o > | /tmp/ccY3kbki.s: Assembler messages: > | /tmp/ccY3kbki.s:1600: Error: found 'L', expected: ')' > | /tmp/ccY3kbki.s:1600: Error: found 'L', expected: ')' > | /tmp/ccY3kbki.s:1600: Error: found 'L', expected: ')' > | /tmp/ccY3kbki.s:1600: Error: found 'L', expected: ')' > | /tmp/ccY3kbki.s:1600: Error: junk at end of line, first unrecognized character > | is `L' > | /tmp/ccY3kbki.s:1723: Error: found 'L', expected: ')' > | /tmp/ccY3kbki.s:1723: Error: found 'L', expected: ')' > | /tmp/ccY3kbki.s:1723: Error: found 'L', expected: ')' > | /tmp/ccY3kbki.s:1723: Error: found 'L', expected: ')' > | /tmp/ccY3kbki.s:1723: Error: junk at end of line, first unrecognized character > | is `L' > | scripts/Makefile.build:249: recipe for target > | 'arch/arm64/kvm/hyp/vhe/debug-sr.o' failed > > The issue here is that older versions of binutils (up to and including > 2.27.0) don't like an 'L' suffix on constants. For plain assembly files, > UL() avoids this suffix, but in C files this gets added, and so for > inline assembly we can't directly use a constant defined with `UL()`. > > We could avoid this by passing the constant as an input parameter, but > this isn't practical given the way we use the alternative macros. > Instead, just open code the constant without the `UL` suffix, and for > consistency do this for both the inline assembly macro and the regular > assembly macro. Couldn't we just remove the UL() and avoid inconsistently open-coding anything? TBH I fail to see why it's there in the first place - 1 << 15 is well within the range of int on arm64, and I don't see ARM64_CB_BIT being used in any wider arithmetic anywhere either :/ Thanks, Robin. > Signed-off-by: Mark Rutland > Fixes: 4c0bd995d73ed889 ("arm64: alternatives: have callbacks take a cap") > Reported-by: Jon Hunter > Link: https://lore.kernel.org/linux-arm-kernel/3cecc3a5-30b0-f0bd-c3de-9e09bd21909b@nvidia.com/ > Tested-by: Jon Hunter > Cc: Ard Biesheuvel > Cc: Catalin Marinas > Cc: Will Deacon > --- > arch/arm64/include/asm/alternative-macros.h | 12 +++++++++--- > 1 file changed, 9 insertions(+), 3 deletions(-) > > diff --git a/arch/arm64/include/asm/alternative-macros.h b/arch/arm64/include/asm/alternative-macros.h > index 966767debaa3..b5ac0b85c9bb 100644 > --- a/arch/arm64/include/asm/alternative-macros.h > +++ b/arch/arm64/include/asm/alternative-macros.h > @@ -2,12 +2,18 @@ > #ifndef __ASM_ALTERNATIVE_MACROS_H > #define __ASM_ALTERNATIVE_MACROS_H > > +#include > #include > > #include > #include > > -#define ARM64_CB_BIT (UL(1) << 15) > +/* > + * Binutils 2.27.0 can't handle a 'UL' suffix on constants, so for the assembly > + * macros below we must use we must use `(1 << ARM64_CB_SHIFT)`. > + */ > +#define ARM64_CB_SHIFT 15 > +#define ARM64_CB_BIT BIT(ARM64_CB_SHIFT) > > #if ARM64_NCAPS >= ARM64_CB_BIT > #error "cpucaps have overflown ARM64_CB_BIT" > @@ -80,7 +86,7 @@ > __ALTERNATIVE_CFG(oldinstr, newinstr, feature, IS_ENABLED(cfg)) > > #define ALTERNATIVE_CB(oldinstr, feature, cb) \ > - __ALTERNATIVE_CFG_CB(oldinstr, ARM64_CB_BIT | (feature), 1, cb) > + __ALTERNATIVE_CFG_CB(oldinstr, (1 << ARM64_CB_SHIFT) | (feature), 1, cb) > #else > > #include > @@ -150,7 +156,7 @@ > .macro alternative_cb cap, cb > .set .Lasm_alt_mode, 0 > .pushsection .altinstructions, "a" > - altinstruction_entry 661f, \cb, ARM64_CB_BIT | \cap, 662f-661f, 0 > + altinstruction_entry 661f, \cb, (1 << ARM64_CB_SHIFT) | \cap, 662f-661f, 0 > .popsection > 661: > .endm _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel