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

Re: [Xen-devel] x86: fix rdrand asm()


  • To: Jan Beulich <JBeulich@xxxxxxxx>, xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Keir Fraser <keir.xen@xxxxxxxxx>
  • Date: Wed, 25 Sep 2013 17:06:41 +0100
  • Delivery-date: Wed, 25 Sep 2013 16:07:01 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xen.org>
  • Thread-index: Ac66CTjBmdihOg3yJ02FmmJM0FUzhQ==
  • Thread-topic: x86: fix rdrand asm()

On 25/09/2013 16:46, "Jan Beulich" <JBeulich@xxxxxxxx> wrote:

> Just learned the hard way that at least for non-volatile asm()s gcc
> indeed does what the documentation says: It may move it across jumps
> (i.e. ahead of the cpu_has() check). While the documentation claims
> that this can also happen for volatile asm()s, if that was the case
> we'd have many more problems in our code (and e,g, Linux would too).
> 
> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
> 
> --- a/xen/include/asm-x86/random.h
> +++ b/xen/include/asm-x86/random.h
> @@ -8,7 +8,7 @@ static inline unsigned int arch_get_rand
>      unsigned int val = 0;
>  
>      if ( cpu_has(&current_cpu_data, X86_FEATURE_RDRAND) )
> -        asm ( ".byte 0x0f,0xc7,0xf0" : "+a" (val) );
> +        __asm__ __volatile__ ( ".byte 0x0f,0xc7,0xf0" : "+a" (val) );

Although not consistently applied, we use 'asm volatile' rather than
'__asm__ __volatile__' generally. So we should here. Apart from that
Acked-by: Keir Fraser <keir@xxxxxxx>

>      return val;
>  }
> 
> 
> 



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.