From nobody Sun Jan 02 19:08:17 2022 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 2AE5C191F6EB; Sun, 2 Jan 2022 19:08:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JRpLT6S9Rz4YBm; Sun, 2 Jan 2022 19:08:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id AB5641714A; Sun, 2 Jan 2022 19:08:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 202J8HlB057868; Sun, 2 Jan 2022 19:08:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 202J8Hp0057867; Sun, 2 Jan 2022 19:08:17 GMT (envelope-from git) Date: Sun, 2 Jan 2022 19:08:17 GMT Message-Id: <202201021908.202J8Hp0057867@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 0510df0ea497 - stable/13 - amd64 native vdso: add unwind annotations to the signal trampoline List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 0510df0ea49734ad4922718fdb5cdb8c52d78435 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1641150498; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=WAV8At3CYGt9b2Yp7PXtoWAwfkBCrIPJ7QzRceGJZ5w=; b=BDPecKTA9cJR+EzImQwO0il7FkB4+uu+N1vVj60feUcH9RVYKPy4QCsceKzD5Ll5+SA+5i t1solf/t+WpTRgPtjqkH6E02W5Ub2u0PWW6zRtdWj3DFaEtG8BxXireOCwOP/MJp3Dj91I ULzdnQ1+iyycmMwC6crzCFimG12856qZ68XF39B2l2cq9nNvSJBA0BUrRyYTUgs3o/z9ac SbtYPFRQZgxoQhX1bddwXQqeh8AkLMQxIwv0Yus9yZsK60bPM8ITZuCazrUzIA9mye7bl4 B4E8jU752t/bgvtC3v9wrOEW1XdtMXbVCiwLtv+cSF9kVh7SP0RyQRbXkX01bQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1641150498; a=rsa-sha256; cv=none; b=AIKoSPqf3RL0o/Up4akV/TchRPFjRrOELcOKfoovvYE94jjmP2vYjvV0WS/fvv1Zd2lIF/ zn14PzFXRromBK/XXXwwxNCScp4STnW+MU1jmEqhT9Xn5LEJaFo3b8bio5zjEeNhicV2la /OepgIsus28lFoqa6ZYXQI+aDl3VxSNdtxpeyEcScw3MUW5zw/jvCgHaMpHp0Yi3Dvduo+ RrO2q/LFsSPjb96jK+8bbDZCbZY3ys4VZ/1HPwHk0SPsUzYGGQ22mdK0E3pxJEB6pe8zEz QsPliBF33k1SgD/Z72Px41vm1MPl1m/XEbXj2lIYpTTqpH7NJ3JeOGSrX1PD5g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=0510df0ea49734ad4922718fdb5cdb8c52d78435 commit 0510df0ea49734ad4922718fdb5cdb8c52d78435 Author: Konstantin Belousov AuthorDate: 2021-11-15 18:29:45 +0000 Commit: Konstantin Belousov CommitDate: 2022-01-02 16:43:01 +0000 amd64 native vdso: add unwind annotations to the signal trampoline (cherry picked from commit 5b8918fac6fa9c150f68a0ec0805385ee7029ec3) --- sys/amd64/amd64/genassym.c | 27 +++++++++++++++++++++++++ sys/amd64/amd64/sigtramp.S | 50 ++++++++++++++++++++++++++++++++++++++++++++++ sys/tools/amd64_vdso.sh | 2 +- 3 files changed, 78 insertions(+), 1 deletion(-) diff --git a/sys/amd64/amd64/genassym.c b/sys/amd64/amd64/genassym.c index 7c29368828d0..f61ce120d156 100644 --- a/sys/amd64/amd64/genassym.c +++ b/sys/amd64/amd64/genassym.c @@ -205,6 +205,33 @@ ASSYM(PTI_SIZE, sizeof(struct pti_frame)); ASSYM(SIGF_HANDLER, offsetof(struct sigframe, sf_ahu.sf_handler)); ASSYM(SIGF_UC, offsetof(struct sigframe, sf_uc)); ASSYM(UC_EFLAGS, offsetof(ucontext_t, uc_mcontext.mc_rflags)); +ASSYM(UC_RDI, offsetof(ucontext_t, uc_mcontext.mc_rdi)); +ASSYM(UC_RSI, offsetof(ucontext_t, uc_mcontext.mc_rsi)); +ASSYM(UC_RDX, offsetof(ucontext_t, uc_mcontext.mc_rdx)); +ASSYM(UC_RCX, offsetof(ucontext_t, uc_mcontext.mc_rcx)); +ASSYM(UC_R8, offsetof(ucontext_t, uc_mcontext.mc_r8)); +ASSYM(UC_R9, offsetof(ucontext_t, uc_mcontext.mc_r9)); +ASSYM(UC_RAX, offsetof(ucontext_t, uc_mcontext.mc_rax)); +ASSYM(UC_RBX, offsetof(ucontext_t, uc_mcontext.mc_rbx)); +ASSYM(UC_RBP, offsetof(ucontext_t, uc_mcontext.mc_rbp)); +ASSYM(UC_R10, offsetof(ucontext_t, uc_mcontext.mc_r10)); +ASSYM(UC_R11, offsetof(ucontext_t, uc_mcontext.mc_r11)); +ASSYM(UC_R12, offsetof(ucontext_t, uc_mcontext.mc_r12)); +ASSYM(UC_R13, offsetof(ucontext_t, uc_mcontext.mc_r13)); +ASSYM(UC_R14, offsetof(ucontext_t, uc_mcontext.mc_r14)); +ASSYM(UC_R15, offsetof(ucontext_t, uc_mcontext.mc_r15)); +ASSYM(UC_FS, offsetof(ucontext_t, uc_mcontext.mc_fs)); +ASSYM(UC_GS, offsetof(ucontext_t, uc_mcontext.mc_gs)); +ASSYM(UC_ES, offsetof(ucontext_t, uc_mcontext.mc_es)); +ASSYM(UC_DS, offsetof(ucontext_t, uc_mcontext.mc_ds)); +ASSYM(UC_RIP, offsetof(ucontext_t, uc_mcontext.mc_rip)); +ASSYM(UC_CS, offsetof(ucontext_t, uc_mcontext.mc_cs)); +ASSYM(UC_RFLAGS, offsetof(ucontext_t, uc_mcontext.mc_rflags)); +ASSYM(UC_RSP, offsetof(ucontext_t, uc_mcontext.mc_rsp)); +ASSYM(UC_SS, offsetof(ucontext_t, uc_mcontext.mc_ss)); +ASSYM(UC_FSBASE, offsetof(ucontext_t, uc_mcontext.mc_fsbase)); +ASSYM(UC_GSBASE, offsetof(ucontext_t, uc_mcontext.mc_gsbase)); + ASSYM(ENOENT, ENOENT); ASSYM(EFAULT, EFAULT); ASSYM(ENAMETOOLONG, ENAMETOOLONG); diff --git a/sys/amd64/amd64/sigtramp.S b/sys/amd64/amd64/sigtramp.S index 05bf30293a9a..6c2895a14a0a 100644 --- a/sys/amd64/amd64/sigtramp.S +++ b/sys/amd64/amd64/sigtramp.S @@ -2,6 +2,11 @@ * Copyright (c) 2003 Peter Wemm * All rights reserved. * + * Copyright (c) 2021 The FreeBSD Foundation + * + * Portions of this software were developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -36,13 +41,58 @@ * Signal trampoline, mapped as vdso into shared page. */ ENTRY(__vdso_sigcode) + .cfi_startproc + .cfi_signal_frame + .cfi_def_cfa %rsp, 0 + .cfi_offset %rdi, SIGF_UC + UC_RDI + .cfi_offset %rsi, SIGF_UC + UC_RSI + .cfi_offset %rdx, SIGF_UC + UC_RDX + .cfi_offset %rcx, SIGF_UC + UC_RCX + .cfi_offset %r8, SIGF_UC + UC_R8 + .cfi_offset %r9, SIGF_UC + UC_R9 + .cfi_offset %rax, SIGF_UC + UC_RAX + .cfi_offset %rbx, SIGF_UC + UC_RBX + .cfi_offset %rbp, SIGF_UC + UC_RBP + .cfi_offset %r10, SIGF_UC + UC_R10 + .cfi_offset %r11, SIGF_UC + UC_R11 + .cfi_offset %r12, SIGF_UC + UC_R12 + .cfi_offset %r13, SIGF_UC + UC_R13 + .cfi_offset %r14, SIGF_UC + UC_R14 + .cfi_offset %r15, SIGF_UC + UC_R15 +#if 0 +/* + * Gnu as complains about %fs/%gs/%es/%ds registers offsets not being + * multiple of 8, but gas + ld.bfd work for %cs/%ss. + * + * Clang IAS + ld.lld combination cannot handle any of the segment + * registers. Also, clang IAS does not know %rflags/%fs.base/%gs.base + * registers names, use dwarf registers numbers from psABI directly. + */ + .cfi_offset %fs, SIGF_UC + UC_FS + .cfi_offset %gs, SIGF_UC + UC_GS + .cfi_offset %es, SIGF_UC + UC_ES + .cfi_offset %ds, SIGF_UC + UC_DS +#endif + .cfi_offset %rip, SIGF_UC + UC_RIP +#if 0 + .cfi_offset %cs, SIGF_UC + UC_CS +#endif + .cfi_offset 49 /* %rflags */, SIGF_UC + UC_RFLAGS + .cfi_offset %rsp, SIGF_UC + UC_RSP +#if 0 + .cfi_offset %ss, SIGF_UC + UC_SS +#endif + .cfi_offset 58 /* %fs.base */, SIGF_UC + UC_FSBASE + .cfi_offset 59 /* %gs.base */, SIGF_UC + UC_GSBASE call *SIGF_HANDLER(%rsp) /* call signal handler */ lea SIGF_UC(%rsp),%rdi /* get ucontext_t */ pushq $0 /* junk to fake return addr. */ + .cfi_def_cfa %rsp, 8 movq $SYS_sigreturn,%rax syscall /* enter kernel with args */ 0: hlt /* trap priviliged instruction */ jmp 0b + .cfi_endproc END(__vdso_sigcode) .section .note.GNU-stack,"",%progbits diff --git a/sys/tools/amd64_vdso.sh b/sys/tools/amd64_vdso.sh index 39406eccd2ef..6a4111ffabc8 100644 --- a/sys/tools/amd64_vdso.sh +++ b/sys/tools/amd64_vdso.sh @@ -55,5 +55,5 @@ ${CC} -x assembler-with-cpp -DLOCORE -fPIC -nostdinc -c \ "${S}"/tools/vdso_wrap.S ${NM} -D elf-vdso.so.1 | \ - awk '/__vdso_sigcode/{printf "#define VDSO_SIGCODE_OFFSET 0x%s\n",$1}' \ + ${AWK} '/__vdso_sigcode/{printf "#define VDSO_SIGCODE_OFFSET 0x%s\n",$1}' \ >vdso_offsets.h