Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4699781imw; Tue, 12 Jul 2022 12:40:15 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vOR2xmv7BakVNiaz06eHOKFLnQURiUvxFIpc6atJNfbR74urF78B30PoEYIE3MWSr5fULx X-Received: by 2002:a63:6c06:0:b0:40d:e2a0:278c with SMTP id h6-20020a636c06000000b0040de2a0278cmr21581640pgc.328.1657654814984; Tue, 12 Jul 2022 12:40:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657654814; cv=none; d=google.com; s=arc-20160816; b=o0WoZMbEvnw9kF4wbTLK8j7qsBF+01Oa+0ltd4mtcJwEkVC0lO5Q+3I/+kZqWjyptn OT/ecxmx7WGPi37Y272loPFPFyCGkDeunFZSqFX9XPWpQtInWiahkYm9vqFlLoVyIQ5l h3itgXP/kKQr6ELmTi55bQfBTadtsEUqqyFxUTheZo0Xf5WR/2f4T6l2p5y5HrwUoRgO pP8MN114aaPqvkHU3YqLpKnBdKDxemOSDGv9aiID/v1XVr7zLKKpDzHZVz/BJbiKY1+b e3ZVQQd1DYhEuSnlZw8Ba/H3QF7L1ZOyaqEWlalxgb8F4niiG7MQBRgZGgYxcbZgZJWK mmkQ== 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=AEjr/2GgfYq4fiOQNDovrd+kZaTwe5fCB+kHNFArCrA=; b=QDIW8mP176BRNNrGVoZdfOirWqRsESHrDqMHUrpQPVxff9NmL0/EEfaCLI2Y+P5CAt HfPfs1iDDj1rWNM2s4U5XUH0KwI/13paqL/TGne5C4ee5OqXPzQnz1Ikl4qH2SJkMqH3 POGTBkTDyLBPDhxmeMjkLCiALfmAOxsgS4GrFRHDuScJ8XWWwwGdz00zFjArJnF/9nl0 HRHWecJuDj8kLe7tLuIsDWd1hO6xUu9VvFE9OQlUXInn/G7K9uzyRgfOP4XhRUFYUzqz nibg68HLehO8kQX+cfytoejLjfmmaBZPYOmlmYQqg7yNI3c1BcQ9xdsFVsHO3wUzICD6 8Xlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qL2n2ZyY; 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 b8-20020a056a0002c800b0052ae2e0afdesi3832224pft.69.2022.07.12.12.40.02; Tue, 12 Jul 2022 12:40:14 -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=qL2n2ZyY; 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 S234399AbiGLS6L (ORCPT + 99 others); Tue, 12 Jul 2022 14:58:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234978AbiGLS51 (ORCPT ); Tue, 12 Jul 2022 14:57:27 -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 2FB8FDC892; Tue, 12 Jul 2022 11:47:16 -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 D6AEEB81BAC; Tue, 12 Jul 2022 18:47:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 15C7EC3411C; Tue, 12 Jul 2022 18:47:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657651633; bh=6XerrlduLrZI2GtrTstCZEHooVumelY789m2NBzA1Sw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qL2n2ZyYmio1ELQ6LedaWzCswa8c/bqt+kTmuVbSVg6iTQwYuky9nxny9Dn1V+RPc Ngc/hQHKPVDHf1z1KzvfPOEYrDh9YKET91nPCZ4dx4W3lbI8ot9HaIkr9HCGZmfuvs 390ZWhHfImVyogNtufu3yzX2IxHy5mdFdYVN5L+I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Josh Poimboeuf , "Peter Zijlstra (Intel)" , Borislav Petkov , Thadeu Lima de Souza Cascardo , Ben Hutchings Subject: [PATCH 5.10 115/130] x86/speculation: Use cached host SPEC_CTRL value for guest entry/exit Date: Tue, 12 Jul 2022 20:39:21 +0200 Message-Id: <20220712183251.768172760@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220712183246.394947160@linuxfoundation.org> References: <20220712183246.394947160@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 bbb69e8bee1bd882784947095ffb2bfe0f7c9470 upstream. There's no need to recalculate the host value for every entry/exit. Just use the cached value in spec_ctrl_current(). Signed-off-by: Josh Poimboeuf Signed-off-by: Peter Zijlstra (Intel) 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 | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -199,7 +199,7 @@ 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 = x86_spec_ctrl_base; + u64 msrval, guestval, hostval = spec_ctrl_current(); struct thread_info *ti = current_thread_info(); /* Is MSR_SPEC_CTRL implemented ? */ @@ -212,15 +212,6 @@ x86_virt_spec_ctrl(u64 guest_spec_ctrl, guestval = hostval & ~x86_spec_ctrl_mask; guestval |= guest_spec_ctrl & x86_spec_ctrl_mask; - /* SSBD controlled in MSR_SPEC_CTRL */ - if (static_cpu_has(X86_FEATURE_SPEC_CTRL_SSBD) || - static_cpu_has(X86_FEATURE_AMD_SSBD)) - hostval |= ssbd_tif_to_spec_ctrl(ti->flags); - - /* Conditional STIBP enabled? */ - if (static_branch_unlikely(&switch_to_cond_stibp)) - hostval |= stibp_tif_to_spec_ctrl(ti->flags); - if (hostval != guestval) { msrval = setguest ? guestval : hostval; wrmsrl(MSR_IA32_SPEC_CTRL, msrval); @@ -1353,7 +1344,6 @@ static void __init spectre_v2_select_mit pr_err(SPECTRE_V2_EIBRS_EBPF_MSG); if (spectre_v2_in_ibrs_mode(mode)) { - /* Force it so VMEXIT will restore correctly */ x86_spec_ctrl_base |= SPEC_CTRL_IBRS; write_spec_ctrl_current(x86_spec_ctrl_base, true); }