From nobody Tue Oct 7 09:52:18 2025 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 3B0AF27467F; Thu, 10 Jul 2025 16:35:51 +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=1752165353; cv=none; b=BylLYRPz3H69ByYwH6mYPfoxvwVBecqpEkJdyrjJ+pR+TjI99ZVKE8DVIK9e1tGjL9ZA80ZPuSpTBavq+9vbPiYXf8kplElL5vn3ENnIx4nojpPMhrtvbRjJ5Bpgx2vxpZDUFZ2UH3DX+oTEtaOIPk0Ol+5bsdO7+z/z6mQrZEU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752165353; c=relaxed/simple; bh=YV0VSTJJjV0h9e42aBPXGTMpvmHUVB+yyBLnSmUVBvU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dxlnbkC75mDjkBPCbKeXScNvvMNO0962Rq61G/sLwy244dwSqdTJ1wyYMdzPpaAvZeFfZxzGbP6aZizfzg9c3DylZ3zQ4EMwg6racYKj4KXpqLvrnY/yLA89YhQvTznZPg7wEQBfwNByrSO6HSmSFgOy0o5EQFamw2V8NOk8k8I= 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=nvBJayk6; 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="nvBJayk6" Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 56ACALZE008445; Thu, 10 Jul 2025 16:35:29 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=fZXRz+KqG+SX1i5fb oP0I5c38GMmIS1nFUAT1eqLBQs=; b=nvBJayk6mzjB3EIU5Ok82j59OhGBqiSl6 PuzNeNQvqf6TvsOBgRD1tXr2C0ybSb/BhKj0yEnH0lfWY7W2FpT4iVol8E1fcIzy Tdve2rFBh3reg+cx57eC1t0aRx5vHCsW/Vqph3BJ3/MQha12E7udc0sGx2i+zxfr ZkMB8ryFfANHCAq0kJitOcDI9GDWKB3N4pLLxvLNryIbOGLNXTarNBE3qLEoav9C cfVtnVwL/LC+EA79tz4Wl5zLf7Wl5iPo4igbQN+aibuVHUXspS7soTyr0eTeEMzd r7Z6fO/FC+UhIy+CEQmwuPoYX1oJ1StOM9V5GtecPjjgUOvfk/M9Q== Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 47svb26ata-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Jul 2025 16:35:29 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 56AFkiMN024330; Thu, 10 Jul 2025 16:35:28 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 47qh32p8ma-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Jul 2025 16:35:28 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 56AGZOhI53215676 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 10 Jul 2025 16:35:24 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9D78F20043; Thu, 10 Jul 2025 16:35:24 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5FF6E2004D; Thu, 10 Jul 2025 16:35:24 +0000 (GMT) Received: from tuxmaker.lnxne.boe (unknown [9.152.85.9]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 10 Jul 2025 16:35:24 +0000 (GMT) From: Jens Remus To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, bpf@vger.kernel.org, x86@kernel.org, Steven Rostedt Cc: Jens Remus , Heiko Carstens , Vasily Gorbik , Ilya Leoshkevich , Masami Hiramatsu , Mathieu Desnoyers , Josh Poimboeuf , Peter Zijlstra , Ingo Molnar , Jiri Olsa , Namhyung Kim , Thomas Gleixner , Andrii Nakryiko , Indu Bhagat , "Jose E. Marchesi" , Beau Belgrave , Linus Torvalds , Andrew Morton , Jens Axboe , Florian Weimer , Sam James Subject: [RFC PATCH v1 01/16] fixup! unwind_user: Add frame pointer support Date: Thu, 10 Jul 2025 18:35:07 +0200 Message-ID: <20250710163522.3195293-2-jremus@linux.ibm.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250710163522.3195293-1-jremus@linux.ibm.com> References: <20250710163522.3195293-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-Spam-Details-Enc: AW1haW4tMjUwNzEwMDEzOSBTYWx0ZWRfX+3pElTM+YwPF mGcaPMLwi0geM6lWsra2Z6IHpDwdGBh4K0I1q8PESiP+RKE+3RJOLhN60cCJODBlnILond0o2so da/w4bB50b44/Nd8GPx6uWcR8jJY7YcU3MLkw4/8PwPujM/MGY9D2dvTWCyj709IEwgt6O2mscp qX7xgJWT2uvYz8azzYVx3BmS++BU1X7PGTeCqJ9XQbHfhdDTpXVRVgOdn0T8/ijxL77CpOCDn4O UfqjDVy0cnxeQhtzNZreHz/1WZWeWVjwInJfaRN1niyuBWTmYzffkE15nbk+8Fs+yK+/T2P0gz8 /L5u4d0tk5eC5B/XA7u4YjkDEjjXFH+G+0O8PeL9ksxEZUNh1EYmoT3YvY9SeuS/0K/I0nTtxst 7WBa08o1/bZYDPfKYVAJm1XEZ02TWjGv20nXe7kocfgW4DkzQQv5s3+2bpBjomoYX2N+eFMk X-Authority-Analysis: v=2.4 cv=Y774sgeN c=1 sm=1 tr=0 ts=686febd1 cx=c_pps a=aDMHemPKRhS1OARIsFnwRA==:117 a=aDMHemPKRhS1OARIsFnwRA==:17 a=Wb1JkmetP80A:10 a=u97DrBQfMCEPXbZYdeQA:9 X-Proofpoint-ORIG-GUID: k_938dfeGE6hVkIM4mdgE6QD-cW4mW5t X-Proofpoint-GUID: k_938dfeGE6hVkIM4mdgE6QD-cW4mW5t X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.7,FMLib:17.12.80.40 definitions=2025-07-10_04,2025-07-09_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 adultscore=0 priorityscore=1501 malwarescore=0 bulkscore=0 impostorscore=0 lowpriorityscore=0 phishscore=0 suspectscore=0 mlxlogscore=999 mlxscore=0 clxscore=1015 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505280000 definitions=main-2507100139 Content-Type: text/plain; charset="utf-8" --- kernel/unwind/user.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kernel/unwind/user.c b/kernel/unwind/user.c index 6e7ca9f1293a..d0181c636c6b 100644 --- a/kernel/unwind/user.c +++ b/kernel/unwind/user.c @@ -74,6 +74,7 @@ static int unwind_user_next(struct unwind_user_state *sta= te) goto done; } =20 + /* Get the Canonical Frame Address (CFA) */ if (frame->use_fp) { if (state->fp < state->sp) goto done; @@ -81,11 +82,9 @@ static int unwind_user_next(struct unwind_user_state *st= ate) } else { cfa =3D state->sp; } - - /* Get the Canonical Frame Address (CFA) */ cfa +=3D frame->cfa_off; =20 - /* stack going in wrong direction? */ + /* Make sure that stack is not going in wrong direction */ if (cfa <=3D state->sp) goto done; =20 @@ -94,10 +93,11 @@ static int unwind_user_next(struct unwind_user_state *s= tate) if ((cfa + frame->ra_off) & ((1 << shift) - 1)) goto done; =20 - /* Find the Return Address (RA) */ + /* Get the Return Address (RA) */ if (unwind_get_user_long(ra, cfa + frame->ra_off, state)) goto done; =20 + /* Get the Frame Pointer (FP) */ if (frame->fp_off && unwind_get_user_long(fp, cfa + frame->fp_off, state)) goto done; =20 --=20 2.48.1 From nobody Tue Oct 7 09:52:18 2025 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 D053D2EFDB7; Thu, 10 Jul 2025 16:36:13 +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=1752165375; cv=none; b=h4AZ+Jjp9k2TUr12M8UhuutBOKSBjEEsomJLS3Z7KwZ+M3RBWHvm2SwQoxlaf0ZbX2y/W4L3HkFKTx34aowIf02hSsYz9FrD3i3/13hyeBdBQOUJnqVG+SRBlyBIFcoOebJla+oZPO27SRicZ5O+0/IZroIxJ6F/5RCZkERsWhA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752165375; c=relaxed/simple; bh=0vJWpp1BmbZ+f0zTAZ3jlmEW/uAv+t+YKzeyKWWg1RQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KkHkWiiHEthX+dxXRnqi2afit4gKriWdCPlfxCPdAk18+cPmXhLS298nNRk9Unmn6z+n+uTwlCq1ST4E7UdHs39p5jiWGNZRsdY+CH/CYsSVR8gnx0mb0+/CTliBkMe1AWHis2rKoI0X/ZbwLhT2G0iRTOeKdxrUFVihGPUEda8= 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=F1TFFg+B; 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="F1TFFg+B" Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 56AGWGg3003799; Thu, 10 Jul 2025 16:35:29 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=J0Aj3viCRgNhlNDYJ Ou/WXWjIHdWC6edfdvJr86GHWw=; b=F1TFFg+BMuCsYVHCMpv9A74uF6sRButiw zyu3hTT7ZwHhk/hte72mkj7ro8Kh5WXbcJgtjglns0uRY6ZoGY8KC2Om0o1MSsXE Vk3cibfPg+MGewTbLCCc1+PrTMjAGInYHsM8/LKQV3rGOm3b1hjfltUOTY5P6pg4 BkUfg2lpofhK7wSY905bOUsXE2tIhJro46LaEoMWDCPPfUpeZRmmNDyWSe1MfJ/k /yYZKH3hOLbZ9G7sNsYk7Og0Gg/LXbpdpbX9iO1FtCKhj/GSyqVUg6y6MqcGECZo DAR00WnYQTfb3+G2dEMGd79fvvxf772EVLVtO1pIxB0VbP8Oeg3ew== 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 47pusse6a4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Jul 2025 16:35:29 +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 56ADaNBQ021525; Thu, 10 Jul 2025 16:35:28 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 47qectxrmw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Jul 2025 16:35:28 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 56AGZO7V60555664 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 10 Jul 2025 16:35:25 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DCB1220043; Thu, 10 Jul 2025 16:35:24 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A1AA22004B; Thu, 10 Jul 2025 16:35:24 +0000 (GMT) Received: from tuxmaker.lnxne.boe (unknown [9.152.85.9]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 10 Jul 2025 16:35:24 +0000 (GMT) From: Jens Remus To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, bpf@vger.kernel.org, x86@kernel.org, Steven Rostedt Cc: Jens Remus , Heiko Carstens , Vasily Gorbik , Ilya Leoshkevich , Masami Hiramatsu , Mathieu Desnoyers , Josh Poimboeuf , Peter Zijlstra , Ingo Molnar , Jiri Olsa , Namhyung Kim , Thomas Gleixner , Andrii Nakryiko , Indu Bhagat , "Jose E. Marchesi" , Beau Belgrave , Linus Torvalds , Andrew Morton , Jens Axboe , Florian Weimer , Sam James Subject: [RFC PATCH v1 02/16] s390: asm/dwarf.h should only be included in assembly files Date: Thu, 10 Jul 2025 18:35:08 +0200 Message-ID: <20250710163522.3195293-3-jremus@linux.ibm.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250710163522.3195293-1-jremus@linux.ibm.com> References: <20250710163522.3195293-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-Authority-Analysis: v=2.4 cv=Vaj3PEp9 c=1 sm=1 tr=0 ts=686febd1 cx=c_pps a=bLidbwmWQ0KltjZqbj+ezA==:117 a=bLidbwmWQ0KltjZqbj+ezA==:17 a=62EC5onNXgn9lpaB:21 a=Wb1JkmetP80A:10 a=VnNF1IyMAAAA:8 a=AB0lExOjSfRHyy3z6bMA:9 X-Proofpoint-GUID: OC2ueetbyejJeOUMHdFkDZQbM4J5xhad X-Proofpoint-ORIG-GUID: OC2ueetbyejJeOUMHdFkDZQbM4J5xhad X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNzEwMDEzOSBTYWx0ZWRfX+fRxaAqnNCEy /smFp9yN4tOoaquCC0pqfKU/EvUiXOH1zJwkSl4ep/HjkjHt/dosHdyPylt/nznJnVFslQboEbS Vz8ibRni232TyAL9BlMqjubagMyQmzx3mdjCTcadkMyXh0URU3YH8coA/LICKDklacpyX87nn0y YcuGwmwrYeAQJvQFttdGxmoSArUxSCKhmq2XibnYhBSN/b6QUgML0c1n+CYJtpPz4Sv9r0IvM79 iE27pgE1223OURYEIV1Gu3qbZpxqKsfqFfa1Vkp6eupsiRKIilt6cxlN1Vvt1nDjyngTrGlxG4c xbiEWStfwdoY5yX2e7Df3HH/vgy+Eoe9yaGe30pntNvLDdzGe1K4yVnQLXdI2l8qCNuvp5jOplU yY01Q3CRD62wgBvxgsK4YQQL3p5BLCI3pBIhggQZV4CxN7ET0K49TrA8C04kanuTlpjPQOVd X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.7,FMLib:17.12.80.40 definitions=2025-07-10_04,2025-07-09_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 mlxlogscore=935 suspectscore=0 clxscore=1015 adultscore=0 lowpriorityscore=0 impostorscore=0 malwarescore=0 bulkscore=0 mlxscore=0 spamscore=0 phishscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505280000 definitions=main-2507100139 Content-Type: text/plain; charset="utf-8" Align to x86 and add a compile-time check that asm/dwarf.h is only included in pure assembly files. Signed-off-by: Jens Remus --- arch/s390/include/asm/dwarf.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/s390/include/asm/dwarf.h b/arch/s390/include/asm/dwarf.h index 390906b8e386..fdf51f66a9ed 100644 --- a/arch/s390/include/asm/dwarf.h +++ b/arch/s390/include/asm/dwarf.h @@ -2,7 +2,9 @@ #ifndef _ASM_S390_DWARF_H #define _ASM_S390_DWARF_H =20 -#ifdef __ASSEMBLY__ +#ifndef __ASSEMBLY__ +#warning "asm/dwarf.h should be only included in pure assembly files" +#endif =20 #define CFI_STARTPROC .cfi_startproc #define CFI_ENDPROC .cfi_endproc @@ -33,6 +35,4 @@ .cfi_sections .eh_frame, .debug_frame #endif =20 -#endif /* __ASSEMBLY__ */ - #endif /* _ASM_S390_DWARF_H */ --=20 2.48.1 From nobody Tue Oct 7 09:52:18 2025 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 EFE3E274B25; Thu, 10 Jul 2025 16:35:52 +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=1752165354; cv=none; b=uqniHValqZzTbBid9BxXOjzq+auvw4T/9+9InIpMCwPlDtlTWs41d390omjUpzeBTtaB34dm6r/c5pdL6GeoVJEv6fnNClCRqt67QVsCKgiQQO6i3xGG1rFHh3o6zBQUaleNCfDdcTQ2JnbwneyOJSr5vhI3ltRWU+GdrQ7oDZg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752165354; c=relaxed/simple; bh=ZX5VEKy+tXemUjC+v9hW4xDNrhvfiApab+IDAU5Z9Ys=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UHYhrTBT6HDY10/FdexaBTiMF6yLZKwyNwOoV1wDL/3MAAH9xjxdSiHfasv7Af6VDjp1tHJC0SjMr9nN/b2fwFMvG5UV+JmKO1ebr7uwhdgz8eeV/r1XEZaE3j20M9SyUKgJERI9PFc2TmA4xyEmgaijOLjRVXro+z7dxPSaQCI= 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=lA5+eq0W; 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="lA5+eq0W" Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 56AD5iu8028946; Thu, 10 Jul 2025 16:35:30 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=oQgc8Tb7yTrO5jNCO Lp9cjAZeN86sDDgbZi+kb5fn50=; b=lA5+eq0WolCPQhzQBDKf3+IzBCdXGd7NS zSOOPHpdOSRyseRPVSar0LmwOqbwAiH+QtAapA52XuErEL6mVhvNMrj1oIKv28RG AM2cORLnHlIxewsSikXOHSCDgpdB1vJ20J/SABoGNr9ibSloBT+8QtOPZQHk+Chs RA3L9YvOmrGRx4yhXhwkKuYXmBqgfxJuKqxAAPHYYSzvZTUx/p0R5EuM7n4ZryQi l7rDcTfpA/3j/xv6LWjl98HWo7CCRmC55TJbwLKe3zs7uzaQomgT1Unxoz/XTbop pvN955a7M4jMcDQId2sdwbxyCEX2QLl9nIX/AzpjGEdSDa+326nRA== 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 47ptjrd3aw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Jul 2025 16:35:29 +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 56AFnBuK013555; Thu, 10 Jul 2025 16:35:28 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 47qgkm6bbv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Jul 2025 16:35:28 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 56AGZPcK58458488 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 10 Jul 2025 16:35:25 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 279262004B; Thu, 10 Jul 2025 16:35:25 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E0DEF2004D; Thu, 10 Jul 2025 16:35:24 +0000 (GMT) Received: from tuxmaker.lnxne.boe (unknown [9.152.85.9]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 10 Jul 2025 16:35:24 +0000 (GMT) From: Jens Remus To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, bpf@vger.kernel.org, x86@kernel.org, Steven Rostedt Cc: Jens Remus , Heiko Carstens , Vasily Gorbik , Ilya Leoshkevich , Masami Hiramatsu , Mathieu Desnoyers , Josh Poimboeuf , Peter Zijlstra , Ingo Molnar , Jiri Olsa , Namhyung Kim , Thomas Gleixner , Andrii Nakryiko , Indu Bhagat , "Jose E. Marchesi" , Beau Belgrave , Linus Torvalds , Andrew Morton , Jens Axboe , Florian Weimer , Sam James Subject: [RFC PATCH v1 03/16] s390/vdso: Avoid emitting DWARF CFI for non-vDSO Date: Thu, 10 Jul 2025 18:35:09 +0200 Message-ID: <20250710163522.3195293-4-jremus@linux.ibm.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250710163522.3195293-1-jremus@linux.ibm.com> References: <20250710163522.3195293-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-Authority-Analysis: v=2.4 cv=GL8IEvNK c=1 sm=1 tr=0 ts=686febd1 cx=c_pps a=AfN7/Ok6k8XGzOShvHwTGQ==:117 a=AfN7/Ok6k8XGzOShvHwTGQ==:17 a=Wb1JkmetP80A:10 a=VwQbUJbxAAAA:8 a=meVymXHHAAAA:8 a=VnNF1IyMAAAA:8 a=BeDKgDnIR9-QKG0Pbi4A:9 a=2JgSa4NbpEOStq-L5dxp:22 X-Proofpoint-ORIG-GUID: -9wqBJZ7nR8PW5ex_BvQ3nIrMUn_d7Xe X-Proofpoint-GUID: -9wqBJZ7nR8PW5ex_BvQ3nIrMUn_d7Xe X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNzEwMDEzOSBTYWx0ZWRfXzMU6D3+v4Nwd AhhGmxIxJLd4PeChfBf4kssqHijisjgT3A8Y+s7yItf93cIN1eDtr5CUfXGae+LCIzovjOLVzmt Zc2oVLNMLd9GVseAPUvv7Hw5ASW0XsCPHxJByNZC1zqcOkVuWOKK90t8/BmfzX95EiAcS9eTPTk 8N6xC3k4ccGCpTmOxZtIzI12yGksJgGH3yVVukWQiOJyL0v0DeiqzhALK38/HUtzY82AgMo9aqn V/QI3PDYbKIiVkUIX8epXoKw1daPklJ8V0OwYwIF5qQoaT3pobal2dIwkGHYUZBQPPG7eh5L/Fj G+fYE2sXRCCGq1cPegPdZxptaCDzrKizG9OMRqqp8S0Y90GzY35NtrJQj1HdCo9Mu5l6nAhNbOr Z18qI/vtWxn5O/FZZGCxWt8n8BiD4llUu6FRG4cwAHC2Q9EALkJkbeeP7zNcME/hvN4dTyZ/ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.7,FMLib:17.12.80.40 definitions=2025-07-10_04,2025-07-09_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 phishscore=0 clxscore=1015 impostorscore=0 suspectscore=0 bulkscore=0 adultscore=0 priorityscore=1501 mlxscore=0 spamscore=0 mlxlogscore=956 lowpriorityscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505280000 definitions=main-2507100139 Content-Type: text/plain; charset="utf-8" This replicates Josh's x86 commit TODO ("x86/asm: Avoid emitting DWARF CFI for non-VDSO") for s390. It also aligns asm/dwarf.h to x86 asm/dwarf2.h. It was decided years ago that .cfi_* annotations aren't maintainable in the kernel. For the kernel proper, ensure the CFI_* macros don't do anything. On the other hand the vDSO library *does* use them, so user space can unwind through it. Make sure these macros only work for vDSO. They aren't actually being used outside of vDSO anyway, so there's no functional change. Signed-off-by: Jens Remus --- Notes (jremus): Link to latest x86 patch: https://lore.kernel.org/all/20250425024022.477374378@goodmis.org/ arch/s390/include/asm/dwarf.h | 45 ++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/arch/s390/include/asm/dwarf.h b/arch/s390/include/asm/dwarf.h index fdf51f66a9ed..5052ee6a40f7 100644 --- a/arch/s390/include/asm/dwarf.h +++ b/arch/s390/include/asm/dwarf.h @@ -6,6 +6,18 @@ #warning "asm/dwarf.h should be only included in pure assembly files" #endif =20 +.macro nocfi args:vararg +.endm + +#ifdef BUILD_VDSO + + /* + * For the vDSO, emit both runtime unwind information and debug + * symbols for the .dbg file. + */ + + .cfi_sections .eh_frame, .debug_frame + #define CFI_STARTPROC .cfi_startproc #define CFI_ENDPROC .cfi_endproc #define CFI_DEF_CFA_OFFSET .cfi_def_cfa_offset @@ -16,23 +28,24 @@ #ifdef CONFIG_AS_CFI_VAL_OFFSET #define CFI_VAL_OFFSET .cfi_val_offset #else -#define CFI_VAL_OFFSET # +#define CFI_VAL_OFFSET nocfi #endif =20 -#ifndef BUILD_VDSO - /* - * Emit CFI data in .debug_frame sections and not in .eh_frame - * sections. The .eh_frame CFI is used for runtime unwind - * information that is not being used. Hence, vmlinux.lds.S - * can discard the .eh_frame sections. - */ - .cfi_sections .debug_frame -#else - /* - * For vDSO, emit CFI data in both, .eh_frame and .debug_frame - * sections. - */ - .cfi_sections .eh_frame, .debug_frame -#endif +#else /* !BUILD_VDSO */ + +/* + * On s390, these macros aren't used outside vDSO. As well they shouldn't= be: + * they're fragile and very difficult to maintain. + */ + +#define CFI_STARTPROC nocfi +#define CFI_ENDPROC nocfi +#define CFI_DEF_CFA_OFFSET nocfi +#define CFI_ADJUST_CFA_OFFSET nocfi +#define CFI_RESTORE nocfi +#define CFI_REL_OFFSET nocfi +#define CFI_VAL_OFFSET nocfi + +#endif /* !BUILD_VDSO */ =20 #endif /* _ASM_S390_DWARF_H */ --=20 2.48.1 From nobody Tue Oct 7 09:52:18 2025 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 B54432F3638; Thu, 10 Jul 2025 16:36:14 +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=1752165377; cv=none; b=XYCVOs6t1Oz6olS43VQb3KV0p1wwcD3bwN3219Nx4tTYNFKRKJT7rwBO7eqo+InL9rN+iH+HkvgVXXg6unk2e6bayx/wvHdoG2tzvW6NNwkSchedp6LnJD1Xz9GB3uRrOJNx8J9RqY9+GmDFVm03awew7cr0NjNHACUMGo/5nT4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752165377; c=relaxed/simple; bh=UAfYvcgiWHiEJ2gXy4pbjpo8hgDaubvexbeOgsWvoLs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iwj7D7D8tBb/tpFJr3uX9oOSigtDkjjyNvyMRNELYHfXFZacasSOrqdO5Ee6Qj25D3dnCQmKwr9WyU8oTtBRdBxW4W9bYmQFXuMy839PdiUW/75BKtO9XPvFzY4tKujwsNIlV8PJU8rKhQ1ug4PHIGaMeN/TQ78TWctfpLDTLfI= 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=oactIFl0; 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="oactIFl0" Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 56AEfUbp000348; Thu, 10 Jul 2025 16:35:31 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=BGFsyTN5Rs0FfQXqr x7kt0aBQ1EuAK8UL32ZCDucfW0=; b=oactIFl0OxUPj5L8mthME5b+suG/zfGMS dKBr1q8zQlR4aMspRTWRuhDCoVI4HRDQODQgZuZNqAbGupj/A4MJmGtlDfOvk5ES s5ouZu/iUruOLA6xVkJp9v+BY2OQICD0Bw/EkXhPxKqPs0vtzOskI0Njlro46qCR z1r6ufudiI47m9HKV142/3NtV8/JyTkXK4cLi+RX7mm++c6hnWzGTTweTn7N1zsE krsBpapRe3SU0eCcxLlHPsxoNr7EWlz3t4dtYpyB9+fCVNRzvQ8lJytQARpXPdy+ 0T/rtttdzcbJJfQckByaWRKdRHrU1igjFSSjMJFSDDBuWeXG8lPVQ== Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 47puk4e419-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Jul 2025 16:35:30 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 56AF9mAD003362; Thu, 10 Jul 2025 16:35:29 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 47qfvmpen6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Jul 2025 16:35:29 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 56AGZPOV58458490 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 10 Jul 2025 16:35:25 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 66CE02004B; Thu, 10 Jul 2025 16:35:25 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2C04B20040; Thu, 10 Jul 2025 16:35:25 +0000 (GMT) Received: from tuxmaker.lnxne.boe (unknown [9.152.85.9]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 10 Jul 2025 16:35:25 +0000 (GMT) From: Jens Remus To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, bpf@vger.kernel.org, x86@kernel.org, Steven Rostedt Cc: Jens Remus , Heiko Carstens , Vasily Gorbik , Ilya Leoshkevich , Masami Hiramatsu , Mathieu Desnoyers , Josh Poimboeuf , Peter Zijlstra , Ingo Molnar , Jiri Olsa , Namhyung Kim , Thomas Gleixner , Andrii Nakryiko , Indu Bhagat , "Jose E. Marchesi" , Beau Belgrave , Linus Torvalds , Andrew Morton , Jens Axboe , Florian Weimer , Sam James Subject: [RFC PATCH v1 04/16] s390/vdso: Enable SFrame generation in vDSO Date: Thu, 10 Jul 2025 18:35:10 +0200 Message-ID: <20250710163522.3195293-5-jremus@linux.ibm.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250710163522.3195293-1-jremus@linux.ibm.com> References: <20250710163522.3195293-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-Spam-Details-Enc: AW1haW4tMjUwNzEwMDEzOSBTYWx0ZWRfX7+ZiYKLNBkWK /SwqOv6+jZohcevzklBjB4YbMuneJCDLbV9pJGo/HMvBxv7NHon120dRPPsKjTHYL2PPeQJP77+ P83V/FLwuW3f9ucGGetBVfI57Yvx6pxCpE8y4tiCnFsYt2AUPDE1RNPjlyi2aYE1SJp14fsJcNt af0Jg1EJesto/JL/pLe94C1ST8vy2CphohnxSr3fvFJguG4sfSj80JIgCgliUnQWJ2voH0n7Nq1 7fmaVXZM0MN8oLhbEUdmMcFz/og3tbUBO3xJqn+88KqaTpogMi2yY28giTFqBaDfggHEsTYFFC7 NMxrcio36id4/YtHj9yYC3UjxW38OsDgws1+yDwijZNRmL7FribPze+mvLW2/Mhv7VKRauDX61I ben1vzAfyaP510scfVl4bKykZ3qTBQr+YhxHvNtPwsdAIKKblTcogojwXogzjWp8AYbt55zZ X-Authority-Analysis: v=2.4 cv=XYeJzJ55 c=1 sm=1 tr=0 ts=686febd2 cx=c_pps a=3Bg1Hr4SwmMryq2xdFQyZA==:117 a=3Bg1Hr4SwmMryq2xdFQyZA==:17 a=Wb1JkmetP80A:10 a=VwQbUJbxAAAA:8 a=meVymXHHAAAA:8 a=VnNF1IyMAAAA:8 a=M6Dy1fKG3ZVxTaNKAucA:9 a=2JgSa4NbpEOStq-L5dxp:22 X-Proofpoint-ORIG-GUID: ZcfnYn22iBecuFvuwfMNbOsEVD3NtGee X-Proofpoint-GUID: ZcfnYn22iBecuFvuwfMNbOsEVD3NtGee X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.7,FMLib:17.12.80.40 definitions=2025-07-10_04,2025-07-09_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 lowpriorityscore=0 adultscore=0 priorityscore=1501 suspectscore=0 mlxscore=0 impostorscore=0 phishscore=0 bulkscore=0 clxscore=1015 spamscore=0 mlxlogscore=677 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505280000 definitions=main-2507100139 Content-Type: text/plain; charset="utf-8" This replicates Josh's commit TODO ("x86/vdso: Enable sframe generation in VDSO") for s390. Enable SFrame generation in the vDSO library so kernel and user space can unwind through it. Signed-off-by: Jens Remus --- Notes (jremus): Link to latest x86 patch: https://lore.kernel.org/all/20250425024023.173709192@goodmis.org/ arch/s390/include/asm/dwarf.h | 4 ++++ arch/s390/kernel/vdso64/Makefile | 7 ++++++- arch/s390/kernel/vdso64/vdso64.lds.S | 5 +++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/arch/s390/include/asm/dwarf.h b/arch/s390/include/asm/dwarf.h index 5052ee6a40f7..aeb54e716d5a 100644 --- a/arch/s390/include/asm/dwarf.h +++ b/arch/s390/include/asm/dwarf.h @@ -16,7 +16,11 @@ * symbols for the .dbg file. */ =20 +#ifdef CONFIG_AS_SFRAME + .cfi_sections .eh_frame, .debug_frame, .sframe +#else .cfi_sections .eh_frame, .debug_frame +#endif =20 #define CFI_STARTPROC .cfi_startproc #define CFI_ENDPROC .cfi_endproc diff --git a/arch/s390/kernel/vdso64/Makefile b/arch/s390/kernel/vdso64/Mak= efile index d8f0df742809..e96156b9c4df 100644 --- a/arch/s390/kernel/vdso64/Makefile +++ b/arch/s390/kernel/vdso64/Makefile @@ -20,7 +20,11 @@ targets :=3D $(obj-vdso64) $(obj-cvdso64) vdso64.so vdso= 64.so.dbg obj-vdso64 :=3D $(addprefix $(obj)/, $(obj-vdso64)) obj-cvdso64 :=3D $(addprefix $(obj)/, $(obj-cvdso64)) =20 -KBUILD_AFLAGS +=3D -DBUILD_VDSO +ifeq ($(CONFIG_AS_SFRAME),y) + SFRAME_CFLAGS :=3D -Wa,--gsframe +endif + +KBUILD_AFLAGS +=3D -DBUILD_VDSO $(SFRAME_CFLAGS) KBUILD_CFLAGS +=3D -DBUILD_VDSO -DDISABLE_BRANCH_PROFILING =20 KBUILD_AFLAGS_64 :=3D $(filter-out -m64,$(KBUILD_AFLAGS)) @@ -32,6 +36,7 @@ KBUILD_CFLAGS_64 :=3D $(filter-out -mno-pic-data-is-text-= relative,$(KBUILD_CFLAGS_ KBUILD_CFLAGS_64 :=3D $(filter-out -munaligned-symbols,$(KBUILD_CFLAGS_64)) KBUILD_CFLAGS_64 :=3D $(filter-out -fno-asynchronous-unwind-tables,$(KBUIL= D_CFLAGS_64)) KBUILD_CFLAGS_64 +=3D -m64 -fPIC -fno-common -fno-builtin -fasynchronous-u= nwind-tables +KBUILD_CFLAGS_64 +=3D $(SFRAME_CFLAGS) ldflags-y :=3D -shared -soname=3Dlinux-vdso64.so.1 \ --hash-style=3Dboth --build-id=3Dsha1 -T =20 diff --git a/arch/s390/kernel/vdso64/vdso64.lds.S b/arch/s390/kernel/vdso64= /vdso64.lds.S index e4f6551ae898..7acecb0d9b7e 100644 --- a/arch/s390/kernel/vdso64/vdso64.lds.S +++ b/arch/s390/kernel/vdso64/vdso64.lds.S @@ -50,6 +50,9 @@ SECTIONS =20 .eh_frame_hdr : { *(.eh_frame_hdr) } :text :eh_frame_hdr .eh_frame : { KEEP (*(.eh_frame)) } :text + + .sframe : { *(.sframe) } :text :sframe + .gcc_except_table : { *(.gcc_except_table .gcc_except_table.*) } =20 .rela.dyn ALIGN(8) : { *(.rela.dyn) } @@ -114,6 +117,7 @@ SECTIONS * Very old versions of ld do not recognize this name token; use the const= ant. */ #define PT_GNU_EH_FRAME 0x6474e550 +#define PT_GNU_SFRAME 0x6474e554 =20 /* * We must supply the ELF program headers explicitly to get just one @@ -125,6 +129,7 @@ PHDRS dynamic PT_DYNAMIC FLAGS(4); /* PF_R */ note PT_NOTE FLAGS(4); /* PF_R */ eh_frame_hdr PT_GNU_EH_FRAME; + sframe PT_GNU_SFRAME; } =20 /* --=20 2.48.1 From nobody Tue Oct 7 09:52:18 2025 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 C76AA2F432C; Thu, 10 Jul 2025 16:36:18 +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=1752165381; cv=none; b=q9QSZR+yTWDPSWwnLdN1ThXRtIbvvI5EVIOTwpkpXWaQX0MR+rSQlzCq6CkvFtBErumijDoF0Ir+mgKHJ5RLb6ZfQmmAobgm3LjRVMyQqbW8+Fa/2xzwjEdzLBPjib6hzCMUG4Qx35a8g781Bsg49Mc7yBainkFUhxobYj/bBY0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752165381; c=relaxed/simple; bh=BSLmG/zva1ZbV3dNebNDMzo5CQbuvBqjOM0xaAdun00=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IsAp4hYXZ+JDh5YF3ZNUwv4FAySVNS8w6CbK3kRvpilM8/47paOD5n196927/7hRTz/Yp6rSLlnatoiM80zDCwm34K1hZ/uLUbBIptT/cg8IJt9KWtqHJCOcLwgYDKBNr/OGxV/X5kXH6pLpqJQ125TTspWsZTIOF1dFTLVZwcE= 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=BcxTlCG4; 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="BcxTlCG4" Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 56ABp2QD013115; Thu, 10 Jul 2025 16:35:30 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=3QS8mQ0ldtZ+JHt4A wmOeYRF1jVUxSj14mdrcEB6qDw=; b=BcxTlCG4fIMKnhA2z7rvvUV8VetieOwdB CeIFr5qHJOBN+jYfkfHgLQtSRQenDgP5chx1eA5UV9CZAGr37Nl4W6JoMOPJpU1P ShVMGlI1/gSBpkfyjN3zf1QAGKhMNb/NPOVtlx5iH+R2hUpgNUTElzOHRnBZzWTc UabSfWW++n4DpG5bSvSsWe4+pCH0cIA49+CO4LZO4h9JsbpZAhkyXQUXjQ/QXWtA Uzbswq+PZyDnfbBeHqcYI7apfy6sTDaPDOtKn3YTIJ+qt3fs02g5CpQVA0Iks07m E2mVDtt9WhdLNYyZNXFLvBxlRz9Hn7ZDn3UUX5UZlJ+sdj9VEPWZQ== 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 47t3xdc560-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Jul 2025 16:35:30 +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 56AFOe6w013582; Thu, 10 Jul 2025 16:35:29 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 47qgkm6bbx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Jul 2025 16:35:29 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 56AGZPI558458492 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 10 Jul 2025 16:35:25 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A5CBC20040; Thu, 10 Jul 2025 16:35:25 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6AFDB2004E; Thu, 10 Jul 2025 16:35:25 +0000 (GMT) Received: from tuxmaker.lnxne.boe (unknown [9.152.85.9]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 10 Jul 2025 16:35:25 +0000 (GMT) From: Jens Remus To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, bpf@vger.kernel.org, x86@kernel.org, Steven Rostedt Cc: Jens Remus , Heiko Carstens , Vasily Gorbik , Ilya Leoshkevich , Masami Hiramatsu , Mathieu Desnoyers , Josh Poimboeuf , Peter Zijlstra , Ingo Molnar , Jiri Olsa , Namhyung Kim , Thomas Gleixner , Andrii Nakryiko , Indu Bhagat , "Jose E. Marchesi" , Beau Belgrave , Linus Torvalds , Andrew Morton , Jens Axboe , Florian Weimer , Sam James Subject: [RFC PATCH v1 05/16] s390/vdso: Keep function symbols in vDSO Date: Thu, 10 Jul 2025 18:35:11 +0200 Message-ID: <20250710163522.3195293-6-jremus@linux.ibm.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250710163522.3195293-1-jremus@linux.ibm.com> References: <20250710163522.3195293-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-ORIG-GUID: w_vmXR7S9YdXTkDzv2pYjcLu7v7plaOd X-Authority-Analysis: v=2.4 cv=MLRgmNZl c=1 sm=1 tr=0 ts=686febd2 cx=c_pps a=AfN7/Ok6k8XGzOShvHwTGQ==:117 a=AfN7/Ok6k8XGzOShvHwTGQ==:17 a=Wb1JkmetP80A:10 a=VwQbUJbxAAAA:8 a=meVymXHHAAAA:8 a=VnNF1IyMAAAA:8 a=Y8jfv7Xf8eAsT8039CcA:9 a=2JgSa4NbpEOStq-L5dxp:22 X-Proofpoint-GUID: w_vmXR7S9YdXTkDzv2pYjcLu7v7plaOd X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNzEwMDEzOSBTYWx0ZWRfXxOKx7UHyHkId T4tAryGvOwhw/TbQwCgUNBSao0VwPmRjlSThv6EtRG7tQUtm0y94rqNGfehfXWsvcQ4lRUiLU/O z9oxjr2OxFaR7L/Ld5bmITYcCHLzpmH6NNgriERz+bnSfy+bL8EYAq1EWKYqMHdrKczgeOcwFYr 0I31Yp+885CtihhhhMwtwoB0whdwRFBTJ2MlAgcDLZl3QdVzY57CbibUsivHZuEafQY3f0nqk7L +qStTMVRwV2ylbBgg7fiCRRjhkSTE3c4vsBpIHdINt2QwSM4l3w3LYOpCeeZlzoemilz8iGehUT 8ep+Zp9/m/W37up6t+akUqAjII4wwaA40UQ8nQPSumSt6ceYysuQVYzw100/H2OcCGrauhrqPQl /dVwy3JNVUwdGSsRblMpvPWTjV2TkEL4VsJkK924ZHRERNhRg6AueSC0ogpvzb1jantl0c2T X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.7,FMLib:17.12.80.40 definitions=2025-07-10_04,2025-07-09_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 suspectscore=0 adultscore=0 priorityscore=1501 mlxscore=0 clxscore=1015 impostorscore=0 malwarescore=0 mlxlogscore=862 lowpriorityscore=0 phishscore=0 spamscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505280000 definitions=main-2507100139 Content-Type: text/plain; charset="utf-8" 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. Signed-off-by: Jens Remus --- Notes (jremus): Alternatively use objcopy option -g instead of -S (and the -w -K filters), as Josh did in "x86/vdso: Enable sframe generation in VDSO": https://lore.kernel.org/all/20250425024023.173709192@goodmis.org/ =20 Note that this change does not cause the vDSO build-id to change. perf record may therefore not dump an updated copy of the vDSO to ~/.debug/[vdso]//vdso, so that perf script may use a stale copy without .symtab. Resolve by deleting ~/.debug/. arch/s390/kernel/vdso64/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/s390/kernel/vdso64/Makefile b/arch/s390/kernel/vdso64/Mak= efile index e96156b9c4df..067753352697 100644 --- a/arch/s390/kernel/vdso64/Makefile +++ b/arch/s390/kernel/vdso64/Makefile @@ -58,7 +58,7 @@ $(obj)/vdso64.so.dbg: $(obj)/vdso64.lds $(obj-vdso64) $(o= bj-cvdso64) FORCE $(call if_changed,vdso_and_check) =20 # strip rule for the .so file -$(obj)/%.so: OBJCOPYFLAGS :=3D -S +$(obj)/%.so: OBJCOPYFLAGS :=3D -S -w -K "__arch_*" -K "__cvdso_*" -K "__s3= 90_vdso_*" $(obj)/%.so: $(obj)/%.so.dbg FORCE $(call if_changed,objcopy) =20 --=20 2.48.1 From nobody Tue Oct 7 09:52:18 2025 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 D047E2EFDB6; Thu, 10 Jul 2025 16:36:13 +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=1752165375; cv=none; b=J7MWv1mCCQ5aVPC81S7+rDPZwiz8R4qaFHtxr/H9UaXIEZb5DwcIRPkrLnSsNK5OPWKjbv5SSQrYhUTabsy9CT8Tb4gvaeNhc48niIff5ETJ17bv+5E4jFeSWGZhH/an76ERM2fUp8uTqj0gbiVHvzVttICKh+SrUfeF/GHRBaM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752165375; c=relaxed/simple; bh=tlHRS/3dt5vPHNG7TOjoA/M9EqsgRoiFmsUModFlv+A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZIKm4uoy3aCKzS36VqXo9X5iicXrulg5B6KQp0YoGNK/UI8yN66HkTqnlI1dX9BtLqYeA82pWANkTZFMEndyrowprRHkjbJmwxUCWobt4olFzFoONmeiYxWKzjZA8GsCWpwnIllJg4jX3d4IreBWGBdj832mgHj0jR6Z8DxIAuQ= 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=FwszoUsv; 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="FwszoUsv" Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 56AC0FgV001435; Thu, 10 Jul 2025 16:35:31 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=QAhNw+3PmjnJqXWn4 rXxvRrX6iP/uIyWxAm1aAO/TlI=; b=FwszoUsv0OZayXeLnPgXkTy0k3N6VlDqd CgsEo7HSysyowbkTH/Qx1qRsPqB72mAdQbpm1m+PQACbMG1ioXo86DD+Xu8GitNM Qz9NowIKahs3viwakfJqa3+Yu1HHlTKO1XJinrf8K8vx3ZXdFxcHsNQynCf+LQX2 mldTqNoR/KgYOq1nwr7cPUeG3q7VZLRDqO7K7RSobrxhN+JtMAst7SPPudbve5zE aI4xscvZ1Zk6BqGd+ha06e5X+8DNtB7AoAPuDHKKMsooeOoXLVdn/YoVb8zSKe+A 3IRCuVJ1a03pgopoq4wzggq/KXL5IDkhpnRS69T/TB4PbZoKuhczg== Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 47pusse6a7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Jul 2025 16:35:31 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 56ADuSbL010799; Thu, 10 Jul 2025 16:35:30 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 47qes0eqta-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Jul 2025 16:35:29 +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 56AGZQG726935998 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 10 Jul 2025 16:35:26 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E503A20043; Thu, 10 Jul 2025 16:35:25 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AA7D12004B; Thu, 10 Jul 2025 16:35:25 +0000 (GMT) Received: from tuxmaker.lnxne.boe (unknown [9.152.85.9]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 10 Jul 2025 16:35:25 +0000 (GMT) From: Jens Remus To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, bpf@vger.kernel.org, x86@kernel.org, Steven Rostedt Cc: Jens Remus , Heiko Carstens , Vasily Gorbik , Ilya Leoshkevich , Masami Hiramatsu , Mathieu Desnoyers , Josh Poimboeuf , Peter Zijlstra , Ingo Molnar , Jiri Olsa , Namhyung Kim , Thomas Gleixner , Andrii Nakryiko , Indu Bhagat , "Jose E. Marchesi" , Beau Belgrave , Linus Torvalds , Andrew Morton , Jens Axboe , Florian Weimer , Sam James Subject: [RFC PATCH v1 06/16] unwind_user: Enable archs that define CFA = SP_callsite + offset Date: Thu, 10 Jul 2025 18:35:12 +0200 Message-ID: <20250710163522.3195293-7-jremus@linux.ibm.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250710163522.3195293-1-jremus@linux.ibm.com> References: <20250710163522.3195293-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-Authority-Analysis: v=2.4 cv=Vaj3PEp9 c=1 sm=1 tr=0 ts=686febd3 cx=c_pps a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==:17 a=Wb1JkmetP80A:10 a=VnNF1IyMAAAA:8 a=D-3WH5monn3MMgO2UeQA:9 X-Proofpoint-GUID: u41CYhcIwMbRZ4l0KPS3Lv9yXfOHmsHn X-Proofpoint-ORIG-GUID: u41CYhcIwMbRZ4l0KPS3Lv9yXfOHmsHn X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNzEwMDEzOSBTYWx0ZWRfXxpR7Ce40CS1q qjSY9skIuztPq21MiiMpV4NPDQ9rCQ6O8juCBFwUdHhoFvHglGZBxT0tVqP3veFgCWAKp8KNE0V LlWBB/VoVJhkmAuq5hjWWPvHhqEDKEceaX2Zh/zGiH72rJpBU/uElJ/5jRW/VoH3y0CbgQwVMDr myRfX240ZqcjedMZRnsf6Woz5I9HPPGr9kUqdI5WJatUekD8ii0hRGtxJhRdJd6UCwZAeiHxqOL a+NIGlDL9c7beW8OyQMHIaxK7uD4TmD4NYLzbZvVx09I+AU/u5dlsInEjGHRFVogCkJ9rd2Ah27 zgnOA8Yx4KD1t2ghHj2BCgx8vg2HhHkB8jJFzvV/yqresPjaVK2kf/bvKCv1Hejbe+X5ddqJjcl ofl6MWN0yPsJj/1UyInAWEoSL1CZwbVwZY9Zm6ovauu7zv2gexu+pp/BN8Yuo/5qkXPMcm4L X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.7,FMLib:17.12.80.40 definitions=2025-07-10_04,2025-07-09_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 mlxlogscore=812 suspectscore=0 clxscore=1015 adultscore=0 lowpriorityscore=0 impostorscore=0 malwarescore=0 bulkscore=0 mlxscore=0 spamscore=0 phishscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505280000 definitions=main-2507100139 Content-Type: text/plain; charset="utf-8" Most architectures define their CFA as the value of the stack pointer (SP) at the call site in the previous frame, as suggested by the DWARF standard: CFA =3D Enable unwinding of user space for architectures, such as s390, which define their CFA as the value of the SP at the call site in the previous frame with an offset: CFA =3D + offset Signed-off-by: Jens Remus --- Notes (jremus): Alternatively the conditional definition of generic_sframe_sp_val_off() could be moved into kernel/unwind/sframe.c. arch/x86/include/asm/unwind_user.h | 2 ++ include/asm-generic/Kbuild | 1 + include/asm-generic/unwind_user_sframe.h | 30 ++++++++++++++++++++++++ include/linux/unwind_user_types.h | 1 + kernel/unwind/sframe.c | 2 ++ kernel/unwind/user.c | 8 ++++--- 6 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 include/asm-generic/unwind_user_sframe.h diff --git a/arch/x86/include/asm/unwind_user.h b/arch/x86/include/asm/unwi= nd_user.h index 19634a73612d..c2881840adf4 100644 --- a/arch/x86/include/asm/unwind_user.h +++ b/arch/x86/include/asm/unwind_user.h @@ -8,6 +8,7 @@ .cfa_off =3D (s32)sizeof(long) * 2, \ .ra_off =3D (s32)sizeof(long) * -1, \ .fp_off =3D (s32)sizeof(long) * -2, \ + .sp_val_off =3D (s32)0, \ .use_fp =3D true, =20 #ifdef CONFIG_IA32_EMULATION @@ -16,6 +17,7 @@ .cfa_off =3D (s32)sizeof(u32) * 2, \ .ra_off =3D (s32)sizeof(u32) * -1, \ .fp_off =3D (s32)sizeof(u32) * -2, \ + .sp_val_off =3D (s32)0, \ .use_fp =3D true, =20 #define in_compat_mode(regs) !user_64bit_mode(regs) diff --git a/include/asm-generic/Kbuild b/include/asm-generic/Kbuild index b797a2434396..64a15cde776c 100644 --- a/include/asm-generic/Kbuild +++ b/include/asm-generic/Kbuild @@ -60,6 +60,7 @@ mandatory-y +=3D topology.h mandatory-y +=3D trace_clock.h mandatory-y +=3D uaccess.h mandatory-y +=3D unwind_user.h +mandatory-y +=3D unwind_user_sframe.h mandatory-y +=3D unwind_user_types.h mandatory-y +=3D vermagic.h mandatory-y +=3D vga.h diff --git a/include/asm-generic/unwind_user_sframe.h b/include/asm-generic= /unwind_user_sframe.h new file mode 100644 index 000000000000..6c87a7f29861 --- /dev/null +++ b/include/asm-generic/unwind_user_sframe.h @@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_GENERIC_UNWIND_USER_SFRAME_H +#define _ASM_GENERIC_UNWIND_USER_SFRAME_H + +#include + +/** + * generic_sframe_sp_val_off - Get generic SP value offset from CFA. + * + * During unwinding the stack pointer (SP) at call site can be derived + * from the Canonical Frame Address (CFA) as follows: + * + * SP =3D CFA + SP_val_off + * + * Most architectures define the CFA as value of SP at call site, as + * suggested by DWARF. For those architectures the SP value offset + * from CFA is 0, so that the SP at call site computes as: + * + * SP =3D CFA + * + * Returns the generic SP value offset from CFA of 0. + */ +static inline s32 generic_sframe_sp_val_off(void) +{ + return 0; +} + +#define sframe_sp_val_off generic_sframe_sp_val_off + +#endif /* _ASM_GENERIC_UNWIND_USER_SFRAME_H */ diff --git a/include/linux/unwind_user_types.h b/include/linux/unwind_user_= types.h index 4d50476e950e..8050a3237a03 100644 --- a/include/linux/unwind_user_types.h +++ b/include/linux/unwind_user_types.h @@ -25,6 +25,7 @@ struct unwind_user_frame { s32 cfa_off; s32 ra_off; s32 fp_off; + s32 sp_val_off; bool use_fp; }; =20 diff --git a/kernel/unwind/sframe.c b/kernel/unwind/sframe.c index 6159f072bdb6..acbf791e713b 100644 --- a/kernel/unwind/sframe.c +++ b/kernel/unwind/sframe.c @@ -12,6 +12,7 @@ #include #include #include +#include #include =20 #include "sframe.h" @@ -313,6 +314,7 @@ static __always_inline int __find_fre(struct sframe_sec= tion *sec, frame->ra_off =3D fre->ra_off; frame->fp_off =3D fre->fp_off; frame->use_fp =3D SFRAME_FRE_CFA_BASE_REG_ID(fre->info) =3D=3D SFRAME_BA= SE_REG_FP; + frame->sp_val_off =3D sframe_sp_val_off(); =20 return 0; } diff --git a/kernel/unwind/user.c b/kernel/unwind/user.c index d0181c636c6b..45c8c6932ba6 100644 --- a/kernel/unwind/user.c +++ b/kernel/unwind/user.c @@ -52,7 +52,7 @@ static int unwind_user_next(struct unwind_user_state *sta= te) { struct unwind_user_frame *frame; struct unwind_user_frame _frame; - unsigned long cfa =3D 0, fp, ra =3D 0; + unsigned long cfa =3D 0, sp, fp, ra =3D 0; unsigned int shift; =20 if (state->done) @@ -84,8 +84,10 @@ static int unwind_user_next(struct unwind_user_state *st= ate) } cfa +=3D frame->cfa_off; =20 + /* Get the Stack Pointer (SP) */ + sp =3D cfa + frame->sp_val_off; /* Make sure that stack is not going in wrong direction */ - if (cfa <=3D state->sp) + if (sp <=3D state->sp) goto done; =20 /* Make sure that the address is word aligned */ @@ -102,7 +104,7 @@ static int unwind_user_next(struct unwind_user_state *s= tate) goto done; =20 state->ip =3D ra; - state->sp =3D cfa; + state->sp =3D sp; if (frame->fp_off) state->fp =3D fp; =20 --=20 2.48.1 From nobody Tue Oct 7 09:52:18 2025 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 7B2D1271441; Thu, 10 Jul 2025 16:35:51 +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=1752165353; cv=none; b=m8srOcf273jIrgth3nZVIdTTg3mlXzHs1XzeA47oer4QMxwAtB1YQ8Sny+2W2bUhDGEWEBSatYcQgl0mr8Ml+S5tIx1w8MvjPCm7rKwmhoqu58HP2FVr8z8Vmo57YQ04b9NM6ysnKzvpCbGNhKz4faxTQG1oXkKQjIPPufqHrQc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752165353; c=relaxed/simple; bh=WeMe4aAFoj8CCDszqd7zTqOwo34LjyucoBCk9E/sNAg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YDRxU1NGvmDP3sLvkoto9T/Ki/F0EnptVq8RqoG3AcenY4CyL05fsNBJ3+r6vHntoDlOAmsl7w35AEjLtvawwq1o8yc+zloZdomB7vZrhT1rAudwKgU/h2YewDIghg5x5XxkCb+etkZuzfmEM1/hK+V4mTSFTEIxWEWoOCFURg4= 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=YLHh1Chu; 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="YLHh1Chu" Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 56ACJJav010221; Thu, 10 Jul 2025 16:35:31 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=a2QnHXfSjqiJcYDdg SLbDeTmwAq43ZDRI3vvdFCTwp8=; b=YLHh1ChufYeacNR0LblxBCU/PThYOBH8u imhtso02uTaZA8Mpeh9k355DJe76tMqMTgwcAUDLEtCsVsJ4rEECUXzo5UVkF3E3 RC741d2bALqf5232cXqw2hefs7FAJy/DxpG/ieMUC8hHcT2KyX61NICNFujYwcLG PQMvfBwsuYEDX0olG4rUgwmSyTKa3W91EhlmmKPxiYzBTmRmIHbk4xw+54Le8EM+ kiZDlnkVHEN3H+1IYc0ccZ0RaBe6cSeSFGFimprTO4bulr/Bg0kX0O/JqlS7Bjcs H/E0Ej3IG8m9NDvT3ZJZRA7WFYLwOZqbG+nJET6umdjS2FPhvaVvw== Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 47svb26ate-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Jul 2025 16:35:30 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 56AEdWPo003123; Thu, 10 Jul 2025 16:35:30 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 47qfvmpenb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Jul 2025 16:35:30 +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 56AGZQSN13304230 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 10 Jul 2025 16:35:26 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3B65020040; Thu, 10 Jul 2025 16:35:26 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E9F5E2004E; Thu, 10 Jul 2025 16:35:25 +0000 (GMT) Received: from tuxmaker.lnxne.boe (unknown [9.152.85.9]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 10 Jul 2025 16:35:25 +0000 (GMT) From: Jens Remus To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, bpf@vger.kernel.org, x86@kernel.org, Steven Rostedt Cc: Jens Remus , Heiko Carstens , Vasily Gorbik , Ilya Leoshkevich , Masami Hiramatsu , Mathieu Desnoyers , Josh Poimboeuf , Peter Zijlstra , Ingo Molnar , Jiri Olsa , Namhyung Kim , Thomas Gleixner , Andrii Nakryiko , Indu Bhagat , "Jose E. Marchesi" , Beau Belgrave , Linus Torvalds , Andrew Morton , Jens Axboe , Florian Weimer , Sam James Subject: [RFC PATCH v1 07/16] unwind_user: Enable archs that do not necessarily save RA Date: Thu, 10 Jul 2025 18:35:13 +0200 Message-ID: <20250710163522.3195293-8-jremus@linux.ibm.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250710163522.3195293-1-jremus@linux.ibm.com> References: <20250710163522.3195293-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-Spam-Details-Enc: AW1haW4tMjUwNzEwMDEzOSBTYWx0ZWRfX1fZS5HfnoCKn covDhxdqgyesad77GoNAbsLf1DclPuRfgEHTX/rMgCd3FMzzYBKqlAItLiFmtU/50q3h9UgiK30 E8SWutf3k4txyxRNer1l38dJLamaB0kiKnddvJiQE0/Z1fgZDD0llZ8cpuOE/FykWh852HFIYH3 3aGHC2LXmEKlUQz4o7Es5KITLWz4g5qVhKmq3ArnY3WmrYpYtsiGmDvio6ckhxAoumjHrQHtYl5 HVn9NfFYtI65vvfAfSP0/U0ZHu56xqrg8JhEAruTvDS9VU11EazxLQOjRViFXLRqgxAOY1bcnRF IC+g46pN2iJzoU6VtFegUeZgfGdjsApzcI0ku4z0tteKAvIG5YHjy4qriOJ4YSZgnSWJfOpjDgE mbf0pRFujsE9YXRmngshM5O9Ah85Z6XQxIygK24AR3w3E09vWByl6DtSLVexzos2SLmz81kH X-Authority-Analysis: v=2.4 cv=Y774sgeN c=1 sm=1 tr=0 ts=686febd3 cx=c_pps a=3Bg1Hr4SwmMryq2xdFQyZA==:117 a=3Bg1Hr4SwmMryq2xdFQyZA==:17 a=Wb1JkmetP80A:10 a=VnNF1IyMAAAA:8 a=-JoFLTHXnnuQBJsBKZgA:9 X-Proofpoint-ORIG-GUID: FzkgWJBakICnhs7gazxtaS3x9RVSQtcu X-Proofpoint-GUID: FzkgWJBakICnhs7gazxtaS3x9RVSQtcu X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.7,FMLib:17.12.80.40 definitions=2025-07-10_04,2025-07-09_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 adultscore=0 priorityscore=1501 malwarescore=0 bulkscore=0 impostorscore=0 lowpriorityscore=0 phishscore=0 suspectscore=0 mlxlogscore=999 mlxscore=0 clxscore=1015 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505280000 definitions=main-2507100139 Content-Type: text/plain; charset="utf-8" Not all architectures have the return address (RA) in user space saved on the stack on function entry, as x86-64 does due to its CALL instruction pushing the RA onto the stack. Architectures/ABIs, such as s390, also do not necessarily enforce to save the RA in user space on the stack in the function prologue or even at all, for instance in leaf functions. Treat a RA offset from CFA of zero as indication that the RA is not saved on the stack. In that case obtain the RA from the RA register. Allow the SP to be unchanged in the topmost frame, for architectures where SP at function entry =3D=3D SP at call site. Note that treating a RA offset from CFA of zero as indication that the RA is not saved on the stack additionally allows for architectures, such as s390, where the frame pointer (FP) may be saved without the RA being saved as well. Provided that such architectures represent this in SFrame by encoding the "missing" RA offset using a padding RA offset with a value of zero. Signed-off-by: Jens Remus --- arch/Kconfig | 5 +++++ include/linux/ptrace.h | 8 ++++++++ include/linux/sframe.h | 4 ++-- include/linux/unwind_user_types.h | 1 + kernel/unwind/sframe.c | 21 +++++++++++--------- kernel/unwind/user.c | 32 ++++++++++++++++++++++--------- 6 files changed, 51 insertions(+), 20 deletions(-) diff --git a/arch/Kconfig b/arch/Kconfig index 86eec85cb898..367eaf7e62e0 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -450,6 +450,11 @@ config HAVE_UNWIND_USER_SFRAME bool select UNWIND_USER =20 +config HAVE_USER_RA_REG + bool + help + The arch passes the return address (RA) in user space in a register. + config SFRAME_VALIDATION bool "Enable .sframe section debugging" depends on HAVE_UNWIND_USER_SFRAME diff --git a/include/linux/ptrace.h b/include/linux/ptrace.h index 90507d4afcd6..a245c8586673 100644 --- a/include/linux/ptrace.h +++ b/include/linux/ptrace.h @@ -397,6 +397,14 @@ static inline void user_single_step_report(struct pt_r= egs *regs) #define exception_ip(x) instruction_pointer(x) #endif =20 +#ifndef user_return_address +static inline unsigned long user_return_address(const struct pt_regs *regs) +{ + WARN_ON_ONCE(1); + return 0; +} +#endif + extern int task_current_syscall(struct task_struct *target, struct syscall= _info *info); =20 extern void sigaction_compat_abi(struct k_sigaction *act, struct k_sigacti= on *oact); diff --git a/include/linux/sframe.h b/include/linux/sframe.h index b79c5ec09229..e3c6414f1a17 100644 --- a/include/linux/sframe.h +++ b/include/linux/sframe.h @@ -33,7 +33,7 @@ extern void sframe_free_mm(struct mm_struct *mm); extern int sframe_add_section(unsigned long sframe_start, unsigned long sf= rame_end, unsigned long text_start, unsigned long text_end); extern int sframe_remove_section(unsigned long sframe_addr); -extern int sframe_find(unsigned long ip, struct unwind_user_frame *frame); +extern int sframe_find(unsigned long ip, struct unwind_user_frame *frame, = bool topmost); =20 static inline bool current_has_sframe(void) { @@ -52,7 +52,7 @@ static inline int sframe_add_section(unsigned long sframe= _start, unsigned long s return -ENOSYS; } static inline int sframe_remove_section(unsigned long sframe_addr) { retur= n -ENOSYS; } -static inline int sframe_find(unsigned long ip, struct unwind_user_frame *= frame) { return -ENOSYS; } +static inline int sframe_find(unsigned long ip, struct unwind_user_frame *= frame, bool topmost) { return -ENOSYS; } static inline bool current_has_sframe(void) { return false; } =20 #endif /* CONFIG_HAVE_UNWIND_USER_SFRAME */ diff --git a/include/linux/unwind_user_types.h b/include/linux/unwind_user_= types.h index 8050a3237a03..adef01698bb3 100644 --- a/include/linux/unwind_user_types.h +++ b/include/linux/unwind_user_types.h @@ -35,6 +35,7 @@ struct unwind_user_state { unsigned long fp; struct arch_unwind_user_state arch; enum unwind_user_type type; + bool topmost; bool done; }; =20 diff --git a/kernel/unwind/sframe.c b/kernel/unwind/sframe.c index acbf791e713b..5bfaf06e6cd2 100644 --- a/kernel/unwind/sframe.c +++ b/kernel/unwind/sframe.c @@ -222,12 +222,8 @@ static __always_inline int __read_fre(struct sframe_se= ction *sec, offset_count--; =20 ra_off =3D sec->ra_off; - if (!ra_off) { - if (!offset_count--) { - dbg_sec_uaccess("zero offset_count, can't find ra_off\n"); - return -EFAULT; - } - + if (!ra_off && offset_count) { + offset_count--; UNSAFE_GET_USER_INC(ra_off, cur, offset_size, Efault); } =20 @@ -257,7 +253,8 @@ static __always_inline int __read_fre(struct sframe_sec= tion *sec, =20 static __always_inline int __find_fre(struct sframe_section *sec, struct sframe_fde *fde, unsigned long ip, - struct unwind_user_frame *frame) + struct unwind_user_frame *frame, + bool topmost) { unsigned char fde_type =3D SFRAME_FUNC_FDE_TYPE(fde->info); struct sframe_fre *fre, *prev_fre =3D NULL; @@ -310,6 +307,12 @@ static __always_inline int __find_fre(struct sframe_se= ction *sec, return -EINVAL; fre =3D prev_fre; =20 + if ((!IS_ENABLED(CONFIG_HAVE_USER_RA_REG) || !topmost) && !fre->ra_off) { + dbg_sec_uaccess("fde addr 0x%x: zero ra_off\n", + fde->start_addr); + return -EINVAL; + } + frame->cfa_off =3D fre->cfa_off; frame->ra_off =3D fre->ra_off; frame->fp_off =3D fre->fp_off; @@ -319,7 +322,7 @@ static __always_inline int __find_fre(struct sframe_sec= tion *sec, return 0; } =20 -int sframe_find(unsigned long ip, struct unwind_user_frame *frame) +int sframe_find(unsigned long ip, struct unwind_user_frame *frame, bool to= pmost) { struct mm_struct *mm =3D current->mm; struct sframe_section *sec; @@ -343,7 +346,7 @@ int sframe_find(unsigned long ip, struct unwind_user_fr= ame *frame) if (ret) goto end; =20 - ret =3D __find_fre(sec, &fde, ip, frame); + ret =3D __find_fre(sec, &fde, ip, frame, topmost); end: user_read_access_end(); =20 diff --git a/kernel/unwind/user.c b/kernel/unwind/user.c index 45c8c6932ba6..03a6da36192f 100644 --- a/kernel/unwind/user.c +++ b/kernel/unwind/user.c @@ -3,6 +3,7 @@ * Generic interfaces for unwinding user space */ #include +#include #include #include #include @@ -53,6 +54,7 @@ static int unwind_user_next(struct unwind_user_state *sta= te) struct unwind_user_frame *frame; struct unwind_user_frame _frame; unsigned long cfa =3D 0, sp, fp, ra =3D 0; + bool topmost =3D state->topmost; unsigned int shift; =20 if (state->done) @@ -63,7 +65,7 @@ static int unwind_user_next(struct unwind_user_state *sta= te) } else if (sframe_state(state)) { /* sframe expects the frame to be local storage */ frame =3D &_frame; - if (sframe_find(state->ip, frame)) { + if (sframe_find(state->ip, frame, topmost)) { if (!IS_ENABLED(CONFIG_HAVE_UNWIND_USER_FP)) goto done; frame =3D &fp_frame; @@ -86,18 +88,28 @@ static int unwind_user_next(struct unwind_user_state *s= tate) =20 /* Get the Stack Pointer (SP) */ sp =3D cfa + frame->sp_val_off; - /* Make sure that stack is not going in wrong direction */ - if (sp <=3D state->sp) + /* + * Make sure that stack is not going in wrong direction. Allow SP + * to be unchanged for the topmost frame, by subtracting topmost, + * which is either 0 or 1. + */ + if (sp <=3D state->sp - topmost) goto done; =20 - /* Make sure that the address is word aligned */ - shift =3D sizeof(long) =3D=3D 4 || compat_fp_state(state) ? 2 : 3; - if ((cfa + frame->ra_off) & ((1 << shift) - 1)) - goto done; =20 /* Get the Return Address (RA) */ - if (unwind_get_user_long(ra, cfa + frame->ra_off, state)) - goto done; + if (frame->ra_off) { + /* Make sure that the address is word aligned */ + shift =3D sizeof(long) =3D=3D 4 || compat_fp_state(state) ? 2 : 3; + if ((cfa + frame->ra_off) & ((1 << shift) - 1)) + goto done; + if (unwind_get_user_long(ra, cfa + frame->ra_off, state)) + goto done; + } else { + if (!IS_ENABLED(CONFIG_HAVE_USER_RA_REG) || !topmost) + goto done; + ra =3D user_return_address(task_pt_regs(current)); + } =20 /* Get the Frame Pointer (FP) */ if (frame->fp_off && unwind_get_user_long(fp, cfa + frame->fp_off, state)) @@ -110,6 +122,7 @@ static int unwind_user_next(struct unwind_user_state *s= tate) =20 arch_unwind_user_next(state); =20 + state->topmost =3D false; return 0; =20 done: @@ -140,6 +153,7 @@ static int unwind_user_start(struct unwind_user_state *= state) state->ip =3D instruction_pointer(regs); state->sp =3D user_stack_pointer(regs); state->fp =3D frame_pointer(regs); + state->topmost =3D true; =20 arch_unwind_user_init(state, regs); =20 --=20 2.48.1 From nobody Tue Oct 7 09:52:18 2025 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 E3AFD2F3C0A; Thu, 10 Jul 2025 16:36:15 +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=1752165378; cv=none; b=F6Mnv66uQjZO4QBsQcqf98hGuu5P2FIzMLNnKIMojr/X3P/h4KtsBxW554y4Ht6ET4NdJ9wyWEbZ0QAH+u9urK73HSqoatlW5vuZawbbFQbb2xoYmhKc61UscbWIjzQKbxDARPhkV5sNKiIRQDcGNJ8C/Ub65Y4pQzl9ESxO6iA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752165378; c=relaxed/simple; bh=UdioYf0z4JVe2wXZvP/BlmlAGkoYzh2BI1YAg26Hbfk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=k4XwRaQ43jERfY9MQabZ69NDc/yfiG1hUZhPkz5etq8crjdnYZni3xZ62ZU7MMlvU3sHa9GBw/s2fvMHHVE8kbSUMbFUkLVgzztineP9EXQakcU8yr4alPSzpOS6s3USexrcD5kNIDVMIYxaseLYvlM9mONrBxrmSrcw5HFCTkM= 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=dRidxiDA; 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="dRidxiDA" Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 56A9r57d021381; Thu, 10 Jul 2025 16:35:32 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=4mp0aqcfM1Kn4YKur 468ryV/tNEjFl+WQRVzoAREwUU=; b=dRidxiDAJU/FkxPiVuayLKhRonqcmkqAU pQrp8lfe7vUG2Tz5y6hS/pLXHRoTXQtcpzUZEA3fS1xQJP56U81iShklBufJa1R7 a4kSvLVEIcRaaz7z4QCH8B+Ti0njMwXvlCmkD7CSSWehgUQEvIkH7RWdlNqr846t dN4KP5QmE/iG6STM3oOZMgeV73bXyiJ7QNj6CNgUodazBGBgeW1yMsaht7TxKGnc qG1aY0BVBiFrR3hQbnIX7ZMGz6AL7H5UJfThovUvGvjjYYmFoir5EvegriA5nt4z nmGV5CD/FRGoH/8yPLn+eyQB3ykpKOIJXEC/sOGhIZ8fiJlsVUReg== 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 47pusse6a8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Jul 2025 16:35:31 +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 56AEFv3n025528; Thu, 10 Jul 2025 16:35:30 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 47qfcpek04-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Jul 2025 16:35:30 +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 56AGZQjZ29622824 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 10 Jul 2025 16:35:26 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 83D9F20040; Thu, 10 Jul 2025 16:35:26 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 400C420043; Thu, 10 Jul 2025 16:35:26 +0000 (GMT) Received: from tuxmaker.lnxne.boe (unknown [9.152.85.9]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 10 Jul 2025 16:35:26 +0000 (GMT) From: Jens Remus To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, bpf@vger.kernel.org, x86@kernel.org, Steven Rostedt Cc: Jens Remus , Heiko Carstens , Vasily Gorbik , Ilya Leoshkevich , Masami Hiramatsu , Mathieu Desnoyers , Josh Poimboeuf , Peter Zijlstra , Ingo Molnar , Jiri Olsa , Namhyung Kim , Thomas Gleixner , Andrii Nakryiko , Indu Bhagat , "Jose E. Marchesi" , Beau Belgrave , Linus Torvalds , Andrew Morton , Jens Axboe , Florian Weimer , Sam James Subject: [RFC PATCH v1 08/16] unwind_user: Enable archs that save RA/FP in other registers Date: Thu, 10 Jul 2025 18:35:14 +0200 Message-ID: <20250710163522.3195293-9-jremus@linux.ibm.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250710163522.3195293-1-jremus@linux.ibm.com> References: <20250710163522.3195293-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-Authority-Analysis: v=2.4 cv=Vaj3PEp9 c=1 sm=1 tr=0 ts=686febd3 cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==:17 a=Wb1JkmetP80A:10 a=VnNF1IyMAAAA:8 a=7C_LGUadM1zRbwzA-T8A:9 X-Proofpoint-GUID: LXBNRzcFvCvy3QEhgmZ03k_QwlJiJxy7 X-Proofpoint-ORIG-GUID: LXBNRzcFvCvy3QEhgmZ03k_QwlJiJxy7 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNzEwMDEzOSBTYWx0ZWRfX4GJMXdDP+XJh 3t1yPPicdscjvUj6Ttl50LKfsGqVJi0/8UOYfVWY52yc5V640EcPnKIViuwqL0K/e9aaeGqv1+1 P8kGrI1kaFfR/F2BTLI2uMu0RB4xFH+69CGuD9dayC4t9yEJ+hduUU3SD5vEkllAxjkNTc1i9yc N3qQB8pIL6MQHN0n2K3WBuviGlKTijAz5tBiOdrjr6Zc5l0fPELdzeq3s6pHdG3UVIksDNnMyZH n8z4Fv8tyXwRIFDyZLKCdjCwt7xSrBMg399wylkQBJSze70R3f+dKuueJ7Ur0OiOD9vDQyOohXo VcU9HUywwWVmfhZS3hOOTYR7tHusYLHtDBXCNC9eCrsrEly9Az1ZeLcgV+wvmdcEI5XCx/F2FCJ e1YO9Ge4//uFN0rWBAIe0M7067gcx+/U0A2INuVrdUF2jZiYuKnIPiHA4M49YcEHv14pQbIc X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.7,FMLib:17.12.80.40 definitions=2025-07-10_04,2025-07-09_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 mlxlogscore=754 suspectscore=0 clxscore=1015 adultscore=0 lowpriorityscore=0 impostorscore=0 malwarescore=0 bulkscore=0 mlxscore=0 spamscore=0 phishscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505280000 definitions=main-2507100139 Content-Type: text/plain; charset="utf-8" Enable unwinding of user space for architectures, such as s390, that save the return address (RA) and/or frame pointer (FP) in other registers. This is only valid in the topmost frame, for instance when in a leaf function. Signed-off-by: Jens Remus --- arch/Kconfig | 7 ++++ arch/x86/include/asm/unwind_user.h | 24 +++++++++--- include/asm-generic/unwind_user.h | 20 ++++++++++ include/asm-generic/unwind_user_sframe.h | 24 ++++++++++++ include/linux/unwind_user_types.h | 18 ++++++++- kernel/unwind/sframe.c | 4 +- kernel/unwind/user.c | 47 ++++++++++++++++++++---- 7 files changed, 126 insertions(+), 18 deletions(-) diff --git a/arch/Kconfig b/arch/Kconfig index 367eaf7e62e0..9e28dffe42cb 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -455,6 +455,13 @@ config HAVE_USER_RA_REG help The arch passes the return address (RA) in user space in a register. =20 +config HAVE_UNWIND_USER_LOC_REG + bool + help + The arch potentially saves the return address (RA) and/or frame + pointer (FP) register values in user space in other registers, when + in the topmost frame (e.g. in leaf function). + config SFRAME_VALIDATION bool "Enable .sframe section debugging" depends on HAVE_UNWIND_USER_SFRAME diff --git a/arch/x86/include/asm/unwind_user.h b/arch/x86/include/asm/unwi= nd_user.h index c2881840adf4..925d208aa39d 100644 --- a/arch/x86/include/asm/unwind_user.h +++ b/arch/x86/include/asm/unwind_user.h @@ -5,18 +5,30 @@ #include =20 #define ARCH_INIT_USER_FP_FRAME \ - .cfa_off =3D (s32)sizeof(long) * 2, \ - .ra_off =3D (s32)sizeof(long) * -1, \ - .fp_off =3D (s32)sizeof(long) * -2, \ + .cfa_off =3D (s32)sizeof(long) * 2, \ + .ra =3D { \ + .loc =3D UNWIND_USER_LOC_STACK, \ + .frame_off =3D (s32)sizeof(long) * -1, \ + }, \ + .fp =3D { \ + .loc =3D UNWIND_USER_LOC_STACK, \ + .frame_off =3D (s32)sizeof(long) * -2, \ + }, \ .sp_val_off =3D (s32)0, \ .use_fp =3D true, =20 #ifdef CONFIG_IA32_EMULATION =20 #define ARCH_INIT_USER_COMPAT_FP_FRAME \ - .cfa_off =3D (s32)sizeof(u32) * 2, \ - .ra_off =3D (s32)sizeof(u32) * -1, \ - .fp_off =3D (s32)sizeof(u32) * -2, \ + .cfa_off =3D (s32)sizeof(u32) * 2, \ + .ra =3D { \ + .loc =3D UNWIND_USER_LOC_STACK, \ + .frame_off =3D (s32)sizeof(u32) * -1, \ + }, \ + .fp =3D { \ + .loc =3D UNWIND_USER_LOC_STACK, \ + .frame_off =3D (s32)sizeof(u32) * -2, \ + }, \ .sp_val_off =3D (s32)0, \ .use_fp =3D true, =20 diff --git a/include/asm-generic/unwind_user.h b/include/asm-generic/unwind= _user.h index b8882b909944..3891b7cfe3b8 100644 --- a/include/asm-generic/unwind_user.h +++ b/include/asm-generic/unwind_user.h @@ -2,4 +2,24 @@ #ifndef _ASM_GENERIC_UNWIND_USER_H #define _ASM_GENERIC_UNWIND_USER_H =20 +#include + +#ifndef unwind_user_get_reg + +/** + * generic_unwind_user_get_reg - Get register value. + * @val: Register value. + * @regnum: DWARF register number to obtain the value from. + * + * Returns zero if successful. Otherwise -EINVAL. + */ +static inline int generic_unwind_user_get_reg(unsigned long *val, int regn= um) +{ + return -EINVAL; +} + +#define unwind_user_get_reg generic_unwind_user_get_reg + +#endif /* !unwind_user_get_reg */ + #endif /* _ASM_GENERIC_UNWIND_USER_H */ diff --git a/include/asm-generic/unwind_user_sframe.h b/include/asm-generic= /unwind_user_sframe.h index 6c87a7f29861..8cef3e0857b6 100644 --- a/include/asm-generic/unwind_user_sframe.h +++ b/include/asm-generic/unwind_user_sframe.h @@ -2,8 +2,31 @@ #ifndef _ASM_GENERIC_UNWIND_USER_SFRAME_H #define _ASM_GENERIC_UNWIND_USER_SFRAME_H =20 +#include #include =20 +/** + * generic_sframe_set_frame_reginfo - Populate info to unwind FP/RA regist= er + * from SFrame offset. + * @reginfo: Unwind info for FP/RA register. + * @offset: SFrame offset value. + * + * A non-zero offset value denotes a stack offset from CFA and indicates + * that the register is saved on the stack. A zero offset value indicates + * that the register is not saved. + */ +static inline void generic_sframe_set_frame_reginfo( + struct unwind_user_reginfo *reginfo, + s32 offset) +{ + if (offset) { + reginfo->loc =3D UNWIND_USER_LOC_STACK; + reginfo->frame_off =3D offset; + } else { + reginfo->loc =3D UNWIND_USER_LOC_NONE; + } +} + /** * generic_sframe_sp_val_off - Get generic SP value offset from CFA. * @@ -25,6 +48,7 @@ static inline s32 generic_sframe_sp_val_off(void) return 0; } =20 +#define sframe_set_frame_reginfo generic_sframe_set_frame_reginfo #define sframe_sp_val_off generic_sframe_sp_val_off =20 #endif /* _ASM_GENERIC_UNWIND_USER_SFRAME_H */ diff --git a/include/linux/unwind_user_types.h b/include/linux/unwind_user_= types.h index adef01698bb3..57fd16e314cf 100644 --- a/include/linux/unwind_user_types.h +++ b/include/linux/unwind_user_types.h @@ -21,10 +21,24 @@ struct unwind_stacktrace { unsigned long *entries; }; =20 +enum unwind_user_loc { + UNWIND_USER_LOC_NONE, + UNWIND_USER_LOC_STACK, + UNWIND_USER_LOC_REG, +}; + +struct unwind_user_reginfo { + enum unwind_user_loc loc; + union { + s32 frame_off; + int regnum; + }; +}; + struct unwind_user_frame { s32 cfa_off; - s32 ra_off; - s32 fp_off; + struct unwind_user_reginfo ra; + struct unwind_user_reginfo fp; s32 sp_val_off; bool use_fp; }; diff --git a/kernel/unwind/sframe.c b/kernel/unwind/sframe.c index 5bfaf06e6cd2..43ef3a8c4c26 100644 --- a/kernel/unwind/sframe.c +++ b/kernel/unwind/sframe.c @@ -314,8 +314,8 @@ static __always_inline int __find_fre(struct sframe_sec= tion *sec, } =20 frame->cfa_off =3D fre->cfa_off; - frame->ra_off =3D fre->ra_off; - frame->fp_off =3D fre->fp_off; + sframe_set_frame_reginfo(&frame->ra, fre->ra_off); + sframe_set_frame_reginfo(&frame->fp, fre->fp_off); frame->use_fp =3D SFRAME_FRE_CFA_BASE_REG_ID(fre->info) =3D=3D SFRAME_BA= SE_REG_FP; frame->sp_val_off =3D sframe_sp_val_off(); =20 diff --git a/kernel/unwind/user.c b/kernel/unwind/user.c index 03a6da36192f..ee00d39d2a8e 100644 --- a/kernel/unwind/user.c +++ b/kernel/unwind/user.c @@ -98,26 +98,57 @@ static int unwind_user_next(struct unwind_user_state *s= tate) =20 =20 /* Get the Return Address (RA) */ - if (frame->ra_off) { + switch (frame->ra.loc) { + case UNWIND_USER_LOC_NONE: + if (!IS_ENABLED(CONFIG_HAVE_USER_RA_REG) || !topmost) + goto done; + ra =3D user_return_address(task_pt_regs(current)); + break; + case UNWIND_USER_LOC_STACK: + if (!frame->ra.frame_off) + goto done; /* Make sure that the address is word aligned */ shift =3D sizeof(long) =3D=3D 4 || compat_fp_state(state) ? 2 : 3; - if ((cfa + frame->ra_off) & ((1 << shift) - 1)) + if ((cfa + frame->ra.frame_off) & ((1 << shift) - 1)) goto done; - if (unwind_get_user_long(ra, cfa + frame->ra_off, state)) + if (unwind_get_user_long(ra, cfa + frame->ra.frame_off, state)) goto done; - } else { - if (!IS_ENABLED(CONFIG_HAVE_USER_RA_REG) || !topmost) + break; + case UNWIND_USER_LOC_REG: + if (!IS_ENABLED(CONFIG_HAVE_UNWIND_USER_LOC_REG) || !topmost) goto done; - ra =3D user_return_address(task_pt_regs(current)); + if (unwind_user_get_reg(&ra, frame->ra.regnum)) + goto done; + break; + default: + WARN_ON_ONCE(1); + goto done; } =20 /* Get the Frame Pointer (FP) */ - if (frame->fp_off && unwind_get_user_long(fp, cfa + frame->fp_off, state)) + switch (frame->fp.loc) { + case UNWIND_USER_LOC_NONE: + break; + case UNWIND_USER_LOC_STACK: + if (!frame->fp.frame_off) + goto done; + if (unwind_get_user_long(fp, cfa + frame->fp.frame_off, state)) + goto done; + break; + case UNWIND_USER_LOC_REG: + if (!IS_ENABLED(CONFIG_HAVE_UNWIND_USER_LOC_REG) || !topmost) + goto done; + if (unwind_user_get_reg(&fp, frame->fp.regnum)) + goto done; + break; + default: + WARN_ON_ONCE(1); goto done; + } =20 state->ip =3D ra; state->sp =3D sp; - if (frame->fp_off) + if (frame->fp.loc !=3D UNWIND_USER_LOC_NONE) state->fp =3D fp; =20 arch_unwind_user_next(state); --=20 2.48.1 From nobody Tue Oct 7 09:52:18 2025 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 BE4782F1989; Thu, 10 Jul 2025 16:35:57 +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=1752165359; cv=none; b=sJuvOAXU4nP2uPeu0yLqEcKHkZsdMZaeiLwIyFzfw0R9i7CmSxCLxQiV4d6t4lbtzem17Jbut8o8xibAdi47QMgcrn2e7cWMi/qOh3ifSeiboo1KogWwyOXN/ZpL4OrHNQVjzOMgPXXCuFWXohUoEajOZM3KLLE1VBMHjwPk8sw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752165359; c=relaxed/simple; bh=v2hOjtlwbj3g1hX2d26zeY4TfESRrouASt/PND3A8MY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mm/WKxKNFmCmBvlX6ey5uZ/is1aUbWIqOvXhIGKZIASd5N/AN5o0Tr4W3xFgucwLkfMHqoATqsGWqPb1v1HpZCQVrIArf8F8D2Zg6RB067BA0uFl34gKVzqed9PtyAsgnTytuGPjRHTZ+oF1YRSL0npd++pVZ9aFbUCKDbVVsCU= 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=kbUC6low; 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="kbUC6low" Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 56AB7Akr023830; Thu, 10 Jul 2025 16:35:32 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=6gDEz5N4zauu273L0 4Rm/AckpJgUD1W4BKQOI5obf84=; b=kbUC6lowLPgt64V5myDQcnNPGgZ+53Y2M shBCiq92mVC5UVlCr/cUcgRf1DbvS+j+2YrS94eOa0zazYoUaSFCT40MesTdgno0 pXcvR5YSsApJzKFtZ1hm7fDZq0n08Vj78VODS4jEL8A9DXG8BMFoKGhvk4w4G6WU zPukF9I+QIzervtkcs3LtfKcM57sb+dYWnwcLF+0U6699GbItF1NyDm1aCmi/kCq gSTNRUmoKSUdElBh+DJ1SYyrYWCFPfPnOHW7nH2OIOnXB64w6w+Rs1yo9vcbKST6 Fw5HfIMjgS6LCiiNrnbOh3bpOkdqEhVRiNJpqJZqZ0Yuj39upe9zw== Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 47ptjrd3ba-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Jul 2025 16:35:31 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 56ADhsCM010851; Thu, 10 Jul 2025 16:35:30 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 47qes0eqtf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Jul 2025 16:35:30 +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 56AGZQ9829622826 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 10 Jul 2025 16:35:26 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C38D020040; Thu, 10 Jul 2025 16:35:26 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8848F2004B; Thu, 10 Jul 2025 16:35:26 +0000 (GMT) Received: from tuxmaker.lnxne.boe (unknown [9.152.85.9]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 10 Jul 2025 16:35:26 +0000 (GMT) From: Jens Remus To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, bpf@vger.kernel.org, x86@kernel.org, Steven Rostedt Cc: Jens Remus , Heiko Carstens , Vasily Gorbik , Ilya Leoshkevich , Masami Hiramatsu , Mathieu Desnoyers , Josh Poimboeuf , Peter Zijlstra , Ingo Molnar , Jiri Olsa , Namhyung Kim , Thomas Gleixner , Andrii Nakryiko , Indu Bhagat , "Jose E. Marchesi" , Beau Belgrave , Linus Torvalds , Andrew Morton , Jens Axboe , Florian Weimer , Sam James Subject: [RFC PATCH v1 09/16] unwind_user/sframe: Enable archs with encoded SFrame CFA offsets Date: Thu, 10 Jul 2025 18:35:15 +0200 Message-ID: <20250710163522.3195293-10-jremus@linux.ibm.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250710163522.3195293-1-jremus@linux.ibm.com> References: <20250710163522.3195293-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-Authority-Analysis: v=2.4 cv=GL8IEvNK c=1 sm=1 tr=0 ts=686febd3 cx=c_pps a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==:17 a=Wb1JkmetP80A:10 a=VnNF1IyMAAAA:8 a=Og4hOgGxDI197znzLmcA:9 X-Proofpoint-ORIG-GUID: eIOvg8Wub475XZyy23-eoHTnvFKsHL4r X-Proofpoint-GUID: eIOvg8Wub475XZyy23-eoHTnvFKsHL4r X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNzEwMDEzOSBTYWx0ZWRfX5HZjNHwLj/gH 9xIzYquVxSacjVxI9K5pMvOcTDYwxkZ96PYItwu+TV91D6xvF0x6WsGW+c1sKfNm2Xz6nnoBMuK sYUPRkyYzgBvadYXY1v3ypFya0H8On2d1irUt5I/PJA+1lVDTtDvmiPfwKGEGWmqABq8Z6E2D/c AJ/vhywwZiApok8R6g/RbuWnaiCE4QVbxC6NXIY8P5cIE5402LnchihDMEMwTMXRB33VUafdURc E+cbRhvtFUfSCN62fHIcZOZvyBI7zpo0k7Z4RRlwcMgrbqszQSITqhBoZF9aSGKqnaYGt8ecBRC 6MQz+fRqgzD5rT5E+8CDqkFcfUEGQJQ99/oyS86PGewF32oyJYvPHe4z3mRQnHPhWgboz3w5Nhf jiT4wQ4G01odhthsbAwHdwbWMwURgca4AGar2pFDgmvMdgqYCIx5XMi1740dC25qWzTb+4TP X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.7,FMLib:17.12.80.40 definitions=2025-07-10_04,2025-07-09_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 phishscore=0 clxscore=1015 impostorscore=0 suspectscore=0 bulkscore=0 adultscore=0 priorityscore=1501 mlxscore=0 spamscore=0 mlxlogscore=918 lowpriorityscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505280000 definitions=main-2507100139 Content-Type: text/plain; charset="utf-8" Enable architectures, such as s390, which store SFrame CFA offset values encoded, to e.g. make (better) use of unsigned 8-bit SFrame offsets. Signed-off-by: Jens Remus --- include/asm-generic/unwind_user_sframe.h | 11 +++++++++++ kernel/unwind/sframe.c | 1 + 2 files changed, 12 insertions(+) diff --git a/include/asm-generic/unwind_user_sframe.h b/include/asm-generic= /unwind_user_sframe.h index 8cef3e0857b6..cea0410a259a 100644 --- a/include/asm-generic/unwind_user_sframe.h +++ b/include/asm-generic/unwind_user_sframe.h @@ -5,6 +5,16 @@ #include #include =20 +/** + * generic_sframe_cfa_offset_decode - Decode SFrame CFA offset. + * + * Returns the decoded SFrame CFA offset value. + */ +static inline s32 generic_sframe_cfa_offset_decode(s32 offset) +{ + return offset; +} + /** * generic_sframe_set_frame_reginfo - Populate info to unwind FP/RA regist= er * from SFrame offset. @@ -48,6 +58,7 @@ static inline s32 generic_sframe_sp_val_off(void) return 0; } =20 +#define sframe_cfa_offset_decode generic_sframe_cfa_offset_decode #define sframe_set_frame_reginfo generic_sframe_set_frame_reginfo #define sframe_sp_val_off generic_sframe_sp_val_off =20 diff --git a/kernel/unwind/sframe.c b/kernel/unwind/sframe.c index 43ef3a8c4c26..e8658401a286 100644 --- a/kernel/unwind/sframe.c +++ b/kernel/unwind/sframe.c @@ -220,6 +220,7 @@ static __always_inline int __read_fre(struct sframe_sec= tion *sec, =20 UNSAFE_GET_USER_INC(cfa_off, cur, offset_size, Efault); offset_count--; + cfa_off =3D sframe_cfa_offset_decode(cfa_off); =20 ra_off =3D sec->ra_off; if (!ra_off && offset_count) { --=20 2.48.1 From nobody Tue Oct 7 09:52:18 2025 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 B06292F0C62; Thu, 10 Jul 2025 16:35: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=1752165357; cv=none; b=VY+Xbid3+Fofil+Wt96I8KYSq+mjTmH0fIXAJxIRasPWf+Tx5mqeCxUYZjyYNq+swyY5xinJbZM9vJVjRcOV+03LXulRTLxFy5xErFiAChl8gEj0c399/4baf7iOwiuc6gKhkTkJlThS7e5IGX/S8Lk6SAfcBTKcLHZONIenA4E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752165357; c=relaxed/simple; bh=tCCMdkDak8azEkCoj0uFghu2c8I0OJT7NBUep4hLlwM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=K8WOqoRFIo4x7H/HFDGT/rY2S2hwSyxfr0xabU6wmPuYYwIbPuOrvfeVDOnRWlhyGTrHyAxVdBjkSDU0QyAtgTxBmkdxMLCkGb8IjdAnBbV1K7zRZ9j8Wv9XMeuWKY6nfUZuxx9Ip3FZsthTpSZ3bSV/79gmpViMt1ZnHHoK7jo= 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=sWICare4; 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="sWICare4" Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 56ADjWJR010569; Thu, 10 Jul 2025 16:35:31 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=PB0WTAltW+KHElMPJ xVOA/EfdsSdDGp+uN+1+3ZTOrs=; b=sWICare4JL42xnPgo16mE5QLDKq4lJPRG kTUZMGBbOuekVKul3NEmWZXaE0Y9Oy//h0HzxwWNxBq/E0HmhpTixXAUjq3ummV5 ye6ylTyzPLShOEeqpNHPct7nSW45s6irSpqIwP+osEIDTZ27/Sa9P6hnmmGavgwY 0141JDNlj8WoauOOCkbkmGd7XBcEKc7W1rgDlO6h3c3WXQjAMQiI4kJx/LPeFAwq mIUyNIl+RBUCVy0VneWMDW294cUnhGtCTS8EoSHQkd5tfhW1bPO+U7ZMafRN+FJd DBeEmmCNSKKStS0TEBvgE4oNBB7KDBGiwP8AIjk/j69cTdpSXZhow== 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 47svb26atf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Jul 2025 16:35:31 +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 56ADeR2d021561; Thu, 10 Jul 2025 16:35:30 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 47qectxrn3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Jul 2025 16:35:30 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 56AGZRAu35062184 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 10 Jul 2025 16:35:27 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0EEAF20040; Thu, 10 Jul 2025 16:35:27 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C804620043; Thu, 10 Jul 2025 16:35:26 +0000 (GMT) Received: from tuxmaker.lnxne.boe (unknown [9.152.85.9]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 10 Jul 2025 16:35:26 +0000 (GMT) From: Jens Remus To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, bpf@vger.kernel.org, x86@kernel.org, Steven Rostedt Cc: Jens Remus , Heiko Carstens , Vasily Gorbik , Ilya Leoshkevich , Masami Hiramatsu , Mathieu Desnoyers , Josh Poimboeuf , Peter Zijlstra , Ingo Molnar , Jiri Olsa , Namhyung Kim , Thomas Gleixner , Andrii Nakryiko , Indu Bhagat , "Jose E. Marchesi" , Beau Belgrave , Linus Torvalds , Andrew Morton , Jens Axboe , Florian Weimer , Sam James Subject: [RFC PATCH v1 10/16] s390/ptrace: Enable HAVE_USER_RA_REG Date: Thu, 10 Jul 2025 18:35:16 +0200 Message-ID: <20250710163522.3195293-11-jremus@linux.ibm.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250710163522.3195293-1-jremus@linux.ibm.com> References: <20250710163522.3195293-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-Spam-Details-Enc: AW1haW4tMjUwNzEwMDEzOSBTYWx0ZWRfX5SP91U9/IjWP STby5G9VsC4J3JET7d6kaMfjtFmt1bJ1vLqcbh5bM+oNfv4ADYxJQyqPRwIVDWB7YmjxNyzbxUj qJuO+dPbN0s37LjSD7BAzmwuc9suo68tildYiFjBUgxIB7p08DBpEKD0jIK67knTbn0Ok/FzXsi jAnXF/kPmMJOMqwlKJ3nKIC9wm5N0IpSng7y86IBGwEOYffuMyF2c8fJOJYZVTRM9vxGetZXfjn AY62jUxO5cj3oavEahGs9Nflz3rmbLhQieI2FIyNR8+ZspixfN5FFGvAjbGT1ulFbv2mpCeVKM2 oAgg5cyx3gUACM9Z6B+Dwcw/xU21rjdqFXtH3Ko7cjMGjLvk09NjsY7ykuF/zSibKhi/M35tr1A OHQrY1CBG5Gji3s2Uf0QAj0DbcqAUDQdcTqelCPgw+iSobidD6bziUlJ11QZhd4GwHJzsWwe X-Authority-Analysis: v=2.4 cv=Y774sgeN c=1 sm=1 tr=0 ts=686febd3 cx=c_pps a=bLidbwmWQ0KltjZqbj+ezA==:117 a=bLidbwmWQ0KltjZqbj+ezA==:17 a=Wb1JkmetP80A:10 a=VnNF1IyMAAAA:8 a=pHnkZ9Rrd0NqFIkZcxAA:9 X-Proofpoint-ORIG-GUID: 9XpdvCNjV8cvLI7n4flAvGPCGeyCQTkG X-Proofpoint-GUID: 9XpdvCNjV8cvLI7n4flAvGPCGeyCQTkG X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.7,FMLib:17.12.80.40 definitions=2025-07-10_04,2025-07-09_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 adultscore=7 priorityscore=1501 malwarescore=0 bulkscore=0 impostorscore=0 lowpriorityscore=0 phishscore=0 suspectscore=0 mlxlogscore=531 mlxscore=0 clxscore=1015 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505280000 definitions=main-2507100139 Content-Type: text/plain; charset="utf-8" Provide user_return_address(). Additionally provide frame_pointer(). On s390 register 11 is the preferred frame pointer (FP) register and register 14 is the return address (RA) register in user space. While at it convert instruction_pointer() and user_stack_pointer() from macros to inline functions, to align their definition with x86-64 and AArch64. Signed-off-by: Jens Remus --- arch/s390/Kconfig | 1 + arch/s390/include/asm/ptrace.h | 25 ++++++++++++++++++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig index 0c16dc443e2f..f4ea52c1f0ba 100644 --- a/arch/s390/Kconfig +++ b/arch/s390/Kconfig @@ -239,6 +239,7 @@ config S390 select HAVE_SETUP_PER_CPU_AREA select HAVE_SOFTIRQ_ON_OWN_STACK select HAVE_SYSCALL_TRACEPOINTS + select HAVE_USER_RA_REG select HAVE_VIRT_CPU_ACCOUNTING select HAVE_VIRT_CPU_ACCOUNTING_IDLE select HOTPLUG_SMT diff --git a/arch/s390/include/asm/ptrace.h b/arch/s390/include/asm/ptrace.h index 0905fa99a31e..71d81280e5eb 100644 --- a/arch/s390/include/asm/ptrace.h +++ b/arch/s390/include/asm/ptrace.h @@ -212,8 +212,6 @@ void update_cr_regs(struct task_struct *task); #define arch_has_block_step() (1) =20 #define user_mode(regs) (((regs)->psw.mask & PSW_MASK_PSTATE) !=3D 0) -#define instruction_pointer(regs) ((regs)->psw.addr) -#define user_stack_pointer(regs)((regs)->gprs[15]) #define profile_pc(regs) instruction_pointer(regs) =20 static inline long regs_return_value(struct pt_regs *regs) @@ -230,11 +228,32 @@ static inline void instruction_pointer_set(struct pt_= regs *regs, int regs_query_register_offset(const char *name); const char *regs_query_register_name(unsigned int offset); =20 -static __always_inline unsigned long kernel_stack_pointer(struct pt_regs *= regs) +static __always_inline unsigned long kernel_stack_pointer(const struct pt_= regs *regs) { return regs->gprs[15]; } =20 +static __always_inline unsigned long instruction_pointer(const struct pt_r= egs *regs) +{ + return regs->psw.addr; +} + +static __always_inline unsigned long frame_pointer(const struct pt_regs *r= egs) +{ + return regs->gprs[11]; +} + +static __always_inline unsigned long user_stack_pointer(const struct pt_re= gs *regs) +{ + return regs->gprs[15]; +} + +static __always_inline unsigned long user_return_address(const struct pt_r= egs *regs) +{ + return regs->gprs[14]; +} +#define user_return_address user_return_address + static __always_inline unsigned long regs_get_register(struct pt_regs *reg= s, unsigned int offset) { if (offset >=3D NUM_GPRS) --=20 2.48.1 From nobody Tue Oct 7 09:52:18 2025 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 B763C2F002D; Thu, 10 Jul 2025 16:35: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=1752165356; cv=none; b=QJvCUD9beyBMKSE7FqNK1zaTPtbOJI5jlE3zh5ZbHA6Wt51QPR+PzOYFBen0Tlkv96Y48DkMrRwYbuJkxNCvEh+8kqIcXtFFmk7NoAz+lHROavGAAcHBsihkwBN0UUFyQCEA0w8w8AxDlD9xysr0y07GXMPaIsOFCnjDzRtoLwA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752165356; c=relaxed/simple; bh=n2itvvYUlCn5rgqIWxDID7RATFS5DLZ9PhmNJ3gj1Ag=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KvStBKUIFrOPs5Zj8oI7R72LYNxAguHXPkoM3lxZKA8qV2bihQq9Q2NgT9jDC4rR8Cvpv3DHLk1v+VVdsCMF1RfRvSoT3a6938umzoPrjm4CSAuMnsBP4pjIydEThN01V9XFWEtvJzTciOx3f/COwTE0iNryUZ1WFoyvEZd/Wh8= 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=tTiTEq+N; 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="tTiTEq+N" Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 56AEKlkn017806; Thu, 10 Jul 2025 16:35:32 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=Ox5LynZ1Gk1k/gXvB MjGHkBXTN4Op7+eW6pteOyVnRk=; b=tTiTEq+NqOps46//OqNpRezVgEKBxZkZP SDCipor3oZgNiF3sSBJThSjFlGW/8NRtyhSDKB2XZjeb5RxVbJsggqChpi7EbvxE oQhbX6npPQPaIR6og/49nBuVN+LvMKgutz+/zh+wk3sCPyUMA1fUNSxTPYEFz6Lf IKYz911foELLqtc1D29uA645+zAriMVy1vk429EmposcFEn5+pdLdnQSq23bCaJh i8menPzdM0SNIcPDLIUZWqS0TCtaiKJOSqUrIDO5ReAoXIT3/1GqnUHG0QxHd2oZ KWiBfSuBikJa5BspH73KOB9L+5czeNP3C1Q2IElEiPXRgaoxs+ooQ== Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 47puqnmyru-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Jul 2025 16:35:32 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 56AEd7nW002855; Thu, 10 Jul 2025 16:35:31 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 47qfvmpeng-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Jul 2025 16:35:31 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 56AGZRZ835062186 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 10 Jul 2025 16:35:27 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4E29C20040; Thu, 10 Jul 2025 16:35:27 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 138F72004D; Thu, 10 Jul 2025 16:35:27 +0000 (GMT) Received: from tuxmaker.lnxne.boe (unknown [9.152.85.9]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 10 Jul 2025 16:35:27 +0000 (GMT) From: Jens Remus To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, bpf@vger.kernel.org, x86@kernel.org, Steven Rostedt Cc: Jens Remus , Heiko Carstens , Vasily Gorbik , Ilya Leoshkevich , Masami Hiramatsu , Mathieu Desnoyers , Josh Poimboeuf , Peter Zijlstra , Ingo Molnar , Jiri Olsa , Namhyung Kim , Thomas Gleixner , Andrii Nakryiko , Indu Bhagat , "Jose E. Marchesi" , Beau Belgrave , Linus Torvalds , Andrew Morton , Jens Axboe , Florian Weimer , Sam James Subject: [RFC PATCH v1 11/16] s390/unwind_user/sframe: Enable HAVE_UNWIND_USER_SFRAME Date: Thu, 10 Jul 2025 18:35:17 +0200 Message-ID: <20250710163522.3195293-12-jremus@linux.ibm.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250710163522.3195293-1-jremus@linux.ibm.com> References: <20250710163522.3195293-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-Authority-Analysis: v=2.4 cv=FZ43xI+6 c=1 sm=1 tr=0 ts=686febd4 cx=c_pps a=3Bg1Hr4SwmMryq2xdFQyZA==:117 a=3Bg1Hr4SwmMryq2xdFQyZA==:17 a=Wb1JkmetP80A:10 a=NEAV23lmAAAA:8 a=VnNF1IyMAAAA:8 a=qHp_k-hexZ09bc3ecLAA:9 X-Proofpoint-GUID: Xx2EcqiWmTC3hCxCkIdaNByd1b0R4iNU X-Proofpoint-ORIG-GUID: Xx2EcqiWmTC3hCxCkIdaNByd1b0R4iNU X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNzEwMDEzOSBTYWx0ZWRfXybDdb6T2sG4Y ONAEAoN7Je5r+hAcp6RL5cGu+u8dqnxUuosQG+JOE6aIg9sBtzJvzWHflqg4T7REdRI4kWuXWsI mKJ48ScVaV/qqwd4WmnRHcYCKSHtJ7xrH/pPNFpq/aWbMYfRDRs9+oxIXDv7FShUPBFnzti2KYL /jXwTENkAkPW+j8T/kYpM38/CFNSX3ono5srg67NgQZ4FjaLo6t3AC5J/EramZCgO5mKLVjOvwo q+l8bg5PZhvOOq34bBD59FsMjA5xWNX8DrUN9TQUPezA4ZeHlWlZU3J3Zp2+hgq9/7VgEXI8HII Ptm4i5sZGjI/91iwrcW3inhO8z0qmptb4B1/CP2bShWqM+m2X49jq2C/p5zdZYnoLoIviC4qc6n mE7rC+wBEUi8LA6/S+xw0QCYY/2GWiO/gMTbQyIgsKhJXR1DU5/y2WjOU1jaoKzWXsj8QYdN X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.7,FMLib:17.12.80.40 definitions=2025-07-10_04,2025-07-09_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 mlxscore=0 priorityscore=1501 malwarescore=0 mlxlogscore=999 clxscore=1015 spamscore=0 bulkscore=0 phishscore=0 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505280000 definitions=main-2507100139 Content-Type: text/plain; charset="utf-8" Add s390 support for unwinding of user space using SFrame. This leverages the previous commits to address the following s390 particularities: - The CFA is defined as the value of the stack pointer (SP) at call site in the previous frame + 160. Therefore the SP unwinds as SP =3D CFA - 160. Therefore use a SP value offset from CFA of -160. - The return address (RA) is not saved on the stack at function entry. It is also not saved in the function prologue, when in leaf functions. Therefore the RA does not necessarily need to be unwound in the first unwinding step for the topmost frame. - The frame pointer (FP) and/or return address (RA) may be saved in other registers when in leaf functions. GCC effectively uses floating-point registers (FPR) for this purpose. Therefore DWARF register numbers may be encoded in the SFrame FP/RA offsets. - To make use of the signed 8-bit SFrame offset size and effectively reduce the .sframe section size the SFrame CFA offset values are encoded as (CFA - 160) / 8. This is because the lowest CFA offset value on s390 is by definition +160 (=3D value at function entry), which does not fit into a signed 8-bit SFrame offset. Therefore the CFA offset values are stored adjusted by -160. Additionally they are scaled by the s390-specific DWARF data scaling factor of 8. The s390x ELF ABI [1] guarantees that the CFA offset values are always aligned on an 8-byte boundary. [1]: s390x ELF ABI, https://github.com/IBM/s390x-abi/releases Signed-off-by: Jens Remus --- arch/s390/Kconfig | 2 + arch/s390/include/asm/unwind_user.h | 83 ++++++++++++++++++++++ arch/s390/include/asm/unwind_user_sframe.h | 37 ++++++++++ 3 files changed, 122 insertions(+) create mode 100644 arch/s390/include/asm/unwind_user.h create mode 100644 arch/s390/include/asm/unwind_user_sframe.h diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig index f4ea52c1f0ba..8b29a8f0f9c3 100644 --- a/arch/s390/Kconfig +++ b/arch/s390/Kconfig @@ -239,6 +239,8 @@ config S390 select HAVE_SETUP_PER_CPU_AREA select HAVE_SOFTIRQ_ON_OWN_STACK select HAVE_SYSCALL_TRACEPOINTS + select HAVE_UNWIND_USER_LOC_REG + select HAVE_UNWIND_USER_SFRAME select HAVE_USER_RA_REG select HAVE_VIRT_CPU_ACCOUNTING select HAVE_VIRT_CPU_ACCOUNTING_IDLE diff --git a/arch/s390/include/asm/unwind_user.h b/arch/s390/include/asm/un= wind_user.h new file mode 100644 index 000000000000..daae1545e203 --- /dev/null +++ b/arch/s390/include/asm/unwind_user.h @@ -0,0 +1,83 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_S390_UNWIND_USER_H +#define _ASM_S390_UNWIND_USER_H + +#include +#include +#include + +static inline void __s390_get_dwarf_fpr(unsigned long *val, int regnum) +{ + switch (regnum) { + case 16: + fpu_std(0, (freg_t *)val); + break; + case 17: + fpu_std(2, (freg_t *)val); + break; + case 18: + fpu_std(4, (freg_t *)val); + break; + case 19: + fpu_std(6, (freg_t *)val); + break; + case 20: + fpu_std(1, (freg_t *)val); + break; + case 21: + fpu_std(3, (freg_t *)val); + break; + case 22: + fpu_std(5, (freg_t *)val); + break; + case 23: + fpu_std(7, (freg_t *)val); + break; + case 24: + fpu_std(8, (freg_t *)val); + break; + case 25: + fpu_std(10, (freg_t *)val); + break; + case 26: + fpu_std(12, (freg_t *)val); + break; + case 27: + fpu_std(14, (freg_t *)val); + break; + case 28: + fpu_std(9, (freg_t *)val); + break; + case 29: + fpu_std(11, (freg_t *)val); + break; + case 30: + fpu_std(13, (freg_t *)val); + break; + case 31: + fpu_std(15, (freg_t *)val); + break; + default: + *val =3D 0; + } +} + +static inline int s390_unwind_user_get_reg(unsigned long *val, int regnum) +{ + if (0 <=3D regnum && regnum <=3D 15) { + struct pt_regs *regs =3D task_pt_regs(current); + *val =3D regs->gprs[regnum]; + } else if (16 <=3D regnum && regnum <=3D 31) { + __s390_get_dwarf_fpr(val, regnum); + } else { + return -EINVAL; + } + + return 0; +} + +#define unwind_user_get_reg s390_unwind_user_get_reg + +#include + +#endif /* _ASM_S390_UNWIND_USER_H */ diff --git a/arch/s390/include/asm/unwind_user_sframe.h b/arch/s390/include= /asm/unwind_user_sframe.h new file mode 100644 index 000000000000..2216e6921fd8 --- /dev/null +++ b/arch/s390/include/asm/unwind_user_sframe.h @@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_S390_UNWIND_USER_SFRAME_H +#define _ASM_S390_UNWIND_USER_SFRAME_H + +#include +#include + +static inline s32 arch_sframe_cfa_offset_decode(s32 offset) +{ + return (offset << 3) + 160; +} + +static inline void arch_sframe_set_frame_reginfo( + struct unwind_user_reginfo *reginfo, + s32 offset) +{ + if (offset & 1) { + reginfo->loc =3D UNWIND_USER_LOC_REG; + reginfo->regnum =3D offset >> 1; + } else if (offset) { + reginfo->loc =3D UNWIND_USER_LOC_STACK; + reginfo->frame_off =3D offset; + } else { + reginfo->loc =3D UNWIND_USER_LOC_NONE; + } +} + +static inline s32 arch_sframe_sp_val_off(void) +{ + return -160; +} + +#define sframe_cfa_offset_decode arch_sframe_cfa_offset_decode +#define sframe_set_frame_reginfo arch_sframe_set_frame_reginfo +#define sframe_sp_val_off arch_sframe_sp_val_off + +#endif /* _ASM_S390_UNWIND_USER_SFRAME_H */ --=20 2.48.1 From nobody Tue Oct 7 09:52:18 2025 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 3A4002F002D; Thu, 10 Jul 2025 16:36:00 +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=1752165362; cv=none; b=VhPd7K3uKLgRzxsGvcb2R+zfrLfKaJHZU2AcCjvt4S+JnQ0l1bqHP7gq2cVGbMW2XdvfO9kdHKpvCBhUnFZBLoB9Umq1DWSzEywu1SgsaM0v9ZwJFZ6m4H6HS315DzzbLjOiY1fasoQGy2QTFy6uPMVFF8JUsieW5b0iARwY71E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752165362; c=relaxed/simple; bh=enTOsuCqjALpapvYJ9I7QkN0U6oAXy2MiVcKV5e8ivY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=t2gUi0DT6jQ04u2g00pkY0PCU8zE0Ao8R7Rq3TvdNo0Bjb68gR5CyhR/RV4cpnFSxz0ERkDc2RXlE7XCU+p9zx1abaB1IacLyM2P/MIB6dxs3zvZK6DPUPvxu790eNrbQ+7GA7pSii+nnLnVSGwwdgAGpq2/6qdcyIbnsB6rIJM= 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=MdOEuyXR; 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="MdOEuyXR" Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 56AB7Aks023830; Thu, 10 Jul 2025 16:35:33 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=mWM+yaAd4FMlrFJ91 xRDMXfu+Sdz7jbSI0RwWQTtlr0=; b=MdOEuyXRp9KX/yA2bWS0zkivYONWTZPEC xw3hlK3JA1bR/CgI1XvQXQPOxUpTZGN2O2gdr6mco2pcK5pfUQm0tCE08101z6C5 5SF1AJcPhmYxTBgwHoI6Ol4ILRVcpwccp/ABNclRtzKN37Qk8IMbax0THuQCjCmJ CatK9/19MeoaBWl5ZerlfC0+0b7+QDgOzE4TCWqCweNvuAGTAbslIGxw+3TGujWb HVYSs9R6rPt3945e7SCH50zh/WnvNVTd+007cbpGsAzN5vy2sVSdg+SHxUeIJ9Vi FgD4Uq47ztH0UcNJ+aOUxkwDWHRW2bIR7bpwbZyC+CbH0gaYehKpw== 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 47ptjrd3bc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Jul 2025 16:35:32 +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 56AEGXmY025623; Thu, 10 Jul 2025 16:35:32 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 47qfcpek07-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Jul 2025 16:35:31 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 56AGZRR135062190 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 10 Jul 2025 16:35:27 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9003120043; Thu, 10 Jul 2025 16:35:27 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 529102004B; Thu, 10 Jul 2025 16:35:27 +0000 (GMT) Received: from tuxmaker.lnxne.boe (unknown [9.152.85.9]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 10 Jul 2025 16:35:27 +0000 (GMT) From: Jens Remus To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, bpf@vger.kernel.org, x86@kernel.org, Steven Rostedt Cc: Jens Remus , Heiko Carstens , Vasily Gorbik , Ilya Leoshkevich , Masami Hiramatsu , Mathieu Desnoyers , Josh Poimboeuf , Peter Zijlstra , Ingo Molnar , Jiri Olsa , Namhyung Kim , Thomas Gleixner , Andrii Nakryiko , Indu Bhagat , "Jose E. Marchesi" , Beau Belgrave , Linus Torvalds , Andrew Morton , Jens Axboe , Florian Weimer , Sam James Subject: [RFC PATCH v1 12/16] unwind_user/backchain: Introduce back chain user space unwinding Date: Thu, 10 Jul 2025 18:35:18 +0200 Message-ID: <20250710163522.3195293-13-jremus@linux.ibm.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250710163522.3195293-1-jremus@linux.ibm.com> References: <20250710163522.3195293-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-Authority-Analysis: v=2.4 cv=GL8IEvNK c=1 sm=1 tr=0 ts=686febd4 cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==:17 a=Wb1JkmetP80A:10 a=VnNF1IyMAAAA:8 a=lmyv6DA6xqyH8GGdWh0A:9 X-Proofpoint-ORIG-GUID: ndzDO_VFZBLUlab7uuKnHmlevyGHUr6q X-Proofpoint-GUID: ndzDO_VFZBLUlab7uuKnHmlevyGHUr6q X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNzEwMDEzOSBTYWx0ZWRfX79q1kXPe/vot zFjaFFocjr8DJBMJ52xxFHDOPbuU4oBNL9C5lrxtXW35UfVy9kdJunJqPVM190eWPBfxMk6mEez c/LpmIYe4thdQRR+jgIBYtRgYqbIYr5TShe1XAV9itjO7Pgvbxei9r/EVe/xLsQIlqq+JzUD6Fc UkqywUS/GH7NgAicncOKZavvGdWZsPXu8ywRWE5elZr+mJxi6SUvGa1As8VC9hqTbKeZDB0gyLf IqMFXv42XkEGsYl+/OtPmep6GJcRaqXCn6/PGwkmWb6NBASAVWs7pNH4rWjtgABzlheH8aqOgWG oBFANsSjJwKzXcYPJhKjsZFxV042aCYS/dMINfShlIBxL5gTatOC1JqEufH+DLhMGGI7pbUDZi9 Dh2Il8jUJFl03EUbuOMJWFimGdT+FIJ5HemFUk0s2R8QScftgsFN1v4lK0dXo4XwiEMC3BCV X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.7,FMLib:17.12.80.40 definitions=2025-07-10_04,2025-07-09_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 phishscore=0 clxscore=1015 impostorscore=0 suspectscore=0 bulkscore=0 adultscore=0 priorityscore=1501 mlxscore=0 spamscore=0 mlxlogscore=999 lowpriorityscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505280000 definitions=main-2507100139 Content-Type: text/plain; charset="utf-8" Add support for unwinding of user space using back chain to the unwind user interface. Use it as secondary fallback for unwinding using SFrame, if that fails and the primary fallback using frame pointer is not available. Signed-off-by: Jens Remus --- arch/Kconfig | 6 ++++++ include/linux/unwind_user_backchain.h | 17 +++++++++++++++++ include/linux/unwind_user_types.h | 1 + kernel/unwind/Makefile | 1 + kernel/unwind/user.c | 24 +++++++++++++++++++++--- kernel/unwind/user_backchain.c | 13 +++++++++++++ 6 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 include/linux/unwind_user_backchain.h create mode 100644 kernel/unwind/user_backchain.c diff --git a/arch/Kconfig b/arch/Kconfig index 9e28dffe42cb..4fe16ad6f053 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -438,6 +438,12 @@ config HAVE_HARDLOCKUP_DETECTOR_ARCH config UNWIND_USER bool =20 +config HAVE_UNWIND_USER_BACKCHAIN + bool + select UNWIND_USER + help + The arch supports unwinding of user space using back chain. + config HAVE_UNWIND_USER_FP bool select UNWIND_USER diff --git a/include/linux/unwind_user_backchain.h b/include/linux/unwind_u= ser_backchain.h new file mode 100644 index 000000000000..daae74c97c54 --- /dev/null +++ b/include/linux/unwind_user_backchain.h @@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_UNWIND_USER_BACKCHAIN_H +#define _LINUX_UNWIND_USER_BACKCHAIN_H + +struct unwind_user_state; + +#ifdef CONFIG_HAVE_UNWIND_USER_BACKCHAIN + +extern int unwind_user_backchain_next(struct unwind_user_state *state); + +#else /* !CONFIG_HAVE_UNWIND_USER_BACKCHAIN */ + +static inline int unwind_user_backchain_next(struct unwind_user_state *sta= te) { return -EINVAL; } + +#endif /* !CONFIG_HAVE_UNWIND_USER_BACKCHAIN */ + +#endif /* _LINUX_UNWIND_USER_BACKCHAIN_H */ diff --git a/include/linux/unwind_user_types.h b/include/linux/unwind_user_= types.h index 57fd16e314cf..41b1bc082cb1 100644 --- a/include/linux/unwind_user_types.h +++ b/include/linux/unwind_user_types.h @@ -14,6 +14,7 @@ enum unwind_user_type { UNWIND_USER_TYPE_FP, UNWIND_USER_TYPE_COMPAT_FP, UNWIND_USER_TYPE_SFRAME, + UNWIND_USER_TYPE_BACKCHAIN, }; =20 struct unwind_stacktrace { diff --git a/kernel/unwind/Makefile b/kernel/unwind/Makefile index 146038165865..38cef261abcb 100644 --- a/kernel/unwind/Makefile +++ b/kernel/unwind/Makefile @@ -1,2 +1,3 @@ obj-$(CONFIG_UNWIND_USER) +=3D user.o deferred.o + obj-$(CONFIG_HAVE_UNWIND_USER_BACKCHAIN) +=3D user_backchain.o obj-$(CONFIG_HAVE_UNWIND_USER_SFRAME) +=3D sframe.o diff --git a/kernel/unwind/user.c b/kernel/unwind/user.c index ee00d39d2a8e..3c3f75bc146b 100644 --- a/kernel/unwind/user.c +++ b/kernel/unwind/user.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include =20 @@ -39,6 +40,12 @@ static inline bool sframe_state(struct unwind_user_state= *state) state->type =3D=3D UNWIND_USER_TYPE_SFRAME; } =20 +static inline bool backchain_state(struct unwind_user_state *state) +{ + return IS_ENABLED(CONFIG_HAVE_UNWIND_USER_BACKCHAIN) && + state->type =3D=3D UNWIND_USER_TYPE_BACKCHAIN; +} + #define unwind_get_user_long(to, from, state) \ ({ \ int __ret; \ @@ -66,12 +73,20 @@ static int unwind_user_next(struct unwind_user_state *s= tate) /* sframe expects the frame to be local storage */ frame =3D &_frame; if (sframe_find(state->ip, frame, topmost)) { - if (!IS_ENABLED(CONFIG_HAVE_UNWIND_USER_FP)) - goto done; - frame =3D &fp_frame; + if (IS_ENABLED(CONFIG_HAVE_UNWIND_USER_FP)) { + frame =3D &fp_frame; + } else if (IS_ENABLED(CONFIG_HAVE_UNWIND_USER_BACKCHAIN)) { + if (unwind_user_backchain_next(state)) + goto done; + goto done_backchain; + } } } else if (fp_state(state)) { frame =3D &fp_frame; + } else if (backchain_state(state)) { + if (unwind_user_backchain_next(state)) + goto done; + goto done_backchain; } else { goto done; } @@ -153,6 +168,7 @@ static int unwind_user_next(struct unwind_user_state *s= tate) =20 arch_unwind_user_next(state); =20 +done_backchain: state->topmost =3D false; return 0; =20 @@ -178,6 +194,8 @@ static int unwind_user_start(struct unwind_user_state *= state) state->type =3D UNWIND_USER_TYPE_SFRAME; else if (IS_ENABLED(CONFIG_HAVE_UNWIND_USER_FP)) state->type =3D UNWIND_USER_TYPE_FP; + else if (IS_ENABLED(CONFIG_HAVE_UNWIND_USER_BACKCHAIN)) + state->type =3D UNWIND_USER_TYPE_BACKCHAIN; else state->type =3D UNWIND_USER_TYPE_NONE; =20 diff --git a/kernel/unwind/user_backchain.c b/kernel/unwind/user_backchain.c new file mode 100644 index 000000000000..5b60a3d4f34f --- /dev/null +++ b/kernel/unwind/user_backchain.c @@ -0,0 +1,13 @@ +// SPDX-License-Identifier: GPL-2.0 + +#define pr_fmt(fmt) "backchain: " fmt + +#include +#include +#include +#include + +int unwind_user_backchain_next(struct unwind_user_state *state) +{ + return arch_unwind_user_backchain_next(state); +} --=20 2.48.1 From nobody Tue Oct 7 09:52:18 2025 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 746812EA75D; Thu, 10 Jul 2025 16:35:53 +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=1752165355; cv=none; b=s88O9k0zXTnvWuVHcSriYfTVtaGmObRhzqf+WAxx4gdMVCqqwaoJEreG7+JKPIheGAxyAWl9xe5tW720zDJi2LNzaSqGh354fVR6FyenBPJ7W+ORMiVUfXkqeuXGOOZnFtOhkIinALHzpUjcXcKLANtGMK9qQ+78G2OkO9Qs+lw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752165355; c=relaxed/simple; bh=GGGqBykxmPKNbFLbbNLu5/UXUc4cBSMzmQzN8nKLNqs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=R+16r8fbsrOs/wQ4M5R8uNwiFf4IxD7YujyYVgKJ6GVJ7IY00jh/CqEGxL2dMJZOEYnmS6rHQBKpfZWShqyasNq236+z+w7d6U5aWX1VvZRgFdqUrYYgSWpMkoq3uLTO2qfk4OBr0S5MzrRE1nhpW93RNUwJ3FN1liWQVsf2AcY= 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=KMrnC4AS; 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="KMrnC4AS" Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 56AEmt9l010501; Thu, 10 Jul 2025 16:35:33 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=xDNNFrWOHVtkRntgQ YJ4X4jcEUv8xSxxWAxiZhUQMl4=; b=KMrnC4ASoRufg17i/ox/kfnH9zaMWaLCM U9XIotMdUzggSYkPRI9Y12tyFTwfHdn/sZQMbfcC12DLQYeccoz3AIJpkVbd6yC9 QNNMCiFpJ4M6FqoUWDMT70pZ+WHnCR6lnTwyzH6nXY1HZJ1W3zaf8a5AjnauVUGW gmoj7nboXjUznpP4EbhmcUDatxQYyTeVrrWCZGiDm9OVgQXtUsJO8JQsem2A7iUb MoxqwoJxB0DCj0QObtSl9dm+MEWV8Zr2RCpup0BdDj1tl71YnZKtXCEBIVZbIf7Q /9sdKmcLjuEyJRCY6XT3ll35bHgz9b8/fXBl5At4kxj3l8vFov6uQ== Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 47svb26atk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Jul 2025 16:35:32 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 56AG1dOt024678; Thu, 10 Jul 2025 16:35:31 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 47qh32p8mp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Jul 2025 16:35:31 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 56AGZROT35062192 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 10 Jul 2025 16:35:28 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D231E2004B; Thu, 10 Jul 2025 16:35:27 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9224E2004E; Thu, 10 Jul 2025 16:35:27 +0000 (GMT) Received: from tuxmaker.lnxne.boe (unknown [9.152.85.9]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 10 Jul 2025 16:35:27 +0000 (GMT) From: Jens Remus To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, bpf@vger.kernel.org, x86@kernel.org, Steven Rostedt Cc: Jens Remus , Heiko Carstens , Vasily Gorbik , Ilya Leoshkevich , Masami Hiramatsu , Mathieu Desnoyers , Josh Poimboeuf , Peter Zijlstra , Ingo Molnar , Jiri Olsa , Namhyung Kim , Thomas Gleixner , Andrii Nakryiko , Indu Bhagat , "Jose E. Marchesi" , Beau Belgrave , Linus Torvalds , Andrew Morton , Jens Axboe , Florian Weimer , Sam James Subject: [RFC PATCH v1 13/16] s390/unwind_user/backchain: Enable HAVE_UNWIND_USER_BACKCHAIN Date: Thu, 10 Jul 2025 18:35:19 +0200 Message-ID: <20250710163522.3195293-14-jremus@linux.ibm.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250710163522.3195293-1-jremus@linux.ibm.com> References: <20250710163522.3195293-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-Spam-Details-Enc: AW1haW4tMjUwNzEwMDEzOSBTYWx0ZWRfX9BjtxvQxsv7N MwfarMQIZA/zSK97sJXAOWC7QwfsJns/OqybuEashRiqv7gcf2YyTPlGLHuR6x9E2U1I7nE4spN eeAqfTyz72ZY0iEIlMUY0PlrTSZGINEyhzrVwGvd5r+ARfyvYISEt5V0GWTQeOOOX2CZLmmmW3N yV0IWNpBSxxAwwRSMaDci9zIRICJJ4WdyHWyGeqy+vNIOz8n37b8/NdyGDvT0vQMGE7iqPDT1cA KyjbW4qWyZ3+eESf13pI70wJt7CaV0sRP1d0zr5sREjAYBJ0unui+7a9GdW/NZRjfjKImzAvpS6 jaImvXBIEOq5jdD8B9TXIqtbqj5eHSotmlGLcggMjyq1QYAzr4WVUI6kcnf+tkQ6z9JDJwjviG6 oTa9Nd4yvx8uIBnkTWHuAK8kPllNsRDbkChN2aetTGirWA6UcVqFroEijNBRoQWoTcdTIUaA X-Authority-Analysis: v=2.4 cv=Y774sgeN c=1 sm=1 tr=0 ts=686febd4 cx=c_pps a=aDMHemPKRhS1OARIsFnwRA==:117 a=aDMHemPKRhS1OARIsFnwRA==:17 a=Wb1JkmetP80A:10 a=VnNF1IyMAAAA:8 a=Paj0-Z-736eVyoMAdw0A:9 X-Proofpoint-ORIG-GUID: XZblb3XbvUWysOM4LG_V39skfnzDmK8u X-Proofpoint-GUID: XZblb3XbvUWysOM4LG_V39skfnzDmK8u X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.7,FMLib:17.12.80.40 definitions=2025-07-10_04,2025-07-09_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 adultscore=0 priorityscore=1501 malwarescore=0 bulkscore=0 impostorscore=0 lowpriorityscore=0 phishscore=0 suspectscore=0 mlxlogscore=563 mlxscore=0 clxscore=1015 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505280000 definitions=main-2507100139 Content-Type: text/plain; charset="utf-8" Enable unwinding of user space using back chain on s390. Based on arch_stack_walk_user_common() in arch/s390/kernel/stacktrace.c. Signed-off-by: Jens Remus --- arch/s390/Kconfig | 1 + arch/s390/include/asm/unwind_user_backchain.h | 127 ++++++++++++++++++ 2 files changed, 128 insertions(+) create mode 100644 arch/s390/include/asm/unwind_user_backchain.h diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig index 8b29a8f0f9c3..49f231123040 100644 --- a/arch/s390/Kconfig +++ b/arch/s390/Kconfig @@ -239,6 +239,7 @@ config S390 select HAVE_SETUP_PER_CPU_AREA select HAVE_SOFTIRQ_ON_OWN_STACK select HAVE_SYSCALL_TRACEPOINTS + select HAVE_UNWIND_USER_BACKCHAIN select HAVE_UNWIND_USER_LOC_REG select HAVE_UNWIND_USER_SFRAME select HAVE_USER_RA_REG diff --git a/arch/s390/include/asm/unwind_user_backchain.h b/arch/s390/incl= ude/asm/unwind_user_backchain.h new file mode 100644 index 000000000000..ceb56b9d8411 --- /dev/null +++ b/arch/s390/include/asm/unwind_user_backchain.h @@ -0,0 +1,127 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_S390_UNWIND_USER_BACKCHAIN_H +#define _ASM_S390_UNWIND_USER_BACKCHAIN_H + +#include +#ifndef ASM_OFFSETS_C +#include +#endif + +struct stack_frame_user { + unsigned long backchain; + unsigned long unused; + /* Argument register save area. */ + unsigned long r2; + unsigned long r3; + unsigned long r4; + unsigned long r5; + unsigned long r6; + /* Other register save area. */ + unsigned long r7; + unsigned long r8; + unsigned long r9; + unsigned long r10; + unsigned long r11; + unsigned long r12; + unsigned long r13; + unsigned long r14; + unsigned long r15; + /* FP argument register save area. */ + unsigned long f0; + unsigned long f2; + unsigned long f4; + unsigned long f6; +}; + +struct stack_frame_vdso_wrapper { + struct stack_frame_user sf; + unsigned long return_address; +}; + +/** + * ip_invalid - Perform some basic checks whether an instruction pointer (= IP) + * taken from an unreliable source is invalid + * @ip: The instruction pointer to be validated + * + * returns whether the instruction pointer is invalid + */ +static inline bool ip_invalid(unsigned long ip) +{ + if (ip & 1) + return true; + if (ip < mmap_min_addr) + return true; + if (ip >=3D current->mm->context.asce_limit) + return true; + return false; +} + +/** + * ip_within_vdso - Check whether an instruction pointer (IP) is within vD= SO + * @ip: The instruction pointer + * + * returns whether the instruction pointer is within vDSO + */ +static inline bool ip_within_vdso(unsigned long ip) +{ + return in_range(ip, current->mm->context.vdso_base, vdso_text_size()); +} + +/** + * arch_unwind_user_backchain_next - Unwind one frame using backchain + * @state: The unwind user state + * + * returns zero when successful, otherwise -EINVAL. + */ +static inline int arch_unwind_user_backchain_next(struct unwind_user_state= *state) +{ + struct stack_frame_user __user *sf; + unsigned long sp, ra; + + sf =3D (void __user *)state->sp; + if (__get_user(sp, (unsigned long __user *)&sf->backchain)) + return -EINVAL; + + /* + * vDSO entry code on s390 has a non-standard stack frame layout. + * See vDSO user wrapper code for details. + */ + if (!sp && ip_within_vdso(state->ip)) { + struct stack_frame_vdso_wrapper *sf_vdso =3D (void __user *)sf; + + if (__get_user(ra, (unsigned long __user *)&sf_vdso->return_address)) + return -EINVAL; + sf =3D (void __user *)((unsigned long)sf + STACK_FRAME_VDSO_OVERHEAD); + if (__get_user(sp, (unsigned long __user *)&sf->backchain)) + return -EINVAL; + } else { + sf =3D (void __user *)sp; + if (__get_user(ra, (unsigned long __user *)&sf->r14)) + return -EINVAL; + } + + /* ABI requires SP to be 8-byte aligned. */ + if (sp & 0x7) + return -EINVAL; + + /* + * If the IP is invalid and this is the topmost frame, + * assume the RA register has not been saved yet. + */ + if (ip_invalid(ra)) { + if (!state->topmost || !IS_ENABLED(CONFIG_HAVE_USER_RA_REG)) + return -EINVAL; + + ra =3D user_return_address(task_pt_regs(current)); + if (ip_invalid(ra)) + return -EINVAL; + } + + state->sp =3D sp; + state->ip =3D ra; + state->fp =3D 0; + + return 0; +} + +#endif /* _ASM_S390_UNWIND_USER_BACKCHAIN_H */ --=20 2.48.1 From nobody Tue Oct 7 09:52:18 2025 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 CA4662F2366; Thu, 10 Jul 2025 16:36:01 +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=1752165363; cv=none; b=jc4JcAPPSXyOY12yC1EwHbOpAZycv/qbFCaAwKaFeEOmpOLQncgXGJLWLmcyFQOZiipAw9hvRJ0H8Paob4ECc+Qiz3y3Dwl7zM/R61GkX1cecEaOyRihFZJpmQVMvYMNSLIW00s2nV9U9eyAZ8LmyhMp6bsA/1ORNJMkMn0dYkA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752165363; c=relaxed/simple; bh=lRRs4ZXJpUwxnruw9Aw1vFLZ3QwboXxyNzSGKh/SutU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BTyQVOK+/6PGSTXBrzuZIEnGeJFQu63pQU6aRh/5Py0+U3BgtbO4/e/fg7A3L4XnuNBhxZWsBd/LRHC0Mwc0vAAd563jsCStWIDSfDc2x0LAiKJN2WrUlWAkyxbNFWkiCZMtLJyeMK0mnEgx3JnEpCrwP8Ml13HXhHVcSSKBVWI= 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=gXTMrzN5; 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="gXTMrzN5" Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 56ACALZF008445; Thu, 10 Jul 2025 16:35:33 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=dLpURqXy0X9ikZ433 zJ2XsLbDK7WPIJsqR+KifaA20A=; b=gXTMrzN5dXI6yOiJJ+ZS00w1nT4CUvohU icZ6WmAj12tPlAnoaKsK9Grbs6x8yR0kyXHI7neiXpvqS6LP+iKyuJY89LGekvZ5 r02uDAedsCH/shKfo1whtnthNpdUvttUkT0ojayTMmQ4Ua03tdHWGwrfRA/dmhve DPU3bQxjcKwy+Zfcjl/GRrApi19AzcXoHriXaUScYovyALBDcmlX9OKP8my/C5i5 CrM7UYNS3QpMq5K9Q6oM93IBwNBjP9Fm5NeuX62hF90EFwK9l0mP6HkQdGkhdovD BwrtNkoYqT/gDGg0fFUx8NappTtzvSrwtDRMhseHzfpXt+98/6dyA== Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 47svb26atm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Jul 2025 16:35:32 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 56AEvlu5024684; Thu, 10 Jul 2025 16:35:32 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 47qh32p8mq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Jul 2025 16:35:31 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 56AGZSYi12714312 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 10 Jul 2025 16:35:28 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2367F2005A; Thu, 10 Jul 2025 16:35:28 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D72442004D; Thu, 10 Jul 2025 16:35:27 +0000 (GMT) Received: from tuxmaker.lnxne.boe (unknown [9.152.85.9]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 10 Jul 2025 16:35:27 +0000 (GMT) From: Jens Remus To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, bpf@vger.kernel.org, x86@kernel.org, Steven Rostedt Cc: Jens Remus , Heiko Carstens , Vasily Gorbik , Ilya Leoshkevich , Masami Hiramatsu , Mathieu Desnoyers , Josh Poimboeuf , Peter Zijlstra , Ingo Molnar , Jiri Olsa , Namhyung Kim , Thomas Gleixner , Andrii Nakryiko , Indu Bhagat , "Jose E. Marchesi" , Beau Belgrave , Linus Torvalds , Andrew Morton , Jens Axboe , Florian Weimer , Sam James , "Steven Rostedt (Google)" Subject: [RFC PATCH v1 14/16] PREREQ: x86/asm: Avoid emitting DWARF CFI for non-VDSO Date: Thu, 10 Jul 2025 18:35:20 +0200 Message-ID: <20250710163522.3195293-15-jremus@linux.ibm.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250710163522.3195293-1-jremus@linux.ibm.com> References: <20250710163522.3195293-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-Spam-Details-Enc: AW1haW4tMjUwNzEwMDEzOSBTYWx0ZWRfXzgzNkj0fboa1 oeO4a2w/N+AxGb7uCCfwYWnWAcv4I87VwzXptAvUzxbXfGta8gMUMacp3Suujus9CPju+gv0gGt YlIgkkgXx6+wyD/GqTqDMcb0GCI1brVREe4A5rr17KlAiVta3JIEHhYEmiVAGq169Bo0vmqKmHy A4HsJCMhboqYyKC1cFOvg6Qn/gZiAcdF6PHBnwvO0z7c1OFxmuUxDi85gsGGVKDFuUlH4Nulsfv 91pCxzrCjvb+HEQv/FWcX+nqOidjgdKsyMvB2B0j/TNuBvWPV/fHadBE9z1ST+o5c8L71LaZCaM aU7zhzIQr7qHYUqxIvCZV5W8sd7sx14a/nALHMurlTUDiFbSwartht+UxNnfj0goKsUjhXWQyGL YaRMKsbr6OLhb9fLMIWZJOUPvdnANMGSjI2YqR6wgWfSehWlatDTjQXlpGWuwopVSViFw25C X-Authority-Analysis: v=2.4 cv=Y774sgeN c=1 sm=1 tr=0 ts=686febd5 cx=c_pps a=aDMHemPKRhS1OARIsFnwRA==:117 a=aDMHemPKRhS1OARIsFnwRA==:17 a=Wb1JkmetP80A:10 a=VwQbUJbxAAAA:8 a=meVymXHHAAAA:8 a=zOOTxvlrTZNIKiBVQswA:9 a=2JgSa4NbpEOStq-L5dxp:22 X-Proofpoint-ORIG-GUID: qQ5hGor0rDVpNc66sxy5Y8W-sqMf2aOH X-Proofpoint-GUID: qQ5hGor0rDVpNc66sxy5Y8W-sqMf2aOH X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.7,FMLib:17.12.80.40 definitions=2025-07-10_04,2025-07-09_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 adultscore=0 priorityscore=1501 malwarescore=0 bulkscore=0 impostorscore=0 lowpriorityscore=0 phishscore=0 suspectscore=0 mlxlogscore=862 mlxscore=0 clxscore=1015 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505280000 definitions=main-2507100139 Content-Type: text/plain; charset="utf-8" From: Josh Poimboeuf It was decided years ago that .cfi_* annotations aren't maintainable in the kernel. They were replaced by objtool unwind hints. For the kernel proper, ensure the CFI_* macros don't do anything. On the other hand the VDSO library *does* use them, so user space can unwind through it. Make sure these macros only work for VDSO. They aren't actually being used outside of VDSO anyway, so there's no functional change. Signed-off-by: Josh Poimboeuf Signed-off-by: Steven Rostedt (Google) --- Notes (jremus): Link: https://lore.kernel.org/all/20250425024022.477374378@goodmis.org/ =20 This is only a prerequisite for the subsequent prerequisite patch "x86/vdso: Enable sframe generation in VDSO" to apply cleanly. arch/x86/include/asm/dwarf2.h | 51 ++++++++++++++++++++++++----------- 1 file changed, 35 insertions(+), 16 deletions(-) diff --git a/arch/x86/include/asm/dwarf2.h b/arch/x86/include/asm/dwarf2.h index 302e11b15da8..65d958ef1178 100644 --- a/arch/x86/include/asm/dwarf2.h +++ b/arch/x86/include/asm/dwarf2.h @@ -6,6 +6,15 @@ #warning "asm/dwarf2.h should be only included in pure assembly files" #endif =20 +#ifdef BUILD_VDSO + + /* + * For the vDSO, emit both runtime unwind information and debug + * symbols for the .dbg file. + */ + + .cfi_sections .eh_frame, .debug_frame + #define CFI_STARTPROC .cfi_startproc #define CFI_ENDPROC .cfi_endproc #define CFI_DEF_CFA .cfi_def_cfa @@ -21,21 +30,31 @@ #define CFI_UNDEFINED .cfi_undefined #define CFI_ESCAPE .cfi_escape =20 -#ifndef BUILD_VDSO - /* - * Emit CFI data in .debug_frame sections, not .eh_frame sections. - * The latter we currently just discard since we don't do DWARF - * unwinding at runtime. So only the offline DWARF information is - * useful to anyone. Note we should not use this directive if we - * ever decide to enable DWARF unwinding at runtime. - */ - .cfi_sections .debug_frame -#else - /* - * For the vDSO, emit both runtime unwind information and debug - * symbols for the .dbg file. - */ - .cfi_sections .eh_frame, .debug_frame -#endif +#else /* !BUILD_VDSO */ + +/* + * On x86, these macros aren't used outside VDSO. As well they shouldn't = be: + * they're fragile and very difficult to maintain. + */ + +.macro nocfi args:vararg +.endm + +#define CFI_STARTPROC nocfi +#define CFI_ENDPROC nocfi +#define CFI_DEF_CFA nocfi +#define CFI_DEF_CFA_REGISTER nocfi +#define CFI_DEF_CFA_OFFSET nocfi +#define CFI_ADJUST_CFA_OFFSET nocfi +#define CFI_OFFSET nocfi +#define CFI_REL_OFFSET nocfi +#define CFI_REGISTER nocfi +#define CFI_RESTORE nocfi +#define CFI_REMEMBER_STATE nocfi +#define CFI_RESTORE_STATE nocfi +#define CFI_UNDEFINED nocfi +#define CFI_ESCAPE nocfi + +#endif /* !BUILD_VDSO */ =20 #endif /* _ASM_X86_DWARF2_H */ --=20 2.48.1 From nobody Tue Oct 7 09:52:18 2025 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 D63ED2F1994; Thu, 10 Jul 2025 16:35:57 +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=1752165359; cv=none; b=iWRwqSbbYILJeHyklBtsNmi+/YMGD0XA+gwkL3KVazA0cJEEGBa7vATaMTEhj85j5Oacp9yLSZH+W4ifI2G0Gisesfb8Pi/RSL70/HbSlLgWyFUk9F++G+1qV2otOUlrHiOJ1n2/CRrEeepfLxet6J+oUjxz1219gv0YYYYB/us= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752165359; c=relaxed/simple; bh=KYs1ceJENroDnUDxMw8CSyDdmDwONMFDpRkG9gCVQU0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=K4oZQGFdRIBk3QVhUEtMk189fDnfz72kE6FmLzX5OkV4joUGpjWysPO8iM661a8d5KRqub+MPEdLVgLwNeDm9h9KpyenHC1FB2a6uKMuWMM35zWrqrhWVQeqslvxGEh3YCqCbG2vlsM4EKlqsn6gaYyL1ryVcsnotdRJ0MU9l1c= 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=JZLheqKM; 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="JZLheqKM" Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 56AD5iuA028946; Thu, 10 Jul 2025 16:35:34 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=KrkxlXID0uInFpjQ8 IQoc2pW64e8vi2BEAPTzF7Znlc=; b=JZLheqKMirWKx0B+sLwiyxFeg0EzUa8TI DI0FQ7WSflnSOC3HAhHPZJB/yvWng6zNcFhchW6y4LKUuEOQjhyxTABOoNU4SJ+C CwqFADXo4FU7n2zIpGJVyvv5C5Zr5NL5Qkgdins/w9WZ3XinxqEQYAX4nSYMkpWX ACXmWdW/By5qgQLOMWLitVZnNVFrDIrNKcKir2hIXRpQ9ao4U7i+zsdMtr1vDjMF OOVd1S5QtA5KQutybO44I6f98MG2sSRhAerHXxzU+MbYwsHe185YDzQkNmWmPUjo jW8kO50vhV1YET/NPORePZXzt1U+zsAcmEzLCRv4uLoLKgSBwMvsw== 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 47ptjrd3bd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Jul 2025 16:35:33 +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 56AF4hNf013616; Thu, 10 Jul 2025 16:35:32 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 47qgkm6bc6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Jul 2025 16:35:32 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 56AGZSJI12714314 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 10 Jul 2025 16:35:28 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 670A02004B; Thu, 10 Jul 2025 16:35:28 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 27DFE20063; Thu, 10 Jul 2025 16:35:28 +0000 (GMT) Received: from tuxmaker.lnxne.boe (unknown [9.152.85.9]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 10 Jul 2025 16:35:28 +0000 (GMT) From: Jens Remus To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, bpf@vger.kernel.org, x86@kernel.org, Steven Rostedt Cc: Jens Remus , Heiko Carstens , Vasily Gorbik , Ilya Leoshkevich , Masami Hiramatsu , Mathieu Desnoyers , Josh Poimboeuf , Peter Zijlstra , Ingo Molnar , Jiri Olsa , Namhyung Kim , Thomas Gleixner , Andrii Nakryiko , Indu Bhagat , "Jose E. Marchesi" , Beau Belgrave , Linus Torvalds , Andrew Morton , Jens Axboe , Florian Weimer , Sam James , "Steven Rostedt (Google)" Subject: [RFC PATCH v1 15/16] PREREQ: x86/vdso: Enable sframe generation in VDSO Date: Thu, 10 Jul 2025 18:35:21 +0200 Message-ID: <20250710163522.3195293-16-jremus@linux.ibm.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250710163522.3195293-1-jremus@linux.ibm.com> References: <20250710163522.3195293-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-Authority-Analysis: v=2.4 cv=GL8IEvNK c=1 sm=1 tr=0 ts=686febd5 cx=c_pps a=AfN7/Ok6k8XGzOShvHwTGQ==:117 a=AfN7/Ok6k8XGzOShvHwTGQ==:17 a=Wb1JkmetP80A:10 a=VwQbUJbxAAAA:8 a=meVymXHHAAAA:8 a=6um0ROA3cFbXW2b5GMEA:9 a=2JgSa4NbpEOStq-L5dxp:22 X-Proofpoint-ORIG-GUID: JRIN3E5Xi3FJ8BYjaneJzGrh9Og3E1E1 X-Proofpoint-GUID: JRIN3E5Xi3FJ8BYjaneJzGrh9Og3E1E1 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNzEwMDEzOSBTYWx0ZWRfXx90kOBlahgzh kaZOzdwX14SVgAmiIXxfeMUzpeMQ+s+hI7Mz0zZ3dQvL5DC9wgf2rJ+B5fGRBKhOsPCiVAjYskv WDj478bPA8OBYV3Q4jI8KMzC5f5MH2A6JtycY2zdZzBD/9LfHErPJN8E6HM82TOgS9TlfwL6yc3 YZXkphRQmyQpdeGQUBt2PrkuzRmrAEkFl2uABwbHAf+1pUtjMewKugLTPpFRgRkdFuL10B0USbd F639aoSPt1jCdpDwfrKhA3qoLyUiIbMF6TWJ2IAznqDFSg99JaKGubopdE4l+Di92LL7pVio6O3 4Hyq1HPW3EVrJvp8lXevWnV3wa+zV2eMuoMMXAWc2KG7hnB7T1htjT0O9ebrvFWl6doFNsTtj4r CloP3ms6jUBp/dA6l+H+eUi7HPQU6/EkNRNECwe3PL3625bfDN2fpSTGwXLLU1AyBFLdBEjD X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.7,FMLib:17.12.80.40 definitions=2025-07-10_04,2025-07-09_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 phishscore=0 clxscore=1015 impostorscore=0 suspectscore=0 bulkscore=0 adultscore=0 priorityscore=1501 mlxscore=0 spamscore=0 mlxlogscore=999 lowpriorityscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505280000 definitions=main-2507100139 Content-Type: text/plain; charset="utf-8" From: Josh Poimboeuf Enable sframe generation in the VDSO library so kernel and user space can unwind through it. Signed-off-by: Josh Poimboeuf Signed-off-by: Steven Rostedt (Google) --- Notes (jremus): Link: https://lore.kernel.org/all/20250425024023.173709192@goodmis.org/ =20 This is a prerequisite for patch "s390/vdso: Enable SFrame generation in vDSO" to actually generate SFrame in vDSO, as it introduces config option CONFIG_AS_SFRAME. arch/Kconfig | 3 +++ arch/x86/entry/vdso/Makefile | 10 +++++++--- arch/x86/entry/vdso/vdso-layout.lds.S | 3 +++ arch/x86/include/asm/dwarf2.h | 5 ++++- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/arch/Kconfig b/arch/Kconfig index 4fe16ad6f053..1c3daccd9072 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -435,6 +435,9 @@ config HAVE_HARDLOCKUP_DETECTOR_ARCH It uses the same command line parameters, and sysctl interface, as the generic hardlockup detectors. =20 +config AS_SFRAME + def_bool $(as-instr,.cfi_sections .sframe\n.cfi_startproc\n.cfi_endproc) + config UNWIND_USER bool =20 diff --git a/arch/x86/entry/vdso/Makefile b/arch/x86/entry/vdso/Makefile index 54d3e9774d62..2dc0e0ca19a7 100644 --- a/arch/x86/entry/vdso/Makefile +++ b/arch/x86/entry/vdso/Makefile @@ -47,13 +47,17 @@ quiet_cmd_vdso2c =3D VDSO2C $@ $(obj)/vdso-image-%.c: $(obj)/vdso%.so.dbg $(obj)/vdso%.so $(obj)/vdso2c F= ORCE $(call if_changed,vdso2c) =20 +ifeq ($(CONFIG_AS_SFRAME),y) + SFRAME_CFLAGS :=3D -Wa,-gsframe +endif + # # Don't omit frame pointers for ease of userspace debugging, but do # optimize sibling calls. # CFL :=3D $(PROFILING) -mcmodel=3Dsmall -fPIC -O2 -fasynchronous-unwind-tab= les -m64 \ $(filter -g%,$(KBUILD_CFLAGS)) -fno-stack-protector \ - -fno-omit-frame-pointer -foptimize-sibling-calls \ + -fno-omit-frame-pointer $(SFRAME_CFLAGS) -foptimize-sibling-calls \ -DDISABLE_BRANCH_PROFILING -DBUILD_VDSO =20 ifdef CONFIG_MITIGATION_RETPOLINE @@ -63,7 +67,7 @@ endif endif =20 $(vobjs): KBUILD_CFLAGS :=3D $(filter-out $(PADDING_CFLAGS) $(CC_FLAGS_LTO= ) $(CC_FLAGS_CFI) $(RANDSTRUCT_CFLAGS) $(GCC_PLUGINS_CFLAGS) $(RETPOLINE_CF= LAGS),$(KBUILD_CFLAGS)) $(CFL) -$(vobjs): KBUILD_AFLAGS +=3D -DBUILD_VDSO +$(vobjs): KBUILD_AFLAGS +=3D -DBUILD_VDSO $(SFRAME_CFLAGS) =20 # # vDSO code runs in userspace and -pg doesn't help with profiling anyway. @@ -104,7 +108,7 @@ $(obj)/%-x32.o: $(obj)/%.o FORCE =20 targets +=3D vdsox32.lds $(vobjx32s-y) =20 -$(obj)/%.so: OBJCOPYFLAGS :=3D -S --remove-section __ex_table +$(obj)/%.so: OBJCOPYFLAGS :=3D -g --remove-section __ex_table $(obj)/%.so: $(obj)/%.so.dbg FORCE $(call if_changed,objcopy) =20 diff --git a/arch/x86/entry/vdso/vdso-layout.lds.S b/arch/x86/entry/vdso/vd= so-layout.lds.S index ec1ac191a057..c57cfddfc37d 100644 --- a/arch/x86/entry/vdso/vdso-layout.lds.S +++ b/arch/x86/entry/vdso/vdso-layout.lds.S @@ -59,6 +59,7 @@ SECTIONS .eh_frame_hdr : { *(.eh_frame_hdr) } :text :eh_frame_hdr .eh_frame : { KEEP (*(.eh_frame)) } :text =20 + .sframe : { *(.sframe) } :text :sframe =20 /* * Text is well-separated from actual data: there's plenty of @@ -87,6 +88,7 @@ SECTIONS * Very old versions of ld do not recognize this name token; use the const= ant. */ #define PT_GNU_EH_FRAME 0x6474e550 +#define PT_GNU_SFRAME 0x6474e554 =20 /* * We must supply the ELF program headers explicitly to get just one @@ -98,4 +100,5 @@ PHDRS dynamic PT_DYNAMIC FLAGS(4); /* PF_R */ note PT_NOTE FLAGS(4); /* PF_R */ eh_frame_hdr PT_GNU_EH_FRAME; + sframe PT_GNU_SFRAME; } diff --git a/arch/x86/include/asm/dwarf2.h b/arch/x86/include/asm/dwarf2.h index 65d958ef1178..ce294e6c9017 100644 --- a/arch/x86/include/asm/dwarf2.h +++ b/arch/x86/include/asm/dwarf2.h @@ -12,8 +12,11 @@ * For the vDSO, emit both runtime unwind information and debug * symbols for the .dbg file. */ - +#if defined(__x86_64__) && defined(CONFIG_AS_SFRAME) + .cfi_sections .eh_frame, .debug_frame, .sframe +#else .cfi_sections .eh_frame, .debug_frame +#endif =20 #define CFI_STARTPROC .cfi_startproc #define CFI_ENDPROC .cfi_endproc --=20 2.48.1 From nobody Tue Oct 7 09:52:18 2025 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 88EC82EFDB5; Thu, 10 Jul 2025 16:36:13 +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=1752165375; cv=none; b=TjhGhhdrZqN5C2Qm3FkNNT6pq89hIrvpFRrn+S0Huy5rIhI09fMiC/BIfhbfg5K8ppTUFi9kh5lMYgd2ginv55zfPpd11uhAKUYi4SB+NMWIxKFzPZqt3y+yLrNrTFSo+IWdcGy81yRv8hGG3rBJYE1Z1kuHxiDIBViP5UGMnuM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752165375; c=relaxed/simple; bh=HDpOlHn07MCMCz6ZR8ox5wRqbGV6hjvdNacy386wcRM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=P2Eo7eWfHADqvb9Mjs/s6tgcy3j5n55hh3GXlgHNxHgzZVfF5k4GY1RqSag03AcPv5Vy+GP6XJzppZWbPMC2pxelFxzoy26mznt6MZtQVEuNexZoxNV2ajkbK9Muj1bYvZ9VYtS9kXONkr0j70iRZwPXQ8xEV7n0TiURYdj4szM= 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=S6cm0X1A; 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="S6cm0X1A" Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 56A9r57e021381; Thu, 10 Jul 2025 16:35:33 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=WH8heYNKI41hEAvvl +y/eA+1PA5Xi2h4EcmcEcVNNBk=; b=S6cm0X1A1xlkSX9Sw/09DI4AO1VkyFBGZ LognVdNkerM9R7wjnuYMFSDRbEHq/N/letCBjalJtx9WYeQ+SxS8I2KErbuW1V2B CBRoSJ7w8gHltOM6R8nQb2rUSTWSVSVkcBvJOuu5vSiWuCsoj38rOCiDnCnqXEPL TZXR8duE+VNGSUFI0qiYBoEc1je20tyiO+6IM3LMYCVffcluhudTfVgy5A6N00mq PEncxHdQdeqedYhn6putCQYu8iaAi7Ht6yp+xYVobKMkL77mrUeFJbNHDzIgkR+F 4vdsERtStkILwE4+l7slrNqJAyyhZoM693+ONqBbg1GzLPddnkazw== 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 47pusse6aa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Jul 2025 16:35:33 +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 56ADFbx4021531; Thu, 10 Jul 2025 16:35:32 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 47qectxrn6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Jul 2025 16:35:32 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 56AGZSsD12714316 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 10 Jul 2025 16:35:28 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A696520063; Thu, 10 Jul 2025 16:35:28 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6B7442004D; Thu, 10 Jul 2025 16:35:28 +0000 (GMT) Received: from tuxmaker.lnxne.boe (unknown [9.152.85.9]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 10 Jul 2025 16:35:28 +0000 (GMT) From: Jens Remus To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, bpf@vger.kernel.org, x86@kernel.org, Steven Rostedt Cc: Jens Remus , Heiko Carstens , Vasily Gorbik , Ilya Leoshkevich , Masami Hiramatsu , Mathieu Desnoyers , Josh Poimboeuf , Peter Zijlstra , Ingo Molnar , Jiri Olsa , Namhyung Kim , Thomas Gleixner , Andrii Nakryiko , Indu Bhagat , "Jose E. Marchesi" , Beau Belgrave , Linus Torvalds , Andrew Morton , Jens Axboe , Florian Weimer , Sam James Subject: [RFC PATCH v1 16/16] WIP: fixup! s390/unwind_user/sframe: Enable HAVE_UNWIND_USER_SFRAME Date: Thu, 10 Jul 2025 18:35:22 +0200 Message-ID: <20250710163522.3195293-17-jremus@linux.ibm.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250710163522.3195293-1-jremus@linux.ibm.com> References: <20250710163522.3195293-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-Authority-Analysis: v=2.4 cv=Vaj3PEp9 c=1 sm=1 tr=0 ts=686febd5 cx=c_pps a=bLidbwmWQ0KltjZqbj+ezA==:117 a=bLidbwmWQ0KltjZqbj+ezA==:17 a=Wb1JkmetP80A:10 a=VnNF1IyMAAAA:8 a=91u_FrifZQu3ZdA2h5kA:9 X-Proofpoint-GUID: 0aJBZvD1035smR9ojazV5kefpBfgylH6 X-Proofpoint-ORIG-GUID: 0aJBZvD1035smR9ojazV5kefpBfgylH6 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNzEwMDEzOSBTYWx0ZWRfX/XBsHHfW/+nP ZOVtoweC1xqyeGxov+zkxVoXXuotXBggIBdkrhTgduybXumWwEDy4mK1f6WgqySQtWHHHWatxR3 gcwOx/dCN0sFN2ck+51Ci2fRWIIxfBjdMx0Lev0JHU9Dw8AFkvGzu7lz9cCYGvrnyEze5kkOY0/ wQ6wq+YoOerWfieplJP/LXXcoB+PDxuppnI10zBFd4rqNEB3Hid3ej3ucmldwyo72m3NcTQc05e yzcrL9u2/eTlK5xcgSASgRQZY/AEaZFEJQTz8bUw7BQz/bfEJo2tAOYlXiCjZFSBZB+zthi5yey BfdxqIAm/7/M2up39CrwGYtG288/Ymed9OsmOetjw2y2d0WjXsWfpioIHWy8QyUMtN4+EryV3MR lYzJVvjfBQKLnO9TWLmI8nvSYeG4JXYRaUHU4yNgnEjyvXYn02z7jey3IV35b+ACmcpcFmux X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.7,FMLib:17.12.80.40 definitions=2025-07-10_04,2025-07-09_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 mlxlogscore=713 suspectscore=0 clxscore=1015 adultscore=0 lowpriorityscore=0 impostorscore=0 malwarescore=0 bulkscore=0 mlxscore=0 spamscore=0 phishscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505280000 definitions=main-2507100139 Content-Type: text/plain; charset="utf-8" Add s390-specific SFrame format definitions. Note that SFRAME_ABI_* (and thus SFRAME_ABI_S390_ENDIAN_BIG) is currently unused. Include after "sframe.h" to make those s390-specific definitions available to architecture-specific unwind user sframe code, particularly the s390-specific one. Use the s390-specific definitions in the s390-specific unwind user sframe code to get rid of all the magic numbers. Signed-off-by: Jens Remus --- Notes (jremus): Alternatively the s390-specific definitions could also be added to the s390-specific unwind user sframe header. The current implementation follows Binutils approach to have all SFrame format definitions in one central header file. arch/s390/include/asm/unwind_user_sframe.h | 8 ++++---- kernel/unwind/sframe.c | 2 +- kernel/unwind/sframe.h | 16 ++++++++++++++++ 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/arch/s390/include/asm/unwind_user_sframe.h b/arch/s390/include= /asm/unwind_user_sframe.h index 2216e6921fd8..e5139cc2ba5a 100644 --- a/arch/s390/include/asm/unwind_user_sframe.h +++ b/arch/s390/include/asm/unwind_user_sframe.h @@ -7,16 +7,16 @@ =20 static inline s32 arch_sframe_cfa_offset_decode(s32 offset) { - return (offset << 3) + 160; + return SFRAME_V2_S390X_CFA_OFFSET_DECODE(offset); } =20 static inline void arch_sframe_set_frame_reginfo( struct unwind_user_reginfo *reginfo, s32 offset) { - if (offset & 1) { + if (SFRAME_V2_S390X_OFFSET_IS_REGNUM(offset)) { reginfo->loc =3D UNWIND_USER_LOC_REG; - reginfo->regnum =3D offset >> 1; + reginfo->regnum =3D SFRAME_V2_S390X_OFFSET_DECODE_REGNUM(offset); } else if (offset) { reginfo->loc =3D UNWIND_USER_LOC_STACK; reginfo->frame_off =3D offset; @@ -27,7 +27,7 @@ static inline void arch_sframe_set_frame_reginfo( =20 static inline s32 arch_sframe_sp_val_off(void) { - return -160; + return SFRAME_S390X_SP_VAL_OFFSET; } =20 #define sframe_cfa_offset_decode arch_sframe_cfa_offset_decode diff --git a/kernel/unwind/sframe.c b/kernel/unwind/sframe.c index e8658401a286..cd82de310c58 100644 --- a/kernel/unwind/sframe.c +++ b/kernel/unwind/sframe.c @@ -12,11 +12,11 @@ #include #include #include -#include #include =20 #include "sframe.h" #include "sframe_debug.h" +#include =20 struct sframe_fre { unsigned int size; diff --git a/kernel/unwind/sframe.h b/kernel/unwind/sframe.h index e9bfccfaf5b4..3e60b6e30b51 100644 --- a/kernel/unwind/sframe.h +++ b/kernel/unwind/sframe.h @@ -17,6 +17,7 @@ #define SFRAME_ABI_AARCH64_ENDIAN_BIG 1 #define SFRAME_ABI_AARCH64_ENDIAN_LITTLE 2 #define SFRAME_ABI_AMD64_ENDIAN_LITTLE 3 +#define SFRAME_ABI_S390X_ENDIAN_BIG 4 /* s390 64-bit (s390x) */ =20 #define SFRAME_FDE_TYPE_PCINC 0 #define SFRAME_FDE_TYPE_PCMASK 1 @@ -68,4 +69,19 @@ struct sframe_fde { #define SFRAME_FRE_OFFSET_SIZE(data) ((data >> 5) & 0x3) #define SFRAME_FRE_MANGLED_RA_P(data) ((data >> 7) & 0x1) =20 +/* s390 64-bit (s390x) */ + +#define SFRAME_S390X_SP_VAL_OFFSET (-160) + +#define SFRAME_S390X_CFA_OFFSET_ADJUSTMENT SFRAME_S390X_SP_VAL_OFFSET +#define SFRAME_S390X_CFA_OFFSET_ALIGNMENT_FACTOR 8 +#define SFRAME_V2_S390X_CFA_OFFSET_DECODE(offset) \ + (((offset) * SFRAME_S390X_CFA_OFFSET_ALIGNMENT_FACTOR) \ + - SFRAME_S390X_CFA_OFFSET_ADJUSTMENT) + +#define SFRAME_V2_S390X_OFFSET_IS_REGNUM(offset) \ + ((offset) & 1) +#define SFRAME_V2_S390X_OFFSET_DECODE_REGNUM(offset) \ + ((offset) >> 1) + #endif /* _SFRAME_H */ --=20 2.48.1