lkml.org 
[lkml]   [2018]   [Jun]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] x86/spectre_v1: Disable compiler optimizations over array_index_mask_nospec()
Dan,

On Wed, 30 May 2018, Mark Rutland wrote:
> > diff --git a/arch/x86/include/asm/barrier.h b/arch/x86/include/asm/barrier.h
> > index 042b5e892ed1..41f7435c84a7 100644
> > --- a/arch/x86/include/asm/barrier.h
> > +++ b/arch/x86/include/asm/barrier.h
> > @@ -38,10 +38,11 @@ static inline unsigned long array_index_mask_nospec(unsigned long index,
> > {
> > unsigned long mask;
> >
> > - asm ("cmp %1,%2; sbb %0,%0;"
> > + asm volatile ("cmp %1,%2; sbb %0,%0;"
> > :"=r" (mask)
> > :"g"(size),"r" (index)
> > :"cc");
> > + barrier();
> > return mask;
> > }
>
> What does the barrier() prevent?
>
> I don't think that inhibits the insertion of branches, and AFAIK the volatile
> is sufficient to prevent elision of identical array_idx_nospec() calls.
>
> I don't have an objection to it, regardless.
>
> So long as the example is updated in the commit message, feel free to add:

Any update on this?

Thanks,

tglx

\
 
 \ /
  Last update: 2018-06-06 12:25    [W:0.046 / U:5.128 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site