]> xenbits.xensource.com Git - people/andrewcoop/xen-test-framework.git/commitdiff
Fix build with GCC 7
authorAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 31 May 2017 14:21:59 +0000 (15:21 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 31 May 2017 15:59:49 +0000 (16:59 +0100)
c/s e399b894f0 tried to make the function parameter to _ASM_EXTABLE_HANDLER()
visible to the compiler, for the benefit of LTO builds.  Unfortunately, GCC 7
doesn't like the chosen method, citing:

    error: asm operand 4 probably doesn’t match constraints [-Werror]

Instead, revert back to using the function by name, and make it visible to the
compiler by using the "X" constraint.

While making these changes, add a missing reference to
fpu-exception-emulation's probe_avx() and xsa-212's test_main().

Reported-by: Sergey Dyasli <sergey.dyasli@citrix.com>
Reported-by: Wei Liu <wei.liu2@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Tested-by: Wei Liu <wei.liu2@citrix.com>
arch/x86/include/arch/extable.h
arch/x86/include/arch/lib.h
tests/cpuid-faulting/main.c
tests/fpu-exception-emulation/main.c
tests/xsa-173/main.c
tests/xsa-186/main.c
tests/xsa-191/main.c
tests/xsa-192/main.c
tests/xsa-196/main.c
tests/xsa-200/main.c
tests/xsa-212/main.c

index 792f26ca2a82c21508625115c1e6a271dea0fb12..3a6a8f8b05580a6141899410dc87d08344e7acd1 100644 (file)
@@ -15,8 +15,8 @@
  * Sample usage:
  * <pre>
  *   asm volatile ("1: $INSN; 2:"
- *                 _ASM_EXTABLE_HANDLER(1b, 2b, @%c[ex])
- *                 : "=a" (fault) : "0" (0), [ex] "i" (ex_record_fault_eax));
+ *                 _ASM_EXTABLE_HANDLER(1b, 2b, ex_record_fault_eax)
+ *                 : "=a" (fault) : "0" (0), "X" (ex_record_fault_eax));
  * </pre>
  */
 bool ex_record_fault_eax(struct cpu_regs *regs, const struct extable_entry *ex);
@@ -27,8 +27,8 @@ bool ex_record_fault_eax(struct cpu_regs *regs, const struct extable_entry *ex);
  * Sample usage:
  * <pre>
  *   asm volatile ("1: $INSN; 2:"
- *                 _ASM_EXTABLE_HANDLER(1b, 2b, @%c[ex])
- *                 : "=D" (fault) : "0" (0), [ex] "i" (ex_record_fault_edi));
+ *                 _ASM_EXTABLE_HANDLER(1b, 2b, ex_record_fault_edi)
+ *                 : "=D" (fault) : "0" (0), "X" (ex_record_fault_edi));
  * </pre>
  */
 bool ex_record_fault_edi(struct cpu_regs *regs, const struct extable_entry *ex);
index 961274a494335ae3bb6a2a9355c30eed13e3e99a..e336474db1a04e64118e65b43a8567d79e6a8a93 100644 (file)
@@ -19,9 +19,9 @@ static inline bool rdmsr_safe(uint32_t idx, uint64_t *val)
     uint32_t lo, hi, new_idx;
 
     asm volatile("1: rdmsr; 2:"
-                 _ASM_EXTABLE_HANDLER(1b, 2b, %c[ex])
+                 _ASM_EXTABLE_HANDLER(1b, 2b, ex_rdmsr_safe)
                  : "=a" (lo), "=d" (hi), "=c" (new_idx)
-                 : "c" (idx), [ex] "i" (ex_rdmsr_safe));
+                 : "c" (idx), "X" (ex_rdmsr_safe));
 
     bool fault = idx != new_idx;
 
@@ -43,11 +43,11 @@ static inline bool wrmsr_safe(uint32_t idx, uint64_t val)
     uint32_t new_idx;
 
     asm volatile ("1: wrmsr; 2:"
-                  _ASM_EXTABLE_HANDLER(1b, 2b, %c[ex])
+                  _ASM_EXTABLE_HANDLER(1b, 2b, ex_wrmsr_safe)
                   : "=c" (new_idx)
                   : "c" (idx), "a" ((uint32_t)val),
                     "d" ((uint32_t)(val >> 32)),
-                    [ex] "i" (ex_wrmsr_safe));
+                    "X" (ex_wrmsr_safe));
 
     return idx != new_idx;
 }
index cc1baa375176d8f662808d1987e3c9c5b1284ab7..23fa6ca3d2dae2f3504f556804d18aa49b222d22 100644 (file)
@@ -34,9 +34,9 @@ unsigned long stub_cpuid(void)
     unsigned int fault = 0, tmp;
 
     asm volatile("1: cpuid; 2:"
-                 _ASM_EXTABLE_HANDLER(1b, 2b, %c[ex])
+                 _ASM_EXTABLE_HANDLER(1b, 2b, ex_record_fault_edi)
                  : "=a" (tmp), "+D" (fault)
-                 : "a" (0), [ex] "i" (ex_record_fault_edi)
+                 : "a" (0), "X" (ex_record_fault_edi)
                  : "ebx", "ecx", "edx");
 
     return fault;
