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

Sean Christopherson
2025-10-20T16:10:19Z

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?