Re: [PATCH v2 2/3] x86/vmscape: Replace IBPB with branch history clear on exit to userspace

Pawan Gupta
2025-10-20T20:56:11Z

On Mon, Oct 20, 2025 at 09:10:17AM -0700, Sean Christopherson wrote:
> On Wed, Oct 15, 2025, Pawan Gupta wrote:
> > diff --git a/arch/x86/include/asm/nospec-branch.h b/arch/x86/include/asm/nospec-branch.h
> > index 49707e563bdf71bdd05d3827f10dd2b8ac6bca2c..00730cc22c2e7115f6dbb38a1ed8d10383ada5c0 100644
> > --- a/arch/x86/include/asm/nospec-branch.h
> > +++ b/arch/x86/include/asm/nospec-branch.h
> > @@ -534,7 +534,7 @@ void alternative_msr_write(unsigned int msr, u64 val, unsigned int feature)
> > : "memory");
> > }
> >
> > -DECLARE_PER_CPU(bool, x86_ibpb_exit_to_user);
> > +DECLARE_PER_CPU(bool, x86_pred_flush_pending);
>
> Rather than "flush pending", what about using "need" in the name to indicate that
> a flush is necessary? That makes it more obvious that e.g. KVM is marking the
> CPU as needing a flush by some other code, as opposed to implying that KVM itself
> has a pending flush.
>
> And maybe spell out "prediction"? Without the context of features being checked,
> I don't know that I would be able to guess "prediction".
>
> E.g. x86_need_prediction_flush?
>
> Or x86_prediction_flush_exit_to_user if we would prefer to clarify when the flush
> needs to occur?

Ok, ya this is more clear. I would want to make a small change, instead of
"prediction_flush", "predictor_flush" reads better to me. Changing it to:
x86_predictor_flush_exit_to_user.