]> xenbits.xensource.com Git - people/andrewcoop/xen-test-framework.git/commitdiff
Fix x{get,set}bv() build with Clang 3.9
authorAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 6 Mar 2017 13:31:42 +0000 (13:31 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 6 Mar 2017 13:45:05 +0000 (13:45 +0000)
In 32bit builds, Clang objects to using uint64_t's with 32bit asm operands.

  In file included from /local/xen-test-framework.git/arch/x86/pv/traps.c:7:
  /local/xen-test-framework.git/arch/x86/include/arch/lib.h:404:52: error:
  invalid output size for constraint '=d'
      asm volatile ("xgetbv" : "=a" (feat_lo), "=d" (feat_hi)
                                                     ^

  /local/xen-test-framework.git/arch/x86/include/arch/lib.h:412:59: error:
  invalid input size for constraint 'd'
      asm volatile ("xsetbv" :: "a" ((uint32_t)value), "d" (value >> 32),
                                                            ^

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
arch/x86/include/arch/lib.h

index cb3cde09488e6cf3b360ff0e22823998f22a6f1f..405343c98a40b85e182749da77f4393622231612 100644 (file)
@@ -398,18 +398,18 @@ static inline unsigned int str(void)
 
 static inline uint64_t xgetbv(uint32_t index)
 {
-    uint32_t feat_lo;
-    uint64_t feat_hi;
+    uint32_t feat_lo, feat_hi;
 
     asm volatile ("xgetbv" : "=a" (feat_lo), "=d" (feat_hi)
                            :  "c" (index) );
 
-    return feat_lo | (feat_hi << 32);
+    return feat_lo | ((uint64_t)feat_hi << 32);
 }
 
 static inline void xsetbv(uint32_t index, uint64_t value)
 {
-    asm volatile ("xsetbv" :: "a" ((uint32_t)value), "d" (value >> 32),
+    asm volatile ("xsetbv" :: "a" ((uint32_t)value),
+                              "d" ((uint32_t)(value >> 32)),
                               "c" (index) );
 }