From nobody Sun Oct 25 12:12:26 2026 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 4jCFxr6Xp7z6wHZB for ; Sun, 25 Oct 2026 12:12:32 +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) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jCFxr2VL4z4DBp for ; Sun, 25 Oct 2026 12:12:32 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1792930352; 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=nfhNdiUyZD8rH4jGwbp315+DEkmsp+H9a7/yfxXIuGs=; b=YaoYycdOQ6poZVIT6UcnNiqqJhDp4Q409G0+DDCk7j8PJQwPZl4l9o8wKBcUR3/96/0gRR 4DhVz8A2mzNFuDHgCoWf895QXBFra0lxyPYPKNoV+U/SNIUJ+sgkR6vUqlYnzJgauefp58 uJEaEp+qjS6+ok/PArHmK906Kd/OoqjvpFVnNrvvdzwEo1l49vWyRw8HRQMnYJLxGnrfGz 9RHaawUxVyxjqMRE2tcz36JxGvX+ojCjci28xrv8ZhX01RLNPWYK2m8NLkCkacM4Whja3v A8NTFSJWANKexfQw71YJ1I14OC5ljcxDb5kA2QGkF4JxKKZ7jGtv3WfJHj/2Fg== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1792930352; b=ijC3r8yMpGz65hSLCrF/aED7n3i5/Ph5T61HbibEuXxyVPB0Fldk/9oE+LFl1pFgWxiF+7 OQQy5g/pr/IkF7L46k8iBxaP3R16vaC+ysaV5npWXgsidSWUACNFbVRJow6GxGf/V/lfUb hbPOz0ZD/UExhyL1sq9SFM424b7brYROLR6U8+9cqQu/leONx1JZuCqs7lLrVeSRhHw/SD UaCyojH2tpfJg1hbfUrz/QM/IfA/IKVLTVBnsbGhbH+4hFKK1+ga48tB/BXC29ba6emevJ DutXG0DKM4x2RC6W0tvd66y03G+bD4xEiRoV1rvTFSlKzSKxO2dU2GvN1zF90Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1792930352; 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=nfhNdiUyZD8rH4jGwbp315+DEkmsp+H9a7/yfxXIuGs=; b=KscXs+iZScV58uMQ+05ctMRsiUTH8BNfG9lGJxjbbruZXv+P2Poe98Pj2GuQD1kMRrDXay qwJy7kYvPlThp21k9zhKXmjj5jixZrHq1hF2a2yyWIjBR68vhYduQrKF8J9jSIPpwahI/G BjphG/31afIor50hsK9cELTdaGHSWGYVL9ZYlN/Ivq0zLEZZl1JpSB2PfpGHHqAdupAP5F bioROa02OuLgV7rug1Bg4T8KveCBPmdaPOa3xzCIVsoWa03B/l9QiluUdSBUthzdyDOdYH QtqtlfwD2Gj2COPc6iTYnQ2CDGC6dMuXphFSCNnUmeBuQedKR5bRrN+SM6VI5g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jCFxr1sKgzmVQ for ; Sun, 25 Oct 2026 12:12:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 25d06 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sun, 25 Oct 2026 12:12:26 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dimitry Andric Subject: git: 6a936d939b88 - main - Merge commit 4d7292e58078 from llvm-project (by Minsoo Choo): List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: Commit messages for all branches of the src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 6a936d939b886fe3d777d33b0327987c3aa08f51 Auto-Submitted: auto-generated Date: Sun, 25 Oct 2026 12:12:26 +0000 Message-Id: <6addf22a.25d06.caaa0ca@gitrepo.freebsd.org> The branch main has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=6a936d939b886fe3d777d33b0327987c3aa08f51 commit 6a936d939b886fe3d777d33b0327987c3aa08f51 Author: Dimitry Andric AuthorDate: 2026-10-25 11:34:38 +0000 Commit: Dimitry Andric CommitDate: 2026-10-25 12:11:27 +0000 Merge commit 4d7292e58078 from llvm-project (by Minsoo Choo): [libunwind] Unwind through AArch64 FreeBSD signal trampolines (#235065) Retried from https://reviews.llvm.org/D155066. Recognize signal trampolines using KERN_PROC_SIGTRAMP when unwind metadata is unavailable. Restore the interrupted PC, LR, SP, general registers, and valid floating-point registers. Add coverage for unwinding out of an interrupted leaf function on both regular and alternate signal stacks. Assisted-by: GPT MFC after: 1 week --- .../libunwind/include/__libunwind_config.h | 3 + .../llvm-project/libunwind/src/UnwindCursor.hpp | 77 +++++++++++++++++++++- 2 files changed, 79 insertions(+), 1 deletion(-) diff --git a/contrib/llvm-project/libunwind/include/__libunwind_config.h b/contrib/llvm-project/libunwind/include/__libunwind_config.h index bb7fe4c83a3c..493910c3df51 100644 --- a/contrib/llvm-project/libunwind/include/__libunwind_config.h +++ b/contrib/llvm-project/libunwind/include/__libunwind_config.h @@ -36,6 +36,9 @@ # if defined(__linux__) # define _LIBUNWIND_TARGET_LINUX 1 # endif +# if defined(__FreeBSD__) +# define _LIBUNWIND_TARGET_FREEBSD 1 +# endif # if defined(__HAIKU__) # define _LIBUNWIND_TARGET_HAIKU 1 # endif diff --git a/contrib/llvm-project/libunwind/src/UnwindCursor.hpp b/contrib/llvm-project/libunwind/src/UnwindCursor.hpp index 9a1afd3721f5..067a3c238245 100644 --- a/contrib/llvm-project/libunwind/src/UnwindCursor.hpp +++ b/contrib/llvm-project/libunwind/src/UnwindCursor.hpp @@ -41,6 +41,17 @@ #define _LIBUNWIND_CHECK_LINUX_SIGRETURN 1 #endif +#if defined(_LIBUNWIND_TARGET_FREEBSD) && defined(_LIBUNWIND_TARGET_AARCH64) +#include +#include +#include +#include +#include +#include +#include +#define _LIBUNWIND_CHECK_FREEBSD_SIGRETURN 1 +#endif + #if defined(_LIBUNWIND_TARGET_HAIKU) && defined(_LIBUNWIND_TARGET_X86_64) #include #include @@ -1038,7 +1049,8 @@ private: template int stepThroughSigReturn(Registers &) { return UNW_STEP_END; } -#elif defined(_LIBUNWIND_CHECK_HAIKU_SIGRETURN) +#elif defined(_LIBUNWIND_CHECK_FREEBSD_SIGRETURN) || \ + defined(_LIBUNWIND_CHECK_HAIKU_SIGRETURN) bool setInfoForSigReturn(); int stepThroughSigReturn(); #endif @@ -1345,6 +1357,7 @@ private: bool _unwindInfoMissing; bool _isSignalFrame; #if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN) || \ + defined(_LIBUNWIND_CHECK_FREEBSD_SIGRETURN) || \ defined(_LIBUNWIND_TARGET_HAIKU) bool _isSigReturn = false; #endif @@ -2637,6 +2650,7 @@ int UnwindCursor::stepWithTBTable(pint_t pc, tbtable *TBTable, template void UnwindCursor::setInfoBasedOnIPRegister(bool isReturnAddress) { #if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN) || \ + defined(_LIBUNWIND_CHECK_FREEBSD_SIGRETURN) || \ defined(_LIBUNWIND_CHECK_HAIKU_SIGRETURN) _isSigReturn = false; #endif @@ -2762,6 +2776,7 @@ void UnwindCursor::setInfoBasedOnIPRegister(bool isReturnAddress) { #endif // #if defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND) #if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN) || \ + defined(_LIBUNWIND_CHECK_FREEBSD_SIGRETURN) || \ defined(_LIBUNWIND_CHECK_HAIKU_SIGRETURN) if (setInfoForSigReturn()) return; @@ -3053,6 +3068,65 @@ int UnwindCursor::stepThroughSigReturn(Registers_s390x &) { #endif // defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN) && // defined(_LIBUNWIND_TARGET_S390X) +#if defined(_LIBUNWIND_CHECK_FREEBSD_SIGRETURN) +template +bool UnwindCursor::setInfoForSigReturn() { + // Ask the kernel rather than reading instructions at a possibly invalid PC. + // This is only used when no unwind information was found. Keep the result + // local to avoid shared mutable state when unwinding from a signal handler. + struct kinfo_sigtramp kst = {}; + size_t len = sizeof(kst); + int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_SIGTRAMP, getpid()}; + const int savedErrno = errno; + const int result = sysctl(mib, 4, &kst, &len, nullptr, 0); + errno = savedErrno; + if (result != 0) + return false; + + const pint_t pc = static_cast(this->getReg(UNW_REG_IP)); + const pint_t start = reinterpret_cast(kst.ksigtramp_start); + const pint_t end = reinterpret_cast(kst.ksigtramp_end); + if (pc < start || pc >= end) + return false; + + _info = {}; + _info.start_ip = start; + _info.end_ip = end; + _isSigReturn = true; + return true; +} + +#if defined(_LIBUNWIND_TARGET_AARCH64) +template +int UnwindCursor::stepThroughSigReturn() { + // The trampoline leaves SP pointing at the sigframe installed by sendsig(). + const pint_t sigctx = _registers.getSP() + offsetof(struct sigframe, sf_uc) + + offsetof(ucontext_t, uc_mcontext); + const pint_t gprs = sigctx + offsetof(mcontext_t, mc_gpregs); + for (int i = 0; i < 30; ++i) + _registers.setRegister( + UNW_AARCH64_X0 + i, + _addressSpace.get64(gprs + offsetof(struct gpregs, gp_x) + i * 8)); + _registers.setRegister( + UNW_AARCH64_LR, + _addressSpace.get64(gprs + offsetof(struct gpregs, gp_lr))); + _registers.setSP(_addressSpace.get64(gprs + offsetof(struct gpregs, gp_sp))); + _registers.setIP(_addressSpace.get64(gprs + offsetof(struct gpregs, gp_elr))); + + if (_addressSpace.get32(sigctx + offsetof(mcontext_t, mc_flags)) & + _MC_FP_VALID) { + const pint_t fprs = sigctx + offsetof(mcontext_t, mc_fpregs) + + offsetof(struct fpregs, fp_q); + for (int i = 0; i < 32; ++i) + _registers.setFloatRegister(UNW_AARCH64_V0 + i, + _addressSpace.getDouble(fprs + i * 16)); + } + _isSignalFrame = true; + return UNW_STEP_SUCCESS; +} +#endif // defined(_LIBUNWIND_TARGET_AARCH64) +#endif // defined(_LIBUNWIND_CHECK_FREEBSD_SIGRETURN) + #if defined(_LIBUNWIND_CHECK_HAIKU_SIGRETURN) template bool UnwindCursor::setInfoForSigReturn() { @@ -3152,6 +3226,7 @@ template int UnwindCursor::step(bool stage2) { // Use unwinding info to modify register set as if function returned. int result; #if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN) || \ + defined(_LIBUNWIND_CHECK_FREEBSD_SIGRETURN) || \ defined(_LIBUNWIND_CHECK_HAIKU_SIGRETURN) if (_isSigReturn) { result = this->stepThroughSigReturn();