From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C47753D74 for ; Mon, 21 Nov 2022 12:45:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 47FBBC433D7; Mon, 21 Nov 2022 12:45:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1669034736; bh=1CTtsCnIct2bpMiryAs18rseYItU2dP8l4Wp4JezzC4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SHrErmIcW7XvA2OXvMGIxa+l+5iOxqD9ZwobiffuyaBY5EkT/jyglmTN+IB4eQJaT 4pMmgCOiUGkrOxGvpjtrN361GKVerPLzgb7sUd87m2157xLRpZ2WtnhC4MbdmJeEq7 PNqx9BOaes8bmgmmMjZ7vHZB+BP5sDxJ7LaHChxg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Josh Poimboeuf , "Peter Zijlstra (Intel)" , Borislav Petkov , Thadeu Lima de Souza Cascardo , Suleiman Souhlal Subject: [PATCH 4.19 26/34] KVM: VMX: Fix IBRS handling after vmexit Date: Mon, 21 Nov 2022 13:43:48 +0100 Message-Id: <20221121124151.832205642@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221121124150.886779344@linuxfoundation.org> References: <20221121124150.886779344@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: Suleiman Souhlal Signed-off-by: Greg Kroah-Hartman --- arch/x86/kvm/vmx.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -10770,9 +10770,13 @@ u64 __always_inline vmx_spec_ctrl_restor guestval = __rdmsr(MSR_IA32_SPEC_CTRL); /* - * 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 (guestval != hostval) + if (cpu_feature_enabled(X86_FEATURE_KERNEL_IBRS) || + guestval != hostval) native_wrmsrl(MSR_IA32_SPEC_CTRL, hostval); barrier_nospec();