From f2ce613af59d0d3936152c2a41c027e37cdd2687 Mon Sep 17 00:00:00 2001 From: Andrew Cooper Date: Tue, 7 May 2019 11:19:58 +0100 Subject: [PATCH] Use named asm parameters for _ASM_EXTABLE_HANDLER() LTO builds need to know that ex_record_fault_{eax,edi} are referenced from within asm, to avoid the functions being discarded. Previously, this was done with an "X" parameter listing the function twice, but this can lead to copy/paste mistakes. Instead, use a named parameter and the "p" type and "P" modifier, which works compatibly between GCC and Clang. Signed-off-by: Andrew Cooper --- arch/x86/include/arch/extable.h | 8 ++--- arch/x86/include/arch/lib.h | 4 +-- arch/x86/include/arch/msr.h | 8 ++--- arch/x86/pv/traps.c | 6 ++-- tests/cpuid-faulting/main.c | 8 ++--- tests/debug-regs/main.c | 8 ++--- tests/fpu-exception-emulation/main.c | 20 ++++++------- tests/invlpg/main.c | 16 +++++----- tests/nested-vmx/util.c | 12 ++++---- tests/pv-fsgsbase/main.c | 16 +++++----- tests/selftest/main.c | 5 ++-- tests/umip/main.c | 20 ++++++------- tests/xsa-186/main.c | 4 +-- tests/xsa-191/main.c | 8 ++--- tests/xsa-192/main.c | 4 +-- tests/xsa-196/main.c | 4 +-- tests/xsa-200/main.c | 4 +-- tests/xsa-212/main.c | 4 +-- tests/xsa-227/main.c | 4 +-- tests/xsa-259/main.c | 4 +-- tests/xsa-260/main.c | 12 ++++---- tests/xsa-278/main.c | 44 ++++++++++++++-------------- 22 files changed, 111 insertions(+), 112 deletions(-) diff --git a/arch/x86/include/arch/extable.h b/arch/x86/include/arch/extable.h index 8e1baf9..cdff01d 100644 --- a/arch/x86/include/arch/extable.h +++ b/arch/x86/include/arch/extable.h @@ -17,8 +17,8 @@ struct extable_entry; * Sample usage: *
  *   asm volatile ("1: $INSN; 2:"
- *                 _ASM_EXTABLE_HANDLER(1b, 2b, ex_record_fault_eax)
- *                 : "=a" (fault) : "0" (0), "X" (ex_record_fault_eax));
+ *                 _ASM_EXTABLE_HANDLER(1b, 2b, %P[rec])
+ *                 : "=a" (fault) : "0" (0), [rec] "p" (ex_record_fault_eax));
  * 
