From nobody Sun Oct 25 12:12:26 2026 X-Original-To: dev-commits-src-main@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 4jCFxl0gSWz6wJ2y for ; Sun, 25 Oct 2026 12:12:27 +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 4jCFxl0BWHz4DDN for ; Sun, 25 Oct 2026 12:12:27 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1792930347; 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=YT/mCfbU2AlhKBGHKiBVKqQtA1MK/9NHp1wivCOZbm6rJlNRrejRbOzb1HNzaGnmt6VNnG NxnxxjpoLBZl7DhNnR4KK/Dh3hzMEy8v6B3a4YTFI9wMfDqxLAaXJSqwyBd/yegyiqi9Sf BNqAoMXtAHfDUX+H8f+SXTq2TASzH0hkpYP27tkSgk3VJth7IckVthk22QmOrs9GrngUHz jW0H7t9SkyGTvh1w5fkrBe3NIdyWPyaavvkAHyXagtqrxIYdzyYC+N1WGA17kNyx4YCCoH LbEmtNZrVXj3ENJfLL0NxwJaVeZPz7w/xSiDo5JNqUGsKuSQFFl/qMY/ZN1Q/g== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1792930347; b=EOnYkqJ1a4vpSI0snM0MJqSddNfQHAw8nha5Gw3I9G+0Mk8L3lvt1lZxep1l/WFuc/5svI yJeH4Mz+n11YSIhQB1ZG8uXo4h5jVYM5nDLHbHT/iMm8V5ofVHEdLTPN1ssVB+IP4DcXGr Bq/zihYfA1F6lS2tLTVOqzQwszv42FVcvUlimS7wYgUnHc4SqZ2ZqDdl2v281oX6QMW6Ec laGaSPek5UmkhgffkIzVk4/Yc6FJxvjnlu0nV6URy/SGyttBuEoxRFBrM/vzTJrewhSLSu pz4tHJKDUOFRw2OUp5fZp6ocrt7yiMlOs6PxLVUko6HL0c1MfpcOSwKDqJQyOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1792930347; 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=lXp98n4quuLtpimLZNOizcLJcGJea1Vqd2TK+AlCp9X2akcJ7F+uHvSjGGgvTs07u/8zyW m67dmAEqB33eC4LBgKZGItefJt3ByW7PYe8o51+335odq5DOLOsQJlzNw7bUoDkTVYo6tQ 3I/r8Wr1ln1FzA1AJrb4Y0x9puVD4bIDCVrVUU8gxE9xgfMNWfR9b7nE/HoLvsKfWYXWsb 7GZXzo98CVyIb5dB8vte/bqtDNm1yywYAtRomF/J5aXM/1kjJaFI1O1NgHOgoTWnR6fKoZ suo91l/Wd0PC1EqjDrbZ78V/npc2246VjKHmPLdswpfxSTb5dVE0mbcM/ifhtQ== 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 4jCFxk6yWgzmb1 for ; Sun, 25 Oct 2026 12:12:26 +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-main X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org List-Id: Commit messages for the main branch 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();