From: Andrew Cooper Date: Fri, 10 May 2019 16:22:15 +0000 (+0000) Subject: Misc trivial code cleanup X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=5264341e4fb0bd697254160d79b168f740557abb;p=people%2Fandrewcoop%2Fxen-test-framework.git Misc trivial code cleanup * Use named asm parameters for non-trivial blocks * "=r" (x) : "r" (x) is more commonly "+r" (x) * Correct the header guard in x86-gate.h * Remove brackets from absolute memory addresss * Use unsigned int rather than unsigned long and forcing back to int with %k * Drop unused ex_record_fault_eax reference Signed-off-by: Andrew Cooper --- diff --git a/arch/x86/include/arch/div.h b/arch/x86/include/arch/div.h index 8e44898..725cda0 100644 --- a/arch/x86/include/arch/div.h +++ b/arch/x86/include/arch/div.h @@ -40,9 +40,9 @@ static inline uint32_t divmod64(uint64_t *dividend, uint32_t divisor) high /= divisor; } - asm ("divl %2" - : "=a" (low), "=d" (mod) - : "rm" (divisor), "0" (low), "1" (umod)); + asm ("divl %[divisor]" + : "+a" (low), "=d" (mod) + : [divisor] "rm" (divisor), "d" (umod)); *dividend = (((uint64_t)high) << 32) | low; } diff --git a/arch/x86/include/arch/lib.h b/arch/x86/include/arch/lib.h index 6bd0eb6..4e62bf9 100644 --- a/arch/x86/include/arch/lib.h +++ b/arch/x86/include/arch/lib.h @@ -280,10 +280,10 @@ static inline bool write_cr4_safe(unsigned long cr4) { exinfo_t fault = 0; - asm volatile ("1: mov %1, %%cr4; 2:" + asm volatile ("1: mov %[cr4], %%cr4; 2:" _ASM_EXTABLE_HANDLER(1b, 2b, ex_record_fault_edi) : "+D" (fault) - : "r" (cr4), + : [cr4] "r" (cr4), "X" (ex_record_fault_edi)); return fault; diff --git a/arch/x86/include/arch/x86-gate.h b/arch/x86/include/arch/x86-gate.h index 538bab1..5a41006 100644 --- a/arch/x86/include/arch/x86-gate.h +++ b/arch/x86/include/arch/x86-gate.h @@ -114,7 +114,7 @@ static inline void pack_intr_gate( pack_gate(g, 14, sel, offset, dpl, other); } -#endif /* XTF_X86_TSS_H */ +#endif /* XTF_X86_GATE_H */ /* * Local variables: diff --git a/tests/invlpg/main.c b/tests/invlpg/main.c index 826dc30..943c7c2 100644 --- a/tests/invlpg/main.c +++ b/tests/invlpg/main.c @@ -118,7 +118,7 @@ static unsigned int invlpg_refill(void) "andb $~%c[ad], %[pte1];\n\t" /* Clear A/D bits. */ "andb $~%c[ad], %[pte2];\n\t" _ASM_MAYBE_XEN_FEP - "1: invlpg (0x1000); 2:\n\t" /* Invalidate one page only. */ + "1: invlpg 0x1000; 2:\n\t" /* Invalidate one page only. */ _ASM_EXTABLE_HANDLER(1b, 2b, ex_fail) "mov %[zero], 0x1000;\n\t" /* Expect refill. */ "mov %[zero], 0x2000;\n\t" /* Expect no refill. */ @@ -141,7 +141,7 @@ static unsigned int invlpg_fs_refill(void) "andb $~%c[ad], %[pte1];\n\t" /* Clear A/D bits. */ "andb $~%c[ad], %[pte2];\n\t" _ASM_MAYBE_XEN_FEP - "1: invlpg %%fs:(0x1000); 2:\n\t" /* Invalidate one page only. */ + "1: invlpg %%fs:0x1000; 2:\n\t" /* Invalidate one page only. */ _ASM_EXTABLE_HANDLER(1b, 2b, ex_fail) "mov %[zero], 0x1000;\n\t" /* Expect one TLB entry to refil, */ "mov %[zero], 0x2000;\n\t" /* depending on %fs base.*/ @@ -224,7 +224,7 @@ static void test_tlb_refill(void) { unsigned int i; - printk("Testing 'invlpg (0x1000)' with segment bases\n"); + printk("Testing 'invlpg 0x1000' with segment bases\n"); printk(" Test: No segment\n"); run_tlb_refill_test(invlpg_refill, 1); diff --git a/tests/xsa-123/main.c b/tests/xsa-123/main.c index 92e3055..eab70f3 100644 --- a/tests/xsa-123/main.c +++ b/tests/xsa-123/main.c @@ -35,14 +35,12 @@ bool test_needs_fep = true; void test_main(void) { - unsigned long src = 0x1234, dest = 0; + unsigned int src = 0x1234, dest = 0; asm volatile(_ASM_XEN_FEP /* Explicit %cs segment override. */ - ".byte 0x2e;" - "mov %k[src], %k[dest]" - : [src] "=r" (src), [dest] "=r" (dest) - : "0" (src), "1" (dest)); + ".byte 0x2e; mov %[src], %[dest]" + : [src] "+r" (src), [dest] "+r" (dest)); if ( dest != 0x1234 ) xtf_failure(" '%%cs:mov %%reg, %%reg' clobbered hypervisor memory\n"); diff --git a/tests/xsa-265/main.c b/tests/xsa-265/main.c index 760ba49..046faef 100644 --- a/tests/xsa-265/main.c +++ b/tests/xsa-265/main.c @@ -37,7 +37,7 @@ void test_main(void) asm volatile ("mov %[ss], %%ss; int3; 1:" _ASM_TRAP_OK(1b) - :: [ss] "m" (ss), "X" (ex_record_fault_eax)); + :: [ss] "m" (ss)); /* * If Xen is still alive at this point, the erroneous safety check didn't