From patchwork Sat Oct 7 17:10:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 149620 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:403:3b70:6f57 with SMTP id x8csp1028668vqo; Sat, 7 Oct 2023 10:11:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEubgu/qVyiPqTZB0btcXUG25Xg9tkFt7JGWV8Co/FlVplJytqS48enmtj+Pfr7kLz9fBxO X-Received: by 2002:a05:6e02:1a05:b0:349:7cec:db76 with SMTP id s5-20020a056e021a0500b003497cecdb76mr14078719ild.31.1696698705639; Sat, 07 Oct 2023 10:11:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696698705; cv=none; d=google.com; s=arc-20160816; b=0XIii6WefnQpoNasCr8F8LIIYyX8r6HJF1mp4hStEU3j4Ig5+NMqGI4H2hN4TZYjEb grbtGvDSUUm2WIwylr5ZSKCMr1r8uLnWoDYwtydtB4Std4XOg1hX/w5XgMcqr5KL0nG8 GyhMPCXj6siyWuoBen6ahpwQylW1A6TE1N6xO8QQ92lQWe3Tx2r6SETyh60MuV1qz/74 FNlfwq4BVComOwdnifrS0GkZEf5kyLQBB1MiccKhF1SvyxM2VbNNQj/dCU1PhPRVG75X VeC163zcJt/ScXh7eCTJ9GlhcyxyjKqxYJtlz/pjYsOg3o/k4XMO0piYiJJaJVmAYGnD rXGw== 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; 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id be3-20020a656e43000000b0058555ea0a21si6252097pgb.571.2023.10.07.10.11.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Oct 2023 10:11:45 -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; 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 034548053656; Sat, 7 Oct 2023 10:11:43 -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 S1344150AbjJGRLK (ORCPT + 17 others); Sat, 7 Oct 2023 13:11:10 -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 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:43 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772606807309346400 X-GMAIL-MSGID: 1779117542003259760 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