Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4705919imw; Tue, 12 Jul 2022 12:45:04 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uAQ7uyDWWX6kvKBpH8ZkdfeiyVpSEzujAcuS+y7pqgX3vUifk8M/EKaUbHiallQOrJui9l X-Received: by 2002:a17:902:a413:b0:156:15b:524a with SMTP id p19-20020a170902a41300b00156015b524amr26100277plq.106.1657655104347; Tue, 12 Jul 2022 12:45:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657655104; cv=none; d=google.com; s=arc-20160816; b=gDE32ErND59ltjv1hch5nUO2BUsizW+InmCtAU+N4Sj506mvzUfzzK1P77FNBVSkny fDWm3FwLIEYIot1qqoN99Q2iyLdcnFBtAOXt+bTMC6XHJnIw5Mc9tvt5dJp+xtJfvKa3 gHx0f3YHnptmqITfOGJ98FOKPtG/BRr9u1z8UvTcjNv3Um/y/mt9G7Z0zWyecnu14dXf 575lsYLbP7NJ6N3OpQbcfgCB8G3GfF+tloNupRF7LYzGP1AK/tTOoXDFIy2mZt1vmhbP Ib4XTJzyBO5kcu9tzlrmuUW8NIxKX3yTfjuW8dhHRKFoPTp9kb9651PEElqEs7vl024U xSAg== 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=s1OBUtktPQhR+p3j7r6puSJ0XMv64M3lCRo3FqEn0kU=; b=MbMlIjbC4EeYLhXv71PaNzaO9GJrlVDk0/HkOyxgZM1Vup7reldPgzlMMeQk+n7ScI hzltfmfJyhvVi2cd3u5xze8O0DVmPqupl9T4tRIvP+DCFH4dunTYLK67AMp3HJaoj4Bo zD6Xx8SRKQJJ6J6Jj6n3Obs1yLUDW2SPIAh8iicyMHjGIGzUD0N36fCn54+uaK3r7dua FDtIZn+inSIU6zWiBIDlCICFOTh88+HCYmemd3wa+rMXdNJst4lK/maH5RaQnXXH1Anu pthOAmEvTpOeyYVOeb0BU8kgwhVHOx2sgorXS3v+2xVez9FcDdXhUblY5sAoH8cA+ZC+ WtxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="N4L9D/px"; 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 s205-20020a632cd6000000b003fb92ed82b8si14149121pgs.875.2022.07.12.12.44.51; Tue, 12 Jul 2022 12:45:04 -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="N4L9D/px"; 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 S236049AbiGLTPw (ORCPT + 99 others); Tue, 12 Jul 2022 15:15:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236165AbiGLTOd (ORCPT ); Tue, 12 Jul 2022 15:14:33 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0C4EDAB9F; Tue, 12 Jul 2022 11:54:19 -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 6267DB81BAB; Tue, 12 Jul 2022 18:54:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B49C7C3411C; Tue, 12 Jul 2022 18:54:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657652057; bh=afUNIL8EugqzhYqa1lgD+Lbf2agMvsyXkNXYavc+OXY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N4L9D/pxQbCTy4790c8XRJFJZM+TRQfwreilb8XHHSJuPZje6lokl6kOkwoJYzfEL Q0ATODNYaRz8OzG6VaZSIHM2fJEzgUP30v4Z46Yz7D1FTQSQNGc/An6pQLAG7VuCkl qUAXzWSOO0Q6+URUX/+6cV6qHWOnwmRFEyf8GnVM= 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 Subject: [PATCH 5.18 45/61] x86/speculation: Remove x86_spec_ctrl_mask Date: Tue, 12 Jul 2022 20:39:42 +0200 Message-Id: <20220712183238.753910078@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220712183236.931648980@linuxfoundation.org> References: <20220712183236.931648980@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.7 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,T_SCC_BODY_TEXT_LINE 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: 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 @@ -86,12 +86,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(). */ @@ -146,10 +140,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(); @@ -208,19 +198,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); @@ -1659,16 +1640,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