Re: [PATCH] x86/spectre_v1: Disable compiler optimizations over array_index_mask_nospec()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux