From: Weinan Liu <[email protected]>

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]>
Signed-off-by: Dylan Hatch <[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 f8018b5c1f9a..3148ede8c2c6 100644
--- a/arch/arm64/kernel/entry.S
+++ b/arch/arm64/kernel/entry.S
@@ -575,7 +575,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)
        add     sp, x16, #IRQ_STACK_SIZE
        restore_irq x9
        blr     x1
+       .cfi_startproc
+       .cfi_def_cfa 29, 16
+       .cfi_offset 29, -16
+       .cfi_offset 30, -8
 
        save_and_disable_daif x9
        /*
@@ -900,6 +909,7 @@ SYM_FUNC_START(call_on_irq_stack)
        scs_load_current
        restore_irq x9
        ret
+       .cfi_endproc
 SYM_FUNC_END(call_on_irq_stack)
 NOKPROBE(call_on_irq_stack)
 
-- 
2.51.0.355.g5224444f11-goog


Reply via email to