@@ -48,9 +48,9 @@ unsigned long stub_fep_cpuid(void)
 
     asm volatile(_ASM_XEN_FEP
                  "1: cpuid; 2:"
-                 _ASM_EXTABLE_HANDLER(1b, 2b, %c[ex])
+                 _ASM_EXTABLE_HANDLER(1b, 2b, ex_record_fault_edi)
                  : "=a" (tmp), "+D" (fault)
-                 : "a" (0), [ex] "i" (ex_record_fault_edi)
+                 : "a" (0), "X" (ex_record_fault_edi)
                  : "ebx", "ecx", "edx");
 
     return fault;
index 24ec1dff0574d5a586d43ffb72a9a8941bce0863..c8eeb9eeb9016611ef7fcb3127627de7470e3d99 100644 (file)
@@ -77,10 +77,10 @@ exinfo_t probe_x87(bool force)
                   "jz 1f;"
                   _ASM_XEN_FEP
                   "1: fnop; 2:"
-                  _ASM_EXTABLE_HANDLER(1b, 2b, %c[ex])
+                  _ASM_EXTABLE_HANDLER(1b, 2b, ex_record_fault_eax)
                   : "+a" (fault)
                   : [fep] "q" (force),
-                    [ex]  "i" (ex_record_fault_eax));
+                    "X" (ex_record_fault_eax));
 
     return fault;
 }
@@ -110,10 +110,10 @@ exinfo_t probe_x87_wait(bool force)
                   "jz 1f;"
                   _ASM_XEN_FEP
                   "1: wait; 2:"
-                  _ASM_EXTABLE_HANDLER(1b, 2b, %c[ex])
+                  _ASM_EXTABLE_HANDLER(1b, 2b, ex_record_fault_eax)
                   : "+a" (fault)
                   : [fep] "q" (force),
-                    [ex]  "i" (ex_record_fault_eax));
+                    "X" (ex_record_fault_eax));
 
     return fault;
 }
@@ -142,10 +142,10 @@ exinfo_t probe_mmx(bool force)
                   "jz 1f;"
                   _ASM_XEN_FEP
                   "1: movq %%mm0, %%mm0; 2:"
-                  _ASM_EXTABLE_HANDLER(1b, 2b, %c[ex])
+                  _ASM_EXTABLE_HANDLER(1b, 2b, ex_record_fault_eax)
                   : "+a" (fault)
                   : [fep] "q" (force),
-                    [ex]  "i" (ex_record_fault_eax));
+                    "X" (ex_record_fault_eax));
 
     return fault;
 }
@@ -158,10 +158,10 @@ exinfo_t probe_sse(bool force)
                   "jz 1f;"
                   _ASM_XEN_FEP
                   "1: movups %%xmm0, %%xmm0; 2:"
-                  _ASM_EXTABLE_HANDLER(1b, 2b, %c[ex])
+                  _ASM_EXTABLE_HANDLER(1b, 2b, ex_record_fault_eax)
                   : "+a" (fault)
                   : [fep] "q" (force),
-                    [ex]  "i" (ex_record_fault_eax));
+                    "X" (ex_record_fault_eax));
 
     return fault;
 }
@@ -192,7 +192,8 @@ static exinfo_t probe_avx(bool force)
                   "1: vmovups %%xmm0, %%xmm0; 2:"
                   _ASM_EXTABLE_HANDLER(1b, 2b, ex_record_fault_eax)
                   : "+a" (fault)
-                  : [fep] "q" (force));
+                  : [fep] "q" (force),
+                    "X" (ex_record_fault_eax));
 
     return fault;
 }
index dd5a25dab52b070c35a0a63776e1d6e87bd1befa..9376e172a6f27a65b9e5e556f130c1d6a5358670 100644 (file)
@@ -66,10 +66,10 @@ void test_main(void)
     ptr = _p((4ULL << PAE_L3_PT_SHIFT) + MB(1));
 
     asm volatile ("1:mov (%[ptr]), %[val]; 2:"
-                  _ASM_EXTABLE_HANDLER(1b, 2b, %c[ex])
+                  _ASM_EXTABLE_HANDLER(1b, 2b, ex_fault)
                   : [val] "=q" (val)
                   : [ptr] "r" (ptr),
-                    [ex]  "i" (ex_fault)
+                    "X" (ex_fault)
                   : "memory");
 
     if ( seen_fault )
index 894a229970775238cda91d4b0c3bd317dd6755d9..d8766f43bec578e5ca6b21e4e1edc439cbe60b9c 100644 (file)
@@ -178,11 +178,11 @@ void test_main(void)
      * instructions don't get lost.
      */
     asm volatile ("call *%[ptr];"
-                  _ASM_EXTABLE_HANDLER(-1, 0, %c[ex])
+                  _ASM_EXTABLE_HANDLER(-1, 0, ex_fault)
                   : "=a" (res)
                   : "0" (0),
                     [ptr] "r" (stub),
-                    [ex]  "i" (ex_fault)
+                    "X" (ex_fault)
                   : "memory");
 
     if ( res != 0xc0de )
