From nobody Tue Jun 16 08:55:54 2026 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0DEA239DBC7 for ; Fri, 17 Apr 2026 15:08:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776438531; cv=none; b=X1vmAIKhWU1UxIPZzqKCeyiPiGWeS0QcXZ3ksQTQFeHRqkMH1mMfFHrP4cFfAivQ3v6N0eKQv//rBOYMJ9zE4yViyv1RbrsSBUSWnDq5IkqKdwIr/FTvFc/fAz/kGeQiuZArJs1MlZ3eJ5iLtp+Q9/20JOPwd8IfZ/TZaCwNffk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776438531; c=relaxed/simple; bh=1yJGH5kQWk/DYxeD4JVEyqHz0zzZPkB5Dq3w54vSzHg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PbWSr5G+ld24dxfPHLowQLdGMLcx/wa5KDll4m37fPAfPefAxGM1Qr/ZhEC1ePv+E39V4MT7mw161pnZ13c43IIMkHREm6ABYZh1Ely5ADY+ISE+9HOnMLjRgqPr5JHY17KRCnuJ45Dd7jL/Ilhlr11JK72y24j2zQJ1HlmMKhk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=S/Sokx9B; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="S/Sokx9B" Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 63HDdOH61842914; Fri, 17 Apr 2026 15:08:35 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=D+8lIijQhG6N6RcEp GO5kMYNzpa3Tr+MHEu9UN5CrDU=; b=S/Sokx9BBw2YRJBjcAxlBUDYJ5VO/6zKD Op46RHP0Y1ygyrMBASAGbvLp3py715Gs2hjxAcFLR0La8JkNCkaAIJ2SXp7RzfX9 vy1H4SaXJFRgFkEa4HRhmEX5DBMVjzyPADdqpDUvUM2RcG8m1AAagKxHs81QisfI Gj0GO9yD3CGtFTXy4BDIkuYqKuc2LPWs9dvzeXNFvzaYypU6i3/Yz7g3imVImnVt XqbhBP7BszzulpFC1TRn8zjVcTQVSDbwLWlYxaX50gukopAokinxd0WOu/1vtta2 0o7zZq4lCEaGHyr74l4Lc9M2O22lFQCaKvw74TVLfRxTeSPviVMeQ== Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4dh89n36da-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 17 Apr 2026 15:08:34 +0000 (GMT) Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 63HE2bCa026284; Fri, 17 Apr 2026 15:08:33 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 4dg2ujyg5b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 17 Apr 2026 15:08:33 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 63HF8TKL6685086 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 17 Apr 2026 15:08:30 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CB2C420043; Fri, 17 Apr 2026 15:08:29 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 96FD72004D; Fri, 17 Apr 2026 15:08:29 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.87.85.9]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 17 Apr 2026 15:08:29 +0000 (GMT) From: Jens Remus To: Catalin Marinas , Will Deacon , Steven Rostedt , Josh Poimboeuf , Indu Bhagat , Peter Zijlstra , Dylan Hatch , Weinan Liu Cc: Jens Remus , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Heiko Carstens , Ilya Leoshkevich Subject: [PATCH v1 1/4] arm64/unwind_user/fp: Enable HAVE_UNWIND_USER_FP Date: Fri, 17 Apr 2026 17:08:24 +0200 Message-ID: <20260417150827.1183376-2-jremus@linux.ibm.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260417150827.1183376-1-jremus@linux.ibm.com> References: <20260417150827.1183376-1-jremus@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDE3MDE0OSBTYWx0ZWRfXyL+AaX4sW4c1 IztvbvVAcInJEcSMTLTanbumNJLLsJiBjUgjAmn8ghNfyA/+AouV2PHxMofVcMIDkm2HU4nY0cm tlanb96m53gZggVYlfy20dZ6a40ihAVdxCBz/Y2XuVfNEm0w6Dh18etXo9KmMMz2EmPfi9tsGiW FFHJmOuAUzJxsm0n/FJSC/qTY3326BZ0lQpZDMan6Z2r3U8UFDkInqNJqS48b1WODPCvGulSi0l d99ESZkNkbMAN+bthqbsL91qnUGEXT2E53OstsEceUQ7l2Nzm0Joiw9z68A9zpxNytH6kfelfDF zlt5OftCTkHRTyfommkYaHX2VOOD4jv5kvKoJrCctBlHL2wTNnnGOZu10nJuLkUx32oYwFSLq+g 3i0A1ulVfTAxdg5njXZKUINvvGLUyioM0tDMSZQfcXL11nX+gFMvFcBsIR8IjGTQPZV8s9ejDON BJd8zO3iM8zWD4jXZww== X-Authority-Analysis: v=2.4 cv=eJ4jSnp1 c=1 sm=1 tr=0 ts=69e24cf2 cx=c_pps a=AfN7/Ok6k8XGzOShvHwTGQ==:117 a=AfN7/Ok6k8XGzOShvHwTGQ==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=uAbxVGIbfxUO_5tXvNgY:22 a=VnNF1IyMAAAA:8 a=5cNvg9WSwcz2foiWP2IA:9 X-Proofpoint-GUID: iyloqNsP97RSgzY5YMWBlOh_W7aeqEgQ X-Proofpoint-ORIG-GUID: bOd7EevnKLOJgcOLxkyOZ266bQ2hrW3I X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-17_01,2026-04-17_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 lowpriorityscore=0 adultscore=0 priorityscore=1501 clxscore=1011 bulkscore=0 suspectscore=0 spamscore=0 impostorscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604070000 definitions=main-2604170149 Content-Type: text/plain; charset="utf-8" Add arm64 support for unwinding of user space using frame pointer (FP). For this purpose enable the config option HAVE_UNWIND_USER_FP and provide an arm64-specific ARCH_INIT_USER_FP_FRAME definition (specifying the CFA offset from FP and the FP and RA offsets from CFA). Unlike x86, as there is no mean to determine whether the user space IP in the topmost frame is at function entry, rely on the common definition of unwind_user_at_function_start(), which always returns false, and common dummy definition of ARCH_INIT_USER_FP_ENTRY_FRAME. For unwind user in general provide an arm64-specific implementation of unwind_user_word_size(). Signed-off-by: Jens Remus --- arch/arm64/Kconfig | 1 + arch/arm64/include/asm/unwind_user.h | 42 ++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 arch/arm64/include/asm/unwind_user.h diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 38dba5f7e4d2..994fd5162a1d 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -253,6 +253,7 @@ config ARM64 select HAVE_RUST if RUSTC_SUPPORTS_ARM64 select HAVE_STACKPROTECTOR select HAVE_SYSCALL_TRACEPOINTS + select HAVE_UNWIND_USER_FP select HAVE_KPROBES select HAVE_KRETPROBES select HAVE_GENERIC_VDSO diff --git a/arch/arm64/include/asm/unwind_user.h b/arch/arm64/include/asm/= unwind_user.h new file mode 100644 index 000000000000..0641d4d97b0f --- /dev/null +++ b/arch/arm64/include/asm/unwind_user.h @@ -0,0 +1,42 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_ARM64_UNWIND_USER_H +#define _ASM_ARM64_UNWIND_USER_H + +#include +#include + +#ifdef CONFIG_UNWIND_USER + +static inline int unwind_user_word_size(struct pt_regs *regs) +{ +#ifdef COMPAT + if (compat_user_mode(regs)) + return sizeof(int); +#endif + return sizeof(long); +} + +#endif /* CONFIG_UNWIND_USER */ + +#ifdef CONFIG_HAVE_UNWIND_USER_FP + +#define ARCH_INIT_USER_FP_FRAME(ws) \ + .cfa =3D { \ + .rule =3D UNWIND_USER_CFA_RULE_FP_OFFSET, \ + .offset =3D 2*(ws), \ + }, \ + .ra =3D { \ + .rule =3D UNWIND_USER_RULE_CFA_OFFSET_DEREF, \ + .offset =3D -1*(ws), \ + }, \ + .fp =3D { \ + .rule =3D UNWIND_USER_RULE_CFA_OFFSET_DEREF, \ + .offset =3D -2*(ws), \ + }, \ + .outermost =3D false, + +#endif /* CONFIG_HAVE_UNWIND_USER_FP */ + +#include + +#endif /* _ASM_ARM64_UNWIND_USER_H */ --=20 2.51.0 From nobody Tue Jun 16 08:55:54 2026 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B67F03CAE95 for ; Fri, 17 Apr 2026 15:08:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776438537; cv=none; b=CenHtcMfao9vP/kEtSHu2MFS5KRDv10NQak2xa+L2rNEH+JfOoO1hmCfkgFAxnPClgFwYsKabH3g2xWL6cLRnfgLpdXsnJxezJYf2w0Bh9JcHpLGWk+BqC0D/CsyK7HdEFgfCOEICCp8D4R3pr0rIqbwDKDlvR2EjeGe3TALkA8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776438537; c=relaxed/simple; bh=j9S7XoBHRXniwPgIJFDk5NPcfH9xwCMZ3L+l+u5+avg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UBQlniNXiy6g2kTD65RHsNYEj0uKRoWw4l9yB9Fa54TncuLYxzuBWbEhNGzPUAOxqNshFta2KqYW237gIBVgqT1ViQW8WV+2c0D5WV6KjqETqkt86U6y1xUdpWPX/fQGRSJAkvPR3dnRXH+YtsdYG1cBJYe5CBnZscXL2sLrqXg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=XtWcRed5; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="XtWcRed5" Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 63H9fZku1733164; Fri, 17 Apr 2026 15:08:35 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=UKca5QJQ1hxgTQwHY K4x+LZXd06rJ/B93mnhlgY1RYI=; b=XtWcRed5o6MfKsH6GiH1k3GOFR1dcvfHd N8kuTawPEG3JQy5Qigxb4ABu4RjjQXsfWeMaogbBNUl0GzUtLSJvSmSHAkmvfwt2 A1AsV0fyxJfeCKgh7z4njQB43ndofe+1xpxHT6LGNq6R7Fj7QQJV3tGDVl7IHuZT FXxyRuwhuLJUNCErvwpp9o4SLtHGxD+jdNl/P5jJFedTzjNLZsBnncP9LFAKwHsu P4+z9EfEPgxgiOLTvx2bRwUfwlvkOpu88Z3YVjS9w9K7gik3vSqASOPSK6hMdWlG /2zyKnKJyRJFEH1y6L8zypQ28O5tFFFUrECsYa3ErEkeg5RhznTzQ== Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4dh89mhw5h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 17 Apr 2026 15:08:34 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 63HCQfqh003586; Fri, 17 Apr 2026 15:08:34 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4dg1mnqpda-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 17 Apr 2026 15:08:33 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 63HF8U8737421500 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 17 Apr 2026 15:08:30 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0B8A120043; Fri, 17 Apr 2026 15:08:30 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D09E42004B; Fri, 17 Apr 2026 15:08:29 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.87.85.9]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 17 Apr 2026 15:08:29 +0000 (GMT) From: Jens Remus To: Catalin Marinas , Will Deacon , Steven Rostedt , Josh Poimboeuf , Indu Bhagat , Peter Zijlstra , Dylan Hatch , Weinan Liu Cc: Jens Remus , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Heiko Carstens , Ilya Leoshkevich Subject: [PATCH v1 2/4] arm64/uaccess: Add unsafe_copy_from_user() implementation Date: Fri, 17 Apr 2026 17:08:25 +0200 Message-ID: <20260417150827.1183376-3-jremus@linux.ibm.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260417150827.1183376-1-jremus@linux.ibm.com> References: <20260417150827.1183376-1-jremus@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Authority-Analysis: v=2.4 cv=I/dVgtgg c=1 sm=1 tr=0 ts=69e24cf3 cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=V8glGbnc2Ofi9Qvn3v5h:22 a=VwQbUJbxAAAA:8 a=VnNF1IyMAAAA:8 a=DR0qyCAueFOdPjQfhtcA:9 X-Proofpoint-GUID: VN9voE7jdsiIXsDy1wB_9tHxLAk6-xBY X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDE3MDE0OSBTYWx0ZWRfX8Y4dfi4g+C4l LIqjVSU/ldhZASrP7sosUM6uB6+TgFVMy765zyYhcLmysM5RhlC8VYnven32mUaUdk4pua/womj gTxVXgAbZdPPcFxMYgG3qeZZmP7hbcXKIU2T7vGAMvUoBsp0XB8NggB5oLxiiNZLVGHIasS+Smg yhQ/I74huTn/vfD+J9FSlX3sFsjeZR+X7mn4bE68+2wCJO58Lru7yFFBJltds7yfzqDek88nOad /nX75gbqcQhFMBXTifZ9H8EiXqt50j+oZeafMgcsHYsrbp5EW5UiPMTMBLitr3PWJUcoRLppgLD MW84nipmN1R71sLWTapTUzwFNtgdq36L/p08qi6yaZBcOXWxdlKOeTRD5XLe0nUOREn2H5nKoqP 6bwlttkIRVyLcRNBPvwQ1gg5BOdrno1dskGEwJOlB1oJyR4lz2KJBSHeEPvkRAhIA7y3Pq1dLTV GeOKM04tNJAcY6MVxUA== X-Proofpoint-ORIG-GUID: baHr-ceya3FGTbt7zWUuPEtJIg5w4-or X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-17_01,2026-04-17_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 bulkscore=0 clxscore=1011 adultscore=0 lowpriorityscore=0 suspectscore=0 impostorscore=0 phishscore=0 spamscore=0 priorityscore=1501 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604070000 definitions=main-2604170149 Content-Type: text/plain; charset="utf-8" This replicates Josh's x86 patch "x86/uaccess: Add unsafe_copy_from_user() implementation" [1] for arm64. Add an arm64 implementation of unsafe_copy_from_user() similar to the existing unsafe_copy_to_user(). For this purpose rename the unsafe_copy_loop() helper to unsafe_copy_to_user_loop() and introduce a unsafe_copy_from_user_loop() helper. While at it rename the unsafe_copy_to_user() local variables __ucu_{dst|src|len} to __{dst|src|len} and change their pointer type to void * to align to the x86 patch. [1]: x86/uaccess: Add unsafe_copy_from_user() implementation, https://lore.kernel.org/all/20251119132323.1281768-4-jremus@linux.ibm.= com/ Signed-off-by: Jens Remus --- arch/arm64/include/asm/uaccess.h | 39 ++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uacc= ess.h index 9810106a3f66..37d7d16b86a9 100644 --- a/arch/arm64/include/asm/uaccess.h +++ b/arch/arm64/include/asm/uaccess.h @@ -437,7 +437,7 @@ static inline void user_access_restore(unsigned long en= abled) { } * We want the unsafe accessors to always be inlined and use * the error labels - thus the macro games. */ -#define unsafe_copy_loop(dst, src, len, type, label) \ +#define unsafe_copy_to_user_loop(dst, src, len, type, label) \ while (len >=3D sizeof(type)) { \ unsafe_put_user(*(type *)(src),(type __user *)(dst),label); \ dst +=3D sizeof(type); \ @@ -445,15 +445,34 @@ static inline void user_access_restore(unsigned long = enabled) { } len -=3D sizeof(type); \ } =20 -#define unsafe_copy_to_user(_dst,_src,_len,label) \ -do { \ - char __user *__ucu_dst =3D (_dst); \ - const char *__ucu_src =3D (_src); \ - size_t __ucu_len =3D (_len); \ - unsafe_copy_loop(__ucu_dst, __ucu_src, __ucu_len, u64, label); \ - unsafe_copy_loop(__ucu_dst, __ucu_src, __ucu_len, u32, label); \ - unsafe_copy_loop(__ucu_dst, __ucu_src, __ucu_len, u16, label); \ - unsafe_copy_loop(__ucu_dst, __ucu_src, __ucu_len, u8, label); \ +#define unsafe_copy_to_user(_dst, _src, _len, label) \ +do { \ + void __user *__dst =3D (_dst); \ + const void *__src =3D (_src); \ + size_t __len =3D (_len); \ + unsafe_copy_to_user_loop(__dst, __src, __len, u64, label); \ + unsafe_copy_to_user_loop(__dst, __src, __len, u32, label); \ + unsafe_copy_to_user_loop(__dst, __src, __len, u16, label); \ + unsafe_copy_to_user_loop(__dst, __src, __len, u8, label); \ +} while (0) + +#define unsafe_copy_from_user_loop(dst, src, len, type, label) \ + while (len >=3D sizeof(type)) { \ + unsafe_get_user(*(type *)(dst), (type __user *)(src), label); \ + dst +=3D sizeof(type); \ + src +=3D sizeof(type); \ + len -=3D sizeof(type); \ + } + +#define unsafe_copy_from_user(_dst, _src, _len, label) \ +do { \ + void *__dst =3D (_dst); \ + void __user *__src =3D (_src); \ + size_t __len =3D (_len); \ + unsafe_copy_from_user_loop(__dst, __src, __len, u64, label); \ + unsafe_copy_from_user_loop(__dst, __src, __len, u32, label); \ + unsafe_copy_from_user_loop(__dst, __src, __len, u16, label); \ + unsafe_copy_from_user_loop(__dst, __src, __len, u8, label); \ } while (0) =20 #define INLINE_COPY_TO_USER --=20 2.51.0 From nobody Tue Jun 16 08:55:54 2026 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 919FE2DEA93 for ; Fri, 17 Apr 2026 15:08:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776438531; cv=none; b=VZoUQjMbIGxQvJlM5ecMhsTngqN5oj7fJQCJ7Nv4/VVe0LDsWdzsh3TBLGclVaBMuM+Gkj4YjrC9lV0CLIY3M8psw/p3dl8bUHiM0KAjy8lZaOkfr4v2d6URMUlFo1OFsNFyq3i6icmB94eYCSl3WVWGi9DBbwfYo5l5jf8GLDs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776438531; c=relaxed/simple; bh=bpc10ynF6kOuv4QuEd/i/jVpQ3u27dEzS8Ui7HkEh0c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DSDRfDp8aerEX338+RUlAFlN/0EdgNhDzniVTO71MSMKaX5W+u5PDghos2F0NoUJc+DGXVGAchjRIlAvHGS1v9AlfoueNx2SM1FWJYT1S+DvX+b6cBmUVnazpr77T/IgLjwSbv3WU2ZgWtkCrOFJutinhqseVt4TVP/Gbc2W6XE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=Nxx+GH1C; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="Nxx+GH1C" Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 63HDJvAA2130601; Fri, 17 Apr 2026 15:08:35 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=c2KqLQFtOA7xOWG1Z 7g0t9kBHx5RFlh45SgvQkjyRMc=; b=Nxx+GH1CMmATMYkcD/+4WJgkE+x99gtNE 08dhDndO3epRr8Vy3gAGF6xCFC3HhhNet4gx3dyUZKF1/xYZKPsnyMjSmoDMtqcW 8GxxhoOfbPJNn6wV3/PMBtuxwLSDrj+uMTfQcxZWJfKrsvXVCQ+UbJ9Pnw4GYRJk 5pcFNLVtEBO7v9jhOah81RC3+ac/uMosc32frxeG4plmUYjRTpqxeNBe0QkXmwAk gaX6cs0+Y/JGM+512xWRsM6EAuvdfLnwVmyvqj6qPTuhtXuylfVdP1SmqNuAvf91 v1GE2C3EXKQUXNWoEylYMAVYRFX9gn+RcO9ty/XtfcAlQHqbsaKmA== Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4dh89nu8ug-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 17 Apr 2026 15:08:34 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 63HAehHm015158; Fri, 17 Apr 2026 15:08:33 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 4dg0msyvc3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 17 Apr 2026 15:08:33 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 63HF8Uui37421502 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 17 Apr 2026 15:08:30 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 41FAF20043; Fri, 17 Apr 2026 15:08:30 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1164F2004D; Fri, 17 Apr 2026 15:08:30 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.87.85.9]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 17 Apr 2026 15:08:30 +0000 (GMT) From: Jens Remus To: Catalin Marinas , Will Deacon , Steven Rostedt , Josh Poimboeuf , Indu Bhagat , Peter Zijlstra , Dylan Hatch , Weinan Liu Cc: Jens Remus , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Heiko Carstens , Ilya Leoshkevich Subject: [PATCH v1 3/4] arm64/vdso: Enable SFrame generation in vDSO Date: Fri, 17 Apr 2026 17:08:26 +0200 Message-ID: <20260417150827.1183376-4-jremus@linux.ibm.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260417150827.1183376-1-jremus@linux.ibm.com> References: <20260417150827.1183376-1-jremus@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Proofpoint-GUID: G_x5xLLkMNudAsXFhMgzlKdlMokhecXW X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDE3MDE0OSBTYWx0ZWRfX/x5GO7m+k+Og YF0KZGON/xPyEotPWDCReR+wJHo5E/AlKHiX5i9FS17LqiS3rYk9xfNfHKTLV/J/r3ZuCvGiVGx mcudwQ59PXwD4D1mMACOK+S7ifrKxnyyARBqVaBtMx/eRUn5upl2dOyj9zQ0+Zj2s+FotIK3L+K hPiOfuv/qMutl8ZTkgF9GYYdxRM8YMWTEr8bC1tz0XYuAM05wEEq+upFNkLMnukpFsdCxLXA91i PtZ0ZeEm3YoribXvQl/KQGFXTcZDbxmrIOBuZclXv3azpuabYWJrEct3nd/f5+ujssa3yzj0XGN 8nE1OFbsXFpMwbMIM2bYDXHda4UCpUkuNjgnU5p3aqhwbYrmOZd/O24iHu+r4pTTsRiO4gGqnSt EEemMqaORYRV8wnfPpSUyNNLmfZTvInwSCuCwjx+eZNEniOMJLBd1zyFAqdOyogph1w0HdwGvb1 cAtOLEOILtagoRAGnGw== X-Proofpoint-ORIG-GUID: X0ZmsxiAiusL7OWHw_TdbYTeb-nD_QuH X-Authority-Analysis: v=2.4 cv=FY4HAp+6 c=1 sm=1 tr=0 ts=69e24cf3 cx=c_pps a=bLidbwmWQ0KltjZqbj+ezA==:117 a=bLidbwmWQ0KltjZqbj+ezA==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=iQ6ETzBq9ecOQQE5vZCe:22 a=VwQbUJbxAAAA:8 a=VnNF1IyMAAAA:8 a=1XWaLZrsAAAA:8 a=XY4kb5VVk54sx2ePs7AA:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-17_01,2026-04-17_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 priorityscore=1501 bulkscore=0 impostorscore=0 spamscore=0 lowpriorityscore=0 suspectscore=0 clxscore=1011 malwarescore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604070000 definitions=main-2604170149 Content-Type: text/plain; charset="utf-8" This replicates Josh's x86 patch "x86/vdso: Enable sframe generation in VDSO" [1] for arm64. Enable .sframe generation in the vDSO library so kernel and user space can unwind through it. Keep all function symbols in the vDSO .symtab for stack trace purposes. This enables perf to lookup these function symbols in addition to those already exported in vDSO .dynsym. Starting with binutils 2.46 both GNU assembler and GNU linker exclusively support generating and merging .sframe in SFrame V3 format. For vDSO, only if supported by the assembler, generate .sframe, collect it, mark it as KEEP, and generate a GNU_SFRAME program table entry. Otherwise explicitly discard any .sframe. [1]: x86/vdso: Enable sframe generation in VDSO, https://lore.kernel.org/all/20260211141357.271402-7-jremus@linux.ibm.c= om/ Signed-off-by: Jens Remus --- Notes (jremus): @Dylan: Adding -Wa,--gsframe-3 to the VDSO CC_FLAGS_ADD_VDSO (and AS_FLAGS_ADD_VDSO) may clash with your patch [1] that adds likewise to the CC_FLAGS_REMOVE_VDSO. Any idea how to resolve? =20 [1]: [PATCH v3 2/8] arm64, unwind: build kernel with sframe V3 info, https://lore.kernel.org/all/20260406185000.1378082-3-dylanbhatch@g= oogle.com/ arch/arm64/kernel/vdso/Makefile | 14 ++++++++++++-- arch/arm64/kernel/vdso/vdso.lds.S | 21 +++++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kernel/vdso/Makefile b/arch/arm64/kernel/vdso/Makef= ile index 7dec05dd33b7..1f2f01673397 100644 --- a/arch/arm64/kernel/vdso/Makefile +++ b/arch/arm64/kernel/vdso/Makefile @@ -15,6 +15,10 @@ obj-vdso :=3D vgettimeofday.o note.o sigreturn.o vgetran= dom.o vgetrandom-chacha.o targets :=3D $(obj-vdso) vdso.so vdso.so.dbg obj-vdso :=3D $(addprefix $(obj)/, $(obj-vdso)) =20 +ifeq ($(CONFIG_AS_SFRAME3),y) + SFRAME_CFLAGS :=3D -Wa,--gsframe-3 +endif + btildflags-$(CONFIG_ARM64_BTI_KERNEL) +=3D -z force-bti =20 # -Bsymbolic has been added for consistency with arm, the compat vDSO and @@ -41,7 +45,9 @@ CC_FLAGS_REMOVE_VDSO :=3D $(CC_FLAGS_FTRACE) -Os $(CC_FLA= GS_SCS) \ $(CC_FLAGS_LTO) $(CC_FLAGS_CFI) \ -Wmissing-prototypes -Wmissing-declarations =20 -CC_FLAGS_ADD_VDSO :=3D -O2 -mcmodel=3Dtiny -fasynchronous-unwind-tables +CC_FLAGS_ADD_VDSO :=3D -O2 -mcmodel=3Dtiny -fasynchronous-unwind-tables $(= SFRAME_CFLAGS) + +AS_FLAGS_ADD_VDSO :=3D $(SFRAME_CFLAGS) =20 CFLAGS_REMOVE_vgettimeofday.o =3D $(CC_FLAGS_REMOVE_VDSO) CFLAGS_REMOVE_vgetrandom.o =3D $(CC_FLAGS_REMOVE_VDSO) @@ -49,6 +55,10 @@ CFLAGS_REMOVE_vgetrandom.o =3D $(CC_FLAGS_REMOVE_VDSO) CFLAGS_vgettimeofday.o =3D $(CC_FLAGS_ADD_VDSO) CFLAGS_vgetrandom.o =3D $(CC_FLAGS_ADD_VDSO) =20 +AFLAGS_sigreturn.o =3D $(AS_FLAGS_ADD_VDSO) + +AFLAGS_vgetrandom-chacha.o =3D $(AS_FLAGS_ADD_VDSO) + ifneq ($(c-gettimeofday-y),) CFLAGS_vgettimeofday.o +=3D -include $(c-gettimeofday-y) endif @@ -65,7 +75,7 @@ $(obj)/vdso.so.dbg: $(obj)/vdso.lds $(obj-vdso) FORCE $(call if_changed,vdsold_and_vdso_check) =20 # Strip rule for the .so file -$(obj)/%.so: OBJCOPYFLAGS :=3D -S +$(obj)/%.so: OBJCOPYFLAGS :=3D -g $(obj)/%.so: $(obj)/%.so.dbg FORCE $(call if_changed,objcopy) =20 diff --git a/arch/arm64/kernel/vdso/vdso.lds.S b/arch/arm64/kernel/vdso/vds= o.lds.S index 52314be29191..527e107ca4b5 100644 --- a/arch/arm64/kernel/vdso/vdso.lds.S +++ b/arch/arm64/kernel/vdso/vdso.lds.S @@ -15,6 +15,8 @@ #include #include =20 +#define KEEP_SFRAME IS_ENABLED(CONFIG_AS_SFRAME) + OUTPUT_FORMAT("elf64-littleaarch64", "elf64-bigaarch64", "elf64-littleaarc= h64") OUTPUT_ARCH(aarch64) =20 @@ -68,6 +70,13 @@ SECTIONS *(.igot .igot.plt) } :text =20 +#if KEEP_SFRAME + .sframe : { + KEEP (*(.sframe)) + *(.sframe.*) + } :text :sframe +#endif + _end =3D .; PROVIDE(end =3D .); =20 @@ -78,9 +87,18 @@ SECTIONS *(.data .data.* .gnu.linkonce.d.* .sdata*) *(.bss .sbss .dynbss .dynsbss) *(.eh_frame .eh_frame_hdr) +#if !KEEP_SFRAME + *(.sframe) + *(.sframe.*) +#endif } } =20 +/* + * Very old versions of ld do not recognize this name token; use the const= ant. + */ +#define PT_GNU_SFRAME 0x6474e554 + /* * We must supply the ELF program headers explicitly to get just one * PT_LOAD segment, and set the flags explicitly to make segments read-onl= y. @@ -90,6 +108,9 @@ PHDRS text PT_LOAD FLAGS(5) FILEHDR PHDRS; /* PF_R|PF_X */ dynamic PT_DYNAMIC FLAGS(4); /* PF_R */ note PT_NOTE FLAGS(4); /* PF_R */ +#if KEEP_SFRAME + sframe PT_GNU_SFRAME FLAGS(4); /* PF_R */ +#endif } =20 /* --=20 2.51.0 From nobody Tue Jun 16 08:55:54 2026 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B29E83C456B for ; Fri, 17 Apr 2026 15:08:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776438536; cv=none; b=B7B0ocYOPDUhVuI89M7NXOUXt3BIEqtTnUqv7x1COrDYfwQ5ENb/52xq02JCdSLoOdOxJYcec5W8GKYNb/0X2d9i3/75KUSy8Yv4Fl1cq0bFt5+TcRhXMMGuXUvdIckIGv2fkGFpIGkNklCFRtzG3q++fZWDSgNru37G3MYJhDg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776438536; c=relaxed/simple; bh=oQDDbdn7o0Q9xdA0pvw8OWK2TKp46fKZ8xrvzUJTdKQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=StGotDErdpSbT9eGirL1cLXDAYlAc6MQ4do6f6cHlaj1H8UnI4K6Umsl6lmhswM4EP4KUhTlKen6uhCdb5Dtll4/HaelBe7TRH4cOCfqTPLM9/A9lWO/h67yhNfLXImENO4/NdKQxZ5ehzDdFwh9XgR3WnAW9AL1egpnjYSIs9E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=IVJU2Mgt; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="IVJU2Mgt" Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 63HEYWbW1804477; Fri, 17 Apr 2026 15:08:35 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=hZ3/ORV9RtymMCSRu a+nR0oD5sT1rbjTBBVsIvLeDmI=; b=IVJU2MgtNtdl8k7XKk+x8hM8YCITAqs+u VBzN+2qfsz97p+QMav64omqQ9/jyTgj9oyqLCXRMAl6xZrAZUn47RsmgXaZQBP8R 8cV8I63fLrMwyMZo0yMC20cZuBCR0B2taINZOGgOLrt9QPKtaSH/VrpFU+X/9L61 se2pXBPrpxAZyS1N08Pzfnav9EYv3INYdS3Z0ZjlsYN59mnAWsXEVR/ANj4o9pSv 0v52YWlvYompQu7h7bwfEfdALuXgninCSnrAMYg7JU6Wm/wABnUXnWJJttZVbyLX smMRwo2zmyPZFSKcDKRpv1IPyYbwDCtDy5bZJ64qVflN6gUt7g61g== Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4dh89khxeq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 17 Apr 2026 15:08:34 +0000 (GMT) Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 63HDKHwg025643; Fri, 17 Apr 2026 15:08:34 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 4dg2ujyg5c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 17 Apr 2026 15:08:33 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 63HF8Um348365950 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 17 Apr 2026 15:08:30 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7E0DB20043; Fri, 17 Apr 2026 15:08:30 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 49DC92004B; Fri, 17 Apr 2026 15:08:30 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.87.85.9]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 17 Apr 2026 15:08:30 +0000 (GMT) From: Jens Remus To: Catalin Marinas , Will Deacon , Steven Rostedt , Josh Poimboeuf , Indu Bhagat , Peter Zijlstra , Dylan Hatch , Weinan Liu Cc: Jens Remus , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Heiko Carstens , Ilya Leoshkevich Subject: [PATCH v1 4/4] arm64/unwind_user/sframe: Enable sframe unwinding on arm64 Date: Fri, 17 Apr 2026 17:08:27 +0200 Message-ID: <20260417150827.1183376-5-jremus@linux.ibm.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260417150827.1183376-1-jremus@linux.ibm.com> References: <20260417150827.1183376-1-jremus@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Proofpoint-GUID: BfedFkVZO-xnB-Fo-fQ4KpLIcJFkapuE X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDE3MDE0OSBTYWx0ZWRfX67ZZy41hE9XF NVV+6dQU1UONeBOOqW+BZOWiydgr8aOfnE86SBbqe1xH1ukpNTzU3PgiFTOy0oxwpOQ1e0OpTLD qjhsGcq8Oowb4vnDlfFeQVqm3C7SpfCeWLt+Bi2dQQAx6oJyOqEoPiQuggfYnDqD8gSmPvHdxl+ 0NnUTOvt7RtKOoteh83gTzaLoNNVXKRXj7FGrzuzOz2yISt+FOtPgbDMLa3Y/Y6ckoqFgd6CGWk 8yeFuK3pAmbDw+lrhK8fEkDet2+2CACH9UAHS0kxIQd9BtBANAISabpvyMEDuxAvhAn+DFvN42k Zb5mtRqrfz49XZPnuVTKjmucfqZDB+2CxAyvNTwN5xGfUXyVpX2l6EzAQut2rSJG4Nh9/qNUYJz Bd7e/NE/tNcGZIJK+XfD0yKO8ATdRGam7EwvQrm5cOVsm8axx8Z6wYF1+eYduGNIsRmk04UOB/N c77UZwOJhWtLTFgz1iQ== X-Proofpoint-ORIG-GUID: dlX5btp-3IlROH6HW2RI-JoRUw0W6BWx X-Authority-Analysis: v=2.4 cv=W60IkxWk c=1 sm=1 tr=0 ts=69e24cf3 cx=c_pps a=AfN7/Ok6k8XGzOShvHwTGQ==:117 a=AfN7/Ok6k8XGzOShvHwTGQ==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=RzCfie-kr_QcCd8fBx8p:22 a=VnNF1IyMAAAA:8 a=8cyZKrTVTJG3FlwYzZ0A:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-17_01,2026-04-17_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 clxscore=1015 priorityscore=1501 spamscore=0 bulkscore=0 adultscore=0 phishscore=0 lowpriorityscore=0 suspectscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604070000 definitions=main-2604170149 Content-Type: text/plain; charset="utf-8" Add arm64 support for unwinding of user space using SFrame. This leverages the unwind user (sframe) support for s390 which enables architectures that pass the return address in a register, may not necessarily save the return address on the stack (for instance in leaf functions), and have SP at call site equal SP at entry. For this purpose provide arm64-specific unwind_user_get_ra_reg() and unwind_user_get_reg() implementations, which return the value of the link register (LR) or an arbitrary register in the topmost user space frame. Define the arm64 SP and FP DWARF register numbers. Signed-off-by: Jens Remus --- Notes (jremus): Note: An arm64 implementation of unwind_user_get_reg() is strictly only needed, if SFrame V3 flexible FDE would get generated for aarch64, which is currently not the case in GNU Binutils 2.46. arch/arm64/Kconfig | 1 + arch/arm64/include/asm/unwind_user.h | 23 +++++++++++++++++++++ arch/arm64/include/asm/unwind_user_sframe.h | 8 +++++++ 3 files changed, 32 insertions(+) create mode 100644 arch/arm64/include/asm/unwind_user_sframe.h diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 994fd5162a1d..641a3a5fe5c9 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -254,6 +254,7 @@ config ARM64 select HAVE_STACKPROTECTOR select HAVE_SYSCALL_TRACEPOINTS select HAVE_UNWIND_USER_FP + select HAVE_UNWIND_USER_SFRAME select HAVE_KPROBES select HAVE_KRETPROBES select HAVE_GENERIC_VDSO diff --git a/arch/arm64/include/asm/unwind_user.h b/arch/arm64/include/asm/= unwind_user.h index 0641d4d97b0f..3c7fd8c4ba5b 100644 --- a/arch/arm64/include/asm/unwind_user.h +++ b/arch/arm64/include/asm/unwind_user.h @@ -4,6 +4,7 @@ =20 #include #include +#include =20 #ifdef CONFIG_UNWIND_USER =20 @@ -16,6 +17,28 @@ static inline int unwind_user_word_size(struct pt_regs *= regs) return sizeof(long); } =20 +static inline int unwind_user_get_ra_reg(unsigned long *val) +{ + struct pt_regs *regs =3D task_pt_regs(current); + *val =3D regs->regs[AARCH64_INSN_REG_LR]; + return 0; +} +#define unwind_user_get_ra_reg unwind_user_get_ra_reg + +static inline int unwind_user_get_reg(unsigned long *val, unsigned int reg= num) +{ + const struct pt_regs *regs =3D task_pt_regs(current); + + if (regnum <=3D 30) + /* DWARF register numbers 0..15 */ + *val =3D regs->regs[regnum]; + else + return -EINVAL; + + return 0; +} +#define unwind_user_get_reg unwind_user_get_reg + #endif /* CONFIG_UNWIND_USER */ =20 #ifdef CONFIG_HAVE_UNWIND_USER_FP diff --git a/arch/arm64/include/asm/unwind_user_sframe.h b/arch/arm64/inclu= de/asm/unwind_user_sframe.h new file mode 100644 index 000000000000..65c0a6b6c835 --- /dev/null +++ b/arch/arm64/include/asm/unwind_user_sframe.h @@ -0,0 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_ARM64_UNWIND_USER_SFRAME_H +#define _ASM_ARM64_UNWIND_USER_SFRAME_H + +#define SFRAME_REG_SP 31 +#define SFRAME_REG_FP 29 + +#endif /* _ASM_ARM64_UNWIND_USER_SFRAME_H */ --=20 2.51.0