]> xenbits.xensource.com Git - people/andrewcoop/xen-test-framework.git/commitdiff
hypercall: Refine fix for Clang code generation bug github/master
authorAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 11 Nov 2020 12:57:45 +0000 (12:57 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 11 Nov 2020 13:05:03 +0000 (13:05 +0000)
It was incorrect to switch "=a" to "+a" and set up hcall, as the hypercall
number is encoded in the offset within hypercall_page.  Switch res back to
just an output.

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

index bf1d4f1dd530ffc77d673e851cdff294e1a8fa34..34a7026ee159072b018f762396710a00945710ad 100644 (file)
@@ -9,49 +9,48 @@
 
 #define _hypercall32_1(type, hcall, a1)                                 \
     ({                                                                  \
-        long _res = (long)(hcall), _a1 = (long)(a1);                    \
+        long res, _a1 = (long)(a1);                                     \
         asm volatile (                                                  \
             "call hypercall_page + %c[offset]"                          \
-            : "+a" (_res), "+b" (_a1)                                   \
+            : "=a" (res), "+b" (_a1)                                    \
             : [offset] "i" (hcall * 32)                                 \
             : "memory" );                                               \
-        (type)_res;                                                     \
+        (type)res;                                                      \
     })
 
 #define _hypercall32_2(type, hcall, a1, a2)                             \
     ({                                                                  \
-        long _res = (long)(hcall), _a1 = (long)(a1), _a2 = (long)(a2);  \
+        long res, _a1 = (long)(a1), _a2 = (long)(a2);                   \
         asm volatile (                                                  \
             "call hypercall_page + %c[offset]"                          \
-            : "+a" (_res), "+b" (_a1), "+c" (_a2)                       \
+            : "=a" (res), "+b" (_a1), "+c" (_a2)                        \
             : [offset] "i" (hcall * 32)                                 \
             : "memory" );                                               \
-        (type)_res;                                                     \
+        (type)res;                                                      \
     })
 
 #define _hypercall32_3(type, hcall, a1, a2, a3)                         \
     ({                                                                  \
-        long _res = (long)(hcall), _a1 = (long)(a1), _a2 = (long)(a2),  \
-            _a3 = (long)(a3);                                           \
+        long res, _a1 = (long)(a1), _a2 = (long)(a2), _a3 = (long)(a3); \
         asm volatile (                                                  \
             "call hypercall_page + %c[offset]"                          \
-            : "+a" (_res), "+b" (_a1), "+c" (_a2), "+d" (_a3)           \
+            : "=a" (res), "+b" (_a1), "+c" (_a2), "+d" (_a3)            \
             : [offset] "i" (hcall * 32)                                 \
             : "memory" );                                               \
-        (type)_res;                                                     \
+        (type)res;                                                      \
     })
 
 #define _hypercall32_4(type, hcall, a1, a2, a3, a4)                     \
     ({                                                                  \
-        long _res = (long)(hcall), _a1 = (long)(a1), _a2 = (long)(a2),  \
-            _a3 = (long)(a3), _a4 = (long)(a4);                         \
+        long res, _a1 = (long)(a1), _a2 = (long)(a2), _a3 = (long)(a3), \
+            _a4 = (long)(a4);                                           \
         asm volatile (                                                  \
             "call hypercall_page + %c[offset]"                          \
-            : "+a" (_res), "+b" (_a1), "+c" (_a2), "+d" (_a3),          \
+            : "=a" (res), "+b" (_a1), "+c" (_a2), "+d" (_a3),           \
               "+S" (_a4)                                                \
             : [offset] "i" (hcall * 32)                                 \
             : "memory" );                                               \
-        (type)_res;                                                     \
+        (type)res;                                                      \
     })
 
 #endif /* XTF_X86_32_HYPERCALL_H */
index d6db99fe2895e62f4ffa208fdb80c4568ef5b6c4..d283ad344c6d85652f7231847931e15323b5aa68 100644 (file)
@@ -9,50 +9,48 @@
 
 #define _hypercall64_1(type, hcall, a1)                                 \
     ({                                                                  \
-        long _res = (long)(hcall), _a1 = (long)(a1);                    \
+        long res, _a1 = (long)(a1);                                     \
         asm volatile (                                                  \
             "call hypercall_page + %c[offset]"                          \
-            : "+a" (_res), "+D" (_a1)                                   \
+            : "=a" (res), "+D" (_a1)                                    \
             : [offset] "i" (hcall * 32)                                 \
             : "memory" );                                               \
-        (type)_res;                                                     \
+        (type)res;                                                      \
     })
 
 #define _hypercall64_2(type, hcall, a1, a2)                             \
     ({                                                                  \
-        long _res = (long)(hcall), _a1 = (long)(a1), _a2 = (long)(a2);  \
+        long res, _a1 = (long)(a1), _a2 = (long)(a2);                   \
         asm volatile (                                                  \
             "call hypercall_page + %c[offset]"                          \
-            : "+a" (_res), "+D" (_a1), "+S" (_a2)                       \
+            : "=a" (res), "+D" (_a1), "+S" (_a2)                        \
             : [offset] "i" (hcall * 32)                                 \
             : "memory" );                                               \
-        (type)_res;                                                     \
+        (type)res;                                                      \
     })
 
 #define _hypercall64_3(type, hcall, a1, a2, a3)                         \
     ({                                                                  \
-        long _res = (long)(hcall), _a1 = (long)(a1), _a2 = (long)(a2),  \
-            _a3 = (long)(a3);                                           \
+        long res, _a1 = (long)(a1), _a2 = (long)(a2), _a3 = (long)(a3); \
         asm volatile (                                                  \
             "call hypercall_page + %c[offset]"                          \
-            : "+a" (_res), "+D" (_a1), "+S" (_a2), "+d" (_a3)           \
+            : "=a" (res), "+D" (_a1), "+S" (_a2), "+d" (_a3)            \
             : [offset] "i" (hcall * 32)                                 \
             : "memory" );                                               \
-        (type)_res;                                                     \
+        (type)res;                                                      \
     })
 
 #define _hypercall64_4(type, hcall, a1, a2, a3, a4)                     \
     ({                                                                  \
-        long _res = (long)(hcall), _a1 = (long)(a1), _a2 = (long)(a2),  \
-            _a3 = (long)(a3);                                           \
+        long res, _a1 = (long)(a1), _a2 = (long)(a2), _a3 = (long)(a3); \
         register long _a4 asm ("r10") = (long)(a4);                     \
         asm volatile (                                                  \
             "call hypercall_page + %c[offset]"                          \
-            : "+a" (_res), "+D" (_a1), "+S" (_a2), "+d" (_a3),          \
+            : "=a" (res), "+D" (_a1), "+S" (_a2), "+d" (_a3),           \
               "+r" (_a4)                                                \
             : [offset] "i" (hcall * 32)                                 \
             : "memory" );                                               \
-        (type)_res;                                                     \
+        (type)res;                                                      \
     })
 
 #endif /* XTF_X86_64_HYPERCALL_H */