]> xenbits.xensource.com Git - people/andrewcoop/xen-test-framework.git/commitdiff
Remove ambiguous uses of iret/lret
authorAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 5 Jun 2020 19:20:50 +0000 (20:20 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 5 Jun 2020 19:35:38 +0000 (20:35 +0100)
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 <andrew.cooper3@citrix.com>
arch/x86/entry_32.S
arch/x86/include/arch/lib.h
arch/x86/pv/head.S
tests/nmi-taskswitch-priv/main.c
tests/selftest/main.c
tests/xsa-186/main.c
tests/xsa-298/main.c

index 8725fd9f4b1e002f92eb22e128872413ddd0556c..d577603e0865b58c10eddc1325ce3046f4a8d74a 100644 (file)
@@ -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
 
index 4046b9c67d92fad2d7bb9ff508015e69187dc233..3b2b35bcbd33c62e9397f0f49a09da53f135536d 100644 (file)
@@ -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));
 }
 
index 9dd45c99abc8c2a6a676b6644b0cf65930c8a227..7ccf482e7771c93b42d7a69ff7a50d51177696b1 100644 (file)
@@ -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)
index 266690b5ab141a029df87954a92f66ed6af28e55..942cd5985f54e3d72abb2fb36d54946ced475f64 100644 (file)
@@ -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;"
index a5c205bab609491406d8d9fd13593c872e04ca73..50346136cdbb4fe0fd747c7131e0fbd78ce64b5c 100644 (file)
@@ -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;"
index 726acf32dc21f19c882068883b7f6706a21fec89..c7e63df954893a5d433ce11872a90715fc6a51de 100644 (file)
@@ -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),
index 9a62bb2b5a965b2a987ae2a5a3518b02746fbcd3..9d242dbdcc7c1be933ac4c895d8c40889237fcd1 100644 (file)
@@ -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)
 {