Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp454312imi; Fri, 22 Jul 2022 02:44:14 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tOGuxZF6kxkq54/FGT7LYFpZfK0iL4t4cosy8YLaINr2oorUsjQHyniBqjYzfQahJJcRXK X-Received: by 2002:a17:90a:1d0:b0:1ec:7066:49b8 with SMTP id 16-20020a17090a01d000b001ec706649b8mr3274887pjd.163.1658483054345; Fri, 22 Jul 2022 02:44:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658483054; cv=none; d=google.com; s=arc-20160816; b=DjS5H8MEePltYw13wPKfDdKV6g0iYhIskMGE4VzylGvQVAkg0HOF9tAt1FoNWO9aTq S0Fb7qXqNyZRas6Coo9CvpSHzv58B6Hj7fQpbNrW2fmqC4rwypZvQqGP+bhyJJ45nE1o M+/gKgNeIM3a8ibyHFnby4McR7CrStKtVGWFsjEA34QPw4bHJ5SCw0C/TEB2BhsWzsWi rjvGIFxxmLgoFflNnKpJUSDYX1ODkh6S/38Q+U5SsKHauSMJQqYSAF+j1DTRbPAC3Fx1 2iW10LLDYfC5yW8TCcfPHiYkJ2+ChOn8u4j3fL2ACxguFEZBeLzsGVR93G5e9QN5/7ts KiYg== 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=uD4nnprAzynsv2EIuXC4oxvwiwkGILbqc9+Q0ho/esU=; b=wPzeqklffxVErNkC1hA9wx/3cT6oOK6mAM9gzF6vHQL/blI2fHXBA0Zjfevridqrd0 5bdMRHA5VMlY27dBAB7FcqAmz8FJvs7N6MjnuIPc/oAFUFQdTib/hlMDzRx+1UTvNzhU Tic5p3RQZHw1k9wos5PRJByyxcM/Dfwd7Ml5sanoTS+3CiGAdG/iTpvnkLuM6ICQD3sF bQFDYCTcr9+K4mUWY8XB6GEDqFpQJJDi0LSRwCF/QzCKLgwJFxZPL86pc7HyLiGiT9UT EprRogs1jEXYP+TlVstozXLR8suUPHBIS9cydEOmt7ocfEFo3VvWL3ge6k6vtTbowhvK a43A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=G5zQKoMk; 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 e24-20020a63f558000000b003fd55602efasi5185900pgk.362.2022.07.22.02.43.58; Fri, 22 Jul 2022 02:44: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=G5zQKoMk; 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 S235413AbiGVJNh (ORCPT + 99 others); Fri, 22 Jul 2022 05:13:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234865AbiGVJMm (ORCPT ); Fri, 22 Jul 2022 05:12:42 -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 45AB23C8ED; Fri, 22 Jul 2022 02:10:24 -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 D5CF861F4D; Fri, 22 Jul 2022 09:10:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D2CEDC341C6; Fri, 22 Jul 2022 09:10:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658481023; bh=XYlx/CGlMFklOfXxJVZihlVrGPOesdPtbd4itWoo9GI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G5zQKoMkjsQnPwbYBGnxKjEvKXRojVmF+gklvOqC6Rp+p0G2arg63mHyDEUxslaMG Qkc8IPXzHm5/suSnzjOBYiQQtEXCMcL1y9gEXvY4tYInd8Dr32hgFaLlm5m1CbD4sS HIdGA0QA2S9h3BgHX/pU0A7Kjt9AoHgUbfAo1inI= 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 50/70] KVM: VMX: Fix IBRS handling after vmexit Date: Fri, 22 Jul 2022 11:07:45 +0200 Message-Id: <20220722090653.521629173@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 bea7e31a5caccb6fe8ed989c065072354f0ecb52 upstream. For legacy IBRS to work, the IBRS bit needs to be always re-written after vmexit, even if it's already on. 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/kvm/vmx/vmx.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -6845,8 +6845,13 @@ void noinstr vmx_spec_ctrl_restore_host( /* * If the guest/host SPEC_CTRL values differ, restore the host value. + * + * For legacy IBRS, the IBRS bit always needs to be written after + * transitioning from a less privileged predictor mode, regardless of + * whether the guest/host values differ. */ - if (vmx->spec_ctrl != hostval) + if (cpu_feature_enabled(X86_FEATURE_KERNEL_IBRS) || + vmx->spec_ctrl != hostval) native_wrmsrl(MSR_IA32_SPEC_CTRL, hostval); barrier_nospec();