Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp1364401imi; Sat, 23 Jul 2022 03:44:30 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t23z9OnWM0gTWqLUHKNdLHLKlkdj7XWjXRY3Dx5lOz1SHbrNZOOjglp8nrSPGzax71w1Av X-Received: by 2002:a17:902:ab86:b0:16d:a3d:f96f with SMTP id f6-20020a170902ab8600b0016d0a3df96fmr4098485plr.139.1658573070261; Sat, 23 Jul 2022 03:44:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658573070; cv=none; d=google.com; s=arc-20160816; b=1JDAd/pd0sPkWgth7DMjhuTZF7K/wDcfnU/ECgoJnx2g8tqFOpqC7gNHAeN+aNPCwO on9GJaB0xTyiV5AO0pLp80i6Dz/VeGgPECV9ZYU6PhVOOcIcRMKwritXIwfWt+G3QMvB eytvl7UU5E+DSU894WiHd/jMDihdP6f1wGbjU6m5LQiDAoHzTVE5RI6o1sGP3vf/72gY ON9cKvIQ63sUzAg2repyMZ4oM/H9Bz9ZoSZYnLOqPqQxtElIKMyoq8mbgrYwZN81uDqo O+EoZ4HM5l5X8VnyCGVuq6yYASDkaKrrJVJCLg+Hj3nb/K0FE18jPyecfMvsRlWZkBGY t/wQ== 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=doExdPmnA0tcXXQzf3dtX2WqdTNF9l4kWy/RxQ/TjE4sKawxrTDmmRJAMb4M7lds2y 7S52DVCCBrShVxuRW4UrxmxnC1j0xtMbQTM5/QVrt0Laj/PI5zDg7YlAlLYmNk1aC0Oi AAX5s662Tps+e9mwkal98OcDygcY/lXnEbhud9L4GqyArf/W74hT4czfr6rObzq7pWuH P62oUaovx7itA4nNLOBunfdZXEpkM4gHFs2sww5psxXyUe28AA1h29Ti8s1bK9hCdG1y NTV+rc3IW8/r+1o5NTUuzXtHu3dtfLZy8w6HDqxjKnbhlEULeQbwZxgAxTNqs3XCXCxh qXzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2O30ybCC; 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 i2-20020a170902eb4200b0016d26c13a87si7773952pli.525.2022.07.23.03.44.14; Sat, 23 Jul 2022 03:44:30 -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=2O30ybCC; 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 S238928AbiGWKLP (ORCPT + 99 others); Sat, 23 Jul 2022 06:11:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239076AbiGWKJR (ORCPT ); Sat, 23 Jul 2022 06:09:17 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0DBFDCB763; Sat, 23 Jul 2022 03:02:25 -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 C2BECB82C1A; Sat, 23 Jul 2022 10:02:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2BE01C341C0; Sat, 23 Jul 2022 10:02:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658570521; bh=6XerrlduLrZI2GtrTstCZEHooVumelY789m2NBzA1Sw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2O30ybCCTVsXEr+yTcPDMU3M+5gUJYwrTCPAKGTN1pjlwhBZ90awT6zlaFC2tih1q 71OAv7NFy4nhmrN3U5eRovMCFvd53uKh7gbtaVd58vNm6847p+OHa77TjZcrot2rBS 4ufhVv92gAiUQLV0mUP0LYY/xYDkWNTl986e4QO4= 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/148] x86/speculation: Use cached host SPEC_CTRL value for guest entry/exit Date: Sat, 23 Jul 2022 11:55:27 +0200 Message-Id: <20220723095256.580892226@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 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); }