Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2994237pxb; Fri, 12 Feb 2021 06:45:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJzdYzM597HEod8UusCEDUmyN7gYjFxytRNjtITCCPmcHkCWArXN4Ar6Qu2PsQMT5sQABcn4 X-Received: by 2002:a7b:c08f:: with SMTP id r15mr2986406wmh.113.1613141156882; Fri, 12 Feb 2021 06:45:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613141156; cv=none; d=google.com; s=arc-20160816; b=038NWh8cDof7i/L7q82AbIcCUgt0aqvCuw2UVNsOwB8kECr9j1bixFgd+lu3LwratO qAP7QYYkoPMInCI9TqY9XLcxvysqfP02XESJHr+9RmtEZ/XkLURoa8WANbUGlB0IRnCe VEg3lygrOVlBvdJ104lSvuKYLcefwBlszGNlkTKa2Y3mFOOzGyZ/6D/DZB0Cq7GeHjwi YAC8pywlpRxYQ0oj01rnAi6Zlr4OiZSZkvHOfUOlEdefMzAryCt8LnrLwI47DeGuWJCx f34GfVdIx7Zy5i2Pswuyacf0ier85znSqFXOT2+CH85N3pkYALjSMlMZc9D9B+KDObbL Qttw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=QQ0zdTGVhGd8ygBgjGncL0e/lAwjqpz6e6qa9nga29A=; b=mkim87OLUf8V7aksJN19DKPpOwht2DQwO55cXP01tZI+EXRkjUwYxEMtnFDMFzHWzW 6SQfebwG56QFzizYieFzSTCE2xKkd9BZ7OIUPtovw+F/yliO4arwIGjRLFAyDICAE1TC CaM5JVQlNjb5S6yi10As6uFGWiOwwB8gfQ2ak4VnnwRPvnR8cxfaDlS7SlN3DMssbwWL R0Jahp+N7o/DzWA+l6qofx1eywSirNpS5Mp7iJeoN1WTNL4ryUiFBho0sQjx1uHC1rc2 V8eF7aB/HrD2v85ITmU4+Dhs5Oln6S4WAGMYOgy5OukB50YSRo8eBrHbg4ycXq/gpU8f 7Jgw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g8si6908848edf.49.2021.02.12.06.45.33; Fri, 12 Feb 2021 06:45:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231197AbhBLOlp convert rfc822-to-8bit (ORCPT + 99 others); Fri, 12 Feb 2021 09:41:45 -0500 Received: from mail.kernel.org ([198.145.29.99]:47798 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231148AbhBLOlm (ORCPT ); Fri, 12 Feb 2021 09:41:42 -0500 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5EB6864DD9; Fri, 12 Feb 2021 14:41:01 +0000 (UTC) Date: Fri, 12 Feb 2021 09:40:59 -0500 From: Steven Rostedt To: Jason Gerecke Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Josh Poimboeuf , Jason Baron , Jason Gerecke , Ard Biesheuvel , "x86@kernel.org" Subject: Re: [PATCH] RFC: x86/jump_label: Mark arguments as const to satisfy asm constraints Message-ID: <20210212094059.5f8d05e8@gandalf.local.home> In-Reply-To: <20210211214848.536626-1-jason.gerecke@wacom.com> References: <20210211214848.536626-1-jason.gerecke@wacom.com> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 11 Feb 2021 13:48:48 -0800 Jason Gerecke wrote: > When compiling an external kernel module with `-O0` or `-O1`, the following > compile error may be reported: > > ./arch/x86/include/asm/jump_label.h:25:2: error: impossible constraint in ‘asm’ > 25 | asm_volatile_goto("1:" > | ^~~~~~~~~~~~~~~~~ > > It appears that these lower optimization levels prevent GCC from detecting > that the key/branch arguments can be treated as constants and used as > immediate operands. To work around this, explicitly add the `const` label. Yes this makes sense. The "i" constraint needs to be a constant. Reviewed-by: Steven Rostedt (VMware) -- Steve > > Signed-off-by: Jason Gerecke > Cc: Steven Rostedt > Cc: Ard Biesheuvel > --- > Marked RFC since I'm not familiar with this subsystem or the asm blocks that > are impacted. Extra-close inspection would be appreciated. > > arch/x86/include/asm/jump_label.h | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/arch/x86/include/asm/jump_label.h b/arch/x86/include/asm/jump_label.h > index 06c3cc22a058..7f2006645d84 100644 > --- a/arch/x86/include/asm/jump_label.h > +++ b/arch/x86/include/asm/jump_label.h > @@ -20,7 +20,7 @@ > #include > #include > > -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:" > ".byte " __stringify(STATIC_KEY_INIT_NOP) "\n\t" > @@ -36,7 +36,7 @@ static __always_inline bool arch_static_branch(struct static_key *key, bool bran > 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:" > ".byte 0xe9\n\t .long %l[l_yes] - 2f\n\t"