mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 10:11:27 +01:00
x86: fix rdrand asm()
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@suse.com> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com> Acked-by: Keir Fraser <keir@xen.org>
This commit is contained in:
1 parent
7099bd90e1
commit
573fd5bd2d
1 file changed
+1
-1
@@ -8,7 +8,7 @@ static inline unsigned int arch_get_random(void)
|
||||
unsigned int val = 0;
|
||||
|
||||
if ( cpu_has(¤t_cpu_data, X86_FEATURE_RDRAND) )
|
||||
asm ( ".byte 0x0f,0xc7,0xf0" : "+a" (val) );
|
||||
asm volatile ( ".byte 0x0f,0xc7,0xf0" : "+a" (val) );
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||