Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4704924imw; Tue, 12 Jul 2022 12:44:16 -0700 (PDT) X-Google-Smtp-Source: AGRyM1v+1xV7xcS+FKyu2D56Q8UkeUwGkWijx9bvE8CDgrAgGyBdaDD/GpAg6oAaIdwUuV/PSrUN X-Received: by 2002:a62:5bc5:0:b0:528:c346:9632 with SMTP id p188-20020a625bc5000000b00528c3469632mr25337687pfb.48.1657655056024; Tue, 12 Jul 2022 12:44:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657655056; cv=none; d=google.com; s=arc-20160816; b=PzipYhRvfHHhmqaOjxz0sm1KxxUJgT7U+fGmbw8XPSksZ0qAwoljA9bnccv/i8WFPi 9/c1JLYQJEBhfYfjg+qt7WCGHxe3VK/X+qyIzNXxI9iF1WfEYuUGaovN1fwwJ9J/ufSD EsgJY4TACEMPhc4XV6AKR85C3FY+raJATLRjTJWCFySrb2WIyidzGWwKGwH3TtGRozEw mBr92rGB3kw/5MzoyLtQ8HgBlwnrYlaG3BAwKsnc3NEIkjm+L2sWsmP98tjtAZQkWPto nZbN++da9sG04t6Gdl1EZgh6UgNU7+a4ezHI3Kip4iU+pbEpPA7R4Nxs42gGi47/AAu4 SDcQ== 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=F6nCRVJUpgcUlw8Udt2JaDTZu3rApBXGqxzva5ljaVQ=; b=MIj87hmO5rZKhkNNKBEgWTIuki7DGGZ4QhIqTgdzAaj4gXo3k7QFUciGemKpu5Sv5f qQ3on7x0cpGzChP0H7H/XJUzTy+4cLQglC8e64k+FTJW+0YKz9+k6zTuMRLRlsrJU5nk MmmRB7i5skxjQJkcyMVprvmAdhCMOJYxeRAy+m4f0iD8Q8ZOoIAUY+oyhn+X/alb2Aec /5WVeOVFPBtI0C1/fYKoO85fR2Z7GQ1ePLYJbU1l+hjCSgB6mFuTBke2u/iYjdnQMFg9 Tbl3D8nP4ecNOoG/Iyy+/E7sS7FW1StuEXokk+888gnyitoFsJKD6wyb2KqhrJPv+VL3 2g+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Y/c3G9BV"; 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 j18-20020a170902da9200b0016be52879a1si16243374plx.187.2022.07.12.12.44.03; Tue, 12 Jul 2022 12:44: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="Y/c3G9BV"; 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 S236039AbiGLTPr (ORCPT + 99 others); Tue, 12 Jul 2022 15:15:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236147AbiGLTOb (ORCPT ); Tue, 12 Jul 2022 15:14:31 -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 B42D4E7AD4; Tue, 12 Jul 2022 11:54: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 5F389B81B95; Tue, 12 Jul 2022 18:54:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 81FB3C3411C; Tue, 12 Jul 2022 18:54:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657652054; bh=wPsbQJ1Esnk4q8K/3ZlNTMTr2q0GgDEreGwpsNW0F9s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y/c3G9BVKksgQ7AeNRy91N+tFmG85EG6RiZs8afPiQq59WBMW4Nb38UlSFWT7VUOD cfV24+NLmwW3cGTMaF08LLx9OKadNQV5nhW+sSdMN5Ku1i3W8qILvUQPgsqkmYXTxO mT7dQVFTK3BQUhWpb3jCjf4YniZUie5EV8OuhWQ8= 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 Subject: [PATCH 5.18 44/61] x86/speculation: Use cached host SPEC_CTRL value for guest entry/exit Date: Tue, 12 Jul 2022 20:39:41 +0200 Message-Id: <20220712183238.714497254@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 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: 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 @@ -208,7 +208,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 ? */ @@ -221,15 +221,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); @@ -1390,7 +1381,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); }