From: Andrew Cooper Date: Wed, 31 May 2017 14:21:59 +0000 (+0100) Subject: Fix build with GCC 7 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=afd7d33816aee6201a68b94af54f4f12976debf0;p=people%2Fandrewcoop%2Fxen-test-framework.git Fix build with GCC 7 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 Reported-by: Wei Liu Signed-off-by: Andrew Cooper Tested-by: Wei Liu --- diff --git a/arch/x86/include/arch/extable.h b/arch/x86/include/arch/extable.h index 792f26c..3a6a8f8 100644 --- a/arch/x86/include/arch/extable.h +++ b/arch/x86/include/arch/extable.h @@ -15,8 +15,8 @@ * Sample usage: *
  *   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));
  * 
*/ 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: *
  *   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));
  * 
*/ bool ex_record_fault_edi(struct cpu_regs *regs, const struct extable_entry *ex); diff --git a/arch/x86/include/arch/lib.h b/arch/x86/include/arch/lib.h index 961274a..e336474 100644 --- a/arch/x86/include/arch/lib.h +++ b/arch/x86/include/arch/lib.h @@ -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; } diff --git a/tests/cpuid-faulting/main.c b/tests/cpuid-faulting/main.c index cc1baa3..23fa6ca 100644 --- a/tests/cpuid-faulting/main.c +++ b/tests/cpuid-faulting/main.c @@ -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; diff --git a/tests/fpu-exception-emulation/main.c b/tests/fpu-exception-emulation/main.c index 24ec1df..c8eeb9e 100644 --- a/tests/fpu-exception-emulation/main.c +++ b/tests/fpu-exception-emulation/main.c @@ -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; } diff --git a/tests/xsa-173/main.c b/tests/xsa-173/main.c index dd5a25d..9376e17 100644 --- a/tests/xsa-173/main.c +++ b/tests/xsa-173/main.c @@ -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 ) diff --git a/tests/xsa-186/main.c b/tests/xsa-186/main.c index 894a229..d8766f4 100644 --- a/tests/xsa-186/main.c +++ b/tests/xsa-186/main.c @@ -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 ) diff --git a/tests/xsa-191/main.c b/tests/xsa-191/main.c index 7ede48d..ab31261 100644 --- a/tests/xsa-191/main.c +++ b/tests/xsa-191/main.c @@ -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 ) { diff --git a/tests/xsa-192/main.c b/tests/xsa-192/main.c index 17dec92..7e5b10b 100644 --- a/tests/xsa-192/main.c +++ b/tests/xsa-192/main.c @@ -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; } diff --git a/tests/xsa-196/main.c b/tests/xsa-196/main.c index ac7cb9c..16d6bc5 100644 --- a/tests/xsa-196/main.c +++ b/tests/xsa-196/main.c @@ -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; } diff --git a/tests/xsa-200/main.c b/tests/xsa-200/main.c index 69b1d3c..c790d81 100644 --- a/tests/xsa-200/main.c +++ b/tests/xsa-200/main.c @@ -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"); diff --git a/tests/xsa-212/main.c b/tests/xsa-212/main.c index 4b92cc9..5c7fac3 100644 --- a/tests/xsa-212/main.c +++ b/tests/xsa-212/main.c @@ -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) ) {