Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp1065911rdb; Sat, 7 Oct 2023 10:11:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGk9RoOPdz1+65mrJDDWO6OMTo7Xe4UkspcIq1AZ4GWWT4PmfN1aaaLJLOgKuE4qVCb0oJB X-Received: by 2002:a05:6358:4291:b0:143:8601:54d with SMTP id s17-20020a056358429100b001438601054dmr10237305rwc.2.1696698695736; Sat, 07 Oct 2023 10:11:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696698695; cv=none; d=google.com; s=arc-20160816; b=AHDEplGAEJ8rYhPXjdYVa6CA13lNGoTNj+yucgKf9XocTweUvbOEboRmBiJ9Gnh7nS fUsuxlQpf5Zn5PQ0Q6thOqyd75ojQs+08Qzy4ibtfqMAQZ1+oUPeO0L7NAfBILncGf/z LzqMFrkf4tzJ+RCXVMb7OtM9l1E+w4ByTB+GcJqp71COM7b7HuuG0Tlxpn3lE9sl5VT8 qKiH4DM98xBD2ID2Oy7taVGXNs2XaCmryYU3Gwjz3iK7YrX0bF2r1SNvhnYThSiBOg6Q RzdVydnTo4RNOQ00hctXIQ7KS5hurdLyQEepl7VDRyXyvRHe+e/g5UGIfIci9zQF4fLb OOyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=5kiEoVZenwhxVMli/0Xg39anpqA8OnebqM0TKg7l87M=; fh=VtN16c396FjAzMnAwbIibbXxyJVdXGKOCyusHN5c+ig=; b=OWg4lxnawWzG2OSNPYCocP9SQZSqbN3NhAllK6h0TJawtpjk704jedhkFUuRhx7cyx 6vLz9vyGlzkdKwxhBZ0yIkQj3qXB1R82XiXPeJZr1gDVfqY7t81rTj7xWL1dmV2gQt/Z 9IwTsclqChWqO/pAEqxGYwNUa8MrWyrEUam5hNr9JQd9Eczzy9t1igpNNiPi7Nda+KCt inhOCZZtKRb9Vd2BdnqMlrdLTVs/K421U9ARrAuDVrDRBTJhcfazGQuYpuWyuuv+e8nn a2U1oOVlGh6KYwRWjVlQN+19fxTKHtnrXtRmOOQo6QVBj3DyYB3wiM0ZF/F5ZsMaCC4m Edlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=O2ljeJ7D; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=jkO21dyG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id f18-20020a17090ace1200b00278ea235413si8427597pju.31.2023.10.07.10.11.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Oct 2023 10:11:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=O2ljeJ7D; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=jkO21dyG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 6BE548053664; Sat, 7 Oct 2023 10:11:33 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344149AbjJGRLJ (ORCPT + 99 others); Sat, 7 Oct 2023 13:11:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344118AbjJGRLE (ORCPT ); Sat, 7 Oct 2023 13:11:04 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0599A2; Sat, 7 Oct 2023 10:11:01 -0700 (PDT) Date: Sat, 07 Oct 2023 17:10:59 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1696698660; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5kiEoVZenwhxVMli/0Xg39anpqA8OnebqM0TKg7l87M=; b=O2ljeJ7DWqzWuSAcmkP8d3cC4NLYfheMTGuugOMskDc2g67go6jcdctunyY5Poza3puNIs 6V9L6Wf1EY4T7Xdym01uo2KfPI2OzFmJkiXSgKubytDm1ntwMHxN2prMQ++dMsuTGDrqH7 LEJm9iQ9SzGYs4tLxlTA3quk6W/fzNpHwHa1wa/MWQ31XvxbpULU1gUCxvoUid4nW0VmZL a4nPI0lIxDsjuKHbK9Oj88nqnRhhCz6AU4MjLcu+/xS2kgDzzy/TvTVWzzkA4NVIAJzWiI Gy04ZFMYGE0I70z04B6PUIXF33BnsLE+q397+16Q2AatfOxTezHiqETUqfqzVw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1696698660; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5kiEoVZenwhxVMli/0Xg39anpqA8OnebqM0TKg7l87M=; b=jkO21dyGBKA00KscUXdIDd0azQwuWAI7mmmI6wOx1i5AtYZwIfthpD4bRDtMeuo1j/P+Wd T4bSOCousVlAmhAg== From: "tip-bot2 for Waiman Long" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/core] x86/speculation: Add __update_spec_ctrl() helper Cc: Peter Zijlstra , Waiman Long , Ingo Molnar , "Rafael J. Wysocki" , Linus Torvalds , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230727184600.26768-2-longman@redhat.com> References: <20230727184600.26768-2-longman@redhat.com> MIME-Version: 1.0 Message-ID: <169669865996.3135.485844093321921238.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Sat, 07 Oct 2023 10:11:33 -0700 (PDT) X-Spam-Level: ** The following commit has been merged into the sched/core branch of tip: Commit-ID: e3e3bab1844d448a239cd57ebf618839e26b4157 Gitweb: https://git.kernel.org/tip/e3e3bab1844d448a239cd57ebf618839e26b4157 Author: Waiman Long AuthorDate: Thu, 27 Jul 2023 14:45:57 -04:00 Committer: Ingo Molnar CommitterDate: Sat, 07 Oct 2023 11:33:28 +02:00 x86/speculation: Add __update_spec_ctrl() helper 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 Signed-off-by: Ingo Molnar Acked-by: Rafael J. Wysocki Cc: Linus Torvalds Link: https://lore.kernel.org/r/20230727184600.26768-2-longman@redhat.com --- arch/x86/include/asm/spec-ctrl.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/arch/x86/include/asm/spec-ctrl.h b/arch/x86/include/asm/spec-ctrl.h index cb0386f..c648502 100644 --- a/arch/x86/include/asm/spec-ctrl.h +++ b/arch/x86/include/asm/spec-ctrl.h @@ -4,6 +4,7 @@ #include #include +#include /* * On VMENTER we must preserve whatever view of the SPEC_CTRL MSR @@ -76,6 +77,16 @@ static inline u64 ssbd_tif_to_amd_ls_cfg(u64 tifn) return (tifn & _TIF_SSBD) ? x86_amd_ls_cfg_ssbd_mask : 0ULL; } +/* + * This can be used in noinstr functions & should only be called in bare + * metal context. + */ +static __always_inline void __update_spec_ctrl(u64 val) +{ + __this_cpu_write(x86_spec_ctrl_current, val); + native_wrmsrl(MSR_IA32_SPEC_CTRL, val); +} + #ifdef CONFIG_SMP extern void speculative_store_bypass_ht_init(void); #else