Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935103AbeAOOqG (ORCPT + 1 other); Mon, 15 Jan 2018 09:46:06 -0500 Received: from merlin.infradead.org ([205.233.59.134]:40378 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934836AbeAOOp5 (ORCPT ); Mon, 15 Jan 2018 09:45:57 -0500 Date: Mon, 15 Jan 2018 15:45:39 +0100 From: Peter Zijlstra To: David Woodhouse Cc: Dave Hansen , Ashok Raj , linux-kernel@vger.kernel.org, Thomas Gleixner , Tim Chen , Andy Lutomirski , Linus Torvalds , Greg KH , Andrea Arcangeli , Andi Kleen , Arjan Van De Ven , Dan Williams , Paolo Bonzini , Jun Nakajima , Asit Mallick Subject: Re: [PATCH 3/5] x86/ibrs: Add direct access support for MSR_IA32_SPEC_CTRL Message-ID: <20180115144539.GC2228@hirez.programming.kicks-ass.net> References: <1515720739-43819-1-git-send-email-ashok.raj@intel.com> <1515720739-43819-4-git-send-email-ashok.raj@intel.com> <20180112095148.GP3040@hirez.programming.kicks-ass.net> <1515751748.22302.421.camel@infradead.org> <20180115134500.GB2228@hirez.programming.kicks-ass.net> <1516024762.22147.173.camel@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1516024762.22147.173.camel@infradead.org> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On Mon, Jan 15, 2018 at 02:59:22PM +0100, David Woodhouse wrote: > #define IF_FEATURE(ftr) if (static_cpu_has(ftr)) arch_static_assert,? > > ? ?IF_FEATURE(key) { > ? ? ? ?stuff(); > ? ?} > > There might not be a sane way to do that though. And it's OK to have to > manually annotate the call sites where this is for correctness and not > purely optimisation. Something like: #define if_static_likely(_key) \ if (static_branch_likely(_key) && (arch_static_assert(), true)) should work I think. The thing about static_cpu_has() is that it doesn't use jump_labels but alternatives. I could of course also construct an assert for that, but it needs different things.