Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp459499imi; Fri, 22 Jul 2022 02:51:53 -0700 (PDT) X-Google-Smtp-Source: AGRyM1szKnDtgsBL24XqBG5ne+pUx2FbSkW88fM43uPqX3BUTN8ZDzgmEX2ZNAn59UeRdL4qOKxP X-Received: by 2002:a17:907:75f5:b0:72b:40da:a7cd with SMTP id jz21-20020a17090775f500b0072b40daa7cdmr2459361ejc.662.1658483512951; Fri, 22 Jul 2022 02:51:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658483512; cv=none; d=google.com; s=arc-20160816; b=iP/iM5FXN84fYvFBTp7XT2G0wjp+LWVODjp4YbsjQ12gkuhAxs3knJ86tNzMgY1GB/ 8IBmlW378RiA6mmi0kp4J41KwU2SmZ3PSasO2DmGJV2RsXVGmw6qpp+8fQNpm3iK2NS3 U1o6nvR81aw0x6B9bqot3OpVkeQRUWN+kGi3tdXCu863hDAYVyydr15/cQuaC02WWLr/ M4EPK/YB0sB06XvCNuAnAoiNTtXJIdWFKqU8c90sifWR1CCRc1nLcaZPSDZhjVNUSjbI gfl5ZI6pWrJD6bA4GKL3SqBZtXXtxRGKhCe8FnK4xSeOwmGkip9XGjMqlKy9OAyek0zx rDHg== 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=WqCUDuO2lrBJG2iHrzw0WEMMZntCNOyxILDfvOCfRk3kHRb1e0kcmhWUNyHV9ipB4b qcXU9bUXzXUVcOuVott5d4F2STqwZ3g8qQWAXni9KDbF92FFk6c61A7WoA/Iqr6D/MJI E/A5KvQ62CJTvlJ0UnuIpqVCHhQDz3EhckOsJmqk+bXHjsaW0E5nkEaOXSBmsKzIsWOf tRWVZnAiPHQvgXvFXphWg2XHiXL9I3UJKa3pr2eySdYg72+KoyoqZl9CrW2Qrqu9QxML jteg90/XhHOpw73l0DTJbijUU9LWo1QtBj0jMe+JA53RYawx/EG2NKMklrx8egBJDNBA Kewg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=N+300ZjX; 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 dm15-20020a170907948f00b0072f9c657421si4786720ejc.964.2022.07.22.02.51.28; Fri, 22 Jul 2022 02:51:52 -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=N+300ZjX; 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 S235446AbiGVJM4 (ORCPT + 99 others); Fri, 22 Jul 2022 05:12:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235393AbiGVJMO (ORCPT ); Fri, 22 Jul 2022 05:12:14 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3ABBA2B9; Fri, 22 Jul 2022 02:10:05 -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 CBF7FB827BC; Fri, 22 Jul 2022 09:10:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2C682C341C6; Fri, 22 Jul 2022 09:10:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658481002; bh=wPsbQJ1Esnk4q8K/3ZlNTMTr2q0GgDEreGwpsNW0F9s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N+300ZjXRmlqMK/N6J4nzv79eymtUCzPCwY+t5oNxDvtPB2gF8Yk8gbfIuXayqSuk PgxoYfsZ84Zi/lQ2NiV5aFpI7a4IBY00O4vJQXmtymOt7dxxC4Vx/BDBa+mkzWBR+N +T36gFTuaQj4aN8Z2mXR7/n0lKajjCJjqWgwNkKg= 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/70] x86/speculation: Use cached host SPEC_CTRL value for guest entry/exit Date: Fri, 22 Jul 2022 11:07:39 +0200 Message-Id: <20220722090653.186522929@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 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); }