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 B3F98C433FE for ; Thu, 6 Oct 2022 12:04:42 +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:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=jQ3UDiZWbBI4Ka6Aa48l5CyBxVnu4TBqT3phXe6I5Ug=; b=HL4Vh5vEHazlSL 8w8IbVqWWzQX17ZS8C2g/SBmS4BYMciv3GZ/2RZpRjZtJI64InvV7wzHKCwa00zU7TAcPsVAGaV+j M0okhxCuYeaXNQaeVPY6cC54K5Z8SP0c6HtWoVfRSQcnxKL8wMDfr3AdsX8sGxabiDTt7lQkuAzzz vped4HCouQKUh4OH/H4vnhGls95KouwAQfGrArTmDT/+0oSrWHdVXnUEfzhxZ7n94s0unTz24k5Ti h8zgFMT41jbAgWFqqOERhZMC+06mswODitjJ+ykT1gRKEV2Ym2AGvOpVmEmkg5+4EEr/AOoYsy0C/ RdFaMSc93rFeXXE/AhPA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ogPbI-0027nA-5J; Thu, 06 Oct 2022 12:03:40 +0000 Received: from ams.source.kernel.org ([145.40.68.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ogPbE-0027ks-Q3 for linux-arm-kernel@lists.infradead.org; Thu, 06 Oct 2022 12:03:38 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 37D1FB8206F; Thu, 6 Oct 2022 12:03:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 88665C433C1; Thu, 6 Oct 2022 12:03:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1665057814; bh=a8/cEVaLUOgGQJ3COrAs5k+ZjXA5Lp0LYvYgEbdpL1w=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=TVCBmKrs/1cuMquu+VNDu0QXjZUaZRCueZbOeRX4vOKOp68VD1WAfItjGPaNE17WJ sG2qBeuau1r3SAptALzHOPJH3GVq70kEORriYIiQKzJdCArS+HaOPFgTu1VOiiY2MW KCP6YC4EQkoBQwjwbJJbt2rW+AwFKzH1jMNDupN/XtWIQ8EM6HXoz1E1HMCKl8l3Vw O40qWgyrDhwvLPNsN2Gsajl5t6v5UQs5gHtu9HMbx/IlnKZNVQJByxUPAEagTfc8o9 20nzvkonLvM9SUV8M3trh2v5LHehVL6/f0EDolqZ4TPRQj5kRqcAcHszL7s7f6iR9v TfRHB5o0FHd5g== Date: Thu, 6 Oct 2022 19:53:59 +0800 From: Jisheng Zhang To: Mark Rutland Cc: Catalin Marinas , Will Deacon , Peter Zijlstra , Josh Poimboeuf , Jason Baron , Steven Rostedt , Ard Biesheuvel , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] arm64: jump_label: mark arguments as const to satisfy asm constraints Message-ID: References: <20221006075542.2658-1-jszhang@kernel.org> <20221006075542.2658-2-jszhang@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221006_050337_151878_89072C33 X-CRM114-Status: GOOD ( 30.64 ) 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 On Thu, Oct 06, 2022 at 11:14:42AM +0100, Mark Rutland wrote: > On Thu, Oct 06, 2022 at 03:55:41PM +0800, Jisheng Zhang wrote: > > Inspired by x86 commit 864b435514b2("x86/jump_label: Mark arguments as > > const to satisfy asm constraints"), mark arch_static_branch()'s and > > arch_static_branch_jump()'s arguments as const to satisfy asm > > constraints. And Steven in [1] also pointed out that "The "i" > > constraint needs to be a constant." > > It needs to be a *compile-time constant*, but `const` on a function argument > only ensures that the function can't modify the argument, not that it's a compile-time constant is a subset of `const`. > constant in the caller. > > I think this is a quirk of the optimizer rather than anything else. I dunno compiler internals, just tried as commit 864b435514b2 suggested the issue did disappear. PS: I agree with you about this is a quirk or workaround. > > > Tested with building a simple external kernel module with "O0". > > Is building with `-O0` supported? I thought we required using `-O2` or above > for a bunch of code that requires constant propagation, etc. Per the information of Jason's reply in [1]: the reason tring O0/O1 is "to play around with GCC's new static analyzer options". While the reason I constify the arguments is that: in riscv world, even the "-Os" can also reproduce the warnings and errors[2]. Grepping source found arm64 also shares the same style, so these two patches. [2]https://lore.kernel.org/linux-riscv/20220922060958.44203-1-samuel@sholland.org/ > > I don't really have a problem with making this const, but I don't particularly > want to try to "fix" all the other code that depends on constant propagation to > assemble, and I'm worried this is the canary in the coal mine. IMHO, it's a good idea to constify if the arguments can't be modified. > > Thanks, > Mark. > > > > > [1]https://lore.kernel.org/all/20210212094059.5f8d05e8@gandalf.local.home/ > > > > Signed-off-by: Jisheng Zhang > > --- > > arch/arm64/include/asm/jump_label.h | 8 ++++---- > > 1 file changed, 4 insertions(+), 4 deletions(-) > > > > diff --git a/arch/arm64/include/asm/jump_label.h b/arch/arm64/include/asm/jump_label.h > > index cea441b6aa5d..48ddc0f45d22 100644 > > --- a/arch/arm64/include/asm/jump_label.h > > +++ b/arch/arm64/include/asm/jump_label.h > > @@ -15,8 +15,8 @@ > > > > #define JUMP_LABEL_NOP_SIZE AARCH64_INSN_SIZE > > > > -static __always_inline bool arch_static_branch(struct static_key *key, > > - bool branch) > > +static __always_inline bool arch_static_branch(struct static_key * const key, > > + const bool branch) > > { > > asm_volatile_goto( > > "1: nop \n\t" > > @@ -32,8 +32,8 @@ static __always_inline bool arch_static_branch(struct static_key *key, > > return true; > > } > > > > -static __always_inline bool arch_static_branch_jump(struct static_key *key, > > - bool branch) > > +static __always_inline bool arch_static_branch_jump(struct static_key * const key, > > + const bool branch) > > { > > asm_volatile_goto( > > "1: b %l[l_yes] \n\t" > > -- > > 2.37.2 > > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel