Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp1367045imi; Sat, 23 Jul 2022 03:50:33 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vFRr9ZL0vRDWnjuI9yHL5+Mp0MwJtwXGIsz8lkOSQYCEF+34w5/0EkijIwSbUXt/F9PwVV X-Received: by 2002:a17:906:7304:b0:6ff:a76:5b09 with SMTP id di4-20020a170906730400b006ff0a765b09mr3119282ejc.193.1658573433121; Sat, 23 Jul 2022 03:50:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658573433; cv=none; d=google.com; s=arc-20160816; b=Hop+96obh8QFb513e7GXoNu8cgQzOXRskxPUABKfH7W/i86lZITjP/ixE1fk0jZicx 89kmqMCy4AprGnu7k4t4QhJS8I5cMd1WsjYEaZG3ImSm5A8M4PBtFWKpgWrpGIrRjPBi +udrTXZXflrYndpzK8NRxjwFtNiOCJl22AzJh9u56QUwntnQtceaxDiKjjmQB6gH1YS5 Xz9o4VICk0Sjk2IL1bIQlGpqFR90xgXFLTBzoTs5m1Dec2+WCMNnwolQZYfgnFsmZh+S 412FeduStu/QEs9MkBuEaRaJLqIyk9qVQ0jBb0L+bob5HOA2J03atqEGx9FKDcVw5SY8 SyXA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=7r1dbYSgroHqOOOcsb95ifZ1V/Cyvasj1NUOzpp/CSw=; b=SxpQL76ThfnV0UXZZjg2vP3zgCgAFBY/TjbeFavWtigA1zBYRXRgWyZpI5RgxZW52i OpKXgCV8zdy0IQEsrdbtuED7jHnZT8/mOGfvNAzUKQmBrzsfsVt/P9l+fJbJt7uLnIJw q0Xv2ZVdokSJoSEG3nBPhU8Bzl4wQVxU8cngzyyMECc032JmmL4SD3QSmPgyngSueZj1 j1ANByBTme0DDOx6Dluvu8sNQkAp53AJwDoRx6OCUUwX9DwwAZjfvd6vFubggm03LhR3 MAg74oa2juhTON9fSLrmcUAKvhFTfReh24rRYPzRgosXTf0r2d8dcKuk1JLMqBWV/HYG iTqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=iCIIWCRi; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hp33-20020a1709073e2100b0072b870ca25esi5647034ejc.996.2022.07.23.03.50.06; Sat, 23 Jul 2022 03:50:33 -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=@linuxfoundation.org header.s=korg header.b=iCIIWCRi; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238992AbiGWKLV (ORCPT + 99 others); Sat, 23 Jul 2022 06:11:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239103AbiGWKJS (ORCPT ); Sat, 23 Jul 2022 06:09:18 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E2A5CB777; Sat, 23 Jul 2022 03:02:28 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id ABBBCB82B92; Sat, 23 Jul 2022 10:02:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0DE55C341C0; Sat, 23 Jul 2022 10:02:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658570524; bh=rn3X5p8IfphIAOw9YW6Id6cWDmF/8gFuGDqC30KUOfA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iCIIWCRi8HNzYifGSyG4VkJGg0/3lNmlmKNaMaVX1RdDK2mxR5SWhEA52FQ3jcrWy 6aqNgU7NXYLC8rlUotClsstfZ7s6BBHzrfcN5cb+vrOMK6vpNRBB3xeEXRrTT5DRUE 64WieqcgsFlPOeDRfAizZEHjWA2vrpwbvsJ2AheQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Josh Poimboeuf , Borislav Petkov , Paolo Bonzini , Thadeu Lima de Souza Cascardo , Ben Hutchings Subject: [PATCH 5.10 116/148] x86/speculation: Remove x86_spec_ctrl_mask Date: Sat, 23 Jul 2022 11:55:28 +0200 Message-Id: <20220723095256.820899670@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220723095224.302504400@linuxfoundation.org> References: <20220723095224.302504400@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 From: Josh Poimboeuf commit acac5e98ef8d638a411cfa2ee676c87e1973f126 upstream. This mask has been made redundant by kvm_spec_ctrl_test_value(). And it doesn't even work when MSR interception is disabled, as the guest can just write to SPEC_CTRL directly. Signed-off-by: Josh Poimboeuf Signed-off-by: Borislav Petkov Reviewed-by: Paolo Bonzini Signed-off-by: Borislav Petkov Signed-off-by: Thadeu Lima de Souza Cascardo Signed-off-by: Ben Hutchings Signed-off-by: Greg Kroah-Hartman --- arch/x86/kernel/cpu/bugs.c | 31 +------------------------------ 1 file changed, 1 insertion(+), 30 deletions(-) --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -85,12 +85,6 @@ u64 spec_ctrl_current(void) EXPORT_SYMBOL_GPL(spec_ctrl_current); /* - * The vendor and possibly platform specific bits which can be modified in - * x86_spec_ctrl_base. - */ -static u64 __ro_after_init x86_spec_ctrl_mask = SPEC_CTRL_IBRS; - -/* * AMD specific MSR info for Speculative Store Bypass control. * x86_amd_ls_cfg_ssbd_mask is initialized in identify_boot_cpu(). */ @@ -138,10 +132,6 @@ void __init check_bugs(void) if (boot_cpu_has(X86_FEATURE_MSR_SPEC_CTRL)) rdmsrl(MSR_IA32_SPEC_CTRL, x86_spec_ctrl_base); - /* Allow STIBP in MSR_SPEC_CTRL if supported */ - if (boot_cpu_has(X86_FEATURE_STIBP)) - x86_spec_ctrl_mask |= SPEC_CTRL_STIBP; - /* Select the proper CPU mitigations before patching alternatives: */ spectre_v1_select_mitigation(); spectre_v2_select_mitigation(); @@ -199,19 +189,10 @@ void __init check_bugs(void) void x86_virt_spec_ctrl(u64 guest_spec_ctrl, u64 guest_virt_spec_ctrl, bool setguest) { - u64 msrval, guestval, hostval = spec_ctrl_current(); + u64 msrval, guestval = guest_spec_ctrl, hostval = spec_ctrl_current(); struct thread_info *ti = current_thread_info(); - /* Is MSR_SPEC_CTRL implemented ? */ if (static_cpu_has(X86_FEATURE_MSR_SPEC_CTRL)) { - /* - * Restrict guest_spec_ctrl to supported values. Clear the - * modifiable bits in the host base value and or the - * modifiable bits from the guest value. - */ - guestval = hostval & ~x86_spec_ctrl_mask; - guestval |= guest_spec_ctrl & x86_spec_ctrl_mask; - if (hostval != guestval) { msrval = setguest ? guestval : hostval; wrmsrl(MSR_IA32_SPEC_CTRL, msrval); @@ -1622,16 +1603,6 @@ static enum ssb_mitigation __init __ssb_ } /* - * If SSBD is controlled by the SPEC_CTRL MSR, then set the proper - * bit in the mask to allow guests to use the mitigation even in the - * case where the host does not enable it. - */ - if (static_cpu_has(X86_FEATURE_SPEC_CTRL_SSBD) || - static_cpu_has(X86_FEATURE_AMD_SSBD)) { - x86_spec_ctrl_mask |= SPEC_CTRL_SSBD; - } - - /* * We have three CPU feature flags that are in play here: * - X86_BUG_SPEC_STORE_BYPASS - CPU is susceptible. * - X86_FEATURE_SSBD - CPU is able to turn off speculative store bypass