DWARF CFI (Call Frame Information) specifies how to recover the return
address and callee-saved registers at each PC in a given function.
Compilers are able to generate the CFI annotations when they compile
the code to assembly language. For handcrafted assembly, we need to
annotate them by hand.

Annotate CFI unwind info for assembly for interrupt and exception
handlers.

Signed-off-by: Weinan Liu <[email protected]>
---
 arch/arm64/kernel/entry.S | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S
index 5ae2a34b50bd..fe3e3e29ee5d 100644
--- a/arch/arm64/kernel/entry.S
+++ b/arch/arm64/kernel/entry.S
@@ -579,7 +579,12 @@ SYM_CODE_START_LOCAL(el\el\ht\()_\regsize\()_\label)
        .if \el == 0
        b       ret_to_user
        .else
+       .cfi_startproc
+       .cfi_def_cfa_offset PT_REGS_SIZE
+       .cfi_offset 29, S_FP - PT_REGS_SIZE
+       .cfi_offset 30, S_LR - PT_REGS_SIZE
        b       ret_to_kernel
+       .cfi_endproc
        .endif
 SYM_CODE_END(el\el\ht\()_\regsize\()_\label)
        .endm
@@ -889,6 +894,10 @@ SYM_FUNC_START(call_on_irq_stack)
        /* Move to the new stack and call the function there */
        add     sp, x16, #IRQ_STACK_SIZE
        blr     x1
+       .cfi_startproc
+       .cfi_def_cfa 29, 16
+       .cfi_offset 29, -16
+       .cfi_offset 30, -8
 
        /*
         * Restore the SP from the FP, and restore the FP and LR from the frame
@@ -898,6 +907,7 @@ SYM_FUNC_START(call_on_irq_stack)
        ldp     x29, x30, [sp], #16
        scs_load_current
        ret
+       .cfi_endproc
 SYM_FUNC_END(call_on_irq_stack)
 NOKPROBE(call_on_irq_stack)
 
-- 
2.48.1.262.g85cc9f2d1e-goog


Reply via email to