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 10882C433FE for ; Thu, 6 Oct 2022 08:57:10 +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=xsd1g5TSUZKaz5A/+98HNWHUW4ZsCR4eJeisYNRoEWE=; b=mZVY8CEYNiv1jG dOIhRCsGVNcncWJVzKTab74go9HLWnJJAvZwsh9kxRrY+pE7IJimXeq1d1+pfr56zZIsYfLII0oYe 2iwrs/7zVadrbd+q/W78je3vHQ9tS4eoiWgssTPRlG/7Z1l2sHprY1OWw+NFtjDMFYV1t/K/iMUrN pkGhvrsfNu5rRfW/229d/wZrniUIf1ZERvRjbeej+piT8dTnVXqfqBJmMiyuuSio63t+AYL+23OFW QzZ0IsGg2lATmpfJtAc1Pl3CgqNbNbY14tJfRlhmpe85oc10+/pUmz+eRMmDXfLdA8bVfblLGLX6l utRxLSd43AtWg3EHyTmw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ogMfd-000sq2-AB; Thu, 06 Oct 2022 08:55:57 +0000 Received: from ams.source.kernel.org ([2604:1380:4601:e00::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ogMfZ-000snZ-2B for linux-arm-kernel@lists.infradead.org; Thu, 06 Oct 2022 08:55:54 +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 B5800B82019; Thu, 6 Oct 2022 08:55:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2D5CEC433C1; Thu, 6 Oct 2022 08:55:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1665046550; bh=qNPy7O4a2ng4QSgRXiEuq8JWOo4xfUpTONGHO5BvBO8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=YJgXaOXARM923FQWMOOuF3sz2rkCLwE/ECZZUXor1XGKISeZQoOqaWpn9vv7qA3Hm gq+UaV0r4mRfioJ1xyM9+GYZK5fCc4PZnMwZQJuq8rLKX+R8F0MkmxJruBbuVKMzja HuSceZiemWTlX+cHWKnQp8EeSJisoe9qnxOGuJT+tctszZTidJLfKYKY3uIwy3eu4O DSlmL4lmj942H1bM1aJvfdjkdpBqUkTwVFL1i+i1HzTsta+fz/s4uNG9PKqiA+yioU 7lRqDBJ+uD/ZJUDgBOH5bW+4DhGevZQBeJtG0x12CZwCKGz1K1rfe7E9gW35AJT+NA MOwT5wFgN+HZw== Date: Thu, 6 Oct 2022 16:46:16 +0800 From: Jisheng Zhang To: Ard Biesheuvel Cc: Catalin Marinas , Will Deacon , Peter Zijlstra , Josh Poimboeuf , Jason Baron , Steven Rostedt , Mark Rutland , 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_015553_410671_843F1DB8 X-CRM114-Status: GOOD ( 22.15 ) 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 10:17:44AM +0200, Ard Biesheuvel wrote: > On Thu, 6 Oct 2022 at 10:05, 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." > > > > 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" > > Is this still necessary if we specify the constraints in a more > reasonable manner: > > " .quad %c0 - . + %1 \n\t" > : : "i"(key), "i"(branch) : : l_yes); Just tried this locally with the simple external kernel module, the asm operand 0 probably does not match constraints can still be reproduced with "O0". Thanks > > instead of the horrid hack with the char* cast and using a bool as an > array index? > > > > > > @@ -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 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0647BC433FE for ; Thu, 6 Oct 2022 08:56:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231263AbiJFIz6 (ORCPT ); Thu, 6 Oct 2022 04:55:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231255AbiJFIzz (ORCPT ); Thu, 6 Oct 2022 04:55:55 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6EDCF97D4D for ; Thu, 6 Oct 2022 01:55:53 -0700 (PDT) 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 C8797B8204A for ; Thu, 6 Oct 2022 08:55:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2D5CEC433C1; Thu, 6 Oct 2022 08:55:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1665046550; bh=qNPy7O4a2ng4QSgRXiEuq8JWOo4xfUpTONGHO5BvBO8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=YJgXaOXARM923FQWMOOuF3sz2rkCLwE/ECZZUXor1XGKISeZQoOqaWpn9vv7qA3Hm gq+UaV0r4mRfioJ1xyM9+GYZK5fCc4PZnMwZQJuq8rLKX+R8F0MkmxJruBbuVKMzja HuSceZiemWTlX+cHWKnQp8EeSJisoe9qnxOGuJT+tctszZTidJLfKYKY3uIwy3eu4O DSlmL4lmj942H1bM1aJvfdjkdpBqUkTwVFL1i+i1HzTsta+fz/s4uNG9PKqiA+yioU 7lRqDBJ+uD/ZJUDgBOH5bW+4DhGevZQBeJtG0x12CZwCKGz1K1rfe7E9gW35AJT+NA MOwT5wFgN+HZw== Date: Thu, 6 Oct 2022 16:46:16 +0800 From: Jisheng Zhang To: Ard Biesheuvel Cc: Catalin Marinas , Will Deacon , Peter Zijlstra , Josh Poimboeuf , Jason Baron , Steven Rostedt , Mark Rutland , 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-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 06, 2022 at 10:17:44AM +0200, Ard Biesheuvel wrote: > On Thu, 6 Oct 2022 at 10:05, 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." > > > > 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" > > Is this still necessary if we specify the constraints in a more > reasonable manner: > > " .quad %c0 - . + %1 \n\t" > : : "i"(key), "i"(branch) : : l_yes); Just tried this locally with the simple external kernel module, the asm operand 0 probably does not match constraints can still be reproduced with "O0". Thanks > > instead of the horrid hack with the char* cast and using a bool as an > array index? > > > > > > @@ -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 > >