Re: [PATCH v4 09/11] x86/vmscape: Deploy BHB clearing mitigation

From: Pawan Gupta

Date: Fri Nov 21 2025 - 13:29:42 EST


On Fri, Nov 21, 2025 at 04:18:09PM +0200, Nikolay Borisov wrote:
>
>
> On 11/20/25 08:19, Pawan Gupta wrote:
> > IBPB mitigation for VMSCAPE is an overkill on CPUs that are only affected
> > by the BHI variant of VMSCAPE. On such CPUs, eIBRS already provides
> > indirect branch isolation between guest and host userspace. However, branch
> > history from guest may also influence the indirect branches in host
> > userspace.
> >
> > To mitigate the BHI aspect, use clear_bhb_loop().
> >
> > Signed-off-by: Pawan Gupta <pawan.kumar.gupta@xxxxxxxxxxxxxxx>
>
> <snip>
>
> > @@ -3278,6 +3290,9 @@ static void __init vmscape_apply_mitigation(void)
> > {
> > if (vmscape_mitigation == VMSCAPE_MITIGATION_IBPB_EXIT_TO_USER)
> > static_call_update(vmscape_predictor_flush, write_ibpb);
> > + else if (vmscape_mitigation == VMSCAPE_MITIGATION_BHB_CLEAR_EXIT_TO_USER &&
> > + IS_ENABLED(CONFIG_X86_64))
>
> why the x86_64 dependency ?

BHI sequence mitigation is only supported in 64-bit mode. I will add a
comment. Looking at it again, I realized that 64-bit check should be in
vmscape_select_mitigation(), otherwise we report incorrectly on 32-bit.

> > + static_call_update(vmscape_predictor_flush, clear_bhb_loop);
> > }
> > #undef pr_fmt
> > @@ -3369,6 +3384,7 @@ void cpu_bugs_smt_update(void)
> > break;
> > case VMSCAPE_MITIGATION_IBPB_ON_VMEXIT:
> > case VMSCAPE_MITIGATION_IBPB_EXIT_TO_USER:
> > + case VMSCAPE_MITIGATION_BHB_CLEAR_EXIT_TO_USER:
> > /*
> > * Hypervisors can be attacked across-threads, warn for SMT when
> > * STIBP is not already enabled system-wide.
> >
>