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 A4CA9C433FE for ; Thu, 6 Oct 2022 08:19:02 +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:Cc:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=LG2moFCqndpX3XQn5ZEWg+u6fORJyKvkH0Z6UgPJl5M=; b=P07uGjuo2CgjxI MWWAhLgJhrQ3oPncckQZYw6+LjX+hMioO9mQfv8CLVPh7pZe6AxfiCiCu31QUF6Lo0uVAkW873uZ4 HxdMnHpfqZXWr+xZX85cQd/CCX6FInolmkOyWGd3phCfGRW0Q6QxwpIewDtBye3bWCRNzR62UnuWZ tLTyZlbV5dtz+j/7r1IbqlpletnAJS9GIIcCaeuy2RDHrAMj9NXyo/mZhwrnCj+m4eUqShuusFw16 066z/SMf63sofrKy3tXApW3ttJwslOXIdDacEm1NC5YHL31ZrFIubWZ6I7C0F6LZoPdHxCejzY+O7 0ImCmz9LtE0tbOP3tFYw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ogM50-000e44-9h; Thu, 06 Oct 2022 08:18:06 +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 1ogM4x-000e1R-04 for linux-arm-kernel@lists.infradead.org; Thu, 06 Oct 2022 08:18:04 +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 3C403B81FDA for ; Thu, 6 Oct 2022 08:17:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C496FC433B5 for ; Thu, 6 Oct 2022 08:17:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1665044277; bh=sPYhHQSN08fPJZJXmiJjpYtAxcNKjsgm0ubxG7uLtzk=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=tI0J0WnfQHk3JuV8Eq24CSgeSDYJv+GEEjqpHDqS4KWNOPgl6e37MMRL1dHqRmAmv IF8oLcgN4nQITykoZuxmIqUEsSouqVUbgoqYcOUQSVeY5K2swQPOlmVZ4la4BYmyA1 DhmuSda7I+L4XV72hbwXnD6I5na8Jba6TLAFtgYnNnth0f8bHtc/LNu1aRB6FVqmKo C0HRW/As50FLmKhowOAzu4lF7+AWM1JBL4UKgSXucMKN8tLa3Ivosfw7k08ORsxIQE tJv2PedMdp5K/Tb2KECjkh6gDp2FO/Smaw3O35V9BHAKhSYYh1hfgZeIRHjXI9urIa it1EW5pIBIUEg== Received: by mail-lj1-f179.google.com with SMTP id bs18so1365092ljb.1 for ; Thu, 06 Oct 2022 01:17:57 -0700 (PDT) X-Gm-Message-State: ACrzQf1Ril+2fOJTDwPvhj+FKDp8DryEXmeransL7LAe1lq2dA9yNlP0 VLMnzGyKRj+Xm30JZBrOimMuZlFn7inZZo1I2JA= X-Google-Smtp-Source: AMsMyM62fsqxdMGVPNXQrsbsP3/xEv3hgBZrQ63BQpH7bLk3B3O1gEJGiImPdYuXk2ns+3ueyE95/quvsAAb50VuxKw= X-Received: by 2002:a2e:b7d5:0:b0:26d:e725:bd35 with SMTP id p21-20020a2eb7d5000000b0026de725bd35mr1193586ljo.69.1665044275730; Thu, 06 Oct 2022 01:17:55 -0700 (PDT) MIME-Version: 1.0 References: <20221006075542.2658-1-jszhang@kernel.org> <20221006075542.2658-2-jszhang@kernel.org> In-Reply-To: <20221006075542.2658-2-jszhang@kernel.org> From: Ard Biesheuvel Date: Thu, 6 Oct 2022 10:17:44 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 1/2] arm64: jump_label: mark arguments as const to satisfy asm constraints To: Jisheng Zhang 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221006_011803_341810_659019D1 X-CRM114-Status: GOOD ( 20.08 ) 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, 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); 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 8C9EDC433F5 for ; Thu, 6 Oct 2022 08:18:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230514AbiJFISH (ORCPT ); Thu, 6 Oct 2022 04:18:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230340AbiJFISE (ORCPT ); Thu, 6 Oct 2022 04:18:04 -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 89E6A77543 for ; Thu, 6 Oct 2022 01:18:00 -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 3A1F3B82037 for ; Thu, 6 Oct 2022 08:17:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D1B29C43140 for ; Thu, 6 Oct 2022 08:17:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1665044277; bh=sPYhHQSN08fPJZJXmiJjpYtAxcNKjsgm0ubxG7uLtzk=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=tI0J0WnfQHk3JuV8Eq24CSgeSDYJv+GEEjqpHDqS4KWNOPgl6e37MMRL1dHqRmAmv IF8oLcgN4nQITykoZuxmIqUEsSouqVUbgoqYcOUQSVeY5K2swQPOlmVZ4la4BYmyA1 DhmuSda7I+L4XV72hbwXnD6I5na8Jba6TLAFtgYnNnth0f8bHtc/LNu1aRB6FVqmKo C0HRW/As50FLmKhowOAzu4lF7+AWM1JBL4UKgSXucMKN8tLa3Ivosfw7k08ORsxIQE tJv2PedMdp5K/Tb2KECjkh6gDp2FO/Smaw3O35V9BHAKhSYYh1hfgZeIRHjXI9urIa it1EW5pIBIUEg== Received: by mail-lj1-f181.google.com with SMTP id s10so1352323ljp.5 for ; Thu, 06 Oct 2022 01:17:57 -0700 (PDT) X-Gm-Message-State: ACrzQf3Woo+d+fkrVa7SXYBjVbrtVQe7n497WET+bHldjYPPqcOZTYtW 9BHIwlCVQE/N40q1jh9aLMw0LJ8qzPnf7W0CCl0= X-Google-Smtp-Source: AMsMyM62fsqxdMGVPNXQrsbsP3/xEv3hgBZrQ63BQpH7bLk3B3O1gEJGiImPdYuXk2ns+3ueyE95/quvsAAb50VuxKw= X-Received: by 2002:a2e:b7d5:0:b0:26d:e725:bd35 with SMTP id p21-20020a2eb7d5000000b0026de725bd35mr1193586ljo.69.1665044275730; Thu, 06 Oct 2022 01:17:55 -0700 (PDT) MIME-Version: 1.0 References: <20221006075542.2658-1-jszhang@kernel.org> <20221006075542.2658-2-jszhang@kernel.org> In-Reply-To: <20221006075542.2658-2-jszhang@kernel.org> From: Ard Biesheuvel Date: Thu, 6 Oct 2022 10:17:44 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 1/2] arm64: jump_label: mark arguments as const to satisfy asm constraints To: Jisheng Zhang 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 Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); 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 >