mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "tip-bot2 for Yosry Ahmed" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Yosry Ahmed <yosry.ahmed@linux.dev>,
	Ingo Molnar <mingo@kernel.org>, Jim Mattson <jmattson@google.com>,
	Josh Poimboeuf <jpoimboe@kernel.org>,
	Sean Christopherson <seanjc@google.com>,
	x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: x86/bugs] KVM: nVMX: Always use IBPB to properly virtualize IBRS
Date: Thu, 27 Feb 2025 10:12:01 -0000	[thread overview]
Message-ID: <174065112192.10177.13367372055996559360.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20250227012712.3193063-6-yosry.ahmed@linux.dev>

The following commit has been merged into the x86/bugs branch of tip:

Commit-ID:     8c4f28cd81fe86033918eec69d5280b532c05842
Gitweb:        https://git.kernel.org/tip/8c4f28cd81fe86033918eec69d5280b532c05842
Author:        Yosry Ahmed <yosry.ahmed@linux.dev>
AuthorDate:    Thu, 27 Feb 2025 01:27:11 
Committer:     Ingo Molnar <mingo@kernel.org>
CommitterDate: Thu, 27 Feb 2025 10:57:21 +01:00

KVM: nVMX: Always use IBPB to properly virtualize IBRS

On synthesized nested VM-exits in VMX, an IBPB is performed if IBRS is
advertised to the guest to properly provide separate prediction domains
for L1 and L2. However, this is currently conditional on
X86_FEATURE_USE_IBPB, which depends on the host spectre_v2_user
mitigation.

In short, if spectre_v2_user=no, IBRS is not virtualized correctly and
L1 becomes susceptible to attacks from L2. Fix this by performing the
IBPB regardless of X86_FEATURE_USE_IBPB.

Fixes: 2e7eab81425a ("KVM: VMX: Execute IBPB on emulated VM-exit when guest has IBRS")
Signed-off-by: Yosry Ahmed <yosry.ahmed@linux.dev>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Reviewed-by: Jim Mattson <jmattson@google.com>
Acked-by: Josh Poimboeuf <jpoimboe@kernel.org>
Acked-by: Sean Christopherson <seanjc@google.com>
Link: https://lore.kernel.org/r/20250227012712.3193063-6-yosry.ahmed@linux.dev
---
 arch/x86/kvm/vmx/nested.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
index 1df427a..8a7af02 100644
--- a/arch/x86/kvm/vmx/nested.c
+++ b/arch/x86/kvm/vmx/nested.c
@@ -5026,8 +5026,7 @@ void nested_vmx_vmexit(struct kvm_vcpu *vcpu, u32 vm_exit_reason,
 	 * doesn't isolate different VMCSs, i.e. in this case, doesn't provide
 	 * separate modes for L2 vs L1.
 	 */
-	if (guest_cpu_cap_has(vcpu, X86_FEATURE_SPEC_CTRL) &&
-	    cpu_feature_enabled(X86_FEATURE_USE_IBPB))
+	if (guest_cpu_cap_has(vcpu, X86_FEATURE_SPEC_CTRL))
 		indirect_branch_prediction_barrier();
 
 	/* Update any VMCS fields that might have changed while L2 ran */

  reply	other threads:[~2025-02-27 10:12 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-27  1:27 [PATCH v2 0/6] IBPB cleanups and a fixup Yosry Ahmed
2025-02-27  1:27 ` [PATCH v2 1/6] x86/bugs: Move the X86_FEATURE_USE_IBPB check into callers Yosry Ahmed
2025-02-27  1:41   ` Sean Christopherson
2025-02-27 10:12   ` [tip: x86/bugs] " tip-bot2 for Yosry Ahmed
2025-02-27  1:27 ` [PATCH v2 2/6] x86/mm: Remove X86_FEATURE_USE_IBPB checks in cond_mitigation() Yosry Ahmed
2025-02-27 10:12   ` [tip: x86/bugs] " tip-bot2 for Yosry Ahmed
2025-02-27  1:27 ` [PATCH v2 3/6] x86/bugs: Remove the X86_FEATURE_USE_IBPB check in ib_prctl_set() Yosry Ahmed
2025-02-27 10:12   ` [tip: x86/bugs] " tip-bot2 for Yosry Ahmed
2025-02-27  1:27 ` [PATCH v2 4/6] x86/bugs: Use a static branch to guard IBPB on vCPU switch Yosry Ahmed
2025-02-27  1:42   ` Sean Christopherson
2025-02-27 10:12   ` [tip: x86/bugs] " tip-bot2 for Yosry Ahmed
2025-02-27  1:27 ` [PATCH v2 5/6] KVM: nVMX: Always use IBPB to properly virtualize IBRS Yosry Ahmed
2025-02-27 10:12   ` tip-bot2 for Yosry Ahmed [this message]
2025-02-27  1:27 ` [PATCH v2 6/6] x86/bugs: Remove X86_FEATURE_USE_IBPB Yosry Ahmed
2025-02-27 10:12   ` [tip: x86/bugs] " tip-bot2 for Yosry Ahmed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=174065112192.10177.13367372055996559360.tip-bot2@tip-bot2 \
    --to=tip-bot2@linutronix.de \
    --cc=jmattson@google.com \
    --cc=jpoimboe@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=seanjc@google.com \
    --cc=x86@kernel.org \
    --cc=yosry.ahmed@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®