Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp25956374rwd; Mon, 3 Jul 2023 03:31:22 -0700 (PDT) X-Google-Smtp-Source: APBJJlECVGeSt2xzcLqJIZMi73R+u+LBiJcSEdYUvZHYjDyQJaqFhAlWfItMIus7AvIaVzYMxySi X-Received: by 2002:a05:6a20:2595:b0:10c:38d3:437c with SMTP id k21-20020a056a20259500b0010c38d3437cmr10283572pzd.58.1688380281692; Mon, 03 Jul 2023 03:31:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688380281; cv=none; d=google.com; s=arc-20160816; b=H1jvSLFsQJXZ/TreXJfkCsbrzi/jSt5Jchl6uLOW1L6RVXod4ZRg3IGvfvzXx5tk2P XtthpztuEcsaj3PAvGFHwHBeVHsaXphLRUQqu+RSaqYapDsQ1R055xC2NlQmdm+KD/sj pkPTR6hhr0fW8SMD7AGMC3BMJ6rvrg7wFD6YhxE/Jp570gS+CLWo+NXZ1dBaIxFTU60p HeDYQ7jNbNOxyalAndbL7kx67D4M+EEqXNWoG1YEBCR6E1XwTpPEn/nBvBQV6siedMB9 MhaCXardmfITwdytg89o9OySL+6GtpDAp3slE5K7AFOaHFv6cj/4yORGJkQPaiQROlow X7xQ== 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=RdvSBzylMqzcgeZCbeq2y3LzSr6cTTZfwrxa9S1F0VI=; fh=S/sFtnMW9meNGabqkJ7+dKv7Q55i/xo0nYsbXTxHkE4=; b=VcvZOQSV9crz1i3UXZOWLcQAaa+WvOxZ3IlOIA/inVZr5gn7WK43fX6IZCXl3+gIgc VDzxxYbP4qmOtsF2yuD35naeefhnETCMw9vb5bhsl5lh6ZvcvMo6UBY+OlBG2o5qsh4G XOnmJFgw/UUcaqNzn5OKkUG6MOwvSfnz5xcoMu6C2z5eniAYsE5VLjKzx17hf7nrpoyZ 102PDWvctHSf9DtE7Glckll0s3V5zM9sgWnP/gBIhYo96Dwf/QFEhFI9EETiQdVuCj1B vt06lFNyGVhv9uCtgJmVnb7E5te/Tgh8UCy398Q9Oms0EfMJrXNEEl4zXOyOEANjGoWE gNRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b="l1r8nJk/"; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c1-20020a63ea01000000b005533d6eb7c9si4283587pgi.284.2023.07.03.03.31.09; Mon, 03 Jul 2023 03:31:21 -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=@infradead.org header.s=desiato.20200630 header.b="l1r8nJk/"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231199AbjGCK2n (ORCPT + 99 others); Mon, 3 Jul 2023 06:28:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229534AbjGCK2l (ORCPT ); Mon, 3 Jul 2023 06:28:41 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5889FBE; Mon, 3 Jul 2023 03:28:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=RdvSBzylMqzcgeZCbeq2y3LzSr6cTTZfwrxa9S1F0VI=; b=l1r8nJk/ekxSCVihjSWivo5+i8 e9fu4b+qujtiOO1HcA00eg2WW2XD4aR9SsRCwszuEFh+NJUx9cpjiZOWVqhJ08TJEk3HnPAATKTSW XctUeu+cTQ4/5hb4aTCqSeQSLKvwWNIh+PqzWqs4PPjZ1wBVxd1LuuyEIYs2+08ZvxE1tMvYJHL0u jBKhkkCTuNZotMTh4xvdWLUHnvkvreZJmAIvLPzb47UvVuHuGTQWNa2GmZ7UM7QQkBETekTt2qqwM 89TsDVd7OxqRPPiqrN23edONltxI3jFNWEsAOn7rp6k5Q62w50xdSr++vS8kMsRbyQnRaYbVdh730 DAmIroQQ==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qGGn2-00A3td-36; Mon, 03 Jul 2023 10:28:17 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 5A36630023F; Mon, 3 Jul 2023 12:28:15 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 35189202A2A17; Mon, 3 Jul 2023 12:28:15 +0200 (CEST) Date: Mon, 3 Jul 2023 12:28:15 +0200 From: Peter Zijlstra To: Waiman Long Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Josh Poimboeuf , Pawan Gupta , Jacob Pan , Len Brown , Jonathan Corbet , "Rafael J . Wysocki" , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, x86@kernel.org, linux-pm@vger.kernel.org, Robin Jarry , Joe Mario Subject: Re: [PATCH v4 1/4] x86/speculation: Add __update_spec_ctrl() helper Message-ID: <20230703102815.GD4253@hirez.programming.kicks-ass.net> References: <20230628022554.1638318-1-longman@redhat.com> <20230628022554.1638318-2-longman@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230628022554.1638318-2-longman@redhat.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE 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 Tue, Jun 27, 2023 at 10:25:51PM -0400, Waiman Long wrote: > Add a new __update_spec_ctrl() helper which is a variant of > update_spec_ctrl() that can be used in a noinstr function. > > Suggested-by: Peter Zijlstra > Signed-off-by: Waiman Long > --- > arch/x86/include/asm/nospec-branch.h | 11 ++++++++++- > 1 file changed, 10 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/include/asm/nospec-branch.h b/arch/x86/include/asm/nospec-branch.h > index 55388c9f7601..1d363fcea207 100644 > --- a/arch/x86/include/asm/nospec-branch.h > +++ b/arch/x86/include/asm/nospec-branch.h > @@ -9,7 +9,7 @@ > > #include > #include > -#include > +#include > #include > #include > #include > @@ -488,6 +488,15 @@ DECLARE_PER_CPU(u64, x86_spec_ctrl_current); > extern void update_spec_ctrl_cond(u64 val); > extern u64 spec_ctrl_current(void); > > +/* > + * This can be used in noinstr function. > + */ > +static __always_inline void __update_spec_ctrl(u64 val) > +{ > + __this_cpu_write(x86_spec_ctrl_current, val); > + native_wrmsrl(MSR_IA32_SPEC_CTRL, val); > +} Should we also use this to implement update_spec_ctrl() ?