Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp473143imi; Fri, 22 Jul 2022 03:11:16 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uJ1NubnFf0JLrmz+4Rw5/7qEvvemShGyKLoqoqn5XPZR8Wa3s1E3Qp6ik+OXYFGrxBX+mw X-Received: by 2002:a05:6402:350b:b0:43a:e18e:dee6 with SMTP id b11-20020a056402350b00b0043ae18edee6mr2753894edd.31.1658484676372; Fri, 22 Jul 2022 03:11:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658484676; cv=none; d=google.com; s=arc-20160816; b=cKv6SlqJjwUYag8+EiHHqkfZEK7wQjRQu6g0AC8eAigxErrQfqr2bKAjJogbTSYr6i lUb/RMHh6M9iVfUZn48sDT+6L+KoPGNGxQeZY9Lx7hx99MbkhxPnGTJFh52hAStYeZhn W88J73l9pniDiyBK/Fk+ao05f/7H5RLjobablHcKj8STyOAQAJ6gpfJiob0VzaAL19Li vWBIs6mZBiqeqSTHzOvYdmPxz4kk/ZAIsOeF+ol9LrMyLDD7zo6z4yEPkf6bA1qyTcJ/ /qa2G+ErnUUWtqjksr9ooHhXtPLcjQeeWrKNne69p6kEqDoJJR5FoNlMI1wUrAUi4kbs 56vQ== 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=eKcLAxoDaL8qv+n3w1M85Bq26LF3VvJCM9+DhC/bDZjRMO8UU9wCJE3m4RoR7ooD73 nobw+/+zZmJVUepO+DMVyftibtiv6jWxO5WZYBmJJJ2pCopHjgAGk/Iv5Wu0DTrpP47Z QCJiBUXd2i31Fg+w7ijTGNSa7W4kkIzR1ztM0TFKVCJ5REvR2gXCv5/d6+tWyhmQf0Yp NiEgLD4cbu0mprYl8XkK7ai+BkEaICPOO5HbKiuBVxG6ew7CzYxo9NJc+EhWEYsvJ6nC VJ8UUkWcwM9qRp55+rUwnA+ZYVK40Nu8FZkQukVi9+EK0P5LZr90PI4F81M5mHSt3KLT 1W3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HT+lNoSt; 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 gt13-20020a1709072d8d00b007156fe1aa6asi6153786ejc.650.2022.07.22.03.10.51; Fri, 22 Jul 2022 03:11:16 -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=HT+lNoSt; 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 S235438AbiGVJMv (ORCPT + 99 others); Fri, 22 Jul 2022 05:12:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235392AbiGVJMO (ORCPT ); Fri, 22 Jul 2022 05:12:14 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A606AC53; Fri, 22 Jul 2022 02:10:06 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 18F6161F4C; Fri, 22 Jul 2022 09:10:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 23881C341C6; Fri, 22 Jul 2022 09:10:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658481005; bh=afUNIL8EugqzhYqa1lgD+Lbf2agMvsyXkNXYavc+OXY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HT+lNoSt/P1tfcVroxro5KcZO/HlAPBMc/9Qocbq89xwb5bzMnJcKL+5yNDjjMUpd cjZCARrgP5iyo1Bo1JXF5HBOYWLJrWTuIfys4D/jINKvx7C99X099hsa+Lfs2cXReX LG7v4MF/WZ/tR1+lgUsgRgwBdFkEp2gB87jf7XEw= 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/70] x86/speculation: Remove x86_spec_ctrl_mask Date: Fri, 22 Jul 2022 11:07:40 +0200 Message-Id: <20220722090653.241146338@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220722090650.665513668@linuxfoundation.org> References: <20220722090650.665513668@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: 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