From patchwork Wed Oct 4 15:47:13 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: 148381 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:254a:b0:403:3b70:6f57 with SMTP id hf10csp225823vqb; Wed, 4 Oct 2023 08:47:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFMuIuM1vGF62PrWUVcano70LtBdYKMTf1cBJufx4qUAm/sbONxiKQZceconRppsm6XrvBG X-Received: by 2002:a05:6808:23c8:b0:3a7:2598:ab2c with SMTP id bq8-20020a05680823c800b003a72598ab2cmr3282976oib.7.1696434450157; Wed, 04 Oct 2023 08:47:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696434450; cv=none; d=google.com; s=arc-20160816; b=yZtWtKQbtH13t2QyjssqlhiA1BrAQgRtMRYUYYkF7hvtlIh8XIpEw9nAWE5RO0u0QR /mnmWQtEZltMBrX2/Lw37s0dEEOj7icNbrkk7zUlbOGcg2XHEzV8xrKOtmsZA9n2KlXB LVK/rfZ7qimk4VvwBn5M16dF4Mrg4EU5jQleG/mkj9iTsrIg1aanIflH582dvN07slFH tecnUrr1QOWuYoZMQN89eCmJ2rdLO/vwT9gnCquy4VD6lTDomLvNTYgosJaqsiKDXH/m oD/2StXamS8XVxy5je+PrbbXBApdWE6ZsFdR/hEoEsD8JOZDqnKh/XD3FhYP0gVveSAw PXlQ== 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=nH6tE9EI7ysD4tR/3JJt9rHH0u9Mq170wLjzJ0gD99U=; fh=VtN16c396FjAzMnAwbIibbXxyJVdXGKOCyusHN5c+ig=; b=GCBTGy5OlxIl2WgpUqoKMUfbg/TCijeKucY5mKof3dlIyY/Yg3glL089DXNviEtmWp C0llVF2MXycF0obxnk4IumsHQWvNeNdI4w8QmItW77d8TsFgFOOCgM+LXhTqtm98jLSP Qelj9fOL6jknJhoOrehsP65xbonO58X8ofQ5MPQDFHR5CxDkFpxg9nNk9cjUlKbbuWJn nK48PxL/oUsib89xxlrfbdkYmj5WwNEdFDye1+R3vX8HXuqmBFNIpJgQiyTyeq4ACY1h p+kFwgcUlDlG7sgSPLyBSxh65OX1WE4IFpmob20Xst48CmhOM89OO7GUa71niJuB+FN2 6t7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=ujWZsBHx; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=qVGwlnin; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id i69-20020a638748000000b00577f65baa3dsi3653096pge.849.2023.10.04.08.47.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 08:47:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=ujWZsBHx; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=qVGwlnin; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id 459EA822CF8F; Wed, 4 Oct 2023 08:47:29 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242960AbjJDPrZ (ORCPT + 18 others); Wed, 4 Oct 2023 11:47:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233769AbjJDPrT (ORCPT ); Wed, 4 Oct 2023 11:47:19 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E196BCE; Wed, 4 Oct 2023 08:47:15 -0700 (PDT) Date: Wed, 04 Oct 2023 15:47:13 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1696434434; 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=nH6tE9EI7ysD4tR/3JJt9rHH0u9Mq170wLjzJ0gD99U=; b=ujWZsBHxjEcAYyt5AIlbDWAoi6BSFH3jKCRLMu298spiQFv8K8BF1rTiwgC8fQk0VtwRCi CWXjwHjTwz57xcDM19eRXuxxC50OxXee+YuHTxg0/NPvFgeeihxVyXW7ZmgyVwQSJ+MFIh EqYd4pVXb2rI3Q5rbcpQ6MijTGi4kx9cSHqwMJ83jnBoGi2FU55YA5wAJv+vrMVOvogos5 StFoLqs/v5C4cgOU161XFil286a5LaL5BiLEbuLoSx8xDGCIKoJCm35TCgtFOjDBDXG5J3 24ztEdBYheL58dKhv/CViPCKVlmCipvbYLk4PNrzPQj7HFEIrrsBNttX/4MbfQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1696434434; 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=nH6tE9EI7ysD4tR/3JJt9rHH0u9Mq170wLjzJ0gD99U=; b=qVGwlninWedfbjs2YE+fdTnL94uhqCI+HFW2U3Mio+B2h8t+X3Z08RpioJwIdZ006CU0cP n5rxgUzAyvoGPVAg== 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: <169643443360.3135.5068891650571884994.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 04 Oct 2023 08:47:29 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772606807309346400 X-GMAIL-MSGID: 1778840449841198393 The following commit has been merged into the sched/core branch of tip: Commit-ID: aaa3e6678978b5e2b5c6e80e439fc4db9bbdb375 Gitweb: https://git.kernel.org/tip/aaa3e6678978b5e2b5c6e80e439fc4db9bbdb375 Author: Waiman Long AuthorDate: Thu, 27 Jul 2023 14:45:57 -04:00 Committer: Ingo Molnar CommitterDate: Wed, 04 Oct 2023 13:48:48 +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