[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH] xen: drop the nop() macro



There isn't a plausible reason to insert nops like this into code.

The sole use is in do_debug_key(), and exists to prevent the compiler
optimising the tail of the function with 'jmp debugger_trap_fatal'

In practice, a compiler barrier suffices just as well to prevent the tailcall,
and doesn't involve inserting unnecessary instructions.

Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
CC: Jan Beulich <JBeulich@xxxxxxxx>
CC: Wei Liu <wei.liu2@xxxxxxxxxx>
CC: Roger Pau Monné <roger.pau@xxxxxxxxxx>
CC: Stefano Stabellini <sstabellini@xxxxxxxxxx>
CC: Julien Grall <julien.grall@xxxxxxx>

To preempt review questions, the (void) cast can't be dropped without breaking
the ARM build.  I tried cleaning up the debugger infrastructure a little (in
particular to put this debugkey behind CONFIG_CRASH_DEBUG) but it is more than
a 5 minute job to disentangle, and I don't have time.
---
 xen/common/keyhandler.c      | 6 +++---
 xen/include/asm-arm/system.h | 3 ---
 xen/include/asm-x86/system.h | 3 ---
 3 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/xen/common/keyhandler.c b/xen/common/keyhandler.c
index c25a30e..4f4a660 100644
--- a/xen/common/keyhandler.c
+++ b/xen/common/keyhandler.c
@@ -480,9 +480,9 @@ static void do_debug_key(unsigned char key, struct 
cpu_user_regs *regs)
 {
     printk("'%c' pressed -> trapping into debugger\n", key);
     (void)debugger_trap_fatal(0xf001, regs);
-    nop(); /* Prevent the compiler doing tail call
-                             optimisation, as that confuses xendbg a
-                             bit. */
+
+    /* Prevent tail call optimisation, which confuses xendbg. */
+    barrier();
 }
 
 static void do_toggle_alt_key(unsigned char key, struct cpu_user_regs *regs)
diff --git a/xen/include/asm-arm/system.h b/xen/include/asm-arm/system.h
index b94e56f..e5d0626 100644
--- a/xen/include/asm-arm/system.h
+++ b/xen/include/asm-arm/system.h
@@ -5,9 +5,6 @@
 #include <xen/lib.h>
 #include <public/arch-arm.h>
 
-#define nop() \
-    asm volatile ( "nop" )
-
 #define sev()           asm volatile("sev" : : : "memory")
 #define wfe()           asm volatile("wfe" : : : "memory")
 #define wfi()           asm volatile("wfi" : : : "memory")
diff --git a/xen/include/asm-x86/system.h b/xen/include/asm-x86/system.h
index 483cd20..c665499 100644
--- a/xen/include/asm-x86/system.h
+++ b/xen/include/asm-x86/system.h
@@ -17,9 +17,6 @@
 #define clflush(a) \
     asm volatile ( "clflush (%0)" : : "r"(a) )
 
-#define nop() \
-    asm volatile ( "nop" )
-
 #define xchg(ptr,v) \
     ((__typeof__(*(ptr)))__xchg((unsigned long)(v),(ptr),sizeof(*(ptr))))
 
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.