Re: [PATCH v5 7/7] x86/speculation: Add basic IBPB (Indirect Branch Prediction Barrier) support

From: Tim Chen
Date: Fri Jan 26 2018 - 16:36:11 EST


On 01/25/2018 08:14 AM, David Woodhouse wrote:

>
> diff --git a/arch/x86/include/asm/nospec-branch.h b/arch/x86/include/asm/nospec-branch.h
> index 4ad4108..34e384c 100644
> --- a/arch/x86/include/asm/nospec-branch.h
> +++ b/arch/x86/include/asm/nospec-branch.h
> @@ -218,5 +218,18 @@ static inline void vmexit_fill_RSB(void)
> #endif
> }
>
> +static inline void indirect_branch_prediction_barrier(void)
> +{
> + asm volatile(ALTERNATIVE("",
> + "movl %[msr], %%ecx\n\t"
> + "movl %[val], %%eax\n\t"
> + "movl $0, %%edx\n\t"
> + "wrmsr",
> + X86_FEATURE_IBPB)
> + : : [msr] "i" (MSR_IA32_PRED_CMD),
> + [val] "i" (PRED_CMD_IBPB)
> + : "eax", "ecx", "edx", "memory");

With Peter's fixing of paravirt's indirect call for wrmsr,
(https://patchwork.kernel.org/patch/10173547/)
we don't have to worry about indirect call in wrmsr anymore.

Can we use regular wrmsr here?

It will make IBPB tracing straightforward using the
MSR tracepoints.

Tim