[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250925222641.6lgdjua6oavdmih5@desk>
Date: Thu, 25 Sep 2025 15:26:41 -0700
From: Pawan Gupta <pawan.kumar.gupta@...ux.intel.com>
To: "Kaplan, David" <David.Kaplan@....com>
Cc: "x86@...nel.org" <x86@...nel.org>, "H. Peter Anvin" <hpa@...or.com>,
Josh Poimboeuf <jpoimboe@...nel.org>,
Sean Christopherson <seanjc@...gle.com>,
Paolo Bonzini <pbonzini@...hat.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"kvm@...r.kernel.org" <kvm@...r.kernel.org>,
Asit Mallick <asit.k.mallick@...el.com>,
Tao Zhang <tao1.zhang@...el.com>
Subject: Re: [PATCH 2/2] x86/vmscape: Replace IBPB with branch history clear
on exit to userspace
On Thu, Sep 25, 2025 at 03:02:57PM -0700, Pawan Gupta wrote:
> On Thu, Sep 25, 2025 at 06:14:54PM +0000, Kaplan, David wrote:
> > > - if (vmscape_mitigation == VMSCAPE_MITIGATION_AUTO)
> > > + if (vmscape_mitigation == VMSCAPE_MITIGATION_IBPB_EXIT_TO_USER
> > > &&
> > > + !boot_cpu_has(X86_FEATURE_IBPB)) {
> > > + pr_err("IBPB not supported, switching to AUTO select\n");
> > > + vmscape_mitigation = VMSCAPE_MITIGATION_AUTO;
> > > + }
> >
> > I think there's a bug here in case you (theoretically) had a vulnerable
> > CPU that did not have IBPB and did not have BHI_CTRL. In that case, we
> > should select VMSCAPE_MITIGATION_NONE as we have no mitigation available.
> > But the code below will still re-select IBPB I believe even though there
> > is no IBPB.
>
> Yes, you are right. Let me see how to fix that.
Below should fix it.
---
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index 2f1a86d75877..60a2e54155e2 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -3328,8 +3328,10 @@ static void __init vmscape_select_mitigation(void)
*/
if (boot_cpu_has(X86_FEATURE_BHI_CTRL))
vmscape_mitigation = VMSCAPE_MITIGATION_BHB_CLEAR_EXIT_TO_USER;
- else
+ else if (boot_cpu_has(X86_FEATURE_IBPB))
vmscape_mitigation = VMSCAPE_MITIGATION_IBPB_EXIT_TO_USER;
+ else
+ vmscape_mitigation = VMSCAPE_MITIGATION_NONE;
}
static void __init vmscape_update_mitigation(void)
Powered by blists - more mailing lists