From: Andrew Cooper Date: Fri, 5 Jun 2020 19:20:50 +0000 (+0100) Subject: Remove ambiguous uses of iret/lret X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=64cd99ff4af0291c7b2ac2ba7d7dbd0039465d07;p=xtf.git Remove ambiguous uses of iret/lret GAS of at least version 2.34 complains: Warning: no instruction mnemonic suffix given and no register operands; using default for `lret' This is legitimate, as without a suffix, there are up to 3 possible encodings actually meant. Use l/q suffixes as appropriate, using __ASM_SEL() in cases where we need to conditionally select between the suffixes. Use the same trick to clean up some code32/64 statements. Sadly, this cannot be done for the single ambiguous use of lcall, because lcallq isn't accepted as a valid mnemonic. Leave the XSA-298 PoC as it is. Signed-off-by: Andrew Cooper --- diff --git a/arch/x86/entry_32.S b/arch/x86/entry_32.S index 8725fd9..d577603 100644 --- a/arch/x86/entry_32.S +++ b/arch/x86/entry_32.S @@ -31,7 +31,7 @@ containing the entry vector. jmp HYPERCALL_iret /* PV guests use the 'iret' hypercall. */ #else - iret /* HVM guests use a real 'iret' instruction. */ + iretl /* HVM guests use a real 'iret' instruction. */ #endif .endm diff --git a/arch/x86/include/arch/lib.h b/arch/x86/include/arch/lib.h index 4046b9c..3b2b35b 100644 --- a/arch/x86/include/arch/lib.h +++ b/arch/x86/include/arch/lib.h @@ -179,10 +179,7 @@ static inline void write_cs(unsigned long cs) { asm volatile ("push %0;" "push $1f;" -#if __x86_64__ - "rex64 " -#endif - "lret; 1:" + __ASM_SEL(lretl, lretq) "; 1:" :: "rme" (cs)); } diff --git a/arch/x86/pv/head.S b/arch/x86/pv/head.S index 9dd45c9..7ccf482 100644 --- a/arch/x86/pv/head.S +++ b/arch/x86/pv/head.S @@ -18,11 +18,7 @@ ELFNOTE(Xen, XEN_ELFNOTE_FEATURES, .asciz "!writable_page_tables|pae_pgdir_above ELFNOTE(Xen, XEN_ELFNOTE_PAE_MODE, .asciz "yes") .text -#ifdef __x86_64__ - .code64 -#else - .code32 -#endif + __ASM_SEL(.code32, .code64) /* PV entry point. */ GLOBAL(_start) diff --git a/tests/nmi-taskswitch-priv/main.c b/tests/nmi-taskswitch-priv/main.c index 266690b..942cd59 100644 --- a/tests/nmi-taskswitch-priv/main.c +++ b/tests/nmi-taskswitch-priv/main.c @@ -39,7 +39,7 @@ static uint8_t nmi_stack[PAGE_SIZE] __page_aligned_bss; void entry_NMI_task(void); asm("exit_NMI_task:" - "iret;" + "iretl;" "entry_NMI_task:;" "push $0;" diff --git a/tests/selftest/main.c b/tests/selftest/main.c index a5c205b..5034613 100644 --- a/tests/selftest/main.c +++ b/tests/selftest/main.c @@ -254,10 +254,7 @@ asm ("test_idte_handler:;" #endif "mov $0x1e51c0de, %eax;" #if defined (CONFIG_HVM) -#ifdef __x86_64__ - "rex64 " -#endif - "iret;" + __ASM_SEL(iretl, iretq) ";" #else /* CONFIG_HVM */ #ifdef __x86_64__ "push $0;" diff --git a/tests/xsa-186/main.c b/tests/xsa-186/main.c index 726acf3..c7e63df 100644 --- a/tests/xsa-186/main.c +++ b/tests/xsa-186/main.c @@ -41,10 +41,7 @@ void test_int_handler(void); asm(".align 16;" "test_int_handler:" "movl $0xc0de, %eax;" -#ifdef __x86_64__ - "rex64 " -#endif - "iret" + __ASM_SEL(iretl, iretq) ); static const struct xtf_idte idte = { @@ -195,22 +192,16 @@ void test_main(void) asm volatile ("push $%c[cs16];" "push $1f;" -#ifdef __x86_64__ - "rex64 " -#endif - "lret; 1:" + __ASM_SEL(lretl, lretq) ";" - ".code16;" + "1: .code16;" "start_16bit:;" _ASM_XEN_FEP "int $" STR(X86_VEC_AVAIL) ";" "ljmpl $%c[cs], $.Ldone;" "end_16bit:;" -#if __x86_64__ - ".code64;" -#else - ".code32;" -#endif + + __ASM_SEL(.code32, .code64) ";" ".Ldone:" : "=a" (res) : "0" (0), diff --git a/tests/xsa-298/main.c b/tests/xsa-298/main.c index 9a62bb2..9d242db 100644 --- a/tests/xsa-298/main.c +++ b/tests/xsa-298/main.c @@ -44,10 +44,8 @@ const char test_title[] = "XSA-298 PoC"; unsigned int gate_target(void); asm ("gate_target:;" "mov %cs, %eax;" -#ifdef __x86_64__ - "rex64 " -#endif - "lret;"); + __ASM_SEL(lretl, lretq) + ); static void __user_text user1(void) {