xen: drop the nop() macro
PATCH 1/1 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.
---
CC: Jan Beulich <[email protected]>
CC: Wei Liu <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
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(-)
xen/common/keyhandler.c +3 -3
@@ -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)
xen/include/asm-arm/system.h +0 -3
@@ -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")
xen/include/asm-x86/system.h +0 -3
@@ -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))))
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 9 lines · Andrew Cooper
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 'jmpdebugger_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 <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Jan Beulich
Acked-byQuoted 7 lines
Quoted 1 line
Quoted 1 line · On 15.03.19 at 14:41, <[email protected]> wrote:
Quoted 5 lines · Andrew Cooper
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 'jmpdebugger_trap_fatal'
Quoted 6 lines
Quoted 4 lines
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 <[email protected]>Reviewed-by Wei Liu <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Hi Andrew,
Quoted 9 lines · Andrew Cooper
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 'jmpdebugger_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 <[email protected]>
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel