Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1718729pxb; Sat, 2 Apr 2022 00:31:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzxqUeiAt7D/ZFVMVUNyKJb6o3APcc1fme908MWXWhEab3JFr94PR2/6SL7kiKAjJrjo6pC X-Received: by 2002:a17:907:1b27:b0:6d9:ceb6:7967 with SMTP id mp39-20020a1709071b2700b006d9ceb67967mr3084294ejc.186.1648884701239; Sat, 02 Apr 2022 00:31:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648884701; cv=none; d=google.com; s=arc-20160816; b=N+2FAr7ekklONNd1u0lIVxxD9jH6yrnz9HjRIxnVYZtAWzxWRcSaWVu5xjftf3h39z EbrkjJB9DnxUxmkWVyYT1WfQAKn62zAPHZqf9XiD3yax5bCtuKVnr2K6QQ04pr80qKfm CcGUjY6i6qDAB8z2uPDOl7GU3QJyCFbrA95YukN/sE0k7h9jbdlTa42vZ2trRV0JXoSa 7OuJT1VUxfFas5dOphhCM5Hy1dkVz7CVYOQY49HK+kxpQDr6vIAbeeiYP7JsT6Lt0CDh eTGglxIi2f3or30li0FazqBHKoafQNV5DWL3gxIaQJZqN3ujv+jtO6RDmVk1N7k9oBiy yA+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=cqHs2pvOfsJ9Iz3zPAYqJfTmmqvOQWHEv8RxZnTwx+w=; b=KmqCnknJGDDNZioiycYE87th2kM0APdd+oYZj9DW3HxAbSMsBA0ypCikhFC0xqE9VL Q1Iy/+tSqddyLY+YlfUXbT7Nc8Q+3iaWunmeiLdamqcTjBuUpYLuXGZHrLsoHIRNaks5 bPF/RDjnGR6omoEk7MtfnZEElQqk2btXAmY5Wihs/J0pxkKeRF/I99rrCv03BN36q8pw UW05PuGTKYt324kuHwcnEgNHhcNYydlouRRiJQAXBR+lHf56oiydUfSVu7xAu3HwrxSK 0tFtC5ADB91+jCXlS97O+Qi4qCUj3L8uNma6cBYVLIMYf2tbXQDRC+sJKF3qdBaU8Mio YYIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=UimVplzc; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d8-20020a50cf48000000b004195728a438si2851871edk.221.2022.04.02.00.31.16; Sat, 02 Apr 2022 00:31:41 -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=@collabora.com header.s=mail header.b=UimVplzc; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343939AbiDAHsi (ORCPT + 99 others); Fri, 1 Apr 2022 03:48:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241844AbiDAHsh (ORCPT ); Fri, 1 Apr 2022 03:48:37 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 909D625F652 for ; Fri, 1 Apr 2022 00:46:48 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: rcn) with ESMTPSA id 4FC251F47521 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1648799207; bh=UVhZOV6XJ+PfylwaNjtDwbQrX2mrJqZLJFMmEHVtovc=; h=From:To:Cc:Subject:Date:From; b=UimVplzcmG61RHhogAJ9KWXKH4pPeCRCXapcTyqXXKENkGiqe0eDnOIFShrBdL+/d oe36beC32Br3D3tePQlVGm4fc3ZMpA+D96PuqMQmcUQbbmqRnKEA+ZQhlbx3iKzQe/ 1gcmNFHYpKoGplgrxaMKU959OP1xIuG/LQycuA+uSGJ/1I9mDc9AhVrvpE1naOsCSv 9VfjK+fZNQoioqn17xfiDSXscf18NXkJ51ovP7hgZwVGSTeMocupP1zkhloj48DD2s +An8txkG119BLmzls0RJbMpRc04fAFVeTtbY57TVKt+UpJ8mt3VbBx90LkhK72QydG +uZaRvVclvccA== From: =?UTF-8?q?Ricardo=20Ca=C3=B1uelo?= To: linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Ricardo=20Ca=C3=B1uelo?= , Borislav Petkov , Thadeu Lima de Souza Cascardo , Mark Gross , x86@kernel.org, "H. Peter Anvin" , Ingo Molnar , Thomas Gleixner , John Johansen , Steve Beattie , kernel@collabora.com Subject: [PATCH v3] x86/speculation/srbds: do not try to turn mitigation off when not supported Date: Fri, 1 Apr 2022 09:45:17 +0200 Message-Id: <20220401074517.1848264-1-ricardo.canuelo@collabora.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY 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 When SRBDS is mitigated by TSX OFF, update_srbds_msr will still read and write to MSR_IA32_MCU_OPT_CTRL even when that is not supported by the microcode. Checking for X86_FEATURE_SRBDS_CTRL as a CPU feature available makes more sense than checking for SRBDS_MITIGATION_UCODE_NEEDED as the found "mitigation". Signed-off-by: Thadeu Lima de Souza Cascardo Signed-off-by: Borislav Petkov Signed-off-by: Ricardo Cañuelo Tested-by: Ricardo Cañuelo --- Changes in v3: - Simplified and more explicit solution proposed by Boris arch/x86/kernel/cpu/bugs.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c index 6296e1ebed1d..d879a6c93609 100644 --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -446,6 +446,13 @@ void update_srbds_msr(void) if (srbds_mitigation == SRBDS_MITIGATION_UCODE_NEEDED) return; + /* + * A MDS_NO CPU for which SRBDS mitigation is not needed due to TSX + * being disabled and it hasn't received the SRBDS MSR microcode. + */ + if (!boot_cpu_has(X86_FEATURE_SRBDS_CTRL)) + return; + rdmsrl(MSR_IA32_MCU_OPT_CTRL, mcu_ctrl); switch (srbds_mitigation) { -- 2.25.1