From patchwork Thu Oct 6 07:55:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 13000031 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 46109C433FE for ; Thu, 6 Oct 2022 08:06:23 +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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=wNJvjjPSrS8dW9kRowd23CJUGykPhrfhvyxSkRQx7B0=; b=rMist7YRtzLXBh 4oKx26w7TiG6NKvRiv1OYBU9MUZ9euJyugiOlM7AfyBsdk345YNZPIV3DHtmbmYp5+f9gwz7ZFNYt QY48Cdiz2G6cmuLypafNUFOqOTpav2C9M68XFCe8ijQ7McxQboyGJOYVlZhkWWt47T8+Zlys9MbSE 4m9cYjP0br8A+fSoCApoifPTmUJlczNAfzLHp+4HTood6HaBXJEq4x+M8z9A3DyLI1TD9Zi3wYAUe MlGPfAwpcHy9MkZU3YR1/dWi7aX20KI0YRHMkst+sRogj/zlH+8wWbNKD7zxNvMtH19/JKya45ERg eqLNL1iW91f1T/8s6Ocg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ogLso-000abf-7J; Thu, 06 Oct 2022 08:05:30 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ogLse-000aX3-AP for linux-arm-kernel@lists.infradead.org; Thu, 06 Oct 2022 08:05:21 +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 dfw.source.kernel.org (Postfix) with ESMTPS id 6B4166188F; Thu, 6 Oct 2022 08:05:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BFE8AC4347C; Thu, 6 Oct 2022 08:05:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1665043518; bh=fFQNaZ2RLqPaAtkFJag0rwOfiBc5yvWp/CWgrpl1HCA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OytthnZVbgOc8GCwPYORem/9PBnXzM4ld0jpeXCnNWptZpn1/6xMdKoB7kd9SxN3R pFZ86XjViWYhKQ1haiAyIun2om/Zca1N4qnu1XdNdtqFNc22rDoBgx5VvG1O9p1W8f k/I8FsmWWjlCucByuYR0p+wKUrghvhGApLwfw9+sE2BIZnhQV1ZNh5UQz3Hh+uUsBr Eufija/70Xlfd8yjBOiwyv1czID/n/yx9485m88EUuw5CXRJECC8ItC6J2RKK8hxo3 53eDsj83JwmeDF+lpFJnrRpOSgijVHH5WRYTy32/YCtCx+sJK3NmkmAImwAdNQQ4DU GwdokIu0RKcuw== From: Jisheng Zhang To: Catalin Marinas , Will Deacon , Peter Zijlstra , Josh Poimboeuf , Jason Baron , Steven Rostedt , Ard Biesheuvel , Mark Rutland Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] arm64: jump_label: mark arguments as const to satisfy asm constraints Date: Thu, 6 Oct 2022 15:55:41 +0800 Message-Id: <20221006075542.2658-2-jszhang@kernel.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221006075542.2658-1-jszhang@kernel.org> References: <20221006075542.2658-1-jszhang@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221006_010520_416319_EB48E3F6 X-CRM114-Status: GOOD ( 10.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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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." Tested with building a simple external kernel module with "O0". [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" From patchwork Thu Oct 6 07:55:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 13000032 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 5558DC433F5 for ; Thu, 6 Oct 2022 08:06:33 +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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=WtDnh96hJVLut+OypfAxfL1WOgZx6fRB7gQTteMo+U4=; b=HwKeXtdX5Qdv6e YMdBt5YU5MRJ055pYLdpd3MSJ2pdaJD7K4Yl91yX6y8TYLzte1wSpFY6NNEqROMKO7LWJ74x6eFac M6/1PaLY5HP4ZQX5hSvyHOwvKzBdMJDVr7oaQfEX8BUVTcdE2G8PXICLlcDPiRoaQHvON5daj3ZVc T91eXEbKrAwRdn6dPcb/xRnWdUdhXzZztfr3ItG9cniPM3fCFV34MY9EfTRNS3QaaDlK40CsiUFEn ZH8haa00FfKP64jAsqAqZarbpgof3lTcXGmviasotJwKYlgMnXLnR78kFD156zTTx64wBKoZBZYRf YAw8muPIUSfI2Yo8ftMg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ogLsw-000aeJ-Bu; Thu, 06 Oct 2022 08:05:38 +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 1ogLsh-000aYk-Rj for linux-arm-kernel@lists.infradead.org; Thu, 06 Oct 2022 08:05:25 +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 94FC7B81FCF; Thu, 6 Oct 2022 08:05:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 40D81C43142; Thu, 6 Oct 2022 08:05:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1665043521; bh=FRHPtnT6RXzTDlWEaASb9BMb9gXuCOQWF/Rtin4YmmU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TSTomXSeFi/V62uHnwmu+wmfan1lT+N4ClPoCFuEC7a/cOOu43co6UEzLYw2bCTd8 QDbnQUaJhSb/H2I+S5ETP1CbFYU4rHXd7H2Cs3sIZBTcIC7qMhrMm8Zy+APmPTvdT1 rE5POG4SZu9VPcyyzzAmibgp70JnUDfHgL6ZVQPwIFlqn6ivEdQYkzskjWIf8Hbvu4 UL/b+67As+G79Hj9Lo1VaU8/+oKmNaxb87yeZN8XGnbyyvifykGuDQ4eftUsYqxFgf 4CJ3AaRZvQ8PLkma3MiUO7gdT+kenspKI5ol8dGGGrYkgbKHobeEE3Ef6T07mDaAdk 3twnT04m5OELA== From: Jisheng Zhang To: Catalin Marinas , Will Deacon , Peter Zijlstra , Josh Poimboeuf , Jason Baron , Steven Rostedt , Ard Biesheuvel , Mark Rutland Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] arm64: alternative: constify alternative_has_feature_* argument Date: Thu, 6 Oct 2022 15:55:42 +0800 Message-Id: <20221006075542.2658-3-jszhang@kernel.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221006075542.2658-1-jszhang@kernel.org> References: <20221006075542.2658-1-jszhang@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221006_010524_207046_5C7AE7A8 X-CRM114-Status: GOOD ( 13.87 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Inspired by x86 commit 864b435514b2("x86/jump_label: Mark arguments as const to satisfy asm constraints"), constify alternative_has_feature_* argument to satisfy asm constraints. And Steven in [1] also pointed out that "The "i" constraint needs to be a constant." Tested with building a simple external kernel module with "O0". Before the patch, got similar gcc warnings and errors as below: In file included from : In function ‘alternative_has_feature_likely’, inlined from ‘system_capabilities_finalized’ at arch/arm64/include/asm/cpufeature.h:440:9, inlined from ‘arm64_preempt_schedule_irq’ at arch/arm64/kernel/entry-common.c:264:6: include/linux/compiler_types.h:285:33: warning: ‘asm’ operand 0 probably does not match constraints 285 | #define asm_volatile_goto(x...) asm goto(x) | ^~~ arch/arm64/include/asm/alternative-macros.h:232:9: note: in expansion of macro ‘asm_volatile_goto’ 232 | asm_volatile_goto( | ^~~~~~~~~~~~~~~~~ include/linux/compiler_types.h:285:33: error: impossible constraint in ‘asm’ 285 | #define asm_volatile_goto(x...) asm goto(x) | ^~~ arch/arm64/include/asm/alternative-macros.h:232:9: note: in expansion of macro ‘asm_volatile_goto’ 232 | asm_volatile_goto( | ^~~~~~~~~~~~~~~~~ After the patch, the simple external test kernel module is built fine with "-O0". [1]https://lore.kernel.org/all/20210212094059.5f8d05e8@gandalf.local.home/ Signed-off-by: Jisheng Zhang --- arch/arm64/include/asm/alternative-macros.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm64/include/asm/alternative-macros.h b/arch/arm64/include/asm/alternative-macros.h index 3622e9f4fb44..bdf1f6bcd010 100644 --- a/arch/arm64/include/asm/alternative-macros.h +++ b/arch/arm64/include/asm/alternative-macros.h @@ -224,7 +224,7 @@ alternative_endif #include static __always_inline bool -alternative_has_feature_likely(unsigned long feature) +alternative_has_feature_likely(const unsigned long feature) { compiletime_assert(feature < ARM64_NCAPS, "feature must be < ARM64_NCAPS"); @@ -242,7 +242,7 @@ alternative_has_feature_likely(unsigned long feature) } static __always_inline bool -alternative_has_feature_unlikely(unsigned long feature) +alternative_has_feature_unlikely(const unsigned long feature) { compiletime_assert(feature < ARM64_NCAPS, "feature must be < ARM64_NCAPS");