]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
plat/kvm/x86: Add unwinding information to interrupt/exception handlers
authorMarco Schlumpp <marco@unikraft.io>
Mon, 2 Jan 2023 14:15:52 +0000 (15:15 +0100)
committerUnikraft <monkey@unikraft.io>
Fri, 5 May 2023 21:17:15 +0000 (21:17 +0000)
This allows debuggers and profilers to unwind past interrupt/exception
handlers.

Signed-off-by: Marco Schlumpp <marco@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #700

plat/kvm/x86/cpu_vectors_x86_64.S

index 91a93809f6d33a63deaf149b93023007452f7760..a78db9a4f3bc53c572a0177b79d23d260cb3187c 100644 (file)
 /* Taken from solo5 */
 
 #include <x86/traps.h>
+#include <uk/asm/cfi.h>
 
 #define ENTRY(X)     .global X ; .type X, @function ; X:
 
 .macro PUSH_CALLER_SAVE
-       pushq %rdi
-       pushq %rsi
-       pushq %rdx
-       pushq %rcx
-       pushq %rax
-       pushq %r8
-       pushq %r9
-       pushq %r10
-       pushq %r11
-       pushq %rbx
-       pushq %rbp
-       pushq %r12
-       pushq %r13
-       pushq %r14
-       pushq %r15
+       pushq_reg_cfi rdi
+       pushq_reg_cfi rsi
+       pushq_reg_cfi rdx
+       pushq_reg_cfi rcx
+       pushq_reg_cfi rax
+       pushq_reg_cfi r8
+       pushq_reg_cfi r9
+       pushq_reg_cfi r10
+       pushq_reg_cfi r11
+       pushq_reg_cfi rbx
+       pushq_reg_cfi rbp
+       pushq_reg_cfi r12
+       pushq_reg_cfi r13
+       pushq_reg_cfi r14
+       pushq_reg_cfi r15
 .endm
 
 .macro POP_CALLER_SAVE
-       popq %r15
-       popq %r14
-       popq %r13
-       popq %r12
-       popq %rbp
-       popq %rbx
-       popq %r11
-       popq %r10
-       popq %r9
-       popq %r8
-       popq %rax
-       popq %rcx
-       popq %rdx
-       popq %rsi
-       popq %rdi
+       popq_reg_cfi r15
+       popq_reg_cfi r14
+       popq_reg_cfi r13
+       popq_reg_cfi r12
+       popq_reg_cfi rbp
+       popq_reg_cfi rbx
+       popq_reg_cfi r11
+       popq_reg_cfi r10
+       popq_reg_cfi r9
+       popq_reg_cfi r8
+       popq_reg_cfi rax
+       popq_reg_cfi rcx
+       popq_reg_cfi rdx
+       popq_reg_cfi rsi
+       popq_reg_cfi rdi
 .endm
 
 .macro TRAP_ENTRY trapname, has_ec
 ENTRY(ASM_TRAP_SYM(\trapname))
+       .cfi_startproc simple
+       .cfi_signal_frame
+       .cfi_def_cfa rsp, 0
+.if \has_ec
+       /* Error code is pushed on the stack after the return address */
+       .cfi_def_cfa_offset 16
+.else
+       /* There is only the return address on the stack */
+       .cfi_def_cfa_offset 8
+.endif
+       .cfi_offset rip, -8
+       /* Description of the stack with active IST */
+       .cfi_offset cs, 0
+       .cfi_offset rflags, 8
+       .cfi_offset rsp, 16
+       .cfi_offset ss, 24
        cld
 
 .if !\has_ec
-       pushq $0                            /* no error code, pass 0 */
+       pushq_cfi $0                        /* no error code, pass 0 */
 .endif
        PUSH_CALLER_SAVE
        subq $__REGS_PAD_SIZE, %rsp         /* we have some padding */
+       .cfi_adjust_cfa_offset __REGS_PAD_SIZE
 
        movq %rsp, %rdi
        movq __REGS_OFFSETOF_ORIG_RAX(%rsp), %rsi
        call do_\trapname
 
        addq $__REGS_PAD_SIZE, %rsp         /* we have some padding */
+       .cfi_adjust_cfa_offset -__REGS_PAD_SIZE
        POP_CALLER_SAVE
        addq $8, %rsp                       /* discard error code */
+       .cfi_adjust_cfa_offset -8
 
        iretq
+       .cfi_endproc
 .endm
 
 .macro IRQ_ENTRY irqno
 ENTRY(cpu_irq_\irqno)
+       .cfi_startproc simple
+       .cfi_signal_frame
+       .cfi_def_cfa rsp, 8
+       .cfi_offset rip, -8
+
+       /* Description of the stack with active IST */
+       .cfi_offset cs, 0
+       .cfi_offset rflags, 8
+       .cfi_offset rsp, 16
+       .cfi_offset ss, 24
        cld
 
-       pushq $0                            /* no error code */
+       pushq_cfi $0                        /* no error code */
        PUSH_CALLER_SAVE
        subq $__REGS_PAD_SIZE, %rsp         /* we have some padding */
+       .cfi_adjust_cfa_offset __REGS_PAD_SIZE
 
        movq %rsp, %rdi
        movq $\irqno, %rsi
        call _ukplat_irq_handle
 
        addq $__REGS_PAD_SIZE, %rsp         /* we have some padding */
+       .cfi_adjust_cfa_offset -__REGS_PAD_SIZE
        POP_CALLER_SAVE
        addq $8, %rsp
+       .cfi_adjust_cfa_offset -8
 
        iretq
+       .cfi_endproc
 .endm
 
 TRAP_ENTRY divide_error,     0