*/ bool ex_record_fault_eax(struct cpu_regs *regs, const struct extable_entry *ex); @@ -29,8 +29,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, ex_record_fault_edi)
- *                 : "=D" (fault) : "0" (0), "X" (ex_record_fault_edi));
+ *                 _ASM_EXTABLE_HANDLER(1b, 2b, %P[rec])
+ *                 : "=D" (fault) : "0" (0), [rec] "p" (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 4e62bf9..e9857fa 100644 --- a/arch/x86/include/arch/lib.h +++ b/arch/x86/include/arch/lib.h @@ -281,10 +281,10 @@ static inline bool write_cr4_safe(unsigned long cr4) exinfo_t fault = 0; asm volatile ("1: mov %[cr4], %%cr4; 2:" - _ASM_EXTABLE_HANDLER(1b, 2b, ex_record_fault_edi) + _ASM_EXTABLE_HANDLER(1b, 2b, %P[rec]) : "+D" (fault) : [cr4] "r" (cr4), - "X" (ex_record_fault_edi)); + [rec] "p" (ex_record_fault_edi)); return fault; } diff --git a/arch/x86/include/arch/msr.h b/arch/x86/include/arch/msr.h index 9fdc236..7a74467 100644 --- a/arch/x86/include/arch/msr.h +++ b/arch/x86/include/arch/msr.h @@ -37,9 +37,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, ex_rdmsr_safe) + _ASM_EXTABLE_HANDLER(1b, 2b, %P[hnd]) : "=a" (lo), "=d" (hi), "=c" (new_idx) - : "c" (idx), "X" (ex_rdmsr_safe)); + : "c" (idx), [hnd] "p" (ex_rdmsr_safe)); bool fault = idx != new_idx; @@ -71,11 +71,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, ex_wrmsr_safe) + _ASM_EXTABLE_HANDLER(1b, 2b, %P[hnd]) : "=c" (new_idx) : "c" (idx), "a" ((uint32_t)val), "d" ((uint32_t)(val >> 32)), - "X" (ex_wrmsr_safe)); + [hnd] "p" (ex_wrmsr_safe)); return idx != new_idx; } diff --git a/arch/x86/pv/traps.c b/arch/x86/pv/traps.c index 6bb4e44..3ff6cef 100644 --- a/arch/x86/pv/traps.c +++ b/arch/x86/pv/traps.c @@ -234,11 +234,11 @@ void arch_init_traps(void) "jmp 3f;" "2: ret;" "3:" - _ASM_EXTABLE_HANDLER(1b, 3b, ex_pf_user) - _ASM_EXTABLE_HANDLER(0xfff, 2b, ex_pf_user) + _ASM_EXTABLE_HANDLER(1b, 3b, %P[rec]) + _ASM_EXTABLE_HANDLER(0xfff, 2b, %P[rec]) : "+a" (leaked) : [ptr] "r" (0xfff), - "X" (ex_pf_user)); + [rec] "p" (ex_pf_user)); if ( leaked ) panic("Xen's SMEP/SMAP settings leaked into guest context.\n" diff --git a/tests/cpuid-faulting/main.c b/tests/cpuid-faulting/main.c index ecad92d..56ee49e 100644 --- a/tests/cpuid-faulting/main.c +++ b/tests/cpuid-faulting/main.c @@ -30,9 +30,9 @@ unsigned long stub_cpuid(void) unsigned int fault = 0, tmp; asm volatile("1: cpuid; 2:" - _ASM_EXTABLE_HANDLER(1b, 2b, ex_record_fault_edi) + _ASM_EXTABLE_HANDLER(1b, 2b, %P[rec]) : "=a" (tmp), "+D" (fault) - : "a" (0), "X" (ex_record_fault_edi) + : "a" (0), [rec] "p" (ex_record_fault_edi) : "ebx", "ecx", "edx"); return fault; @@ -44,9 +44,9 @@ unsigned long stub_fep_cpuid(void) asm volatile(_ASM_XEN_FEP "1: cpuid; 2:" - _ASM_EXTABLE_HANDLER(1b, 2b, ex_record_fault_edi) + _ASM_EXTABLE_HANDLER(1b, 2b, %P[rec]) : "=a" (tmp), "+D" (fault) - : "a" (0), "X" (ex_record_fault_edi) + : "a" (0), [rec] "p" (ex_record_fault_edi) : "ebx", "ecx", "edx"); return fault; diff --git a/tests/debug-regs/main.c b/tests/debug-regs/main.c index 5f18fea..60c7c86 100644 --- a/tests/debug-regs/main.c +++ b/tests/debug-regs/main.c @@ -101,10 +101,10 @@ static void test_pv_dr7_latch(void) asm volatile ("mov %[dr7], %%dr7;" "movl $0, %[ptr]; 1:" - _ASM_EXTABLE_HANDLER(1b, 1b, ex_record_fault_eax) + _ASM_EXTABLE_HANDLER(1b, 1b, %P[rec]) : "+a" (fault), [ptr] "=m" (dummy) - : [dr7] "r" (dr7), "X" (ex_record_fault_eax)); + : [dr7] "r" (dr7), [rec] "p" (ex_record_fault_eax)); /* Reset any latched %dr7 content. */ write_dr7(0); @@ -166,10 +166,10 @@ static void test_pv_dr7_io_breakpoints(void) /* Attempt to reload an IO breakpoint in %dr0, which should fail ... */ exinfo_t fault = 0; asm volatile ("1: mov %[val], %%dr7; 2:" - _ASM_EXTABLE_HANDLER(1b, 2b, ex_record_fault_eax) + _ASM_EXTABLE_HANDLER(1b, 2b, %P[rec]) : "+a" (fault) : [val] "r" (io0), - "X" (ex_record_fault_eax)); + [rec] "p" (ex_record_fault_eax)); if ( fault != EXINFO_SYM(GP, 0) ) xtf_error("Error: Unexpected fault %pe\n", _p(fault)); diff --git a/tests/fpu-exception-emulation/main.c b/tests/fpu-exception-emulation/main.c index bb4c688..d12b05a 100644 --- a/tests/fpu-exception-emulation/main.c +++ b/tests/fpu-exception-emulation/main.c @@ -72,10 +72,10 @@ exinfo_t probe_x87(bool force) "jz 1f;" _ASM_XEN_FEP "1: fnop; 2:" - _ASM_EXTABLE_HANDLER(1b, 2b, ex_record_fault_eax) + _ASM_EXTABLE_HANDLER(1b, 2b, %P[rec]) : "+a" (fault) : [fep] "q" (force), - "X" (ex_record_fault_eax)); + [rec] "p" (ex_record_fault_eax)); return fault; } @@ -105,10 +105,10 @@ exinfo_t probe_x87_wait(bool force) "jz 1f;" _ASM_XEN_FEP "1: wait; 2:" - _ASM_EXTABLE_HANDLER(1b, 2b, ex_record_fault_eax) + _ASM_EXTABLE_HANDLER(1b, 2b, %P[rec]) : "+a" (fault) : [fep] "q" (force), - "X" (ex_record_fault_eax)); + [rec] "p" (ex_record_fault_eax)); return fault; } @@ -137,10 +137,10 @@ exinfo_t probe_mmx(bool force) "jz 1f;" _ASM_XEN_FEP "1: movq %%mm0, %%mm0; 2:" - _ASM_EXTABLE_HANDLER(1b, 2b, ex_record_fault_eax) + _ASM_EXTABLE_HANDLER(1b, 2b, %P[rec]) : "+a" (fault) : [fep] "q" (force), - "X" (ex_record_fault_eax)); + [rec] "p" (ex_record_fault_eax)); return fault; } @@ -153,10 +153,10 @@ exinfo_t probe_sse(bool force) "jz 1f;" _ASM_XEN_FEP "1: movups %%xmm0, %%xmm0; 2:" - _ASM_EXTABLE_HANDLER(1b, 2b, ex_record_fault_eax) + _ASM_EXTABLE_HANDLER(1b, 2b, %P[rec]) : "+a" (fault) : [fep] "q" (force), - "X" (ex_record_fault_eax)); + [rec] "p" (ex_record_fault_eax)); return fault; } @@ -185,10 +185,10 @@ static exinfo_t probe_avx(bool force) "jz 1f;" _ASM_XEN_FEP "1: vmovups %%xmm0, %%xmm0; 2:" - _ASM_EXTABLE_HANDLER(1b, 2b, ex_record_fault_eax) + _ASM_EXTABLE_HANDLER(1b, 2b, %P[rec]) : "+a" (fault) : [fep] "q" (force), - "X" (ex_record_fault_eax)); + [rec] "p" (ex_record_fault_eax)); return fault; } diff --git a/tests/invlpg/main.c b/tests/invlpg/main.c index 943c7c2..b300f95 100644 --- a/tests/invlpg/main.c +++ b/tests/invlpg/main.c @@ -119,7 +119,7 @@ static unsigned int invlpg_refill(void) "andb $~%c[ad], %[pte2];\n\t" _ASM_MAYBE_XEN_FEP "1: invlpg 0x1000; 2:\n\t" /* Invalidate one page only. */ - _ASM_EXTABLE_HANDLER(1b, 2b, ex_fail) + _ASM_EXTABLE_HANDLER(1b, 2b, %P[hnd]) "mov %[zero], 0x1000;\n\t" /* Expect refill. */ "mov %[zero], 0x2000;\n\t" /* Expect no refill. */ : @@ -127,7 +127,7 @@ static unsigned int invlpg_refill(void) [ad] "i" (_PAGE_AD), [pte1] "m" (pae_l1_identmap[1]), [pte2] "m" (pae_l1_identmap[2]), - "X" (ex_fail) + [hnd] "p" (ex_fail) : "memory"); return ((test_ad(pae_l1_identmap[1]) << 0) | @@ -142,7 +142,7 @@ static unsigned int invlpg_fs_refill(void) "andb $~%c[ad], %[pte2];\n\t" _ASM_MAYBE_XEN_FEP "1: invlpg %%fs:0x1000; 2:\n\t" /* Invalidate one page only. */ - _ASM_EXTABLE_HANDLER(1b, 2b, ex_fail) + _ASM_EXTABLE_HANDLER(1b, 2b, %P[hnd]) "mov %[zero], 0x1000;\n\t" /* Expect one TLB entry to refil, */ "mov %[zero], 0x2000;\n\t" /* depending on %fs base.*/ : @@ -150,7 +150,7 @@ static unsigned int invlpg_fs_refill(void) [ad] "i" (_PAGE_AD), [pte1] "m" (pae_l1_identmap[1]), [pte2] "m" (pae_l1_identmap[2]), - "X" (ex_fail) + [hnd] "p" (ex_fail) : "memory"); return ((test_ad(pae_l1_identmap[1]) << 0) | @@ -244,16 +244,16 @@ static void invlpg_checked(unsigned long linear) { asm volatile (_ASM_MAYBE_XEN_FEP "1: invlpg (%0); 2:" - _ASM_EXTABLE_HANDLER(1b, 2b, ex_fail) - :: "r" (linear)); + _ASM_EXTABLE_HANDLER(1b, 2b, %P[hnd]) + :: "r" (linear), [hnd] "p" (ex_fail)); } static void invlpg_fs_checked(unsigned long linear) { asm volatile (_ASM_MAYBE_XEN_FEP "1: invlpg %%fs:(%0); 2:" - _ASM_EXTABLE_HANDLER(1b, 2b, ex_fail) - :: "r" (linear), "X" (ex_fail)); + _ASM_EXTABLE_HANDLER(1b, 2b, %P[hnd]) + :: "r" (linear), [hnd] "p" (ex_fail)); } static void test_no_fault(void) diff --git a/tests/nested-vmx/util.c b/tests/nested-vmx/util.c index 61611ab..20d8378 100644 --- a/tests/nested-vmx/util.c +++ b/tests/nested-vmx/util.c @@ -83,12 +83,12 @@ exinfo_t stub_vmxon(uint64_t paddr) ASM_FLAG_OUT(, "setc %[fail_invalid];") ASM_FLAG_OUT(, "setz %[fail_valid];") "2:" - _ASM_EXTABLE_HANDLER(1b, 2b, ex_record_fault_edi) + _ASM_EXTABLE_HANDLER(1b, 2b, %P[rec]) : "+D" (ex), ASM_FLAG_OUT("=@ccc", [fail_invalid] "+rm") (fail_invalid), ASM_FLAG_OUT("=@ccz", [fail_valid] "+rm") (fail_valid) : [paddr] "m" (paddr), - "X" (ex_record_fault_edi)); + [rec] "p" (ex_record_fault_edi)); if ( ex ) return ex; @@ -109,12 +109,12 @@ exinfo_t stub_vmptrld(uint64_t paddr) ASM_FLAG_OUT(, "setc %[fail_invalid];") ASM_FLAG_OUT(, "setz %[fail_valid];") "2:" - _ASM_EXTABLE_HANDLER(1b, 2b, ex_record_fault_edi) + _ASM_EXTABLE_HANDLER(1b, 2b, %P[rec]) : "+D" (ex), ASM_FLAG_OUT("=@ccc", [fail_invalid] "+rm") (fail_invalid), ASM_FLAG_OUT("=@ccz", [fail_valid] "+rm") (fail_valid) : [paddr] "m" (paddr), - "X" (ex_record_fault_edi)); + [rec] "p" (ex_record_fault_edi)); if ( ex ) return ex; @@ -135,12 +135,12 @@ exinfo_t __user_text stub_vmxon_user(uint64_t paddr) ASM_FLAG_OUT(, "setc %[fail_invalid];") ASM_FLAG_OUT(, "setz %[fail_valid];") "2:" - _ASM_EXTABLE_HANDLER(1b, 2b, ex_record_fault_edi) + _ASM_EXTABLE_HANDLER(1b, 2b, %P[rec]) : "+D" (ex), ASM_FLAG_OUT("=@ccc", [fail_invalid] "+rm") (fail_invalid), ASM_FLAG_OUT("=@ccz", [fail_valid] "+rm") (fail_valid) : [paddr] "m" (paddr), - "X" (ex_record_fault_edi)); + [rec] "p" (ex_record_fault_edi)); if ( ex ) return ex; diff --git a/tests/pv-fsgsbase/main.c b/tests/pv-fsgsbase/main.c index a9c3bc1..d354238 100644 --- a/tests/pv-fsgsbase/main.c +++ b/tests/pv-fsgsbase/main.c @@ -39,9 +39,9 @@ static exinfo_t stub_rdfsbase(unsigned long unused) exinfo_t fault = 0; asm volatile ("1: rdfsbase %[val]; 2:" - _ASM_EXTABLE_HANDLER(1b, 2b, ex_record_fault_eax) + _ASM_EXTABLE_HANDLER(1b, 2b, %P[rec]) : "+a" (fault), [val] "=r" (tmp) - : "X" (ex_record_fault_eax)); + : [rec] "p" (ex_record_fault_eax)); return fault; } @@ -52,9 +52,9 @@ static exinfo_t stub_rdgsbase(unsigned long unused) exinfo_t fault = 0; asm volatile ("1: rdgsbase %[val]; 2:" - _ASM_EXTABLE_HANDLER(1b, 2b, ex_record_fault_eax) + _ASM_EXTABLE_HANDLER(1b, 2b, %P[rec]) : "+a" (fault), [val] "=r" (tmp) - : "X" (ex_record_fault_eax)); + : [rec] "p" (ex_record_fault_eax)); return fault; } @@ -64,9 +64,9 @@ static exinfo_t stub_wrfsbase(unsigned long val) exinfo_t fault = 0; asm volatile ("1: wrfsbase %[val]; 2:" - _ASM_EXTABLE_HANDLER(1b, 2b, ex_record_fault_eax) + _ASM_EXTABLE_HANDLER(1b, 2b, %P[rec]) : "+a" (fault) - : [val] "r" (val), "X" (ex_record_fault_eax)); + : [val] "r" (val), [rec] "p" (ex_record_fault_eax)); return fault; } @@ -76,9 +76,9 @@ static exinfo_t stub_wrgsbase(unsigned long val) exinfo_t fault = 0; asm volatile ("1: wrgsbase %[val]; 2:" - _ASM_EXTABLE_HANDLER(1b, 2b, ex_record_fault_eax) + _ASM_EXTABLE_HANDLER(1b, 2b, %P[rec]) : "+a" (fault) - : [val] "r" (val), "X" (ex_record_fault_eax)); + : [val] "r" (val), [rec] "p" (ex_record_fault_eax)); return fault; } diff --git a/tests/selftest/main.c b/tests/selftest/main.c index 31dcda1..e39f1e7 100644 --- a/tests/selftest/main.c +++ b/tests/selftest/main.c @@ -240,9 +240,8 @@ static void test_extable_handler(void) printk("Test: Exception Table Handler\n"); asm volatile ("1: ud2a; 2:" - _ASM_EXTABLE_HANDLER(1b, 2b, - test_extable_handler_handler) - :: "X" (test_extable_handler_handler)); + _ASM_EXTABLE_HANDLER(1b, 2b, %P[hnd]) + :: [hnd] "p" (test_extable_handler_handler)); if ( !test_extable_handler_handler_run ) xtf_failure("Fail: Custom handler didn't run\n"); diff --git a/tests/umip/main.c b/tests/umip/main.c index 3b8e17c..40ebc71 100644 --- a/tests/umip/main.c +++ b/tests/umip/main.c @@ -26,10 +26,10 @@ static unsigned long stub_sgdt(unsigned long force) "jz 1f;" _ASM_XEN_FEP "1: sgdt %[tmp]; 2:" - _ASM_EXTABLE_HANDLER(1b, 2b, ex_record_fault_edi) + _ASM_EXTABLE_HANDLER(1b, 2b, %P[rec]) : "+D" (fault), [tmp] "=m" (tmp) : [fep] "q" (force), - "X" (ex_record_fault_edi)); + [rec] "p" (ex_record_fault_edi)); return fault; } @@ -42,10 +42,10 @@ static unsigned long stub_sidt(unsigned long force) "jz 1f;" _ASM_XEN_FEP "1: sidt %[tmp]; 2:" - _ASM_EXTABLE_HANDLER(1b, 2b, ex_record_fault_edi) + _ASM_EXTABLE_HANDLER(1b, 2b, %P[rec]) : "+D" (fault), [tmp] "=m" (tmp) : [fep] "q" (force), - "X" (ex_record_fault_edi)); + [rec] "p" (ex_record_fault_edi)); return fault; } @@ -59,10 +59,10 @@ static unsigned long stub_sldt(unsigned long force) "jz 1f;" _ASM_XEN_FEP "1: sldt %[tmp]; 2:" - _ASM_EXTABLE_HANDLER(1b, 2b, ex_record_fault_edi) + _ASM_EXTABLE_HANDLER(1b, 2b, %P[rec]) : "+D" (fault), [tmp] "=r" (tmp) : [fep] "q" (force), - "X" (ex_record_fault_edi)); + [rec] "p" (ex_record_fault_edi)); return fault; } @@ -76,10 +76,10 @@ static unsigned long stub_str(unsigned long force) "jz 1f;" _ASM_XEN_FEP "1: str %[tmp]; 2:" - _ASM_EXTABLE_HANDLER(1b, 2b, ex_record_fault_edi) + _ASM_EXTABLE_HANDLER(1b, 2b, %P[rec]) : "+D" (fault), [tmp] "=r" (tmp) : [fep] "q" (force), - "X" (ex_record_fault_edi)); + [rec] "p" (ex_record_fault_edi)); return fault; } @@ -93,10 +93,10 @@ static unsigned long stub_smsw(unsigned long force) "jz 1f;" _ASM_XEN_FEP "1: smsw %[tmp]; 2:" - _ASM_EXTABLE_HANDLER(1b, 2b, ex_record_fault_edi) + _ASM_EXTABLE_HANDLER(1b, 2b, %P[rec]) : "+D" (fault), [tmp] "=r" (tmp) : [fep] "q" (force), - "X" (ex_record_fault_edi)); + [rec] "p" (ex_record_fault_edi)); return fault; } diff --git a/tests/xsa-186/main.c b/tests/xsa-186/main.c index 96a72be..cafcf16 100644 --- a/tests/xsa-186/main.c +++ b/tests/xsa-186/main.c @@ -174,11 +174,11 @@ void test_main(void) * instructions don't get lost. */ asm volatile ("call *%[ptr];" - _ASM_EXTABLE_HANDLER(-1, 0, ex_fault) + _ASM_EXTABLE_HANDLER(-1, 0, %P[hnd]) : "=a" (res) : "0" (0), [ptr] "r" (stub), - "X" (ex_fault) + [hnd] "p" (ex_fault) : "memory"); if ( res != 0xc0de ) diff --git a/tests/xsa-191/main.c b/tests/xsa-191/main.c index d3b2c02..f360148 100644 --- a/tests/xsa-191/main.c +++ b/tests/xsa-191/main.c @@ -39,11 +39,11 @@ void test_main(void) write_fs(0); asm volatile (_ASM_XEN_FEP "1: mov %%fs:0, %[dst]; 2:" - _ASM_EXTABLE_HANDLER(1b, 2b, ex_record_fault_edi) + _ASM_EXTABLE_HANDLER(1b, 2b, %P[rec]) : "=D" (fault), [dst] "=r" (tmp) : "D" (0), - "X" (ex_record_fault_edi)); + [rec] "p" (ex_record_fault_edi)); switch ( fault ) { @@ -71,11 +71,11 @@ void test_main(void) asm volatile (_ASM_XEN_FEP "1: mov %[sel], %%fs; 2:" - _ASM_EXTABLE_HANDLER(1b, 2b, ex_record_fault_eax) + _ASM_EXTABLE_HANDLER(1b, 2b, %P[rec]) : "=a" (fault) : "a" (0), [sel] "r" (4), - "X" (ex_record_fault_eax)); + [rec] "p" (ex_record_fault_eax)); switch ( fault ) { diff --git a/tests/xsa-192/main.c b/tests/xsa-192/main.c index 0fee916..f94fac8 100644 --- a/tests/xsa-192/main.c +++ b/tests/xsa-192/main.c @@ -65,10 +65,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, ex_record_fault_eax) + _ASM_EXTABLE_HANDLER(1b, 2b, %P[rec]) : "+a" (fault) : [sel] "r" (LDT_SEL), - "X" (ex_record_fault_eax)); + [rec] "p" (ex_record_fault_eax)); return fault; } diff --git a/tests/xsa-196/main.c b/tests/xsa-196/main.c index 504ea69..0c40729 100644 --- a/tests/xsa-196/main.c +++ b/tests/xsa-196/main.c @@ -51,7 +51,7 @@ unsigned long compat_userspace(void) "start_32bit:;" _ASM_XEN_FEP "1: int $%c[df]; 2:" - _ASM_EXTABLE_HANDLER(1b, 2b, ex_record_fault_eax) + _ASM_EXTABLE_HANDLER(1b, 2b, %P[rec]) /* Return to 64bit. */ "ljmpl $%c[cs], $1f;" @@ -62,7 +62,7 @@ unsigned long compat_userspace(void) : [df] "i" (X86_EXC_DF), [cs32] "i" (__USER_CS32), [cs] "i" (__USER_CS), - "X" (ex_record_fault_eax)); + [rec] "p" (ex_record_fault_eax)); return fault; } diff --git a/tests/xsa-200/main.c b/tests/xsa-200/main.c index b3e75b0..7973777 100644 --- a/tests/xsa-200/main.c +++ b/tests/xsa-200/main.c @@ -43,10 +43,10 @@ void test_main(void) { /* Poke the emulator. */ asm volatile (_ASM_XEN_FEP "1: .byte 0x66; cmpxchg8b %[ptr]; 2:" - _ASM_EXTABLE_HANDLER(1b, 2b, ex_record_fault_edi) + _ASM_EXTABLE_HANDLER(1b, 2b, %P[rec]) : "=A" (prev), [ptr] "+m" (mem), "+D" (fault) : "c" ((uint32_t)(new >> 32)), "b" ((uint32_t)new), - "0" (old), "X" (ex_record_fault_edi)); + "0" (old), [rec] "p" (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 c4293ff..50cc13a 100644 --- a/tests/xsa-212/main.c +++ b/tests/xsa-212/main.c @@ -82,9 +82,9 @@ void test_main(void) printk("Attempting to confirm...\n"); asm volatile ("1: div %%ecx; 2:" - _ASM_EXTABLE_HANDLER(1b, 2b, ex_record_fault_edi) + _ASM_EXTABLE_HANDLER(1b, 2b, %P[rec]) : "+&a" (low), "+&d" (hi), "+D" (fault) - : "c" (0), "X" (ex_record_fault_edi)); + : "c" (0), [rec] "p" (ex_record_fault_edi)); if ( fault == EXINFO_SYM(DE, 0) ) { diff --git a/tests/xsa-227/main.c b/tests/xsa-227/main.c index 8bec92b..a32ec66 100644 --- a/tests/xsa-227/main.c +++ b/tests/xsa-227/main.c @@ -86,11 +86,11 @@ void test_main(void) * Try to use the linear address which was clobbered by the map call. */ asm volatile ("1: mov %[ptr], %[res]; 2:" - _ASM_EXTABLE_HANDLER(1b, 2b, ex_record_fault_eax) + _ASM_EXTABLE_HANDLER(1b, 2b, %P[rec]) : "+a" (fault), [res] "=q" (discard) : [ptr] "m" (*(char *)KB(4)), - "X" (ex_record_fault_eax)); + [rec] "p" (ex_record_fault_eax)); switch ( fault ) { diff --git a/tests/xsa-259/main.c b/tests/xsa-259/main.c index 2cf0733..0432c13 100644 --- a/tests/xsa-259/main.c +++ b/tests/xsa-259/main.c @@ -25,9 +25,9 @@ void test_main(void) exinfo_t fault = 0; asm volatile ("1: int $0x80; 2:" - _ASM_EXTABLE_HANDLER(1b, 2b, ex_record_fault_eax) + _ASM_EXTABLE_HANDLER(1b, 2b, %P[rec]) : "+a" (fault) - : "X" (ex_record_fault_eax)); + : [rec] "p" (ex_record_fault_eax)); /* * If Xen is vulnerable, it should have crashed. If Xen is not diff --git a/tests/xsa-260/main.c b/tests/xsa-260/main.c index 51e7384..2ffd7a2 100644 --- a/tests/xsa-260/main.c +++ b/tests/xsa-260/main.c @@ -84,11 +84,11 @@ static void __user_text user_syscall(void) "btc $%c[bit], %%" _ASM_SP ";" "mov %[ss], %%ss;" "1: syscall; 2:" - _ASM_EXTABLE_HANDLER(1b, 2b, ex_check_UD) + _ASM_EXTABLE_HANDLER(1b, 2b, %P[hnd]) : : [bit] "i" (BITS_PER_LONG - 1), [ss] "m" (user_ss), - "X" (ex_check_UD) + [hnd] "p" (ex_check_UD) #ifdef __x86_64__ : "rbx", "rcx", "r11" #else @@ -118,7 +118,7 @@ static void __user_text user_syscall_compat(void) */ "mov (%k[ss_ptr]), %%ss;" "1: syscall; 2:" - _ASM_EXTABLE_HANDLER(1b, 2b, ex_check_UD) + _ASM_EXTABLE_HANDLER(1b, 2b, %P[hnd]) /* Return to 64bit mode. */ "ljmpl $%c[cs64], $1f; 1:" @@ -127,7 +127,7 @@ static void __user_text user_syscall_compat(void) : [cs32] "i" (__USER_CS32), [ss_ptr] "R" (&user_ss), [cs64] "i" (__USER_CS), - "X" (ex_check_UD) + [hnd] "p" (ex_check_UD) #ifdef __x86_64__ : "rbx", "rcx", "r11" #else @@ -152,9 +152,9 @@ void test_main(void) /* Sanity check that breakpoints are working. */ asm volatile ("mov %[ss], %%ss; nop; 1:" - _ASM_EXTABLE_HANDLER(1b, 1b, ex_record_fault_eax) + _ASM_EXTABLE_HANDLER(1b, 1b, %P[rec]) : "+a" (fault) - : [ss] "m" (ss), "X" (ex_record_fault_eax)); + : [ss] "m" (ss), [rec] "p" (ex_record_fault_eax)); if ( fault != exp ) return xtf_error("Error checking breakpoint\n" diff --git a/tests/xsa-278/main.c b/tests/xsa-278/main.c index c23cf65..919654c 100644 --- a/tests/xsa-278/main.c +++ b/tests/xsa-278/main.c @@ -31,10 +31,10 @@ static exinfo_t stub_vmclear(void) uint64_t addr = 0; asm volatile ("1: vmclear %[ptr]; 2:" - _ASM_EXTABLE_HANDLER(1b, 2b, ex_record_fault_edi) + _ASM_EXTABLE_HANDLER(1b, 2b, %P[rec]) : "+D" (ex) : [ptr] "m" (addr), - "X" (ex_record_fault_edi)); + [rec] "p" (ex_record_fault_edi)); return ex; } @@ -45,10 +45,10 @@ static exinfo_t stub_vmptrld(void) uint64_t addr = 0; asm volatile ("1: vmptrld %[ptr]; 2:" - _ASM_EXTABLE_HANDLER(1b, 2b, ex_record_fault_edi) + _ASM_EXTABLE_HANDLER(1b, 2b, %P[rec]) : "+D" (ex) : [ptr] "m" (addr), - "X" (ex_record_fault_edi)); + [rec] "p" (ex_record_fault_edi)); return ex; } @@ -59,9 +59,9 @@ static exinfo_t stub_vmptrst(void) uint64_t addr; asm volatile ("1: vmptrst %[ptr]; 2:" - _ASM_EXTABLE_HANDLER(1b, 2b, ex_record_fault_edi) + _ASM_EXTABLE_HANDLER(1b, 2b, %P[rec]) : "+D" (ex), [ptr] "=m" (addr) - : "X" (ex_record_fault_edi)); + : [rec] "p" (ex_record_fault_edi)); return ex; } @@ -72,10 +72,10 @@ static exinfo_t stub_vmread(void) unsigned long tmp; asm volatile ("1: vmread %[field], %[value]; 2:" - _ASM_EXTABLE_HANDLER(1b, 2b, ex_record_fault_edi) + _ASM_EXTABLE_HANDLER(1b, 2b, %P[rec]) : "+D" (ex), [value] "=rm" (tmp) : [field] "r" (0l), - "X" (ex_record_fault_edi)); + [rec] "p" (ex_record_fault_edi)); return ex; } @@ -85,10 +85,10 @@ static exinfo_t stub_vmwrite(void) exinfo_t ex = 0; asm volatile ("1: vmwrite %[value], %[field]; 2:" - _ASM_EXTABLE_HANDLER(1b, 2b, ex_record_fault_edi) + _ASM_EXTABLE_HANDLER(1b, 2b, %P[rec]) : "+D" (ex) : [field] "r" (0l), [value] "rm" (0l), - "X" (ex_record_fault_edi)); + [rec] "p" (ex_record_fault_edi)); return ex; } @@ -98,9 +98,9 @@ static exinfo_t stub_vmlaunch(void) exinfo_t ex = 0; asm volatile ("1: vmlaunch; 2:" - _ASM_EXTABLE_HANDLER(1b, 2b, ex_record_fault_edi) + _ASM_EXTABLE_HANDLER(1b, 2b, %P[rec]) : "+D" (ex) - : "X" (ex_record_fault_edi)); + : [rec] "p" (ex_record_fault_edi)); return ex; } @@ -110,9 +110,9 @@ static exinfo_t stub_vmresume(void) exinfo_t ex = 0; asm volatile ("1: vmresume; 2:" - _ASM_EXTABLE_HANDLER(1b, 2b, ex_record_fault_edi) + _ASM_EXTABLE_HANDLER(1b, 2b, %P[rec]) : "+D" (ex) - : "X" (ex_record_fault_edi)); + : [rec] "p" (ex_record_fault_edi)); return ex; } @@ -122,9 +122,9 @@ static exinfo_t stub_vmxoff(void) exinfo_t ex = 0; asm volatile ("1: vmxoff; 2:" - _ASM_EXTABLE_HANDLER(1b, 2b, ex_record_fault_edi) + _ASM_EXTABLE_HANDLER(1b, 2b, %P[rec]) : "+D" (ex) - : "X" (ex_record_fault_edi)); + : [rec] "p" (ex_record_fault_edi)); return ex; } @@ -135,10 +135,10 @@ static exinfo_t stub_vmxon(void) uint64_t addr = ~0ull; asm volatile ("1: vmxon %[ptr]; 2:" - _ASM_EXTABLE_HANDLER(1b, 2b, ex_record_fault_edi) + _ASM_EXTABLE_HANDLER(1b, 2b, %P[rec]) : "+D" (ex) : [ptr] "m" (addr), - "X" (ex_record_fault_edi)); + [rec] "p" (ex_record_fault_edi)); return ex; } @@ -149,10 +149,10 @@ static exinfo_t stub_invept(void) struct { uint64_t eptp, rsvd; } desc; asm volatile ("1: invept %[desc], %[type]; 2:" - _ASM_EXTABLE_HANDLER(1b, 2b, ex_record_fault_edi) + _ASM_EXTABLE_HANDLER(1b, 2b, %P[rec]) : "+D" (ex) : [type] "r" (0l), [desc] "m" (desc), - "X" (ex_record_fault_edi)); + [rec] "p" (ex_record_fault_edi)); return ex; } @@ -163,10 +163,10 @@ static exinfo_t stub_invvpid(void) struct { uint64_t vpid, linear; } desc; asm volatile ("1: invvpid %[desc], %[type]; 2:" - _ASM_EXTABLE_HANDLER(1b, 2b, ex_record_fault_edi) + _ASM_EXTABLE_HANDLER(1b, 2b, %P[rec]) : "+D" (ex) : [type] "r" (0l), [desc] "m" (desc), - "X" (ex_record_fault_edi)); + [rec] "p" (ex_record_fault_edi)); return ex; } -- 2.39.5