From nobody Mon Dec 06 18:48:26 2021 X-Original-To: dev-commits-src-all@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 B4ED818B5B1C; Mon, 6 Dec 2021 18:48:28 +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 4J7CB30ds0z4SXD; Mon, 6 Dec 2021 18:48:27 +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 C21B511176; Mon, 6 Dec 2021 18:48:26 +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 1B6ImQSi065280; Mon, 6 Dec 2021 18:48:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1B6ImQX5065279; Mon, 6 Dec 2021 18:48:26 GMT (envelope-from git) Date: Mon, 6 Dec 2021 18:48:26 GMT Message-Id: <202112061848.1B6ImQX5065279@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 5b8918fac6fa - main - amd64 native vdso: add unwind annotations to the signal trampoline List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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/main X-Git-Reftype: branch X-Git-Commit: 5b8918fac6fa9c150f68a0ec0805385ee7029ec3 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1638816507; 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=C7a1PzhfYqnM0Ut4UGcnA+HhDyzsdD5J/SHQaZfi7zM=; b=XoDlxmK5zOVElGfuK34wU0m+v/Pr0p1ZiK6B/fadr8/gmWCMKfwNIFgTMx8U4o0g/B7SNl Rv49jn6eG2cuonHYzD6G36lQJnjq6jsK4fp6HsFIhUQ6GgTrmwDCF5Bs2p6Wg3rMJrO+g6 TRw0snpadKmyn4YU25MTTSIFpSXFKVmAJTaCxOs/dqiuwB8CXsYYXP4jlxT9cHLgj9aNGn Z5BBzTJ25+YXIspjwXgspCs5eY5erRG8MmEfATHTA/9i1SZOsVGk9obEDAI9mDSkkSjEFn nOa9qP63+GR+rM+HHr1a6+8cIDJbzCJwJu2Ul3SNNc2KgZEbVz9BBU8YFiuOyA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1638816507; a=rsa-sha256; cv=none; b=QpB1GSHh4O7dphX35Y9oYOhnb2pvkh/DXXX/9xQIeMsYkLcr42Qi+RpaDkxWoCdaivY0gU A57yl/w2j5mfmpaOuqDm8jEOgcUSG9rL1y+d8UGkAOALze6oUMM8e3yVNMtZyBwn6rkJsJ yapUhSfnTO8sAMa4X3i4M0n4tAUADvoF1y4pnY0vLfnNrPjw+kg2tuTuctAElhzmrQ53Hu 0Dwxq+xRAgs2B71HCqa+ZGIFBR6nsGrsQYvIGt6MqaVC7jwu5o4GdMnj5Yucqmujf7E9CH s72KUsJucr7kvYZ1+3EZpz7yr1nKs9acweqSMKhE0dUK/yOWrF8VJb6FiohdXQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=5b8918fac6fa9c150f68a0ec0805385ee7029ec3 commit 5b8918fac6fa9c150f68a0ec0805385ee7029ec3 Author: Konstantin Belousov AuthorDate: 2021-11-15 18:29:45 +0000 Commit: Konstantin Belousov CommitDate: 2021-12-06 18:47:17 +0000 amd64 native vdso: add unwind annotations to the signal trampoline Reviewed by: emaste Discussed with: jhb, jrtc27 Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 month Differential revision: https://reviews.freebsd.org/D32960 --- 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