index 7ede48dc8b159e8229b77318def565bc7da31a8a..ab312611f5b2e6193a1aea3eadf4d4589c7f776a 100644 (file)
@@ -44,11 +44,11 @@ void test_main(void)
     write_fs(0);
     asm volatile (_ASM_XEN_FEP
                   "1: mov %%fs:0, %[dst]; 2:"
-                  _ASM_EXTABLE_HANDLER(1b, 2b, %c[ex])
+                  _ASM_EXTABLE_HANDLER(1b, 2b, ex_record_fault_edi)
                   : "=D" (fault),
                     [dst] "=r" (tmp)
                   : "D" (0),
-                    [ex] "i" (ex_record_fault_edi));
+                    "X" (ex_record_fault_edi));
 
     switch ( fault )
     {
@@ -82,11 +82,11 @@ void test_main(void)
 
     asm volatile (_ASM_XEN_FEP
                   "1: mov %[sel], %%fs; 2:"
-                  _ASM_EXTABLE_HANDLER(1b, 2b, %c[ex])
+                  _ASM_EXTABLE_HANDLER(1b, 2b, ex_record_fault_eax)
                   : "=a" (fault)
                   : "a" (0),
                     [sel] "r" (4),
-                    [ex]  "i" (ex_record_fault_eax));
+                    "X" (ex_record_fault_eax));
 
     switch ( fault )
     {
index 17dec929bf6992ece59b3dcbce6307706c444bd3..7e5b10b7f94a218595f84d5d3a5a91ad37869052 100644 (file)
@@ -69,10 +69,10 @@ unsigned long user_ldt_use(void)
 
     /* Attempt to load %fs from the LDT. */
     asm volatile ("1: mov %[sel], %%fs; 2:"
-                  _ASM_EXTABLE_HANDLER(1b, 2b, %c[ex])
+                  _ASM_EXTABLE_HANDLER(1b, 2b, ex_record_fault_eax)
                   : "+a" (fault)
                   : [sel] "r" (LDT_SEL),
-                    [ex]  "i" (ex_record_fault_eax));
+                    "X" (ex_record_fault_eax));
 
     return fault;
 }
index ac7cb9c6f2ac1b2513e80878ca251312b8f67dca..16d6bc5d9c243381486550657567b337682aa615 100644 (file)
@@ -56,7 +56,7 @@ unsigned long compat_userspace(void)
                   "start_32bit:;"
                   _ASM_XEN_FEP
                   "1: int $%c[df]; 2:"
-                  _ASM_EXTABLE_HANDLER(1b, 2b, %c[ex])
+                  _ASM_EXTABLE_HANDLER(1b, 2b, ex_record_fault_eax)
 
                   /* Return to 64bit. */
                   "ljmpl $%c[cs], $1f;"
@@ -67,7 +67,7 @@ unsigned long compat_userspace(void)
                   : [df]   "i" (X86_EXC_DF),
                     [cs32] "i" (GDTE_CS32_DPL3 * 8 + 3),
                     [cs]   "i" (__USER_CS),
-                    [ex]   "i" (ex_record_fault_eax));
+                    "X" (ex_record_fault_eax));
 
     return fault;
 }
index 69b1d3c21b1ee5ce04a80ce1447450e157f3ce49..c790d815a96aff1f5e7bd8051251fd099e1be0c3 100644 (file)
@@ -45,10 +45,10 @@ void test_main(void)
     {
         /* Poke the emulator. */
         asm volatile (_ASM_XEN_FEP "1: .byte 0x66; cmpxchg8b %[ptr]; 2:"
-                      _ASM_EXTABLE_HANDLER(1b, 2b, %c[ex])
+                      _ASM_EXTABLE_HANDLER(1b, 2b, ex_record_fault_edi)
                       : "=A" (prev), [ptr] "+m" (mem), "+D" (fault)
                       : "c" ((uint32_t)(new >> 32)), "b" ((uint32_t)new),
-                        "0" (old), [ex] "i" (ex_record_fault_edi));
+                        "0" (old), "X" (ex_record_fault_edi));
 
         if ( fault == EXINFO_SYM(UD, 0) )
             return xtf_success("Success: Not vulnerable to XSA-200\n");
index 4b92cc946c50d01bae4259fbae394b8b814475c1..5c7fac3fbe8b8069e97bab08a8a16a4841f28c88 100644 (file)
@@ -88,7 +88,7 @@ void test_main(void)
         asm volatile ("1: div %%ecx; 2:"
                       _ASM_EXTABLE_HANDLER(1b, 2b, ex_record_fault_edi)
                       : "+&a" (low), "+&d" (hi), "+D" (fault)
-                      : "c" (0));
+                      : "c" (0), "X" (ex_record_fault_edi));
 
         if ( fault == EXINFO_SYM(DE, 0) )
         {