lkml.org 
[lkml]   [2018]   [Jan]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v4 7/7] x86/speculation: Add basic IBPB (Indirect Branch Prediction Barrier) support
From
Date
On Thu, 2018-01-25 at 12:41 +0100, Borislav Petkov wrote:
>
> > +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");
>
> Lemme paste my simplification suggestion from the other day:
>
> "Btw, we can simplify this a bit by dropping the inputs and marking the 3
> GPRs as clobbered:
>
>         alternative_input("",
>                           "mov $0x49, %%ecx\n\t"
>                           "mov $1, %%eax\n\t"
>                           "xor %%edx, %%edx\n\t"
>                           "wrmsr\n\t",
>                           X86_FEATURE_IBPB,
>                           ASM_NO_INPUT_CLOBBER("eax", "ecx", "edx", "memory"));

Yeah, I saw that; sorry for not replying explicitly.

I did already do the explicit clobbers now you reminded me how to do
them, but I elected not to use ASM_NO_INPUT_CLOBBER() because on
balance, losing the MSR_IA32_PRED_CMD / PRED_CMD_IBPB definitions and
having to hard-code the numbers was not so much of a win.[unhandled content-type:application/x-pkcs7-signature]
\
 
 \ /
  Last update: 2018-01-25 12:48    [W:0.236 / U:0.100 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site