From: Marco Schlumpp Date: Mon, 2 Jan 2023 14:15:52 +0000 (+0100) Subject: plat/kvm/x86: Add unwinding information to interrupt/exception handlers X-Git-Tag: RELEASE-0.13.0~75 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=7f450a9834e4c31a938e8a59e72006ec9389cc18;p=unikraft%2Funikraft.git plat/kvm/x86: Add unwinding information to interrupt/exception handlers This allows debuggers and profilers to unwind past interrupt/exception handlers. Signed-off-by: Marco Schlumpp Reviewed-by: Simon Kuenzer Approved-by: Simon Kuenzer Tested-by: Unikraft CI GitHub-Closes: #700 --- diff --git a/plat/kvm/x86/cpu_vectors_x86_64.S b/plat/kvm/x86/cpu_vectors_x86_64.S index 91a93809f..a78db9a4f 100644 --- a/plat/kvm/x86/cpu_vectors_x86_64.S +++ b/plat/kvm/x86/cpu_vectors_x86_64.S @@ -25,83 +25,118 @@ /* Taken from solo5 */ #include +#include #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