1/*- 2 * Copyright (c) 2003 Peter Wemm <peter@freeBSD.org> 3 * All rights reserved. 4 * 5 * Copyright (c) 2021 The FreeBSD Foundation 6 * 7 * Portions of this software were developed by Konstantin Belousov 8 * under sponsorship from the FreeBSD Foundation. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 * SUCH DAMAGE. 30 * 31 * $FreeBSD$ 32 */ 33 34#include <sys/syscall.h> 35#include <machine/asmacros.h> 36 37#include "assym.inc" 38 39 .text 40/* 41 * Signal trampoline, mapped as vdso into shared page. 42 */ 43ENTRY(__vdso_sigcode) 44 .cfi_startproc 45 .cfi_signal_frame 46 .cfi_def_cfa %rsp, 0 47 .cfi_offset %rdi, SIGF_UC + UC_RDI 48 .cfi_offset %rsi, SIGF_UC + UC_RSI 49 .cfi_offset %rdx, SIGF_UC + UC_RDX 50 .cfi_offset %rcx, SIGF_UC + UC_RCX 51 .cfi_offset %r8, SIGF_UC + UC_R8 52 .cfi_offset %r9, SIGF_UC + UC_R9 53 .cfi_offset %rax, SIGF_UC + UC_RAX 54 .cfi_offset %rbx, SIGF_UC + UC_RBX 55 .cfi_offset %rbp, SIGF_UC + UC_RBP 56 .cfi_offset %r10, SIGF_UC + UC_R10 57 .cfi_offset %r11, SIGF_UC + UC_R11 58 .cfi_offset %r12, SIGF_UC + UC_R12 59 .cfi_offset %r13, SIGF_UC + UC_R13 60 .cfi_offset %r14, SIGF_UC + UC_R14 61 .cfi_offset %r15, SIGF_UC + UC_R15 62#if 0 63/* 64 * Gnu as complains about %fs/%gs/%es/%ds registers offsets not being 65 * multiple of 8, but gas + ld.bfd work for %cs/%ss. 66 * 67 * Clang IAS + ld.lld combination cannot handle any of the segment 68 * registers. Also, clang IAS does not know %rflags/%fs.base/%gs.base 69 * registers names, use dwarf registers numbers from psABI directly. 70 * 71 * LLVM libunwind from stable/13 cannot parse register numbers higher 72 * than 32. Disable %rflags, %fs.base, and %gs.base annotations. 73 */ 74 .cfi_offset %fs, SIGF_UC + UC_FS 75 .cfi_offset %gs, SIGF_UC + UC_GS 76 .cfi_offset %es, SIGF_UC + UC_ES 77 .cfi_offset %ds, SIGF_UC + UC_DS 78#endif 79 .cfi_offset %rip, SIGF_UC + UC_RIP 80#if 0 81 .cfi_offset %cs, SIGF_UC + UC_CS 82 .cfi_offset 49 /* %rflags */, SIGF_UC + UC_RFLAGS 83#endif 84 .cfi_offset %rsp, SIGF_UC + UC_RSP 85#if 0 86 .cfi_offset %ss, SIGF_UC + UC_SS 87 .cfi_offset 58 /* %fs.base */, SIGF_UC + UC_FSBASE 88 .cfi_offset 59 /* %gs.base */, SIGF_UC + UC_GSBASE 89#endif 90 call *SIGF_HANDLER(%rsp) /* call signal handler */ 91 lea SIGF_UC(%rsp),%rdi /* get ucontext_t */ 92 pushq $0 /* junk to fake return addr. */ 93 .cfi_def_cfa %rsp, 8 94 movq $SYS_sigreturn,%rax 95 syscall /* enter kernel with args */ 960: hlt /* trap priviliged instruction */ 97 jmp 0b 98 .cfi_endproc 99END(__vdso_sigcode) 100 101 .section .note.GNU-stack,"",%progbits 102