]> xenbits.xensource.com Git - xen.git/commitdiff
x86/asm: Introduce a tailcall pseduo-op
authorAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 30 Jun 2023 15:11:40 +0000 (16:11 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 5 Jul 2023 14:20:04 +0000 (15:20 +0100)
It was previously noted that CALL/BUG is a weird combination, but there is
good reason to use this pattern.

Introduce an explicit tailcall macro make it clearer in context.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/boot/x86_64.S
xen/arch/x86/include/asm/asm-defns.h
xen/arch/x86/x86_64/entry.S

index 5d12937a0e402463b60968c55b024b08b711091d..04bb62ae8680511cb45ccc2ba2a705b69bcb3dd0 100644 (file)
@@ -74,14 +74,12 @@ ENTRY(__high_start)
 .L_ap_cet_done:
 #endif /* CONFIG_XEN_SHSTK || CONFIG_XEN_IBT */
 
-        call    start_secondary
-        BUG     /* start_secondary() shouldn't return. */
+        tailcall start_secondary
 
 .L_bsp:
         /* Pass off the Multiboot info structure to C land (if applicable). */
         mov     multiboot_ptr(%rip),%edi
-        call    __start_xen
-        BUG     /* __start_xen() shouldn't return. */
+        tailcall __start_xen
 
         .section .data.page_aligned, "aw", @progbits
         .align PAGE_SIZE, 0
index 8bd9007731d5580b667ca69f0ee41ffe3a432148..9a7073ced5beb1ccdf6e12f90ceb6f3fd1c3c4cb 100644 (file)
     .byte 0x0f, 0x01, 0xdd
 .endm
 
+/*
+ * Call a noreturn function.  This could be JMP, but CALL results in a more
+ * helpful backtrace.  BUG is to catch functions which do decide to return...
+ */
+.macro tailcall fn:req
+    call  \fn
+    BUG   /* Shouldn't return */
+.endm
+
 .macro INDIRECT_BRANCH insn:req arg:req
 /*
  * Create an indirect branch.  insn is one of call/jmp, arg is a single
index 8b77d7113bbf54996016bfbe2b6fac5852d69ef6..bca1500e2b452a84f65a6b7961ddba9304ea91d0 100644 (file)
@@ -824,8 +824,7 @@ handle_exception_saved:
         DISPATCH(X86_EXC_CP, do_entry_CP)
 #undef DISPATCH
 
-        call  do_unhandled_trap
-        BUG   /* do_unhandled_trap() shouldn't return. */
+        tailcall do_unhandled_trap
 
 .L_exn_dispatch_done:
         mov   %r15, STACK_CPUINFO_FIELD(xen_cr3)(%r14)
@@ -880,8 +879,7 @@ exception_with_ints_disabled:
 FATAL_exception_with_ints_disabled:
         xorl  %esi,%esi
         movq  %rsp,%rdi
-        call  fatal_trap
-        BUG   /* fatal_trap() shouldn't return. */
+        tailcall fatal_trap
 
 ENTRY(divide_error)
         ENDBR64
@@ -989,8 +987,7 @@ ENTRY(double_fault)
 .Ldblf_cr3_okay:
 
         movq  %rsp,%rdi
-        call  do_double_fault
-        BUG   /* do_double_fault() shouldn't return. */
+        tailcall do_double_fault
 
 ENTRY(nmi)
         ENDBR64
@@ -1085,8 +1082,7 @@ handle_ist_exception:
         DISPATCH(X86_EXC_MC,  do_machine_check)
 #undef DISPATCH
 
-        call  do_unhandled_trap
-        BUG   /* do_unhandled_trap() shouldn't return. */
+        tailcall do_unhandled_trap
 
 .L_ist_dispatch_done:
         mov   %r15, STACK_CPUINFO_FIELD(xen_cr3)(%r14)