Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp639715rwb; Thu, 6 Oct 2022 02:20:55 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4fpxGShiC7x9Z35gXW08NAzDgPlYHf1kULa/EM8FXlfBo1IEnypUZ0kW/AKyJnjS5B4oaH X-Received: by 2002:a17:902:bd46:b0:17e:8ee5:7b61 with SMTP id b6-20020a170902bd4600b0017e8ee57b61mr3686098plx.44.1665048055282; Thu, 06 Oct 2022 02:20:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665048055; cv=none; d=google.com; s=arc-20160816; b=NJv1l0LpENbzWWwuEAJ6jXUwN6LtukiucGnaIloQBymrbxYqdNVvqvotz+EmeY/ZYA z4yHy2A7cTlQaJtS8jMsNadbNfmhgVwKc7iCQ0YS5DX6MHamSKdi39OapacSNQ5y1HFX cp/LRSErWqnx+EmDfvSqABgjuA3cbxzcaozwk/wo+EDqP1FEIq3yJIC6hAilFtEDR92A LbEiBJw4a6tMPNTj8ozDWIb0NL6jaZvRkhLLDjy5QO0QWO/OTUo9tFKYYGDhPcA/R+Bq HXKtcuZ4RYC4weIJjXo1lv8IyyQ3D29H2274rLNnlqsfkLasaH5klO1Hq3sxJNxlVgfX z1oA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=DVIWEiMGPcDTNpeEHoXc8xEXMj8bh5SovOFdQum+fZA=; b=fK799eEln/qD3IxH5RY0RepZ7A03WELrUqjosou/tWUaImi7rdGBq7lfuJ9M3F07Ut yfD58Tb49+I/srhdWJzU/m2lmzE5ZyptelGJz86NgVmObzQwg7rzPMLDV5cP00q3m94U PYMV8sofbDU4N93DaekPNdukq1D3nb2oZ26y/df88hie04S3owmter0d8BGSYmkicnwX MTFKaGt3QvKSyeJSVkZr3lKfApwFNYq505jqlkJCQnb0I346U7tp4n/0u3+q9CvfQPjT FUqii7I0cRBZaHu1zKE+id6v06guSMN7FM3O1XK7OMEurEFykBSw3gLc+Eph1zmIzaz/ R5Yw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jPS6CXjX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d8-20020a17090ad3c800b001fd8713170csi4263089pjw.179.2022.10.06.02.20.32; Thu, 06 Oct 2022 02:20:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jPS6CXjX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231308AbiJFJEo (ORCPT + 99 others); Thu, 6 Oct 2022 05:04:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231313AbiJFJEi (ORCPT ); Thu, 6 Oct 2022 05:04:38 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2404BF0F for ; Thu, 6 Oct 2022 02:04:35 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 85DA5618CA for ; Thu, 6 Oct 2022 09:04:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BFA41C433C1; Thu, 6 Oct 2022 09:04:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1665047073; bh=8/95+/6ABMJ/uxjvKl5XAk6L3AoFggCK8OTm2MLfJOY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=jPS6CXjXu+VZbqVhmUXZ3W/fC74AHDAGMkY7HZugiuNzC97RxxchswmcpvZrOQsY7 mt3zOUTGd2j5jUmTyYkhi1U6+Vhv8yP20TEwxbsQ2E9bJsSEyzf7Gk8inaHJX2TrSq BxRkSLnNnG9ErRRqxzM2G7VsYv3WKfASJEFDB0vRJNGvKtE2gijFuhWXS22e+5PRv6 OhM19Zkjl/RGIzQOFHTEMvx8YPzRB8K6mCR58/3KNIaynjDEWxBL9TMF5iNSnxIIuD ZRYi37haZsHhbldTUmMKeN+xDxrLj8HkzSGlSHcUzOiB0TjkqkTz5vXQ/+C6WLrPzz XaCUb5HFopjEw== Date: Thu, 6 Oct 2022 16:55:00 +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: X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 06, 2022 at 04:46:21PM +0800, Jisheng Zhang wrote: > 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". I mean the "asm operand 0 probably does not match constraints" warning and related error can still be reproduced with "-O0" w/o the series. While after applying the series, I can't reproduce the build warning any more w/ and w/o the above modifications. > > 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 > > >