From: Marco Schlumpp Date: Wed, 21 Dec 2022 10:01:34 +0000 (+0100) Subject: plat/x86: Add unwind information to system call handler X-Git-Tag: RELEASE-0.13.0~76 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=f87e378199fa87c07e77b36c5c979c9194fb1d93;p=unikraft%2Funikraft.git plat/x86: Add unwind information to system call handler Without this information debugging tools do not know how to properly unwind the _ukplat_syscall frame. For example, this causes them to output garbage output for back traces. Signed-off-by: Marco Schlumpp Reviewed-by: Simon Kuenzer Approved-by: Simon Kuenzer Tested-by: Unikraft CI GitHub-Closes: #700 --- diff --git a/plat/common/x86/syscall.S b/plat/common/x86/syscall.S index 11882824a..b809f5721 100644 --- a/plat/common/x86/syscall.S +++ b/plat/common/x86/syscall.S @@ -32,39 +32,46 @@ */ #include +#include #define ENTRY(X) .globl X ; X : ENTRY(_ukplat_syscall) + .cfi_startproc simple + .cfi_def_cfa rsp, 0 + .cfi_register rip, rcx cli /* * Push arguments in the order of 'struct __regs' to the stack. * We are going to handover a refernce to this stack area as * `struct __regs *` argument to the system call handler. */ - pushq $0 /* exception frame filled with zeros */ - pushq $0 /* (rip, cs, eflags, rsp, ss) */ - pushq $0 /* */ - pushq $0 /* */ - pushq $0 /* */ - pushq %rax /* orig_rax */ - 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_cfi $0 /* exception frame filled with zeros */ + pushq_cfi $0 /* (rip, cs, eflags, rsp, ss) */ + pushq_cfi $0 /* */ + pushq_cfi $0 /* */ + pushq_cfi $0 /* */ + pushq_reg_cfi rax /* orig_rax */ + pushq_reg_cfi rdi + pushq_reg_cfi rsi + pushq_reg_cfi rdx + pushq_reg_cfi rcx + .cfi_rel_offset rip, 0 + 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 + /* padding */ subq $(__REGS_PAD_SIZE), %rsp + .cfi_adjust_cfa_offset __REGS_PAD_SIZE sti /* @@ -81,32 +88,37 @@ ENTRY(_ukplat_syscall) */ movq %rsp, %rbp and $~15, %rsp + .cfi_def_cfa_register rbp call ukplat_syscall_handler /* Restore original stack pointer */ movq %rbp, %rsp + .cfi_def_cfa_register rsp cli /* Load the updated state back to registers */ addq $(__REGS_PAD_SIZE), %rsp - 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 + .cfi_adjust_cfa_offset -__REGS_PAD_SIZE + 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 + .cfi_register rip, rcx + popq_reg_cfi rdx + popq_reg_cfi rsi + popq_reg_cfi rdi /* orig_rax and exception frame */ addq $(6 * 8), %rsp + .cfi_adjust_cfa_offset -(6 * 8) sti /* @@ -118,3 +130,4 @@ ENTRY(_ukplat_syscall) * Conference on Virtual Execution Environments (VEE 2019)) */ jmp *%rcx + .cfi_endproc