From nobody Fri Dec 19 15:01:48 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 E0B2B336EFE; Fri, 5 Dec 2025 17:15:28 +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=1764954932; cv=none; b=pmsFCOg08gLGxouqFyNu+CMZofTX5le58HKoIfZaS13d9Tsmw3frC2I7rXARlsojCmjFV6scKdMSK2EWheRB1rI8Klp8wcRdppJF5+gxwn+tFeJ4jMhNRlrPJCD5wHv7YcAkrgxsKPv2WO9fxQqb6HmZYbXs/MUSDrtuE4i1ewQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764954932; c=relaxed/simple; bh=0a+eKf1KW5ejSSq4eH6CMbHXPiDRaoGF3QvlZM1SXQU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sZAIinOrIq348cK30Mq0TCiIRPK9CRe0I7jW2umg+B5+iSnNB7wbZuKFDyzg7IWSh18UNB5RzpLs1lpKljlcvkL/Usn4mDtPjMgyJLocIyGfzYY0veaCPEfjlBHFHgpTwO1YhFT3c85TUiryoNRgUOM5I+hhiwyuudxVoZrBxes= 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=AdXhsXLr; 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="AdXhsXLr" 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 5B5BW4F0003482; Fri, 5 Dec 2025 17:14:54 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=g8Yq2CEK016UerPQC n8BIpK5q3lUk06mi10es+UamvM=; b=AdXhsXLrGaVMQr70KV+ctZ3n8hZAVUbOn gadBuVWEs4vdQK5mNpppYGEV8WojUl8+EN963MxGOC8O354MyxhAxKTACpuyREPa M/M+JR7LpeQLcQ3+6fvDMNSoDLgYzpWmT5aTC55H6v2RVC3LFfTSzbS96UrDUGR/ 4yPWTWQ/0JSSg/FMlWXi4Ep9BqdEFMTfmSBmkhDwMIBPeEUwTxRMiJ2pCvjj6E/Y su/qCz3hRbsUeGHMwogQbVeWvU/0ZUzJPSjUhEOQiOgK4EY5yePPzq5n/PmQBQZ7 Xf3Ybq6dtkAwynM76J6eKfFP8NqLIG0ceP+sL0jAArclZTv3NqSAw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4aqrg5x3bf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Dec 2025 17:14:54 +0000 (GMT) Received: from m0360072.ppops.net (m0360072.ppops.net [127.0.0.1]) by pps.reinject (8.18.1.12/8.18.0.8) with ESMTP id 5B5H6CC1002454; Fri, 5 Dec 2025 17:14:53 GMT 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 4aqrg5x3bc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Dec 2025 17:14:53 +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 5B5EgTSf019120; Fri, 5 Dec 2025 17:14:53 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4arbhyeedv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Dec 2025 17:14:52 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5B5HEnuE28115202 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 5 Dec 2025 17:14:49 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E8B0220040; Fri, 5 Dec 2025 17:14:48 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A332620043; Fri, 5 Dec 2025 17:14:48 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.87.85.9]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 5 Dec 2025 17:14:48 +0000 (GMT) From: Jens Remus To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-s390@vger.kernel.org, bpf@vger.kernel.org, x86@kernel.org, Steven Rostedt Cc: Jens Remus , Heiko Carstens , Vasily Gorbik , Ilya Leoshkevich , Josh Poimboeuf , Masami Hiramatsu , Mathieu Desnoyers , Peter Zijlstra , Ingo Molnar , Jiri Olsa , Arnaldo Carvalho de Melo , Namhyung Kim , Thomas Gleixner , Andrii Nakryiko , Indu Bhagat , "Jose E. Marchesi" , Beau Belgrave , Linus Torvalds , Andrew Morton , Florian Weimer , Kees Cook , "Carlos O'Donell" , Sam James , Dylan Hatch Subject: [RFC PATCH v2 01/15] unwind_user: Enhance comments on get CFA, FP, and RA Date: Fri, 5 Dec 2025 18:14:32 +0100 Message-ID: <20251205171446.2814872-2-jremus@linux.ibm.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251205171446.2814872-1-jremus@linux.ibm.com> References: <20251205171446.2814872-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: mkk7cpMuzwuua4Hbz_94I5_SzCr3o-86 X-Authority-Analysis: v=2.4 cv=Ir0Tsb/g c=1 sm=1 tr=0 ts=6933130e cx=c_pps a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==:17 a=wP3pNCr1ah4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=VnNF1IyMAAAA:8 a=GRZQj7fo7pb9Qcd1f_cA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMTI5MDAyMCBTYWx0ZWRfX075lNLc0quPo Zqkm6jVjnGEuL8MuudgXqxyB9f3cBIj/14K9sK4fiYlxwq2kdJG1TzuM0izzd0w8ad8FfryWWIB A+yZHJ2/Im0Q3ZFwFFOW42JsL3lGmgsV5ab3i7hC8CS8jeczKdPlB+9hxOY30rJhzcxvnHJ5dZG vBKha/H+kjIRERfbbAyeyE9YUdcvX52SFSLPwsHVnaLJPMpKvS8G81en/NKUFUJtslb5ZVPfrJZ TVN05efiYGYAzgmKG5sGhlMKYHc8/Awl/1k8XwTIeNTbCcwVYjoWMlWSyQKsi6Ohc5BLrXVWjOB ie/HwZE9ANDPSo7kWOzEGnS0raERwrxg8LaLb+7F2FcNC8TZegmI6gxIaKlTfp040zzYuj6DDZG 4LIIrBCFsVuXSwrAqD9re6rDcr/JvQ== X-Proofpoint-GUID: x7uEGM00FGLXzBbUnfTfgkicLGCtBQo1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-12-05_06,2025-12-04_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 adultscore=0 impostorscore=0 clxscore=1015 priorityscore=1501 bulkscore=0 spamscore=0 lowpriorityscore=0 suspectscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2510240000 definitions=main-2511290020 Content-Type: text/plain; charset="utf-8" Move the comment "Get the Canonical Frame Address (CFA)" to the top of the sequence of statements that actually get the CFA. Reword the comment "Find the Return Address (RA)" to "Get ...", as the statements actually get the RA. Add a respective comment to the statements that get the FP. This will be useful once future commits extend the logic to get the RA and FP. While at it align the comment on the "stack going in wrong direction" check to the following one on the "address is word aligned" check. Signed-off-by: Jens Remus --- 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 d053295b1f7e..f81c36ab2861 100644 --- a/kernel/unwind/user.c +++ b/kernel/unwind/user.c @@ -38,6 +38,7 @@ static int unwind_user_next_common(struct unwind_user_sta= te *state, return 0; } =20 + /* Get the Canonical Frame Address (CFA) */ if (frame->use_fp) { if (state->fp < state->sp) return -EINVAL; @@ -45,11 +46,9 @@ static int unwind_user_next_common(struct unwind_user_st= ate *state, } 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) return -EINVAL; =20 @@ -57,10 +56,11 @@ static int unwind_user_next_common(struct unwind_user_s= tate *state, if (cfa & (state->ws - 1)) return -EINVAL; =20 - /* Find the Return Address (RA) */ + /* Get the Return Address (RA) */ if (get_user_word(&ra, cfa, frame->ra_off, state->ws)) return -EINVAL; =20 + /* Get the Frame Pointer (FP) */ if (frame->fp_off && get_user_word(&fp, cfa, frame->fp_off, state->ws)) return -EINVAL; =20 --=20 2.51.0 From nobody Fri Dec 19 15:01:48 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 E90132D6E62; Fri, 5 Dec 2025 17:15:31 +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=1764954935; cv=none; b=LyBYF0YHSuDO+geKxT94Ag8BC6kFGxhmZUelLfsryeaaW8CDVfi1VohBPTeXjEJ+6Vd9LxV1JeamT1WMGSJusSyS0Q+mqQqqR016btR76g7GBWcKBSEcvT1I28VaxDUnYImK2Ton7VIPB44eOSvVD7owMN7qXXOyGD5gCO/ePkM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764954935; c=relaxed/simple; bh=LO7KSqmRttHfDWSnaLJdttrenWkMfVNrb5asgKtJh94=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LwqJd+uPLedAXAlQ2+RhcH2VfS/8Hd8k3Z/yQ+nArw0u+fpZHhUiZUYAkBpAhRP/ataItriuC+Kz0V+lCAxZ8J7OvZ4qtGfnLzD0VHT3xba0aUEBHmw72zpGlwOCRfZcqsXj3BOtsvOcpYajlpwzsVJPm5L0z4rvQPp0x0fjCjg= 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=AHL5+/vv; 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="AHL5+/vv" 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 5B58nfPt029716; Fri, 5 Dec 2025 17:14:54 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=ZrwD82QafFvHARSDa Xj8CqGCFuw2POsBCm8ZFs/aQCM=; b=AHL5+/vvaC/k8rb2yJ64JwTE9wmv/E9CR CwCzsUDD8TgnUW4GJyswkDFTsBU+gvzRIUBh3+tW+WPOuNsAsTrBkYwou0kLe/Z3 jd6jyPZKE/scU7mdDr6S0OEQM5qixtKPmab5KY74jCKEcZ5tP2hkfaFoZvGCDzdG VNjnZd+QyGE11YyH0z9/mIl31/hkJlrpkxojyQSxpz2fQtGXvWkAWlxRxeX9HTV9 nn6CPQir5QOYHnClaXa3PebrRVDCURFBwvoAUKYrSED1QfVrB6iPQ0Crb5Iu1eIg tSHt4mbDsnIFhwfgJc8jrkVG24G8ziv0ice0mahSOhTrlap946pYA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4aqq8v664j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Dec 2025 17:14:54 +0000 (GMT) Received: from m0353725.ppops.net (m0353725.ppops.net [127.0.0.1]) by pps.reinject (8.18.1.12/8.18.0.8) with ESMTP id 5B5HEr8n004196; Fri, 5 Dec 2025 17:14:54 GMT 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 4aqq8v664e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Dec 2025 17:14:53 +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 5B5FZ8v7029328; Fri, 5 Dec 2025 17:14:52 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 4ardv1x350-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Dec 2025 17:14:52 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5B5HEnfH61866414 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 5 Dec 2025 17:14:49 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3E83720040; Fri, 5 Dec 2025 17:14:49 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id ED2EE2004B; Fri, 5 Dec 2025 17:14:48 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.87.85.9]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 5 Dec 2025 17:14:48 +0000 (GMT) From: Jens Remus To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-s390@vger.kernel.org, bpf@vger.kernel.org, x86@kernel.org, Steven Rostedt Cc: Jens Remus , Heiko Carstens , Vasily Gorbik , Ilya Leoshkevich , Josh Poimboeuf , Masami Hiramatsu , Mathieu Desnoyers , Peter Zijlstra , Ingo Molnar , Jiri Olsa , Arnaldo Carvalho de Melo , Namhyung Kim , Thomas Gleixner , Andrii Nakryiko , Indu Bhagat , "Jose E. Marchesi" , Beau Belgrave , Linus Torvalds , Andrew Morton , Florian Weimer , Kees Cook , "Carlos O'Donell" , Sam James , Dylan Hatch Subject: [RFC PATCH v2 02/15] unwind_user/fp: Use dummies instead of ifdef Date: Fri, 5 Dec 2025 18:14:33 +0100 Message-ID: <20251205171446.2814872-3-jremus@linux.ibm.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251205171446.2814872-1-jremus@linux.ibm.com> References: <20251205171446.2814872-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: hfxDijMk8zT6-2nFdHEnDhhwdft3gAug X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMTI5MDAwOCBTYWx0ZWRfX7WDIoZH/Z1pc kVGluWZPiRJgnrV4SLpNrvQCvSAfFK2FnMbpr1QtHS2oihLE45L2Ei6uE/P9E+BZ5tWcrjVWTph RrB1uoOUjR22mbDqmI/wfNusrdp4aMWeS+a6DOstTGHPZaCp/fDLVtptFnPLx9q41MbDtbOlp+q j16zYQ+XFkuFVTpeLQDbwOuZ7Hu1zwu7U/c0wBJGc1/M+5YhvJGQuzBX72x2oZaeWU5OYHGnXpF wXIZSVKa4dDZvJ5yNegGntfQjlXnw1Hqq2vXe0zmaK6s9WjmEAyLhUiBHA/tJuzvCrYY+DX61kO V6nOekIw44Z5IUfrxgE9G3KvlK3S3soWE/kcsMlAZm3jlWgTdJRU1x6X6XujcVjnpABY09ZOhe5 2HB9QL3myHXDmC7KLuskPyXXOG/RMg== X-Authority-Analysis: v=2.4 cv=Scz6t/Ru c=1 sm=1 tr=0 ts=6933130e cx=c_pps a=aDMHemPKRhS1OARIsFnwRA==:117 a=aDMHemPKRhS1OARIsFnwRA==:17 a=wP3pNCr1ah4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=VnNF1IyMAAAA:8 a=pRS0VBzutSDFB64YrXgA:9 X-Proofpoint-GUID: mtk1nr0ebyrxbNXUxF_0U0ucU5oWzrKq X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-12-05_06,2025-12-04_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 phishscore=0 bulkscore=0 lowpriorityscore=0 adultscore=0 clxscore=1015 spamscore=0 impostorscore=0 priorityscore=1501 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2510240000 definitions=main-2511290008 Content-Type: text/plain; charset="utf-8" This simplifies the code. unwind_user_next_fp() does not need to return -EINVAL if config option HAVE_UNWIND_USER_FP is disabled, as unwind_user_start() will then not select this unwind method and unwind_user_next() will therefore not call it. Provide (1) a dummy definition of ARCH_INIT_USER_FP_FRAME, if the unwind user method HAVE_UNWIND_USER_FP is not enabled, (2) a common fallback definition of unwind_user_at_function_start() which returns false, and (3) a common dummy definition of ARCH_INIT_USER_FP_ENTRY_FRAME. Note that enabling the config option HAVE_UNWIND_USER_FP without defining ARCH_INIT_USER_FP_FRAME triggers a compile error, which is helpful when implementing support for this unwind user method in an architecture. Enabling the config option when providing an arch- specific unwind_user_at_function_start() definition makes it necessary to also provide an arch-specific ARCH_INIT_USER_FP_ENTRY_FRAME definition. Signed-off-by: Jens Remus --- Notes (jremus): Changes in v3: - Remove comment on #endif. (Ingo) =20 Changes in v2: - Add parameter ws to ARCH_INIT_USER_{FP_FRAME|FP_ENTRY_FRAME}. - Provide common fallback of unwind_user_at_function_start(). - Provide common dummy of ARCH_INIT_USER_FP_ENTRY_FRAME. - Reword commit message accordingly. arch/x86/include/asm/unwind_user.h | 1 + include/linux/unwind_user.h | 18 ++++++++++++++++-- kernel/unwind/user.c | 4 ---- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/arch/x86/include/asm/unwind_user.h b/arch/x86/include/asm/unwi= nd_user.h index f9a1c460150d..a528eee80dd6 100644 --- a/arch/x86/include/asm/unwind_user.h +++ b/arch/x86/include/asm/unwind_user.h @@ -37,6 +37,7 @@ static inline bool unwind_user_at_function_start(struct p= t_regs *regs) { return is_uprobe_at_func_entry(regs); } +#define unwind_user_at_function_start unwind_user_at_function_start =20 #endif /* CONFIG_HAVE_UNWIND_USER_FP */ =20 diff --git a/include/linux/unwind_user.h b/include/linux/unwind_user.h index 7f7282516bf5..64618618febd 100644 --- a/include/linux/unwind_user.h +++ b/include/linux/unwind_user.h @@ -5,8 +5,22 @@ #include #include =20 -#ifndef ARCH_INIT_USER_FP_FRAME - #define ARCH_INIT_USER_FP_FRAME +#ifndef CONFIG_HAVE_UNWIND_USER_FP + +#define ARCH_INIT_USER_FP_FRAME(ws) + +#endif + +#ifndef ARCH_INIT_USER_FP_ENTRY_FRAME +#define ARCH_INIT_USER_FP_ENTRY_FRAME(ws) +#endif + +#ifndef unwind_user_at_function_start +static inline bool unwind_user_at_function_start(struct pt_regs *regs) +{ + return false; +} +#define unwind_user_at_function_start unwind_user_at_function_start #endif =20 int unwind_user(struct unwind_stacktrace *trace, unsigned int max_entries); diff --git a/kernel/unwind/user.c b/kernel/unwind/user.c index f81c36ab2861..fdb1001e3750 100644 --- a/kernel/unwind/user.c +++ b/kernel/unwind/user.c @@ -74,7 +74,6 @@ static int unwind_user_next_common(struct unwind_user_sta= te *state, =20 static int unwind_user_next_fp(struct unwind_user_state *state) { -#ifdef CONFIG_HAVE_UNWIND_USER_FP struct pt_regs *regs =3D task_pt_regs(current); =20 if (state->topmost && unwind_user_at_function_start(regs)) { @@ -88,9 +87,6 @@ static int unwind_user_next_fp(struct unwind_user_state *= state) ARCH_INIT_USER_FP_FRAME(state->ws) }; return unwind_user_next_common(state, &fp_frame); -#else - return -EINVAL; -#endif } =20 static int unwind_user_next_sframe(struct unwind_user_state *state) --=20 2.51.0 From nobody Fri Dec 19 15:01:48 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 370A3346E75; Fri, 5 Dec 2025 17:15:31 +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=1764954936; cv=none; b=u17tew6zg7Mn0i6hQZIkqZ+0Cg77Dm5MkW0xCh7QvDTHOOSx5B9tM6PpywHQW2qi37k8gGFDczj2tiw5VST8KsjjRuCXDgBcXMo7BYoRbpc2ltLG3r5RMagpd/obyoGEsixDsP9TVSfNTlRFh0XdCVRnDtoFV0aYj0DZrdSKk6o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764954936; c=relaxed/simple; bh=06Jr8CXrnJ/jznLO5pfyGkCwQ+wJ2K+YghNV5NW6oLM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=G/OJMRNhuVd81tqLsk51U+BV8J6Jjr7AaaM02xApk13F3gtD0r1CEmbZnlTjdxsOUoevoHKKzyY9IF9xKdQghGePVBdIg3mgtpAgNBfm5sdS2x7NvVnhinL2AxYuf0zWTSHOYrXHuyZlMcvu5ukM4SLOquQ9Vc55+eJtBg0p+yk= 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=G3hxER3X; 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="G3hxER3X" 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 5B5BTO8v031345; Fri, 5 Dec 2025 17:14:55 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=l33Ta/FL4DYsJtSLL UG7m8ggvE9nAmSPbGGN3CmJWKg=; b=G3hxER3XPR+gFgpxkGHaLqVYU2n4kFP/E fQVUXwz+d364om4zkPv2W8MrIkVKWywAqZ+2u3TbRdiUQg109jGFoYJyL+XapsVH h7YeA8ma2Gi9Gp4uznPtzGfhjE92KVRWa/+xUrUCYWAJdATJsE3y2rDjKIh1VUXZ zQ/u+h9B+jbEZXareIgnLb68+lgxCeK1rHVbhvbU7LzUNMWJRaSGCR21n1MbHT7R o0Vbks4PDtF/semn+YMfUbuwq5Zea5mjJf2THHsl3AIV71TgiUEJn+zuhbwwSL8H H5CazufHoEwe+o/1dHR4f+y3ncEU9bAACl6YXchImERyv4VFUsBqA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4aqp8qeb4f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Dec 2025 17:14:54 +0000 (GMT) Received: from m0356516.ppops.net (m0356516.ppops.net [127.0.0.1]) by pps.reinject (8.18.1.12/8.18.0.8) with ESMTP id 5B5HBdjp010497; Fri, 5 Dec 2025 17:14:54 GMT 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 4aqp8qeb48-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Dec 2025 17:14:54 +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 5B5H4dmt024120; Fri, 5 Dec 2025 17:14:53 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 4arb5sxh4f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Dec 2025 17:14:53 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5B5HEnUh35586342 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 5 Dec 2025 17:14:49 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 83DC220040; Fri, 5 Dec 2025 17:14:49 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 42C5F2004E; Fri, 5 Dec 2025 17:14:49 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.87.85.9]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 5 Dec 2025 17:14:49 +0000 (GMT) From: Jens Remus To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-s390@vger.kernel.org, bpf@vger.kernel.org, x86@kernel.org, Steven Rostedt Cc: Jens Remus , Heiko Carstens , Vasily Gorbik , Ilya Leoshkevich , Josh Poimboeuf , Masami Hiramatsu , Mathieu Desnoyers , Peter Zijlstra , Ingo Molnar , Jiri Olsa , Arnaldo Carvalho de Melo , Namhyung Kim , Thomas Gleixner , Andrii Nakryiko , Indu Bhagat , "Jose E. Marchesi" , Beau Belgrave , Linus Torvalds , Andrew Morton , Florian Weimer , Kees Cook , "Carlos O'Donell" , Sam James , Dylan Hatch Subject: [RFC PATCH v2 03/15] x86/unwind_user: Guard unwind_user_word_size() by UNWIND_USER Date: Fri, 5 Dec 2025 18:14:34 +0100 Message-ID: <20251205171446.2814872-4-jremus@linux.ibm.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251205171446.2814872-1-jremus@linux.ibm.com> References: <20251205171446.2814872-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: AW1haW4tMjUxMTI5MDAwMCBTYWx0ZWRfX+CoUFGjSlwXk joFnVdTeWshW9rXTEihZccWMSOKu6s2xdgqILlHjs2xHoWfcthKv20EWzi2Zs0p4xikoJrP/FOl rF5QeZvmJLVIns/se7KOu3OwyV4S2jstDj8NwhZurQo72Vq/QQdmLsCwZlFhEZjvSwksNCOItH6 uXTg3oWFHns7HpF4iSyv5J6onmhtxVLmbMMFIhp9bdjwPzfizrXV0mZpQ8/fBwPpP4dNvNEjkh2 ojRB7TzjgiA5MaL9WperSFtK4jHqNBEajWMIN8bxvyrm3UKi+wGV+bXdd4SSUSQMsy/jABe+4Dg VzqWQ7CyAdZKS4J4wrmYJTl6WvKLW0ARz9Mvc2Z3dGwrsEO1fdsW58ICUd47aFD9RgztnDgoMHs 8EGHKUusFtJCbq03r5ey1nX5D/Nppw== X-Authority-Analysis: v=2.4 cv=dIerWeZb c=1 sm=1 tr=0 ts=6933130e cx=c_pps a=bLidbwmWQ0KltjZqbj+ezA==:117 a=bLidbwmWQ0KltjZqbj+ezA==:17 a=wP3pNCr1ah4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=VnNF1IyMAAAA:8 a=eSOB7Jb69V3AKTYxoYUA:9 X-Proofpoint-ORIG-GUID: MdVGY6p8Cx-v6qCVRq06Rfklfz750NMV X-Proofpoint-GUID: flsZe3_SW_hY4i2rhaHsPf0MRkxS-ute X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-12-05_06,2025-12-04_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 lowpriorityscore=0 clxscore=1015 spamscore=0 malwarescore=0 suspectscore=0 adultscore=0 bulkscore=0 impostorscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2510240000 definitions=main-2511290000 Content-Type: text/plain; charset="utf-8" The unwind user framework in general requires an architecture-specific implementation of unwind_user_word_size() to be present for any unwind method, whether that is fp or a future other method, such as potentially sframe. Guard unwind_user_word_size() by the availability of the UNWIND_USER framework instead of the specific HAVE_UNWIND_USER_FP method. This facilitates to selectively disable HAVE_UNWIND_USER_FP on x86 (e.g. for test purposes) once a new unwind method is added to unwind user. Signed-off-by: Jens Remus --- Notes (jremus): Changes in v3: - Move includes into more common UNWIND_USER guard at the top of the source. asm/ptrace.h is required for struct pt_regs. arch/x86/include/asm/unwind_user.h | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/arch/x86/include/asm/unwind_user.h b/arch/x86/include/asm/unwi= nd_user.h index a528eee80dd6..4d699e4954ed 100644 --- a/arch/x86/include/asm/unwind_user.h +++ b/arch/x86/include/asm/unwind_user.h @@ -2,11 +2,27 @@ #ifndef _ASM_X86_UNWIND_USER_H #define _ASM_X86_UNWIND_USER_H =20 -#ifdef CONFIG_HAVE_UNWIND_USER_FP +#ifdef CONFIG_UNWIND_USER =20 #include #include =20 +static inline int unwind_user_word_size(struct pt_regs *regs) +{ + /* We can't unwind VM86 stacks */ + if (regs->flags & X86_VM_MASK) + return 0; +#ifdef CONFIG_X86_64 + if (!user_64bit_mode(regs)) + return sizeof(int); +#endif + return sizeof(long); +} + +#endif /* CONFIG_UNWIND_USER */ + +#ifdef CONFIG_HAVE_UNWIND_USER_FP + #define ARCH_INIT_USER_FP_FRAME(ws) \ .cfa_off =3D 2*(ws), \ .ra_off =3D -1*(ws), \ @@ -21,18 +37,6 @@ .use_fp =3D false, \ .outermost =3D false, =20 -static inline int unwind_user_word_size(struct pt_regs *regs) -{ - /* We can't unwind VM86 stacks */ - if (regs->flags & X86_VM_MASK) - return 0; -#ifdef CONFIG_X86_64 - if (!user_64bit_mode(regs)) - return sizeof(int); -#endif - return sizeof(long); -} - static inline bool unwind_user_at_function_start(struct pt_regs *regs) { return is_uprobe_at_func_entry(regs); --=20 2.51.0 From nobody Fri Dec 19 15:01:48 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 4954734F476; Fri, 5 Dec 2025 17:15:39 +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=1764954944; cv=none; b=qwJs9k7JEXqr3s2O3fl0+q57C6TOAjq6i4EZmgMh8CZTz+qlrKfe547FdgHZS7xXDIIq/fnuxSK7CZThdbm6U7RCw+7pK8oIPBj2T/9aiR0FuJ2tmieDPzOexyzfsmjdpmFbVKhOr87vmwV3BrzNRoXd3ycSW7qGpm4xBURPeoQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764954944; c=relaxed/simple; bh=kaPUe9HEKn8n1z5tXB04hI3rzMgQLA6Ru2FLKn1YNjE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eeyR8vn46+UkSM+npnLw/wIGIH6eA2XdIRn0+5DcM7ZO4ON/UeXKeJXNPIP6NusmIkeMnNqZfALz08OJKDvitI3kt1GK2xE7TTVGBscan1Y9DhYHXOwIe7+YfhcpYqLyhZdYKJojfvy0n5QjEFMTQ53i4uQDNh3HjXBlpLWl2RY= 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=UVy29g8P; 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="UVy29g8P" 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 5B562uWx013225; Fri, 5 Dec 2025 17:14:55 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=0U9VOyhHCvaJ8UWLX 8BbR5hsyCDcsncf5gTti8J2pdY=; b=UVy29g8PcS7OpfgGLVEpTLWTS3Kodu8xJ 1hepYsUMezSP+heBzlNlkgzjBCFlrJsaT+1T0t2MuLHYN3YnfwsdlMrasjorjuxZ WitZ7J6bJrGCcPJ9kh3dX6N98glgZdKzrFRE1rdJ31Qyrbv4cd+RWr7/WvgqECcB 6S2/fpdcC+Nq/AXo9MJxmZslD/ndsbVoM+v98lENVUAbO/gWrEQaWnqMlv7kfxhn iLQLa3a3xSx7h0hNrMB5DBLlMMmVkH7r2hN0ZNYF3CofUkyGsynlIg79F4HwASVo EIeYeTBFlNo0qUmUYpDbrjg9fHZhLIOWc2LeP3x4ut/SlblNGwq/g== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4aqrja6v9d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Dec 2025 17:14:55 +0000 (GMT) Received: from m0356517.ppops.net (m0356517.ppops.net [127.0.0.1]) by pps.reinject (8.18.1.12/8.18.0.8) with ESMTP id 5B5H2tBS009862; Fri, 5 Dec 2025 17:14:55 GMT 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 4aqrja6v9a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Dec 2025 17:14:54 +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 5B5FBcKa003864; Fri, 5 Dec 2025 17:14:53 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 4ardck65pp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Dec 2025 17:14:53 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5B5HEnTk61866418 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 5 Dec 2025 17:14:50 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C9EB12004F; Fri, 5 Dec 2025 17:14:49 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 888FA2004B; Fri, 5 Dec 2025 17:14:49 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.87.85.9]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 5 Dec 2025 17:14:49 +0000 (GMT) From: Jens Remus To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-s390@vger.kernel.org, bpf@vger.kernel.org, x86@kernel.org, Steven Rostedt Cc: Jens Remus , Heiko Carstens , Vasily Gorbik , Ilya Leoshkevich , Josh Poimboeuf , Masami Hiramatsu , Mathieu Desnoyers , Peter Zijlstra , Ingo Molnar , Jiri Olsa , Arnaldo Carvalho de Melo , Namhyung Kim , Thomas Gleixner , Andrii Nakryiko , Indu Bhagat , "Jose E. Marchesi" , Beau Belgrave , Linus Torvalds , Andrew Morton , Florian Weimer , Kees Cook , "Carlos O'Donell" , Sam James , Dylan Hatch Subject: [RFC PATCH v2 04/15] s390: asm/dwarf.h should only be included in assembly files Date: Fri, 5 Dec 2025 18:14:35 +0100 Message-ID: <20251205171446.2814872-5-jremus@linux.ibm.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251205171446.2814872-1-jremus@linux.ibm.com> References: <20251205171446.2814872-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-GUID: zFe8HpvCA9VbDdwEXg3Af02nT6U1ypeY X-Proofpoint-ORIG-GUID: WQQqPZ2nyQxhim56UGojHHGGvWDhM7Ys X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMTI5MDAyMCBTYWx0ZWRfX6U+c3bxo51oh wd4gX+tK7MZlKkaW05TX/u5nn1PXxGtdEPOaStAkXNUGmxlNUGk1R0jgvdoSAPeSZUnf7r7xOh9 aWJM/H5ih0sVawYNolAsZT4NOwY3/AlQOOrymUKi1QvKjFewysL2o1ZDH/pn1nstJlnBfw9Xc0A F8soKFH7FbHPRaqK/5f6wjXP9FkTrOLcBE+r/WUpxm+XKaMwVtNve4SXPGD4GZ4c2wTUnpCCejH eNpL48NMt+R5dxYeaU+kXcYt06e0Hp9COv2Pdloys3tJ4EhhrnSTpsk7y9Wbrct9oLrk+czY7dq 4/pnir5b9F9LNZ8BpN6pvhD/70EvJE/J/YDZ7a/tZzQhh4Gs9j6CZNidnERUAJzFmMLdZz8waA7 0WPuvMYt5S5ZyJTspOMxs862Nv0sIQ== X-Authority-Analysis: v=2.4 cv=dYGNHHXe c=1 sm=1 tr=0 ts=6933130f cx=c_pps a=AfN7/Ok6k8XGzOShvHwTGQ==:117 a=AfN7/Ok6k8XGzOShvHwTGQ==:17 a=62EC5onNXgn9lpaB:21 a=wP3pNCr1ah4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=VnNF1IyMAAAA:8 a=AB0lExOjSfRHyy3z6bMA:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-12-05_06,2025-12-04_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 spamscore=0 suspectscore=0 clxscore=1015 adultscore=0 lowpriorityscore=0 bulkscore=0 phishscore=0 priorityscore=1501 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2510240000 definitions=main-2511290020 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 --- Notes (jremus): Changes in RFC v2: - Adjust to upstream change of __ASSEMBLY__ to __ASSEMBLER__. 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 e3ad6798d0cd..df9f467910f7 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 __ASSEMBLER__ +#ifndef __ASSEMBLER__ +#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 /* __ASSEMBLER__ */ - #endif /* _ASM_S390_DWARF_H */ --=20 2.51.0 From nobody Fri Dec 19 15:01:48 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 9C9FA34F490; Fri, 5 Dec 2025 17:15:39 +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=1764954945; cv=none; b=SPw3os03VE5gFxtWzRYLb5Z6znCdH6msTrjzQj1q8oi0GotHGNUiHIE5CUAYGrTbtkwcuEh+74vm60gKHzb4bzHS4AMW9iiYFz8ljqaGtQi/Fz+f3zkInyLG+dilrYps/r6qO7pC6Ptp7Srny/8kjqo3V/TEzR09KpU9MrxkQeI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764954945; c=relaxed/simple; bh=n4UqXtWKP9aM7+of2a9zTKNpugsdsHjeuZZ9Y6vQt1g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eWtbkm4K8YTon1bl7cxWyl5rQQ7kP8Ljx4UKFgfudFZjHLymXk/RQHLGYAxFH7XjnrX1AePRepG+MuH1Cqq2yWXM4WJ8JcSjY9cnUZT1Fz27cqf0qa8ll6UZr3DhbV9LeypqkEZENBH4IuyhEkKhxLw7Ar1by+EGzQZJA+vLy/Y= 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=SqzYXw8B; 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="SqzYXw8B" 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 5B5FoJau026734; Fri, 5 Dec 2025 17:14:56 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=YwkCBIDx+CdwD1PaP 1iGkMwFtK6nggvYnNMUdWID+FY=; b=SqzYXw8BvnBgmnJEn08f1YgI7hOAOD+WW wb2fvvjCmGmwloFlWzYpjvYDuKotVwJq/RW+wX5vco9f2wdEFMlBKv2wbIYuBp4+ dTnTnOSnU7dxkr7F89Jw4hVo+z0mLsqtMf8yNNlCpWNg1DyxyUGPLy9JgF5z+BBT rPsjeYD0dwKUyhj+r94wgws3bMPhTKJ3gEHVi2lkciQq+KXjyezyJWz1U6t6mhX7 FKy5woedKWfSMweSirutQRsbwJ5HAmarRucqikcukd/IrNNPMeoE70BiUg2JRL51 wz8YaQtaW2Yzru6q9hIVAJy5LrCJgP1jSsSHq5LEFygVWwF2ITfow== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4aqrh7ey3m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Dec 2025 17:14:56 +0000 (GMT) Received: from m0353729.ppops.net (m0353729.ppops.net [127.0.0.1]) by pps.reinject (8.18.1.12/8.18.0.8) with ESMTP id 5B5HARnV011228; Fri, 5 Dec 2025 17:14:55 GMT 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 4aqrh7ey3f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Dec 2025 17:14:55 +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 5B5EgTSg019120; Fri, 5 Dec 2025 17:14:54 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4arbhyeee0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Dec 2025 17:14:54 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5B5HEone49152258 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 5 Dec 2025 17:14:50 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1B9D12004F; Fri, 5 Dec 2025 17:14:50 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CED7920043; Fri, 5 Dec 2025 17:14:49 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.87.85.9]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 5 Dec 2025 17:14:49 +0000 (GMT) From: Jens Remus To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-s390@vger.kernel.org, bpf@vger.kernel.org, x86@kernel.org, Steven Rostedt Cc: Jens Remus , Heiko Carstens , Vasily Gorbik , Ilya Leoshkevich , Josh Poimboeuf , Masami Hiramatsu , Mathieu Desnoyers , Peter Zijlstra , Ingo Molnar , Jiri Olsa , Arnaldo Carvalho de Melo , Namhyung Kim , Thomas Gleixner , Andrii Nakryiko , Indu Bhagat , "Jose E. Marchesi" , Beau Belgrave , Linus Torvalds , Andrew Morton , Florian Weimer , Kees Cook , "Carlos O'Donell" , Sam James , Dylan Hatch Subject: [RFC PATCH v2 05/15] s390/vdso: Avoid emitting DWARF CFI for non-vDSO Date: Fri, 5 Dec 2025 18:14:36 +0100 Message-ID: <20251205171446.2814872-6-jremus@linux.ibm.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251205171446.2814872-1-jremus@linux.ibm.com> References: <20251205171446.2814872-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=dK+rWeZb c=1 sm=1 tr=0 ts=69331310 cx=c_pps a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==:17 a=wP3pNCr1ah4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=VwQbUJbxAAAA:8 a=meVymXHHAAAA:8 a=VnNF1IyMAAAA:8 a=BeDKgDnIR9-QKG0Pbi4A:9 a=2JgSa4NbpEOStq-L5dxp:22 X-Proofpoint-GUID: I6owunHUd76ubwXa1thWJ8JjoIn5Mz3r X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMTI5MDAyMCBTYWx0ZWRfX+xMnkIeN5F0h iqRaf3KwcyUXbCDx5LjC/Q2Y2lWxfBbWkG5cD+0zmcRJi1ycKgurVq1MKtysy+Ai+HY4ssAMlrl UyUSVicJKMe0IJouO4PcCQfdTVkwlb/SbSvrUvWOxez+feaNPAS0D+HUz4RNmWrhB5Y2c1LslxU ebNUkWoJxQCyDWiTHwzJhtzJiqOTFPp5PwC6pMJaHVixlr5NsdT6WBpCSFVPq9XI0VxSDUjOd4B dtHXa4n5H67W1qFpHTrjMrGDwh/jrjdLbPY+VFpqqVsTqLAbxkyODJyZfxuywSD1wWeo7KEcq3u OE0zpW8HWQ4iPZF6mq5EFh3HsNUaOf80p1ZNyeETkxHsbN9eOOD5Rj2i7z/yGlP1d0x0fEboVVX +GeW/HIEM4aVWX6odyBBiVC44dHOxg== X-Proofpoint-ORIG-GUID: 22VuX9DZGyh6GFv98gNBhplTvioN6VoE X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-12-05_06,2025-12-04_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 lowpriorityscore=0 clxscore=1015 priorityscore=1501 bulkscore=0 adultscore=0 phishscore=0 impostorscore=0 spamscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2510240000 definitions=main-2511290020 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 df9f467910f7..6bcf37256feb 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.51.0 From nobody Fri Dec 19 15:01:48 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 C09132586C8; Fri, 5 Dec 2025 17:15:42 +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=1764954947; cv=none; b=ZC7OExJehzgRl9ebLClMw7rBI2Yty5tIXrPpqupDgZn39CwTGWwpIIZdcKGXWjPYmvX6kGHMpdl4XbQGpDxUcPEBUUCbgPht3GCwVAf05zXpHkgQJLqjruF2YjTHQUEyDFg48D0ij4KO4K+JySFeRNq5Eq39uX+qrTnzozlrd48= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764954947; c=relaxed/simple; bh=uTTzdrUeqQbjvXCuDlyz0FReyMWGuAsohw0+59rIUb8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NHgpyElKZuEdj4eLLYOIMa6KO8zha4sw9qZ5xDXSxe9fFXBow9BnbrEiOHtbeeCGQKoCNHJAoBjVTenSlQyma0Slihg9RGwLDJ+QbKwJeSGEpzLFArXRWf0sqKHF5eUiUjL0OxuANiDOLrNh2hQxs5tGkTJlfmXwEkZ83wzT7VY= 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=L9xY8cik; 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="L9xY8cik" 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 5B5GW9h6008240; Fri, 5 Dec 2025 17:14:56 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=QbfSqQzLjksgns1mI C3zXh+jcYNMEleD5cIrau6YfF0=; b=L9xY8cikd86K5+/GRgHS2HUKhGAexYG5a pbxey+B302vTeoFgmp1IK3mFHQ4IAvfWyJK+FRJ5MfFLYyILmlUnjBIH6TKCZJXv TLahE0K7GKah0Uo1tlEU8h369wcJCmhYjhH7z0KAgQLSjhk8bZLYG91SS9fXp9Sm asv8cIRfUsXDVC/lhCqKTX58HYhBnv7CK0zMoRaxH7pRa8Z7sudJPzVsDh0hjSsE rJAEJfnvc2htjVm/Umg3k4rdBWaUpKuGk4dWW3/DBs+tv+D5bv5U9CR0xiSk7K/O PT3h6DWTRU/s07cDhWb0tUm774KUr2LOSRLxy4UrVSHrQ4zvCFLyA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4aqrbgq43b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Dec 2025 17:14:56 +0000 (GMT) Received: from m0360083.ppops.net (m0360083.ppops.net [127.0.0.1]) by pps.reinject (8.18.1.12/8.18.0.8) with ESMTP id 5B5HBWWu012503; Fri, 5 Dec 2025 17:14:55 GMT 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 4aqrbgq435-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Dec 2025 17:14:55 +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 5B5G2Wbi029392; Fri, 5 Dec 2025 17:14:54 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 4ardv1x353-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Dec 2025 17:14:54 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5B5HEole56230194 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 5 Dec 2025 17:14:50 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6A6E32004E; Fri, 5 Dec 2025 17:14:50 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 24AB020063; Fri, 5 Dec 2025 17:14:50 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.87.85.9]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 5 Dec 2025 17:14:50 +0000 (GMT) From: Jens Remus To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-s390@vger.kernel.org, bpf@vger.kernel.org, x86@kernel.org, Steven Rostedt Cc: Jens Remus , Heiko Carstens , Vasily Gorbik , Ilya Leoshkevich , Josh Poimboeuf , Masami Hiramatsu , Mathieu Desnoyers , Peter Zijlstra , Ingo Molnar , Jiri Olsa , Arnaldo Carvalho de Melo , Namhyung Kim , Thomas Gleixner , Andrii Nakryiko , Indu Bhagat , "Jose E. Marchesi" , Beau Belgrave , Linus Torvalds , Andrew Morton , Florian Weimer , Kees Cook , "Carlos O'Donell" , Sam James , Dylan Hatch Subject: [RFC PATCH v2 06/15] s390/vdso: Keep function symbols in vDSO Date: Fri, 5 Dec 2025 18:14:37 +0100 Message-ID: <20251205171446.2814872-7-jremus@linux.ibm.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251205171446.2814872-1-jremus@linux.ibm.com> References: <20251205171446.2814872-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: rbC8D40I834cE8LCNvIl0TcXcM7u1qgW X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMTI5MDAxNiBTYWx0ZWRfX0JrIZUXQ+e1a TKYGVFY0yJzn+ZFIGLPnP5Gn5xRL0qOjVfoOi56Z011d5yekavFTVfOTR9jvFIQFp1mFl36zvIK jokT8uhkE5eTU7/JYrpL2YTYJKZ5DMhzkNgy5yIuzbP13GtXeRuialGj1IDUE3kTlr9HVSxLkmt 6aJovOwQ9FuLES4glfBTA8B2yABUUSZ8ltgtEvN7vwESszi+rHSh/PFDFOwZSeePeE1GPNJo659 bLXWEC9rVATDaGurhCmqj9e1/5wkuvBHmAFs1AHv5d48TRrUEf8s8dNsqA9+7Vqp/F5Mn8knn2b tgYjl+mDle6aV+9daJBR7W+Fqczz5A4412g4TPs+qlegiLUg2TZ5tSuSiOJp8ZT2feh1pvnP1a7 ZtNRO0w9KetX8/grQkj74mjdeCVmow== X-Authority-Analysis: v=2.4 cv=UO7Q3Sfy c=1 sm=1 tr=0 ts=69331310 cx=c_pps a=aDMHemPKRhS1OARIsFnwRA==:117 a=aDMHemPKRhS1OARIsFnwRA==:17 a=wP3pNCr1ah4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=VwQbUJbxAAAA:8 a=meVymXHHAAAA:8 a=VnNF1IyMAAAA:8 a=BBANP_1BnTx_iyBG_wsA:9 a=2JgSa4NbpEOStq-L5dxp:22 X-Proofpoint-GUID: -pY_xVkp3jvLOrp7z4Vh2HR3elIvWtnH X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-12-05_06,2025-12-04_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 malwarescore=0 bulkscore=0 adultscore=0 priorityscore=1501 impostorscore=0 spamscore=0 phishscore=0 clxscore=1015 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2510240000 definitions=main-2511290016 Content-Type: text/plain; charset="utf-8" Keep all function symbols in the vDSO .symtab for stack trace purposes. This enables a stack tracer, such as perf, to lookup these function symbols in addition to those already exported in vDSO .dynsym. Signed-off-by: Jens Remus --- Notes (jremus): Changes in RFC v2: - Use objcopy flag "-g" instead of "-S" with the cumbersome filter "-w -K "__arch_*" -K "__cvdso_*" -K "__s390_vdso_*" to keep the function symbols, as Josh did in "x86/vdso: Enable sframe generation in VDSO": https://lore.kernel.org/all/20250425024023.173709192@goodmis.org/ - Reword commit message. =20 Note that unlike Josh I did not squash this into the subsequent patch "s390/vdso: Enable SFrame generation in vDSO", as this change is unrelated to enabling the use of SFrame. perf report/script do also benefit from this change when using perf record --call-graph dwarf. =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 report/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 d8f0df742809..8e78dc3ba025 100644 --- a/arch/s390/kernel/vdso64/Makefile +++ b/arch/s390/kernel/vdso64/Makefile @@ -53,7 +53,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 -g $(obj)/%.so: $(obj)/%.so.dbg FORCE $(call if_changed,objcopy) =20 --=20 2.51.0 From nobody Fri Dec 19 15:01:48 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 5FFCF17C77; Fri, 5 Dec 2025 17:15:28 +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=1764954934; cv=none; b=e7npAE9uyTEtGMBQyeBz63MgP5DbYUIaiQV18rfPR89aQet0pbLbzzE6qKborJzStfO340b9BbjKs5w0FHDKBq9ozzNR/41Ipm9OJaH0Q+l41z1882nDeqIIHxKR8QKdZEjOt0vpneex+QawS861jUXZ0Vv2OoqRS8u0Cp4nsYM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764954934; c=relaxed/simple; bh=Ig76xTemWnBp5V9wcafXhVnewT4GyeDWXCD4NFeuEEI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DuiJHJP16n3/1DAECSG1xjRrkQRUWg7reFvSbW/eujQ9VMzNJM2o6jdJzEMC0Wpx/F2VPTqgXXckU2N9IwMZu9qniu2AWqBLe9iU0RFkeB+wRT50nphyy4z6prhe2A1/y/8mL3DA8rHzcjjPllycMy6yUOqnXgDXvZByyA0upbk= 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=E30KpZ3e; 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="E30KpZ3e" 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 5B5Bjoj5026038; Fri, 5 Dec 2025 17:14:56 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=XDw2tSBsdhyOzenUT DEc+daDW0YtX3pVwUrUg8mkf/0=; b=E30KpZ3eIsEL7vt4qiVGSW8nz6YC893yl 3l7S/DWxwLMgqcdmM6gJkkhMwn3rVTxcDuVwYvUNlgqIhFUUdRMuqwAr9ZIyAMFR MT2dRUfRtb9bWKagDJBJyTpGnGZPvxmXSg3D9xGvTwTo+CtKUBjPTD03ilPhIuwT 9BlqeRaxpMr/7udNzWZzX7//0qM9x6wizcNZQKeUobzJl+Vf3FJLejH1ZTJR+p/E eNOvBP/wV99HJjPfs6Osk5zDVOYKcoH98PdbaSqXQk+3wPkyTIZCUpTji7lMc37A N7cF6XiVPt1+sgxdut1QeV0ivevSR2YeJb+HcjoZWxfrUDuuzBppw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4aqq8v664s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Dec 2025 17:14:56 +0000 (GMT) Received: from m0353725.ppops.net (m0353725.ppops.net [127.0.0.1]) by pps.reinject (8.18.1.12/8.18.0.8) with ESMTP id 5B5HEtmh004440; Fri, 5 Dec 2025 17:14:55 GMT 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 4aqq8v664m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Dec 2025 17:14:55 +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 5B5H9aEP024071; Fri, 5 Dec 2025 17:14:54 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 4arb5sxh4m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Dec 2025 17:14:54 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5B5HEoIh35586536 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 5 Dec 2025 17:14:50 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B279320043; Fri, 5 Dec 2025 17:14:50 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6EFB72004F; Fri, 5 Dec 2025 17:14:50 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.87.85.9]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 5 Dec 2025 17:14:50 +0000 (GMT) From: Jens Remus To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-s390@vger.kernel.org, bpf@vger.kernel.org, x86@kernel.org, Steven Rostedt Cc: Jens Remus , Heiko Carstens , Vasily Gorbik , Ilya Leoshkevich , Josh Poimboeuf , Masami Hiramatsu , Mathieu Desnoyers , Peter Zijlstra , Ingo Molnar , Jiri Olsa , Arnaldo Carvalho de Melo , Namhyung Kim , Thomas Gleixner , Andrii Nakryiko , Indu Bhagat , "Jose E. Marchesi" , Beau Belgrave , Linus Torvalds , Andrew Morton , Florian Weimer , Kees Cook , "Carlos O'Donell" , Sam James , Dylan Hatch Subject: [RFC PATCH v2 07/15] s390/vdso: Enable SFrame generation in vDSO Date: Fri, 5 Dec 2025 18:14:38 +0100 Message-ID: <20251205171446.2814872-8-jremus@linux.ibm.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251205171446.2814872-1-jremus@linux.ibm.com> References: <20251205171446.2814872-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: OvygtJfHt49xuN1AlhupT-W9xEwANQsb X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMTI5MDAwOCBTYWx0ZWRfXxog9xW2GVq9Y M9lHy5o0oQc9XAJUQH5aZ1qhdAucheciuHtTTd4MC2zy2OSVX9ux9o+am6qnZECAFhqstaHOAaB hQy3mxolG2jPiw8sH7+IkBQAZjrpXuuX5E8ylQgjitgiWkkuTJgk+dAvysIrIBpjnwT07kWt5l9 QNVqpxC0nea4EvV9gKD74igw0SU/pQ9K3xc74s9IyzbBMuMld6kzOGSpVaSatBn/mQFlKb0sm2A okOZ2GakzmpFumJCKrveeQH2lrHVZw9JHmWR+gcTcBrn54L4GSSbHHSAHokS69po1J2UiwwpAVq csfp2kMnlpTWB06CdpSBXf+IBtrSY2WPdK6ffhHuGVkApw8XefaiWa93VZtozXbiwt9GCuK9DBm LPj4a/O8YoZZ2ob5bCaSC/T4hwaq7g== X-Authority-Analysis: v=2.4 cv=Scz6t/Ru c=1 sm=1 tr=0 ts=69331310 cx=c_pps a=bLidbwmWQ0KltjZqbj+ezA==:117 a=bLidbwmWQ0KltjZqbj+ezA==:17 a=wP3pNCr1ah4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=VwQbUJbxAAAA:8 a=meVymXHHAAAA:8 a=VnNF1IyMAAAA:8 a=dAJiN8YmCtcRjYQ6G8MA:9 a=2JgSa4NbpEOStq-L5dxp:22 X-Proofpoint-GUID: nflwbrWN7yLoguSeV1zeq_mO3GRzyfG3 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-12-05_06,2025-12-04_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 phishscore=0 bulkscore=0 lowpriorityscore=0 adultscore=0 clxscore=1015 spamscore=0 impostorscore=0 priorityscore=1501 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2510240000 definitions=main-2511290008 Content-Type: text/plain; charset="utf-8" This replicates Josh's x86 patch "x86/vdso: Enable sframe generation in VDSO" [1] for s390. Test whether the assembler supports generating SFrame stack trace information. Note that it is insufficient to test whether the assembler supports option --gsframe, as GNU assembler supports that regardless of whether it is actually capable of generating SFrame stack trace information for the architecture. If so enable SFrame stack trace information generation in the vDSO library so kernel and user space can unwind through it. [1]: x86/vdso: Enable sframe generation in VDSO, https://lore.kernel.org/all/20250425024023.173709192@goodmis.org/ Signed-off-by: Jens Remus --- Notes (jremus): Changes in RFC v2: - Introduce config option AS_SFRAME instead of requiring Josh's x86 patch as pre-requisite. - Reword commit message. =20 Link to Josh's latest x86 patch: https://lore.kernel.org/all/20250425024023.173709192@goodmis.org/ arch/Kconfig | 3 +++ arch/s390/include/asm/dwarf.h | 4 ++++ arch/s390/kernel/vdso64/Makefile | 7 ++++++- arch/s390/kernel/vdso64/vdso64.lds.S | 9 +++++++++ 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/arch/Kconfig b/arch/Kconfig index 06c4f909398c..7fa89d70b244 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -482,6 +482,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/s390/include/asm/dwarf.h b/arch/s390/include/asm/dwarf.h index 6bcf37256feb..2f148b15fd7d 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 8e78dc3ba025..f597f3b863d7 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..0205d84369ca 100644 --- a/arch/s390/kernel/vdso64/vdso64.lds.S +++ b/arch/s390/kernel/vdso64/vdso64.lds.S @@ -50,6 +50,11 @@ SECTIONS =20 .eh_frame_hdr : { *(.eh_frame_hdr) } :text :eh_frame_hdr .eh_frame : { KEEP (*(.eh_frame)) } :text + +#ifdef CONFIG_AS_SFRAME + .sframe : { *(.sframe) } :text :sframe +#endif + .gcc_except_table : { *(.gcc_except_table .gcc_except_table.*) } =20 .rela.dyn ALIGN(8) : { *(.rela.dyn) } @@ -114,6 +119,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 +131,9 @@ PHDRS dynamic PT_DYNAMIC FLAGS(4); /* PF_R */ note PT_NOTE FLAGS(4); /* PF_R */ eh_frame_hdr PT_GNU_EH_FRAME; +#ifdef CONFIG_AS_SFRAME + sframe PT_GNU_SFRAME; +#endif } =20 /* --=20 2.51.0 From nobody Fri Dec 19 15:01:48 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 DC4ED1FF7C5; Fri, 5 Dec 2025 17:15:33 +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=1764954937; cv=none; b=QWDI13nQW/N27i2XjMgw/Y4d8D7YjdI8j6eQSGjCqBAjl4Ft4mg30lfiD4cn0qxVsdV26dl/Ax2kZx6mUfMZ3NAH0Jv5ddBMiq0nRFajbMQKUmm3MzImBxZVz+3x21ZTNzFi2mr3/doOn0N7+44tNRl7G7O6KJF2ET8RCnEUYoM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764954937; c=relaxed/simple; bh=MCWyQETxtvllGFIFKl6xSPoQZhSeiVvaKl1pfQKbFGw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=THMCc4+kVZNTyY4LTF+s/SAjU6ymglGD0ZxeKLqR3NgKjjYu4gA3CxJr+M6PT91pyxKa6UXoDPN9rYCViEQMxLb0KO4zcbCiyn4Q9nLMO9BX50NDKGeLPs4RkhzmAhcPEIay5aaY79BPyNPRa3+O2X+rYHBRvnuJt5MiBVh+2yk= 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=RVl5usaW; 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="RVl5usaW" 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 5B5Dmi46010190; Fri, 5 Dec 2025 17:14:56 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=lWzs9539f/hn3ssMI KjEpfKR/q0Qojbj3UelDuXSlec=; b=RVl5usaWzUofIND9oCTdlR/ADLIXpIo5C fPuDDAb75lCv5zkTRcMb/EbUcQqQRWJLLSuqrzMxdsF9eeW8C0zr767Cc7g/IvzR DGyYc145gxId4HhHKs2dZ0ERQig+V7fYTXmMY/Ji8WWN3QQ8u5IG91DOGEAP6Bpw 5LGF2vB4hIYhUeBzEFYLCKjYskoZ9QEkxowz8SXDqihUSREDVbZkBxSveeFEIaG6 R8IGp+FofeR4fY9WC0WT7siAe+9/B4BNm4t6pIgOETJipSGQ//QEaPriXkrcLaKb 0q+cK2GrcgJryKTlUakDloFy80jlw//8DSOaUXi6OersL96zPReyA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4aqp8qeb4n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Dec 2025 17:14:56 +0000 (GMT) Received: from m0356516.ppops.net (m0356516.ppops.net [127.0.0.1]) by pps.reinject (8.18.1.12/8.18.0.8) with ESMTP id 5B5HEtxK017482; Fri, 5 Dec 2025 17:14:56 GMT 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 4aqp8qeb4k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Dec 2025 17:14:55 +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 5B5FxERo029361; Fri, 5 Dec 2025 17:14:55 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 4ardv1x357-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Dec 2025 17:14:54 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5B5HEpGI11993368 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 5 Dec 2025 17:14:51 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 06A4020043; Fri, 5 Dec 2025 17:14:51 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B60A42004B; Fri, 5 Dec 2025 17:14:50 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.87.85.9]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 5 Dec 2025 17:14:50 +0000 (GMT) From: Jens Remus To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-s390@vger.kernel.org, bpf@vger.kernel.org, x86@kernel.org, Steven Rostedt Cc: Jens Remus , Heiko Carstens , Vasily Gorbik , Ilya Leoshkevich , Josh Poimboeuf , Masami Hiramatsu , Mathieu Desnoyers , Peter Zijlstra , Ingo Molnar , Jiri Olsa , Arnaldo Carvalho de Melo , Namhyung Kim , Thomas Gleixner , Andrii Nakryiko , Indu Bhagat , "Jose E. Marchesi" , Beau Belgrave , Linus Torvalds , Andrew Morton , Florian Weimer , Kees Cook , "Carlos O'Donell" , Sam James , Dylan Hatch Subject: [RFC PATCH v2 08/15] unwind_user: Enable archs that define CFA = SP_callsite + offset Date: Fri, 5 Dec 2025 18:14:39 +0100 Message-ID: <20251205171446.2814872-9-jremus@linux.ibm.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251205171446.2814872-1-jremus@linux.ibm.com> References: <20251205171446.2814872-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: AW1haW4tMjUxMTI5MDAwMCBTYWx0ZWRfXygSk4+VdmqiU orH4e5PHWs6FyEG2L6wMRo+SanEayBoMKU6veus/Ogkjj6A32D9bpdFojMyRwyzknmneSDftwyg kGE7rd7gG5pYaQ81x55b832c5vNQe0/6Cnc5UI83wHzy+2yf63NcwUi4q8ov4DmMJgnUpTIg02C Hj7dyoF5wxVLpY79QwRI0V7IWQAadAJOlUSih/Yd2jAswbsGQgG/k02Yl6X7yAKYkLGL3nenRqq 9qm/6Xbqau4M4MxIJaqnb9E5vowERWyDjlJFFjCiif2C7R66lKr0TNQccy0bKpa3HWApCvBhfR/ VYbwm6BPeMX+IRzkUiaWB4dO6SCbyFk48hedpY4vpCqpYRK2nbcu+4MmnjM95GB2oNvrT1dGLex HCGxnNjpQJ9/NwhXhqM/Xu+XUXgr6A== X-Authority-Analysis: v=2.4 cv=dIerWeZb c=1 sm=1 tr=0 ts=69331310 cx=c_pps a=aDMHemPKRhS1OARIsFnwRA==:117 a=aDMHemPKRhS1OARIsFnwRA==:17 a=wP3pNCr1ah4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=VnNF1IyMAAAA:8 a=D-3WH5monn3MMgO2UeQA:9 X-Proofpoint-ORIG-GUID: eQsmupYaf2RzB4oO1mvCIAA8S8CXYDFE X-Proofpoint-GUID: y2RqEz9HuHi3DuxRi0COcZI6oXEgs71M X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-12-05_06,2025-12-04_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 lowpriorityscore=0 clxscore=1015 spamscore=0 malwarescore=0 suspectscore=0 adultscore=0 bulkscore=0 impostorscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2510240000 definitions=main-2511290000 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. Therefore the SP at call site can be unwound using an implicitly assumed value offset from CFA rule with an offset of zero: .cfi_val_offset , 0 As a result the SP at call site computes as follows: SP =3D CFA 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. Do so by enabling architectures to override the default SP value offset from CFA of zero with an architecture-specific one: .cfi_val_offset , offset So that the SP at call site computes as follows: SP =3D CFA + offset Signed-off-by: Jens Remus --- Notes (jremus): Changes in RFC v2: - Reword commit message. (Josh) - Use term "sp_off" instead of "sp_val_off". (Josh) - Move definition, initialization, and setting of sp_off field to happen right after the cfa_off field. - Use SFRAME_SP_OFFSET macro instead of sframe_sp_off() function, which can be overridden by an architecture, such as s390. - Drop lengthy sframe_sp_[val_]off() comment. arch/x86/include/asm/unwind_user.h | 2 ++ include/asm-generic/Kbuild | 1 + include/asm-generic/unwind_user_sframe.h | 12 ++++++++++++ include/linux/unwind_user_types.h | 1 + kernel/unwind/sframe.c | 2 ++ kernel/unwind/user.c | 11 ++++++----- 6 files changed, 24 insertions(+), 5 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 4d699e4954ed..dbdbad0beaf9 100644 --- a/arch/x86/include/asm/unwind_user.h +++ b/arch/x86/include/asm/unwind_user.h @@ -25,6 +25,7 @@ static inline int unwind_user_word_size(struct pt_regs *r= egs) =20 #define ARCH_INIT_USER_FP_FRAME(ws) \ .cfa_off =3D 2*(ws), \ + .sp_off =3D 0, \ .ra_off =3D -1*(ws), \ .fp_off =3D -2*(ws), \ .use_fp =3D true, \ @@ -32,6 +33,7 @@ static inline int unwind_user_word_size(struct pt_regs *r= egs) =20 #define ARCH_INIT_USER_FP_ENTRY_FRAME(ws) \ .cfa_off =3D 1*(ws), \ + .sp_off =3D 0, \ .ra_off =3D -1*(ws), \ .fp_off =3D 0, \ .use_fp =3D false, \ diff --git a/include/asm-generic/Kbuild b/include/asm-generic/Kbuild index 295c94a3ccc1..b1d448ef4a50 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 vermagic.h mandatory-y +=3D vga.h mandatory-y +=3D video.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..8c9ac47bc8bd --- /dev/null +++ b/include/asm-generic/unwind_user_sframe.h @@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_GENERIC_UNWIND_USER_SFRAME_H +#define _ASM_GENERIC_UNWIND_USER_SFRAME_H + +#include + +#ifndef SFRAME_SP_OFFSET +/* Most archs/ABIs define CFA as SP at call site, so that SP =3D CFA + 0. = */ +#define SFRAME_SP_OFFSET 0 +#endif + +#endif /* _ASM_GENERIC_UNWIND_USER_SFRAME_H */ diff --git a/include/linux/unwind_user_types.h b/include/linux/unwind_user_= types.h index 616cc5ee4586..4656aa08a7db 100644 --- a/include/linux/unwind_user_types.h +++ b/include/linux/unwind_user_types.h @@ -29,6 +29,7 @@ struct unwind_stacktrace { =20 struct unwind_user_frame { s32 cfa_off; + s32 sp_off; s32 ra_off; s32 fp_off; bool use_fp; diff --git a/kernel/unwind/sframe.c b/kernel/unwind/sframe.c index 6465e7a315bc..7952b041dd23 100644 --- a/kernel/unwind/sframe.c +++ b/kernel/unwind/sframe.c @@ -12,6 +12,7 @@ #include #include #include +#include #include =20 #include "sframe.h" @@ -307,6 +308,7 @@ static __always_inline int __find_fre(struct sframe_sec= tion *sec, fre =3D prev_fre; =20 frame->cfa_off =3D fre->cfa_off; + frame->sp_off =3D SFRAME_SP_OFFSET; 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; diff --git a/kernel/unwind/user.c b/kernel/unwind/user.c index fdb1001e3750..6c75a7411871 100644 --- a/kernel/unwind/user.c +++ b/kernel/unwind/user.c @@ -30,7 +30,7 @@ get_user_word(unsigned long *word, unsigned long base, in= t off, unsigned int ws) static int unwind_user_next_common(struct unwind_user_state *state, const struct unwind_user_frame *frame) { - unsigned long cfa, fp, ra; + unsigned long cfa, sp, fp, ra; =20 /* Stop unwinding when reaching an outermost frame. */ if (frame->outermost) { @@ -48,12 +48,13 @@ static int unwind_user_next_common(struct unwind_user_s= tate *state, } cfa +=3D frame->cfa_off; =20 + /* Get the Stack Pointer (SP) */ + sp =3D cfa + frame->sp_off; /* Make sure that stack is not going in wrong direction */ - if (cfa <=3D state->sp) + if (sp <=3D state->sp) return -EINVAL; - /* Make sure that the address is word aligned */ - if (cfa & (state->ws - 1)) + if (sp & (state->ws - 1)) return -EINVAL; =20 /* Get the Return Address (RA) */ @@ -65,7 +66,7 @@ static int unwind_user_next_common(struct unwind_user_sta= te *state, return -EINVAL; =20 state->ip =3D ra; - state->sp =3D cfa; + state->sp =3D sp; if (frame->fp_off) state->fp =3D fp; state->topmost =3D false; --=20 2.51.0 From nobody Fri Dec 19 15:01:48 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 CE30934FF6F; Fri, 5 Dec 2025 17:15:41 +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=1764954945; cv=none; b=O0wyNWbArgrkQfqcZmIaC6EpDQ1mSLTU2XQVyVvuAzYrq3w7ca0SWoTi8n87r0gKsGxFLxnIEzfmRStlIR6UHCXAprYhESl/cjzo8AUDCIHzH++hk7Enp3MAJNU18ypORuMuaEVfKglcBJacwVKWlq0a2q4UdSzisQlBGzhb/p8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764954945; c=relaxed/simple; bh=EpVPiNSvNCIlBsoRFqWSixIr1ltDc1FtGXz6ucCai4E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XSaj0lWBmZJElpxhUfbiSW5WSMx2WSN/kkN3h9HcbDJq7ilI51SToxE+dBu2LalsVqSZJ4E/9FT5RFhlBWuSGktFfE4nkMn825RekQl8Yz1QSaiCZfBoXPPyyTwGVanIE4Uvo6g7GoWU5GoeaJInDuJWFQsZJ/2OeCfo6X1h/+s= 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=YZpw/alu; 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="YZpw/alu" 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 5B5FHjet027523; Fri, 5 Dec 2025 17:14:57 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=/8a31K4Sd6aU33so4 PMuO/2Yjkyh5Fe6LtDEMdSPIt8=; b=YZpw/aluxMHToNB5bTrOt3KvWBdsCLinm POInPKg4y7MoezHNM+/FLzG1eozEIdqWaVosUoRGK6pwylGW9iWaayFmrRCVwGTi 2dSMcjIRTllCmoiLSoVBs2Kka8MPxGhwEpdaqkz0CrmjHNc0QaU9u3UalCQkIGUU c37SfyiAihtTFSd8D92ssCCzoishD856iXvEVGfdCvg72wyPtwdUs0bVFOoQVWdf WJBw7HhJ4SpIzYcXNYeEMs0M+QSEVMDcajDInoJfCHrrg2lPGPvrBnEjTxQv+5Wu WE3KvfHzTdOT6oOt4RKkKeEXvzJaE5W8NNKeQcWP7CUsFgSG/azAA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4aqrja6v9k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Dec 2025 17:14:57 +0000 (GMT) Received: from m0356517.ppops.net (m0356517.ppops.net [127.0.0.1]) by pps.reinject (8.18.1.12/8.18.0.8) with ESMTP id 5B5H7s4s019258; Fri, 5 Dec 2025 17:14:56 GMT 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 4aqrja6v9f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Dec 2025 17:14:56 +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 5B5EkMV0019069; Fri, 5 Dec 2025 17:14:55 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4arbhyeee1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Dec 2025 17:14:55 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5B5HEp4x26214780 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 5 Dec 2025 17:14:51 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 51C462005A; Fri, 5 Dec 2025 17:14:51 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 09DEF2004E; Fri, 5 Dec 2025 17:14:51 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.87.85.9]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 5 Dec 2025 17:14:50 +0000 (GMT) From: Jens Remus To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-s390@vger.kernel.org, bpf@vger.kernel.org, x86@kernel.org, Steven Rostedt Cc: Jens Remus , Heiko Carstens , Vasily Gorbik , Ilya Leoshkevich , Josh Poimboeuf , Masami Hiramatsu , Mathieu Desnoyers , Peter Zijlstra , Ingo Molnar , Jiri Olsa , Arnaldo Carvalho de Melo , Namhyung Kim , Thomas Gleixner , Andrii Nakryiko , Indu Bhagat , "Jose E. Marchesi" , Beau Belgrave , Linus Torvalds , Andrew Morton , Florian Weimer , Kees Cook , "Carlos O'Donell" , Sam James , Dylan Hatch Subject: [RFC PATCH v2 09/15] unwind_user: Enable archs that pass RA in a register Date: Fri, 5 Dec 2025 18:14:40 +0100 Message-ID: <20251205171446.2814872-10-jremus@linux.ibm.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251205171446.2814872-1-jremus@linux.ibm.com> References: <20251205171446.2814872-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-GUID: 9qRHTvcCAPbtXjbEQLgo5bVv-5kMUubc X-Proofpoint-ORIG-GUID: U2GWtFQuv6ABtv9_Fn_8oY7ag7CFbmVy X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMTI5MDAyMCBTYWx0ZWRfX/rgkUDUii6EV jzyF93REMD+9SlEZX9I7ug5mP1ZRYTeLEWsImp6Rz8Txjdmvv0cFrFY+ezt5MkVPvqeqwbI/R1/ 26dl0/zqR+Fya0gdE4jbj6kKOd2XS1M2TiSprY1TMw+scOnHvJHQDhLLp4aJ9PrijzELPHRZq/r hj8wdWFF59Y73FSNIf7yzFOnQyG0udl/FUipWJHNyc8HqRS4XiMtbT4mWqi2JXkC6fdtt13jbhS FXM0cUpM65vjQYgWcrGWFSHAwnXSjNcNfeX004gOQV6LjqYWTgSKW5+CwXkPkLmmE/zRBug4g10 7ceAJbVYuo6tGDwnvI7LiPGcpBeHvEQPwXb5k0nE0RXqUCCc7KNRKvLiX7tcWu9ivsfSoHEj6Sj P4dhl5BH1X+gi0Ieo39TXIVg/AzMLA== X-Authority-Analysis: v=2.4 cv=dYGNHHXe c=1 sm=1 tr=0 ts=69331311 cx=c_pps a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==:17 a=wP3pNCr1ah4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=VnNF1IyMAAAA:8 a=BZmVhOMqpLk0IJKryeUA:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-12-05_06,2025-12-04_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 spamscore=0 suspectscore=0 clxscore=1015 adultscore=0 lowpriorityscore=0 bulkscore=0 phishscore=0 priorityscore=1501 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2510240000 definitions=main-2511290020 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, such 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). For the topmost frame treat it as indication that the RA is in the link/RA register, such as on arm64 and s390, and obtain it from there. For non-topmost frames treat it as error, as the RA must be saved. Additionally allow the SP to be unchanged in the topmost frame, for architectures where SP at function entry =3D=3D SP at call site, such as arm64 and s390. 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 --- Notes (jremus): Changes in v2: - Reword commit subject and message. - Rename config option USER_RA_REG to UNWIND_USER_RA_REG and reword help text to mention both link and return address register. (Josh) - Move dummy user_return_address() from linux/ptrace.h to linux/unwind_user.h, rename to unwind_user_get_ra_reg(), return -EINVAL, and guard by !CONFIG_HAVE_UNWIND_USER_RA_REG. (Josh) - Do not check for !IS_ENABLED(CONFIG_HAVE_USER_RA_REG), as the dummy implementation of user_return_address() returns -EINVAL. - Drop config option USER_RA_REG / UNWIND_USER_RA_REG, as it is of no value any longer. - Drop topmost checks from unwind user sframe, as they are already done by unwind user. (Josh) include/linux/unwind_user.h | 9 +++++++++ kernel/unwind/sframe.c | 6 ++---- kernel/unwind/user.c | 17 +++++++++++++---- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/include/linux/unwind_user.h b/include/linux/unwind_user.h index 64618618febd..bc2edae39955 100644 --- a/include/linux/unwind_user.h +++ b/include/linux/unwind_user.h @@ -23,6 +23,15 @@ static inline bool unwind_user_at_function_start(struct = pt_regs *regs) #define unwind_user_at_function_start unwind_user_at_function_start #endif =20 +#ifndef unwind_user_get_ra_reg +static inline int unwind_user_get_ra_reg(unsigned long *val) +{ + WARN_ON_ONCE(1); + return -EINVAL; +} +#define unwind_user_get_ra_reg unwind_user_get_ra_reg +#endif + int unwind_user(struct unwind_stacktrace *trace, unsigned int max_entries); =20 #endif /* _LINUX_UNWIND_USER_H */ diff --git a/kernel/unwind/sframe.c b/kernel/unwind/sframe.c index 7952b041dd23..38b3577f5253 100644 --- a/kernel/unwind/sframe.c +++ b/kernel/unwind/sframe.c @@ -228,10 +228,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--) - return -EFAULT; - + if (!ra_off && offset_count) { + offset_count--; UNSAFE_GET_USER_INC(ra_off, cur, offset_size, Efault); } =20 diff --git a/kernel/unwind/user.c b/kernel/unwind/user.c index 6c75a7411871..58e1549cd9f4 100644 --- a/kernel/unwind/user.c +++ b/kernel/unwind/user.c @@ -50,16 +50,25 @@ static int unwind_user_next_common(struct unwind_user_s= tate *state, =20 /* Get the Stack Pointer (SP) */ sp =3D cfa + frame->sp_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 - state->topmost) return -EINVAL; /* Make sure that the address is word aligned */ if (sp & (state->ws - 1)) return -EINVAL; =20 /* Get the Return Address (RA) */ - if (get_user_word(&ra, cfa, frame->ra_off, state->ws)) - return -EINVAL; + if (frame->ra_off) { + if (get_user_word(&ra, cfa, frame->ra_off, state->ws)) + return -EINVAL; + } else { + if (!state->topmost || unwind_user_get_ra_reg(&ra)) + return -EINVAL; + } =20 /* Get the Frame Pointer (FP) */ if (frame->fp_off && get_user_word(&fp, cfa, frame->fp_off, state->ws)) --=20 2.51.0 From nobody Fri Dec 19 15:01:48 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 0C7FC349B08; Fri, 5 Dec 2025 17:15:29 +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=1764954934; cv=none; b=uQKH+KSBNM+GYibK8WzWFR111LvKhh3/T6KOFb9x3zx0EYE8FclI5KnDQYtMUOSKU0vWzUADUEq4SK5ZqmYC8xyFXWbgjPCyI97f8qM6wyI47lwpWUMHF56j2cGxeCmgocbWwGJvUjVB7Ud9MiTdqDwu4rCfvWc7GEl5U6XoXeY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764954934; c=relaxed/simple; bh=BaaazKY4N/gQqcOAQuMq3hnJYhCcrMeU6NqtFo95EdE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aQ2Ozl9aRZyxqwTbtXKSVlFdKlqrmdMHvjF7xBUR3uAl9ACB9LfGTuSxCuaSF0j3TXgSQKqnPx13oz/RrWHVusmct7g5vyvFY3gFe0mB/+m3GbFBS9rO5Mt30FNsdP2OEgJU+sQ3YDLQpgsPBTYZ5j3QzYmd4T24DGt/Pi9ASU8= 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=PJqIhMlF; 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="PJqIhMlF" 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 5B5CbnhN029507; Fri, 5 Dec 2025 17:14:57 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=xqV77jlNdGfgAvl7u ClQOa17ALUwsCcaS1Mv50ZA9CI=; b=PJqIhMlF+oVb6fch22SHxkH1B+b5GtcOW rNOjUsQ9qsm05vkiw5VNRkQG7PpOMx8hZRajpsSiDkjWhH/WvUXkzoai7qCN6KK6 hqfTNT4MdSEGNDZObZBn0XbB7/eYHxEVHrnqxFv1jbm49mbUtawXAomgpc9QwGJf ebfdisUT5Lr3j7dTRm+d1Zx23tWp2FCI5/sGQRzJrlPlWiJpiS4DXowe4UREN9Tw +uhfMAYQMNXVMjZBu1Ni83vG1MxQzpjyGqSzrLSXCbIljeYGF8PwhJR3paLd4y38 L8W/RUxjbM/UU+4yd8yb3HyE1zZulx5i8cMX1MY7opcNd65N8USHw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4aqq8v664w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Dec 2025 17:14:57 +0000 (GMT) Received: from m0353725.ppops.net (m0353725.ppops.net [127.0.0.1]) by pps.reinject (8.18.1.12/8.18.0.8) with ESMTP id 5B5H7RIH021565; Fri, 5 Dec 2025 17:14:56 GMT 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 4aqq8v664r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Dec 2025 17:14:56 +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 5B5Eb9Tp010240; Fri, 5 Dec 2025 17:14:55 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4arcnkpb58-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Dec 2025 17:14:55 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5B5HEpxF26214784 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 5 Dec 2025 17:14:51 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A2A942004E; Fri, 5 Dec 2025 17:14:51 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5429820063; Fri, 5 Dec 2025 17:14:51 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.87.85.9]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 5 Dec 2025 17:14:51 +0000 (GMT) From: Jens Remus To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-s390@vger.kernel.org, bpf@vger.kernel.org, x86@kernel.org, Steven Rostedt Cc: Jens Remus , Heiko Carstens , Vasily Gorbik , Ilya Leoshkevich , Josh Poimboeuf , Masami Hiramatsu , Mathieu Desnoyers , Peter Zijlstra , Ingo Molnar , Jiri Olsa , Arnaldo Carvalho de Melo , Namhyung Kim , Thomas Gleixner , Andrii Nakryiko , Indu Bhagat , "Jose E. Marchesi" , Beau Belgrave , Linus Torvalds , Andrew Morton , Florian Weimer , Kees Cook , "Carlos O'Donell" , Sam James , Dylan Hatch Subject: [RFC PATCH v2 10/15] unwind_user: Enable archs that save RA/FP in other registers Date: Fri, 5 Dec 2025 18:14:41 +0100 Message-ID: <20251205171446.2814872-11-jremus@linux.ibm.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251205171446.2814872-1-jremus@linux.ibm.com> References: <20251205171446.2814872-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: 6pSAVqgkRWaR6NSOf0v0jLVZro9nB8W8 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMTI5MDAwOCBTYWx0ZWRfXzHkjNdTEuIJO qwyZXR/LEV/0Ma77q5VWJEK2xxl7YF3raYUlk9u+/B7rJQeX6qoF2IoCz3CbGi/ixYrSLiSkAvm 1GVk8v9PWcOPjxOOl5s/E96QH/L9BpMo7tJ/G3f84toJThXRvK65ItVLM0BquQc7xd5kUYK97JN QhF6H3L+RAa/FSD//B8gdLvHIHTfwW6pDeqVKX6XaoKogF9UahJRw2KLdcTCaDbb6NEE36h5Ow7 eC4/WcJTOoYQPYLYZbHXirrG1//lKnTEFoHE+D2EBvXjscXabO/xiLwvjchqXXpTCHh5W1rXPTo EghCUAdsV7SNgnqCyrAOnNPiWaUUKxA1w9Rwtu80j+/BQHfGW9AZnuaUBVZXr4B3A3iYMRsB4Li AGEtUgGBZLvUSc8aEDPmHtRL1+AbYQ== X-Authority-Analysis: v=2.4 cv=Scz6t/Ru c=1 sm=1 tr=0 ts=69331311 cx=c_pps a=3Bg1Hr4SwmMryq2xdFQyZA==:117 a=3Bg1Hr4SwmMryq2xdFQyZA==:17 a=wP3pNCr1ah4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=VnNF1IyMAAAA:8 a=-jCn-aex0Ddyt886wV4A:9 X-Proofpoint-GUID: 5nhX3_gGauAHjq09AvhKfodUzaFNN60l X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-12-05_06,2025-12-04_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 phishscore=0 bulkscore=0 lowpriorityscore=0 adultscore=0 clxscore=1015 spamscore=0 impostorscore=0 priorityscore=1501 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2510240000 definitions=main-2511290008 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 --- Notes (jremus): Changes in RFC v2: - Reword HAVE_UNWIND_USER_LOC_REG help text. - Rename struct unwind_user_reginfo field frame_off to offset. (Josh) - Move dummy unwind_user_get_reg() from asm-generic/unwind_user.h to linux/unwind_user.h, drop its function comment, warn once, return -EINVAL, and guard by !HAVE_UNWIND_USER_LOC_REG. (Josh) - Rename generic_sframe_set_frame_reginfo() to sframe_init_reginfo() and drop its function comment. (Josh) - Do not check FP/RA offset for zero for UNWIND_USER_LOC_STACK. (Josh) - Do not check for !IS_ENABLED(CONFIG_HAVE_UNWIND_USER_LOC_REG), as the dummy implementation of unwind_user_get_reg() returns -EINVAL. - Drop config option HAVE_UNWIND_USER_LOC_REG, as it is no longer of any value. - Keep checking for topmost for UNWIND_USER_LOC_REG. (Jens) - Explicitly preserve FP if UNWIND_USER_LOC_NONE and drop later test for frame->fp.loc !=3D UNWIND_USER_LOC_NONE. (Josh) =20 Would it make sense to rename UNWIND_USER_LOC_NONE to one of the following to clarify its meaning for the unwinder? - UNWIND_USER_LOC_UNCHANGED - UNWIND_USER_LOC_RETAIN - UNWIND_USER_LOC_PRESERVED - UNWIND_USER_LOC_IDENTITY arch/x86/include/asm/unwind_user.h | 21 +++++++++++--- include/asm-generic/unwind_user_sframe.h | 15 ++++++++++ include/linux/unwind_user.h | 9 ++++++ include/linux/unwind_user_types.h | 18 ++++++++++-- kernel/unwind/sframe.c | 4 +-- kernel/unwind/user.c | 37 +++++++++++++++++++----- 6 files changed, 89 insertions(+), 15 deletions(-) diff --git a/arch/x86/include/asm/unwind_user.h b/arch/x86/include/asm/unwi= nd_user.h index dbdbad0beaf9..61a9ae9b07ea 100644 --- a/arch/x86/include/asm/unwind_user.h +++ b/arch/x86/include/asm/unwind_user.h @@ -26,16 +26,27 @@ static inline int unwind_user_word_size(struct pt_regs = *regs) #define ARCH_INIT_USER_FP_FRAME(ws) \ .cfa_off =3D 2*(ws), \ .sp_off =3D 0, \ - .ra_off =3D -1*(ws), \ - .fp_off =3D -2*(ws), \ + .ra =3D { \ + .loc =3D UNWIND_USER_LOC_STACK,\ + .offset =3D -1*(ws), \ + }, \ + .fp =3D { \ + .loc =3D UNWIND_USER_LOC_STACK,\ + .offset =3D -2*(ws), \ + }, \ .use_fp =3D true, \ .outermost =3D false, =20 #define ARCH_INIT_USER_FP_ENTRY_FRAME(ws) \ .cfa_off =3D 1*(ws), \ .sp_off =3D 0, \ - .ra_off =3D -1*(ws), \ - .fp_off =3D 0, \ + .ra =3D { \ + .loc =3D UNWIND_USER_LOC_STACK,\ + .offset =3D -1*(ws), \ + }, \ + .fp =3D { \ + .loc =3D UNWIND_USER_LOC_NONE, \ + }, \ .use_fp =3D false, \ .outermost =3D false, =20 @@ -47,4 +58,6 @@ static inline bool unwind_user_at_function_start(struct p= t_regs *regs) =20 #endif /* CONFIG_HAVE_UNWIND_USER_FP */ =20 +#include + #endif /* _ASM_X86_UNWIND_USER_H */ diff --git a/include/asm-generic/unwind_user_sframe.h b/include/asm-generic= /unwind_user_sframe.h index 8c9ac47bc8bd..163961ca5252 100644 --- a/include/asm-generic/unwind_user_sframe.h +++ b/include/asm-generic/unwind_user_sframe.h @@ -2,6 +2,7 @@ #ifndef _ASM_GENERIC_UNWIND_USER_SFRAME_H #define _ASM_GENERIC_UNWIND_USER_SFRAME_H =20 +#include #include =20 #ifndef SFRAME_SP_OFFSET @@ -9,4 +10,18 @@ #define SFRAME_SP_OFFSET 0 #endif =20 +#ifndef sframe_init_reginfo +static inline void +sframe_init_reginfo(struct unwind_user_reginfo *reginfo, s32 offset) +{ + if (offset) { + reginfo->loc =3D UNWIND_USER_LOC_STACK; + reginfo->offset =3D offset; + } else { + reginfo->loc =3D UNWIND_USER_LOC_NONE; + } +} +#define sframe_init_reginfo sframe_init_reginfo +#endif + #endif /* _ASM_GENERIC_UNWIND_USER_SFRAME_H */ diff --git a/include/linux/unwind_user.h b/include/linux/unwind_user.h index bc2edae39955..61fd5c05d0f0 100644 --- a/include/linux/unwind_user.h +++ b/include/linux/unwind_user.h @@ -32,6 +32,15 @@ static inline int unwind_user_get_ra_reg(unsigned long *= val) #define unwind_user_get_ra_reg unwind_user_get_ra_reg #endif =20 +#ifndef unwind_user_get_reg +static inline int unwind_user_get_reg(unsigned long *val, int regnum) +{ + WARN_ON_ONCE(1); + return -EINVAL; +} +#define unwind_user_get_reg unwind_user_get_reg +#endif + int unwind_user(struct unwind_stacktrace *trace, unsigned int max_entries); =20 #endif /* _LINUX_UNWIND_USER_H */ diff --git a/include/linux/unwind_user_types.h b/include/linux/unwind_user_= types.h index 4656aa08a7db..6efc12b6e831 100644 --- a/include/linux/unwind_user_types.h +++ b/include/linux/unwind_user_types.h @@ -27,11 +27,25 @@ 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 offset; + int regnum; + }; +}; + struct unwind_user_frame { s32 cfa_off; s32 sp_off; - s32 ra_off; - s32 fp_off; + struct unwind_user_reginfo ra; + struct unwind_user_reginfo fp; bool use_fp; bool outermost; }; diff --git a/kernel/unwind/sframe.c b/kernel/unwind/sframe.c index 38b3577f5253..45cd7380ac38 100644 --- a/kernel/unwind/sframe.c +++ b/kernel/unwind/sframe.c @@ -307,8 +307,8 @@ static __always_inline int __find_fre(struct sframe_sec= tion *sec, =20 frame->cfa_off =3D fre->cfa_off; frame->sp_off =3D SFRAME_SP_OFFSET; - frame->ra_off =3D fre->ra_off; - frame->fp_off =3D fre->fp_off; + sframe_init_reginfo(&frame->ra, fre->ra_off); + sframe_init_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->outermost =3D fre->ra_undefined; =20 diff --git a/kernel/unwind/user.c b/kernel/unwind/user.c index 58e1549cd9f4..122045cb411f 100644 --- a/kernel/unwind/user.c +++ b/kernel/unwind/user.c @@ -62,22 +62,45 @@ static int unwind_user_next_common(struct unwind_user_s= tate *state, return -EINVAL; =20 /* Get the Return Address (RA) */ - if (frame->ra_off) { - if (get_user_word(&ra, cfa, frame->ra_off, state->ws)) - return -EINVAL; - } else { + switch (frame->ra.loc) { + case UNWIND_USER_LOC_NONE: if (!state->topmost || unwind_user_get_ra_reg(&ra)) return -EINVAL; + break; + case UNWIND_USER_LOC_STACK: + if (get_user_word(&ra, cfa, frame->ra.offset, state->ws)) + return -EINVAL; + break; + case UNWIND_USER_LOC_REG: + if (!state->topmost || unwind_user_get_reg(&ra, frame->ra.regnum)) + return -EINVAL; + break; + default: + WARN_ON_ONCE(1); + return -EINVAL; } =20 /* Get the Frame Pointer (FP) */ - if (frame->fp_off && get_user_word(&fp, cfa, frame->fp_off, state->ws)) + switch (frame->fp.loc) { + case UNWIND_USER_LOC_NONE: + fp =3D state->fp; + break; + case UNWIND_USER_LOC_STACK: + if (get_user_word(&fp, cfa, frame->fp.offset, state->ws)) + return -EINVAL; + break; + case UNWIND_USER_LOC_REG: + if (!state->topmost || unwind_user_get_reg(&fp, frame->fp.regnum)) + return -EINVAL; + break; + default: + WARN_ON_ONCE(1); return -EINVAL; + } =20 state->ip =3D ra; state->sp =3D sp; - if (frame->fp_off) - state->fp =3D fp; + state->fp =3D fp; state->topmost =3D false; return 0; } --=20 2.51.0 From nobody Fri Dec 19 15:01:48 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 31AD534EF17; Fri, 5 Dec 2025 17:15:37 +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=1764954942; cv=none; b=jUGaDlVQyFjQuP41RR8RvZUKhy2jFjC/EKV7eauLy3cjeGPKVRsHU7d/srx+qJ/xrGxxWahsCi1ipYl5/MOP15S+eNRiWw47xd2LslTYSUpRAknPGLhXHE96ZyjB2BSCD/INVzGiBT/ge2f2221NebcbBjkHq/ZzDn/KDgivKbU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764954942; c=relaxed/simple; bh=p68FIoQo9rVwaiDJGwEyYg2Lz3jb4QhHYIY++aIx2F0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Dx65dA7TXgwKoP9aGNtY+rp17vwKroo+p8aspUSodBlLgR6Ru03CH+hWWsUNmwIrrFognk2pnlTbBtXxo9IDrLSgCzOwkG9WCEyHU+HiBfbjJgoZdbTvyHlMz/Xh+Re6bV3a9A9t4y6vtFREK1nEvCrX/VA1FZGNHvsOHtEf8nM= 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=skrD2u9q; 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="skrD2u9q" 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 5B5APLlY002616; Fri, 5 Dec 2025 17:14:58 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=WKEhc0G/ZxtbDpXxD ai3PIhO6YPs7nOrhP98G6G1AL8=; b=skrD2u9qZqRJQLCz3y2xm1lyFvJ6KxeNC 9F7SztGNyTdyWYM0hC+sCPdui0hlg14OytxSQIqYyQ61fC9/cgSTsUObYlWJKjp4 9Vfc8rnxXLhy0z8vUPTRdeRXL/aKYhJvHYQyFYz6RqtXpC87IiUviTsQQTdHPl/d KYr5XH0CMuqFkP0cUf0y8yXJ7jnMW0uohm1IbtSOrZpm2Li3RhIqyzizefT7l1E/ VL+/UJQlC7NHMnY1uuXMcBtKKN1PBuoZD4c3G40gJNaGBGicRiVG9NX28UohJBTa 9eSuY3+GYIbgk5ivcNCT1DE8vLliIMdOfsz62CV1jpNd8dbtYYB5A== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4aqrh7ey3t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Dec 2025 17:14:58 +0000 (GMT) Received: from m0353729.ppops.net (m0353729.ppops.net [127.0.0.1]) by pps.reinject (8.18.1.12/8.18.0.8) with ESMTP id 5B5HER9D019391; Fri, 5 Dec 2025 17:14:57 GMT 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 4aqrh7ey3n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Dec 2025 17:14:57 +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 5B5Fi89t021859; Fri, 5 Dec 2025 17:14:55 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4at8c6qj4c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Dec 2025 17:14:55 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5B5HEquN39322058 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 5 Dec 2025 17:14:52 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E7BB32004B; Fri, 5 Dec 2025 17:14:51 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A5E502004F; Fri, 5 Dec 2025 17:14:51 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.87.85.9]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 5 Dec 2025 17:14:51 +0000 (GMT) From: Jens Remus To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-s390@vger.kernel.org, bpf@vger.kernel.org, x86@kernel.org, Steven Rostedt Cc: Jens Remus , Heiko Carstens , Vasily Gorbik , Ilya Leoshkevich , Josh Poimboeuf , Masami Hiramatsu , Mathieu Desnoyers , Peter Zijlstra , Ingo Molnar , Jiri Olsa , Arnaldo Carvalho de Melo , Namhyung Kim , Thomas Gleixner , Andrii Nakryiko , Indu Bhagat , "Jose E. Marchesi" , Beau Belgrave , Linus Torvalds , Andrew Morton , Florian Weimer , Kees Cook , "Carlos O'Donell" , Sam James , Dylan Hatch Subject: [RFC PATCH v2 11/15] unwind_user/sframe: Enable archs with encoded SFrame CFA offsets Date: Fri, 5 Dec 2025 18:14:42 +0100 Message-ID: <20251205171446.2814872-12-jremus@linux.ibm.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251205171446.2814872-1-jremus@linux.ibm.com> References: <20251205171446.2814872-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=dK+rWeZb c=1 sm=1 tr=0 ts=69331312 cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==:17 a=wP3pNCr1ah4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=VnNF1IyMAAAA:8 a=Og4hOgGxDI197znzLmcA:9 X-Proofpoint-GUID: RMRN7OWk_9MJjrE7cvf-IghfKu4EUnjs X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMTI5MDAyMCBTYWx0ZWRfX8e5OEzpFdqo4 dWPGEpHWigiCCgflh72YgXiQlzkiOEkzmCQTIc8Y1QSdIZH+G3IwJbJNeOl2XcS3g/DKHI7yl1f Nc5qJLNjT/lHweNoQip2b++RKBx95tilPe2PWZcCH8b+Tsa8jhqlq7c3JmMUarYgizvYBVBqCv4 TwKMZb8MqQiMGWMXZvwGJpTV8wJOPFLuVBD1yQm5fdzpMgRpYkSLdab1EOVxsYQvalQU1bfCR9M eHOQ6eKmI2c5X3yLl7pinqzg/QH6PCjw2k+3HO3SExJCM+mt7JGFKhszEHyFoWEjICJpjB5tq6i goCilaBSIHP8QDsvlxxG9G5Bj9OomRalOKjxipl18O6osy6cyEcfD7qYACcF7R+jKtb6qNIZrJI hyu9UfhXWgh0XQqGuMwJiZTlOJebGQ== X-Proofpoint-ORIG-GUID: qLY2n_RsK3nXmW4HSI7Ir3EJHqpPCDgK X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-12-05_06,2025-12-04_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 lowpriorityscore=0 clxscore=1015 priorityscore=1501 bulkscore=0 adultscore=0 phishscore=0 impostorscore=0 spamscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2510240000 definitions=main-2511290020 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 --- Notes (jremus): Changes in RFC v2: - Rename generic_sframe_cfa_offset_decode() to sframe_cfa_offset_decode(). (Josh) include/asm-generic/unwind_user_sframe.h | 8 ++++++++ kernel/unwind/sframe.c | 1 + 2 files changed, 9 insertions(+) diff --git a/include/asm-generic/unwind_user_sframe.h b/include/asm-generic= /unwind_user_sframe.h index 163961ca5252..80ae9bfaa88d 100644 --- a/include/asm-generic/unwind_user_sframe.h +++ b/include/asm-generic/unwind_user_sframe.h @@ -10,6 +10,14 @@ #define SFRAME_SP_OFFSET 0 #endif =20 +#ifndef sframe_cfa_offset_decode +static inline s32 sframe_cfa_offset_decode(s32 offset) +{ + return offset; +} +#define sframe_cfa_offset_decode sframe_cfa_offset_decode +#endif + #ifndef sframe_init_reginfo static inline void sframe_init_reginfo(struct unwind_user_reginfo *reginfo, s32 offset) diff --git a/kernel/unwind/sframe.c b/kernel/unwind/sframe.c index 45cd7380ac38..92f770fc21f6 100644 --- a/kernel/unwind/sframe.c +++ b/kernel/unwind/sframe.c @@ -226,6 +226,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.51.0 From nobody Fri Dec 19 15:01:48 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 CB37B29B795; Fri, 5 Dec 2025 17:15:42 +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=1764954945; cv=none; b=QvmKSw2psvjeejLMTjUW04xSaTpz2Bm13c9/HMltJb+iwU4S/aC6ZHJPCFGGcleeSWujLtHgLFBXqHm2pU6ZRozbpJDcrNSm7WEhOpT1PJ9rYhUf1fElSVDsvEaeVevVTnjRlDDEjLgOQ7i6OD85yGMyLVG4Jb3wRQO55fQoKmE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764954945; c=relaxed/simple; bh=n8pBlgqOyIzV+gOPeF+y2BL0EDkz49lTTImLBPYuSR8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=T+UAKMpsK+wTEB/Cm60a75RfzeUXx+ae5/64XCPe78yPibe8ZlKsUWqEEIQnGh+0+Jy7SYIz7tqxKE/4ZKtgkMyXaryuZmj5g5f7XMrOPsGpQX26y/g58ZFLAeYbhwdvZptnmFS0Cl7oA9SWrtcXbRMsBFRRM3O5tDSkUSo8WCQ= 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=mynPCw3r; 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="mynPCw3r" 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 5B5GW9h8008240; Fri, 5 Dec 2025 17:14:58 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pp1; bh=PRuUhT HO1HY1f+O9bTpuVEIwX5IW29Qy2eK9vjAVf9k=; b=mynPCw3rV79TQSoV6aHi7A evAHNMnxD+oTHMB35K4XLLC3laKnTYVnnv4mj/jQNy7Ni8Bw4p2DfFknneZaRt/W fjj2fTg0J0t2xP8DCMwQLz7/HtNqfSw1kJmTwfH/0pMWMgFR/9vbZp+kdgnQY7yo STLhU8xspbm6xX8gUcw8no5uOcddxwqaJhuwKDR8NpIR1NVXwuXSPIY26qf93JUb t8gpUGqEilMI/nq3hm8z9790DcsQvG4uBsR0H6wuck+hQ2B7axpmq/n7oyNkxCL+ b4t6reY16CxaJMe1GTxHRIX4Or5CB+7eBqAdXyZIjaJyOzmbvqf4tYVWuU3Oj1pw == Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4aqrbgq43h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Dec 2025 17:14:58 +0000 (GMT) Received: from m0360083.ppops.net (m0360083.ppops.net [127.0.0.1]) by pps.reinject (8.18.1.12/8.18.0.8) with ESMTP id 5B5HBWWw012503; Fri, 5 Dec 2025 17:14:57 GMT 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 4aqrbgq43d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Dec 2025 17:14:57 +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 5B5Ei63e019051; Fri, 5 Dec 2025 17:14:56 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4arbhyeee2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Dec 2025 17:14:56 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5B5HEqOZ47644986 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 5 Dec 2025 17:14:52 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3AE6720043; Fri, 5 Dec 2025 17:14:52 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EC7372004D; Fri, 5 Dec 2025 17:14:51 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.87.85.9]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 5 Dec 2025 17:14:51 +0000 (GMT) From: Jens Remus To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-s390@vger.kernel.org, bpf@vger.kernel.org, x86@kernel.org, Steven Rostedt Cc: Jens Remus , Heiko Carstens , Vasily Gorbik , Ilya Leoshkevich , Josh Poimboeuf , Masami Hiramatsu , Mathieu Desnoyers , Peter Zijlstra , Ingo Molnar , Jiri Olsa , Arnaldo Carvalho de Melo , Namhyung Kim , Thomas Gleixner , Andrii Nakryiko , Indu Bhagat , "Jose E. Marchesi" , Beau Belgrave , Linus Torvalds , Andrew Morton , Florian Weimer , Kees Cook , "Carlos O'Donell" , Sam James , Dylan Hatch Subject: [RFC PATCH v2 12/15] s390/ptrace: Provide frame_pointer() Date: Fri, 5 Dec 2025 18:14:43 +0100 Message-ID: <20251205171446.2814872-13-jremus@linux.ibm.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251205171446.2814872-1-jremus@linux.ibm.com> References: <20251205171446.2814872-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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: NZbwaSvgZ_Yf3Sh9IhHOqKZ_R7rYODQP X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMTI5MDAxNiBTYWx0ZWRfX7Gw6EvKRsBmI mSXktRu1YLv1e9ddY4cRmXkAowiRDZQKFNF71hTvpMSPbsBCs6ms9N6aPFxxq7rJeAByjRJa+et Nrcq2kPdV608sL/zhOjcJ5IgnJZIj4RGyUD2ls4BjxNAeWC6v0b9KhZMCkX4YjymQRUq78Bkwwr /idiA0thq5dBWZ3IcjZDC6dAD3CbVLLBhNw3SeKvl6N7O+p6AG4cqUKS7GQcPohQz10I0BAjSFJ GJ36YdvSlSBqg5vMJVTOrCPPfKyoctiRHsz9C5yj/gnySGrJqsL/Qq3CZxxe4NpCkDGu5OFPdmr qn1xvdlpMrO9PQGUPVir8HNVhgissLweIZtmoh8PMS6tCw3J34u0yix0SYlEYG53Nc8uQtn13HE zHW4wn2FPdojxFib7LXTNAN2UTi82g== X-Authority-Analysis: v=2.4 cv=UO7Q3Sfy c=1 sm=1 tr=0 ts=69331312 cx=c_pps a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==:17 a=IkcTkHD0fZMA:10 a=wP3pNCr1ah4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=NEAV23lmAAAA:8 a=VnNF1IyMAAAA:8 a=SdC2vBNBQt3qShdCGKMA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 X-Proofpoint-GUID: 4vnQKU2kTDP9Dtedx-plqcAtkB_Vh2yc X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-12-05_06,2025-12-04_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 malwarescore=0 bulkscore=0 adultscore=0 priorityscore=1501 impostorscore=0 spamscore=0 phishscore=0 clxscore=1015 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2510240000 definitions=main-2511290016 On s390 64-bit the s390x ELF ABI [1] designates register 11 as the "preferred" frame pointer (FP) 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 and arm64. Use const qualifier on struct pt_regs pointers to prevent compiler warnings: arch/s390/kernel/stacktrace.c: In function =E2=80=98arch_stack_walk_user_co= mmon=E2=80=99: arch/s390/kernel/stacktrace.c:114:34: warning: passing argument 1 of =E2=80=98instruction_pointer=E2=80=99 discards =E2=80=98const=E2=80=99 qual= ifier from pointer target type [-Wdiscarded-qualifiers] ... arch/s390/kernel/stacktrace.c:117:48: warning: passing argument 1 of =E2=80=98user_stack_pointer=E2=80=99 discards =E2=80=98const=E2=80=99 quali= fier from pointer target type [-Wdiscarded-qualifiers] ... [1]: s390x ELF ABI, https://github.com/IBM/s390x-abi/releases Signed-off-by: Jens Remus --- Notes (jremus): Changes in RFC v2: - Separate provide frame_pointer() into this new commit. arch/s390/include/asm/ptrace.h | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/arch/s390/include/asm/ptrace.h b/arch/s390/include/asm/ptrace.h index dfa770b15fad..455c119167fc 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) @@ -235,6 +233,22 @@ static __always_inline unsigned long kernel_stack_poin= ter(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 ABI-designated "preferred" frame-pointer register value. */ + 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 regs_get_register(struct pt_regs *reg= s, unsigned int offset) { if (offset >=3D NUM_GPRS) --=20 2.51.0 From nobody Fri Dec 19 15:01:48 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 A9470145B16; Fri, 5 Dec 2025 17:15:28 +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=1764954932; cv=none; b=WgXbmITJCqZ8As/k8DbLF3+8sdEWoItt1E9/8sJZihd/e/2FxWYfQ7d1m67n5EbMpFE5R9wq/V0O+lU5uDozT8E/N72gYG/Ik3oVrLFmqhNy1plrC6WDHHBRtJ1ejGMdKCp5x7pzOlzrWPQqLj7WrRib2j6NGX7vHm4vKnRe2u0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764954932; c=relaxed/simple; bh=gOP+6UJLT+iBPjibPLic1b9SePLoITAw3L4gviO+6pY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lOtsF08L8Fwk+gpoTgMO9bKa6+/k9OPVH8xoL1arpjC2C8BWBcLCTkiaWmO8deSPKyfmrEyKyL/ztnymS0yGYafSWoBwOIy/baUlF2MUVFxVkc9r53nxKT5zUpAFscl9SyVAqOk/bV63yoSYhpLVnkZ8PSc4rHrebEh16H2VG0U= 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=UsojbQ0l; 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="UsojbQ0l" 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 5B5Drf0R010288; Fri, 5 Dec 2025 17:14:58 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=YWOOUB0UikvbXJWWs 3TrXD+M01rnArWa5OIhg9O+1+o=; b=UsojbQ0lILkjlgKmwO3dMOJ3voUvVJ8Fj XlZJUNuuhfXu7HJ+jjvl1zIdWyH6Kf+Zft6mH8Q1D9wG7J6gis9FXXlG94vCMEzO 0jfdPdUmp7AOVJ8QbQlezJTt4j2iRekuBn5MA9/lIrRinjkZjWX9oIm6+3Nk9Kbq XBUy2DWo1zjZwVDELfkBgBG3M5EE/GJz17evNMa6nQT1DVPzIeNoIyzmtq7ohTcs +h8G4WhoMINVUoOhhgtRUAZVeggOsh9pbiEVn+G4VnYXIwdYZDZdjuoWJr44K8LC Qb/qwwHnKH0c1Z0PIiO71E7/lJcne40OEcWyiXujiNdfN4IJAXzPw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4aqp8qeb4v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Dec 2025 17:14:58 +0000 (GMT) Received: from m0356516.ppops.net (m0356516.ppops.net [127.0.0.1]) by pps.reinject (8.18.1.12/8.18.0.8) with ESMTP id 5B5HBdjr010497; Fri, 5 Dec 2025 17:14:57 GMT 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 4aqp8qeb4p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Dec 2025 17:14:57 +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 5B5FhDmK003847; Fri, 5 Dec 2025 17:14:56 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 4ardck65pw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Dec 2025 17:14:56 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5B5HEqTB47644990 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 5 Dec 2025 17:14:52 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8852F20043; Fri, 5 Dec 2025 17:14:52 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3E1E32004F; Fri, 5 Dec 2025 17:14:52 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.87.85.9]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 5 Dec 2025 17:14:52 +0000 (GMT) From: Jens Remus To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-s390@vger.kernel.org, bpf@vger.kernel.org, x86@kernel.org, Steven Rostedt Cc: Jens Remus , Heiko Carstens , Vasily Gorbik , Ilya Leoshkevich , Josh Poimboeuf , Masami Hiramatsu , Mathieu Desnoyers , Peter Zijlstra , Ingo Molnar , Jiri Olsa , Arnaldo Carvalho de Melo , Namhyung Kim , Thomas Gleixner , Andrii Nakryiko , Indu Bhagat , "Jose E. Marchesi" , Beau Belgrave , Linus Torvalds , Andrew Morton , Florian Weimer , Kees Cook , "Carlos O'Donell" , Sam James , Dylan Hatch Subject: [RFC PATCH v2 13/15] s390/unwind_user/sframe: Enable HAVE_UNWIND_USER_SFRAME Date: Fri, 5 Dec 2025 18:14:44 +0100 Message-ID: <20251205171446.2814872-14-jremus@linux.ibm.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251205171446.2814872-1-jremus@linux.ibm.com> References: <20251205171446.2814872-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: AW1haW4tMjUxMTI5MDAwMCBTYWx0ZWRfXzl6Zx9Kx7iip VFCp2CBJhZHAyd22AID9uhRFDShsOcUo1MDIL+e+dmZugP7vYQJGb32SFdQBl09ZSJtsqk+jZbc wB670/gwgonolxWvGZU6s9gKA2DDTd2lUNvrOFEK3xf/NfYiF+/J8o5wEkOv2w/VFMNQTSFaJcw /zcr8W86Gotr+k4rK9dHfzwJZFIcjNNy9y+Yn+vxItOmw5NhNsnDS7hKWWeBrXdOUOWt65Eb8H1 0s/Vm9K4sgu+GsuA9VXu4mjF5Ep4BCm/QzgZgCpcODkmSGZY/C1TC0QquDMgsdIDVvJH+y3M5rN in6vCrESvAwlnXf1p80VbWS8ZtBczuvygZjCr4sYb7VAm8YborWo7RGk+TiFc87/K4go4oOsAd6 XN9gr42UBO6l+HVhStp6VWbqPpnJow== X-Authority-Analysis: v=2.4 cv=dIerWeZb c=1 sm=1 tr=0 ts=69331312 cx=c_pps a=AfN7/Ok6k8XGzOShvHwTGQ==:117 a=AfN7/Ok6k8XGzOShvHwTGQ==:17 a=wP3pNCr1ah4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=NEAV23lmAAAA:8 a=VwQbUJbxAAAA:8 a=VnNF1IyMAAAA:8 a=SgTjFYeX4wDDoTrxqN8A:9 X-Proofpoint-ORIG-GUID: 89x2jJ5rrpBhQ2TMQPiWwYJ-3vCAEGNF X-Proofpoint-GUID: Cmq_Odn8seEpYJfkDP58i_G5vhbKrONt X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-12-05_06,2025-12-04_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 lowpriorityscore=0 clxscore=1015 spamscore=0 malwarescore=0 suspectscore=0 adultscore=0 bulkscore=0 impostorscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2510240000 definitions=main-2511290000 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. 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. [1]: s390x ELF ABI, https://github.com/IBM/s390x-abi/releases Signed-off-by: Jens Remus --- Notes (jremus): Changes in RFC v2: - Provide unwind_user_word_size() to satisfy new unwind user need. Note that support for COMPAT has not been implemented as s390 support for COMPAT is expected to be removed with v6.19: https://lore.kernel.org/all/20251201102713.22472A5b-hca@linux.ibm.com/ - Adjust to changes in preceding patches in this series that enable support in unwind user (sframe) for s390 particularities. =20 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/Kconfig | 1 + arch/s390/include/asm/unwind_user.h | 100 +++++++++++++++++++++ arch/s390/include/asm/unwind_user_sframe.h | 33 +++++++ kernel/unwind/sframe.c | 2 +- kernel/unwind/sframe.h | 14 +++ 5 files changed, 149 insertions(+), 1 deletion(-) 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 df22b10d9141..52d3f3b3e086 100644 --- a/arch/s390/Kconfig +++ b/arch/s390/Kconfig @@ -246,6 +246,7 @@ config S390 select HAVE_SETUP_PER_CPU_AREA select HAVE_SOFTIRQ_ON_OWN_STACK select HAVE_SYSCALL_TRACEPOINTS + select HAVE_UNWIND_USER_SFRAME select HAVE_VIRT_CPU_ACCOUNTING select HAVE_VIRT_CPU_ACCOUNTING_IDLE select HOTPLUG_SMT 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..38dff49d5f86 --- /dev/null +++ b/arch/s390/include/asm/unwind_user.h @@ -0,0 +1,100 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_S390_UNWIND_USER_H +#define _ASM_S390_UNWIND_USER_H + +#include +#include +#include + +#ifdef CONFIG_UNWIND_USER + +static inline int unwind_user_word_size(struct pt_regs *regs) +{ + return sizeof(long); +} + +static inline int arch_unwind_user_get_ra_reg(unsigned long *val) +{ + struct pt_regs *regs =3D task_pt_regs(current); + *val =3D regs->gprs[14]; + return 0; +} +#define unwind_user_get_ra_reg arch_unwind_user_get_ra_reg + +static inline int __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: + return -EINVAL; + } + + return 0; +} + +static inline int arch_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]; + return 0; + } else if (16 <=3D regnum && regnum <=3D 31) { + return __s390_get_dwarf_fpr(val, regnum); + } + + return -EINVAL; +} +#define unwind_user_get_reg arch_unwind_user_get_reg + +#endif /* CONFIG_UNWIND_USER */ + +#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..e3b80c48f326 --- /dev/null +++ b/arch/s390/include/asm/unwind_user_sframe.h @@ -0,0 +1,33 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_S390_UNWIND_USER_SFRAME_H +#define _ASM_S390_UNWIND_USER_SFRAME_H + +#include +#include + +#define SFRAME_SP_OFFSET SFRAME_S390X_SP_VAL_OFFSET + +static inline s32 arch_sframe_cfa_offset_decode(s32 offset) +{ + return SFRAME_V2_S390X_CFA_OFFSET_DECODE(offset); +} +#define sframe_cfa_offset_decode arch_sframe_cfa_offset_decode + +static inline void +arch_sframe_init_reginfo(struct unwind_user_reginfo *reginfo, s32 offset) +{ + if (SFRAME_V2_S390X_OFFSET_IS_REGNUM(offset)) { + reginfo->loc =3D UNWIND_USER_LOC_REG; + reginfo->regnum =3D SFRAME_V2_S390X_OFFSET_DECODE_REGNUM(offset); + } else if (offset) { + reginfo->loc =3D UNWIND_USER_LOC_STACK; + reginfo->offset =3D offset; + } else { + reginfo->loc =3D UNWIND_USER_LOC_NONE; + } +} +#define sframe_init_reginfo arch_sframe_init_reginfo + +#include + +#endif /* _ASM_S390_UNWIND_USER_SFRAME_H */ diff --git a/kernel/unwind/sframe.c b/kernel/unwind/sframe.c index 92f770fc21f6..bd446d55b552 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_fde_internal { unsigned long func_start_addr; diff --git a/kernel/unwind/sframe.h b/kernel/unwind/sframe.h index 69ce0d5b9694..c09f25fbaa2f 100644 --- a/kernel/unwind/sframe.h +++ b/kernel/unwind/sframe.h @@ -18,6 +18,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 @@ -69,4 +70,17 @@ 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.51.0 From nobody Fri Dec 19 15:01:48 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 4723A34B421; Fri, 5 Dec 2025 17:15:26 +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=1764954931; cv=none; b=VXT7hxb+IhO3yF2piSB5Ek5dGbb7anFc+hxhHBe3AXiO9P37S6/uy4HvsGGZkEgvaRISd5UjJnj6VxI+G1tYc9r/3pg+xo/WOaefHknnGxCxlkQbQ3QRtr3Nmfh/rXNQ6QE/y9FYMSpn+/2FGBmN65rnt6lqhG9aw2yE5azSPUM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764954931; c=relaxed/simple; bh=/VJQUCllBAo6tp6f/f6h1Hk6REQ9vW1vQAVDzfgpAoE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=S1dAqKXvobC6r0lWMs68TZA+mfoErB/g0MhcqvaMhY2StXKHkjQFYDXHqVqCNjDN3CBEJDVjsCWjfhbVukJPL6wJtgWarg7Q8W6MVtyIiyYzVgf4wxt+ZQEefUyDXJEhoVDplqLO3/UQBJ/Q3/9hf90+xndSekUO3bFzYPkdZbs= 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=IChS6yQl; 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="IChS6yQl" 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 5B5Cow1Z026058; Fri, 5 Dec 2025 17:14:58 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=tey/Koe1GcsogZgDf jFfgSAa+ebExosUDctFg/uz4UE=; b=IChS6yQl2yoClr/IsAXI2sfvBXNCX4xpa OImj4cy8M6ACeRuR8S2c8iOTP8t/mr9X4U6+OosowzYyuA0aGVYNQWYtjKO6yJq5 D6YtcHPil/xT4OBnrh2AXorPKM+igGWoAEnL4HBHWIa+J93RXQ27GikcemUFqSxq jFn6JuSK9ml48BY99/PId29v1wFzS4EucV4UB4I1hoaNPQgoMV7GM6+COANEkLae zbOfeCFn6bEpIxTsEmyg3ZEj/9AdSF8EXl8qRmNhXNzpy03K1YxqJmbuWcX4sHlh Mayk+wrnPbVO1URRPXotTqEPeB5iPbpyAfFPiPsK+wH1OUPLDvahA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4aqrg5x3bu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Dec 2025 17:14:58 +0000 (GMT) Received: from m0360072.ppops.net (m0360072.ppops.net [127.0.0.1]) by pps.reinject (8.18.1.12/8.18.0.8) with ESMTP id 5B5HA2th010239; Fri, 5 Dec 2025 17:14:57 GMT 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 4aqrg5x3bp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Dec 2025 17:14:57 +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 5B5Ei63f019051; Fri, 5 Dec 2025 17:14:57 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4arbhyeee4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Dec 2025 17:14:56 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5B5HEqWR47644994 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 5 Dec 2025 17:14:53 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D20122004F; Fri, 5 Dec 2025 17:14:52 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8D7F52004D; Fri, 5 Dec 2025 17:14:52 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.87.85.9]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 5 Dec 2025 17:14:52 +0000 (GMT) From: Jens Remus To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-s390@vger.kernel.org, bpf@vger.kernel.org, x86@kernel.org, Steven Rostedt Cc: Jens Remus , Heiko Carstens , Vasily Gorbik , Ilya Leoshkevich , Josh Poimboeuf , Masami Hiramatsu , Mathieu Desnoyers , Peter Zijlstra , Ingo Molnar , Jiri Olsa , Arnaldo Carvalho de Melo , Namhyung Kim , Thomas Gleixner , Andrii Nakryiko , Indu Bhagat , "Jose E. Marchesi" , Beau Belgrave , Linus Torvalds , Andrew Morton , Florian Weimer , Kees Cook , "Carlos O'Donell" , Sam James , Dylan Hatch Subject: [RFC PATCH v2 14/15] unwind_user/backchain: Introduce back chain user space unwinding Date: Fri, 5 Dec 2025 18:14:45 +0100 Message-ID: <20251205171446.2814872-15-jremus@linux.ibm.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251205171446.2814872-1-jremus@linux.ibm.com> References: <20251205171446.2814872-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: JaqfqyTfCNxe5xohRO4YaWy-3AnhamS8 X-Authority-Analysis: v=2.4 cv=Ir0Tsb/g c=1 sm=1 tr=0 ts=69331312 cx=c_pps a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==:17 a=wP3pNCr1ah4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=VnNF1IyMAAAA:8 a=25eHwDaP0uuWkKgxUQEA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMTI5MDAyMCBTYWx0ZWRfX13Xq8lPYriId BH1uuecWESQQzPTrVMlLA6V2MyXUQLu56aHLK4YAlIIsdGu3/lL7Pk4mIbnefQlE97/8LkDqBBX oasqMjxGfYL83q9TgoBld3Z/mVZHmGnZ2ooiNNE02A2YdG1YRiO5G9hr+i/MQ7FDQCSya98cJbQ bx3zidYPv/M35MM8h/Mzg3k/I+OSssBOyu+O8y91+ws4ad/Deer2VPRFBMc16TFoS1UVGgDO7b2 zEccVjyMxf3TCr3ZX5wKEXjBfd+JjR1abEKgdoJvRb7mXTrBa7KC18KlBAsfQyJTke4TOB0B9nr iXXfuptNHqRJJu3pqAvmrL/qnIuoO8DXIIi5NeCSDYi0mN0vPETMji+jyk2nAWBBmtkwqz7cAR0 cnffLxWlQAe1dR+BWsc2DxFhUgeJ2g== X-Proofpoint-GUID: qO5cVrGxnd_X6wR8EBS_oE09CUejmap_ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-12-05_06,2025-12-04_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 adultscore=0 impostorscore=0 clxscore=1015 priorityscore=1501 bulkscore=0 spamscore=0 lowpriorityscore=0 suspectscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2510240000 definitions=main-2511290020 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 --- Notes (jremus): Changes in RFC v2: - Adjusted to latest unwind user enhancements. Does hopefully no longer appear grafted on. arch/Kconfig | 6 ++++++ include/linux/unwind_user_backchain.h | 20 ++++++++++++++++++++ include/linux/unwind_user_types.h | 2 ++ kernel/unwind/user.c | 12 ++++++++++++ 4 files changed, 40 insertions(+) create mode 100644 include/linux/unwind_user_backchain.h diff --git a/arch/Kconfig b/arch/Kconfig index 7fa89d70b244..37fb78a5e876 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -488,6 +488,12 @@ config AS_SFRAME 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..e7a8e584b13f --- /dev/null +++ b/include/linux/unwind_user_backchain.h @@ -0,0 +1,20 @@ +/* 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 arch_unwind_user_next_backchain(struct unwind_user_state *state= ); + +#else /* !CONFIG_HAVE_UNWIND_USER_BACKCHAIN */ + +static inline int arch_unwind_user_next_backchain(struct unwind_user_state= *state) +{ + 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 6efc12b6e831..b44502e90b7f 100644 --- a/include/linux/unwind_user_types.h +++ b/include/linux/unwind_user_types.h @@ -11,6 +11,7 @@ enum unwind_user_type_bits { UNWIND_USER_TYPE_SFRAME_BIT =3D 0, UNWIND_USER_TYPE_FP_BIT =3D 1, + UNWIND_USER_TYPE_BACKCHAIN_BIT =3D 2, =20 NR_UNWIND_USER_TYPE_BITS, }; @@ -20,6 +21,7 @@ enum unwind_user_type { UNWIND_USER_TYPE_NONE =3D 0, UNWIND_USER_TYPE_SFRAME =3D BIT(UNWIND_USER_TYPE_SFRAME_BIT), UNWIND_USER_TYPE_FP =3D BIT(UNWIND_USER_TYPE_FP_BIT), + UNWIND_USER_TYPE_BACKCHAIN =3D BIT(UNWIND_USER_TYPE_BACKCHAIN_BIT), }; =20 struct unwind_stacktrace { diff --git a/kernel/unwind/user.c b/kernel/unwind/user.c index 122045cb411f..5b4649bc91ba 100644 --- a/kernel/unwind/user.c +++ b/kernel/unwind/user.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include =20 @@ -105,6 +106,11 @@ static int unwind_user_next_common(struct unwind_user_= state *state, return 0; } =20 +static int unwind_user_next_backchain(struct unwind_user_state *state) +{ + return arch_unwind_user_next_backchain(state); +} + static int unwind_user_next_fp(struct unwind_user_state *state) { struct pt_regs *regs =3D task_pt_regs(current); @@ -159,6 +165,10 @@ static int unwind_user_next(struct unwind_user_state *= state) if (!unwind_user_next_fp(state)) return 0; continue; + case UNWIND_USER_TYPE_BACKCHAIN: + if (!unwind_user_next_backchain(state)) + return 0; + continue; /* Try next method. */ default: WARN_ONCE(1, "Undefined unwind bit %d", bit); break; @@ -187,6 +197,8 @@ static int unwind_user_start(struct unwind_user_state *= state) state->available_types |=3D UNWIND_USER_TYPE_SFRAME; if (IS_ENABLED(CONFIG_HAVE_UNWIND_USER_FP)) state->available_types |=3D UNWIND_USER_TYPE_FP; + if (IS_ENABLED(CONFIG_HAVE_UNWIND_USER_BACKCHAIN)) + state->available_types |=3D UNWIND_USER_TYPE_BACKCHAIN; =20 state->ip =3D instruction_pointer(regs); state->sp =3D user_stack_pointer(regs); --=20 2.51.0 From nobody Fri Dec 19 15:01:48 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 88B1C34B426; Fri, 5 Dec 2025 17:15:27 +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=1764954931; cv=none; b=QSDD0UVBQZgxebBv6/JpJ9Yvxm4OHorAYwbkXr8FGE1d5v4XN2yJpBcbl25f6my2zGcjI0PDKxnJlIOyD+B+dvX5Fy31uTkn5ebk4dTOiNbRxUzYsBJ1JsCe+hsqeC0MNEl5gK3dZSwvI/F/KB27QfBrRIuJNPPHS3PuC3rst3k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764954931; c=relaxed/simple; bh=HBCyKAoA65FFXNpzph30OSPt55chhPw8iKxAUaVC4dk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IgyhXJVt3X/i0DFXq19RYTeBu0a4TT4N2hSqXFpKE66vtwY26x0031Cz1/PtSB4z8ejLRNZwIdgygT58aHOh2+ksp3ASqB/b1wttxq2kLlW+6Y+jdJv9KxdMdQ5Cw4wTOEnIPHS2CCtEEX8yaX/bMGDoYpQSrHMKQYSny+LP6NQ= 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=aqOUGcpK; 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="aqOUGcpK" 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 5B58Tblq006115; Fri, 5 Dec 2025 17:14:59 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=RGUGmb81k/upQMUHk zVbqvFouk7RSTWlms+ka3S7kHM=; b=aqOUGcpK9AtQ29UIhucxljR9whixRAVTP zCSwhgNvvses0Dg6hj8x/16SKWfUqbxnq4F9Sv1lW3nnVlHSM1xUdTWPbOGI9DZr U1G2PMDg9hAUSVO6YujZj5u2NGcZQPF0OuBj9h8T2/k9RxzB2FBmhEcUakHALKmR 1l0jJrzvBywLNLT3afsOqZEZfUhfNzVgMtd7evy8/XA2iftXt10j6eZrXqYPAc7T ELurEXAdktAXPaO/MxSqotf5uv4gxg+9DyBk2A4+ng4edis6UZJ074Vc1NTKgFcx nstxfwq7WqvaxKr6YQj57mMUCpFVVzQNZxcl5ci6WkV4BtJgYoLXw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4aqrg5x3c0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Dec 2025 17:14:58 +0000 (GMT) Received: from m0360072.ppops.net (m0360072.ppops.net [127.0.0.1]) by pps.reinject (8.18.1.12/8.18.0.8) with ESMTP id 5B5HDNQA015566; Fri, 5 Dec 2025 17:14:58 GMT 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 4aqrg5x3br-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Dec 2025 17:14:58 +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 5B5G794b021504; Fri, 5 Dec 2025 17:14:57 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4at8c6qj4g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Dec 2025 17:14:57 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5B5HEr1D15401368 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 5 Dec 2025 17:14:53 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 23E5720043; Fri, 5 Dec 2025 17:14:53 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D6F162005A; Fri, 5 Dec 2025 17:14:52 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.87.85.9]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 5 Dec 2025 17:14:52 +0000 (GMT) From: Jens Remus To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-s390@vger.kernel.org, bpf@vger.kernel.org, x86@kernel.org, Steven Rostedt Cc: Jens Remus , Heiko Carstens , Vasily Gorbik , Ilya Leoshkevich , Josh Poimboeuf , Masami Hiramatsu , Mathieu Desnoyers , Peter Zijlstra , Ingo Molnar , Jiri Olsa , Arnaldo Carvalho de Melo , Namhyung Kim , Thomas Gleixner , Andrii Nakryiko , Indu Bhagat , "Jose E. Marchesi" , Beau Belgrave , Linus Torvalds , Andrew Morton , Florian Weimer , Kees Cook , "Carlos O'Donell" , Sam James , Dylan Hatch Subject: [RFC PATCH v2 15/15] s390/unwind_user/backchain: Enable HAVE_UNWIND_USER_BACKCHAIN Date: Fri, 5 Dec 2025 18:14:46 +0100 Message-ID: <20251205171446.2814872-16-jremus@linux.ibm.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251205171446.2814872-1-jremus@linux.ibm.com> References: <20251205171446.2814872-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: 1jo5pWau_LBs9yTaqt7mzvhYz3fWWAxy X-Authority-Analysis: v=2.4 cv=Ir0Tsb/g c=1 sm=1 tr=0 ts=69331312 cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==:17 a=wP3pNCr1ah4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=VnNF1IyMAAAA:8 a=3bOCESsrY8nbLZwxsYcA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMTI5MDAyMCBTYWx0ZWRfX1RgK7csGZO/+ oTpnAdWMvXg9qvixPltY1x4UvcTrEDSvQkqsBxul1a/MLNNN9zQOSwRRWlDlqAXddpUIGDdP1mx 2i/cO0cDKhIwHhYbJyORsvNfkYJZQZv/BnPOUtWkf1Y1bWQ7KR32KtfEbXPIuJVnFp/c82DxvYY ht31XYx30QpR1oFNsuYoahBMq8pANzjCqXHx9uj0j5YyoF5EOzmKYbVB2gp07Ok11w6y9aswEHH np5gE8jY6jjx3d87Fkrh8hmNeHmyV4L9YziCnwDJO/NSF1HReD7zjeD/QVz0hm4rbPcwfFCUFbS 4APUBJgI3sBrkOOyNonVGuAS+twwP/QV36Em9FzKzLd0MwW4QI3p84FBiNxqzkSejboJDz4Ebhg YvusOUpvla+2wpHWntNrTouKi0ixPA== X-Proofpoint-GUID: I1CWD7Dl6WYB5hea1O3PRbZ_-STnTtSh X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-12-05_06,2025-12-04_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 adultscore=0 impostorscore=0 clxscore=1015 priorityscore=1501 bulkscore=0 spamscore=0 lowpriorityscore=0 suspectscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2510240000 definitions=main-2511290020 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. Note that an invalid RA obtained from the stack frame pointed to by the back chain is not a valid indication that the IP is still early in the function prologue and a fallback to the RA and SP register r14 and r15 contents should be made. Signed-off-by: Jens Remus --- Notes (jremus): Changes in RFC v2: - Adjusted to latest unwind user changes. - Use struct stack_frame_user and struct stack_frame_vdso_wrapper from asm/stacktrace.h. - In topmost frame do not fallback to RA (and SP) register values if RA is invalid. This is not a valid indication for early prologue. - In topmost frame use RA and SP register values if they match those saved in the frame. This indicates early prologue. arch/s390/Kconfig | 1 + arch/s390/kernel/Makefile | 2 + arch/s390/kernel/unwind_user_backchain.c | 112 +++++++++++++++++++++++ 3 files changed, 115 insertions(+) create mode 100644 arch/s390/kernel/unwind_user_backchain.c diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig index 52d3f3b3e086..5aeb2abd390f 100644 --- a/arch/s390/Kconfig +++ b/arch/s390/Kconfig @@ -246,6 +246,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_SFRAME select HAVE_VIRT_CPU_ACCOUNTING select HAVE_VIRT_CPU_ACCOUNTING_IDLE diff --git a/arch/s390/kernel/Makefile b/arch/s390/kernel/Makefile index eb06ff888314..eb662e95c5fd 100644 --- a/arch/s390/kernel/Makefile +++ b/arch/s390/kernel/Makefile @@ -83,6 +83,8 @@ obj-$(CONFIG_PERF_EVENTS) +=3D perf_pai_crypto.o perf_pai= _ext.o =20 obj-$(CONFIG_TRACEPOINTS) +=3D trace.o =20 +obj-$(CONFIG_HAVE_UNWIND_USER_BACKCHAIN) +=3D unwind_user_backchain.o + # vdso obj-y +=3D vdso64/ obj-$(CONFIG_COMPAT) +=3D vdso32/ diff --git a/arch/s390/kernel/unwind_user_backchain.c b/arch/s390/kernel/un= wind_user_backchain.c new file mode 100644 index 000000000000..4e10ca43ea36 --- /dev/null +++ b/arch/s390/kernel/unwind_user_backchain.c @@ -0,0 +1,112 @@ +// SPDX-License-Identifier: GPL-2.0 + +#define pr_fmt(fmt) "backchain: " fmt + +#include +#include +#include +#include +#include + +/** + * 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) +{ + /* Architecture requires IP to be 2-byte aligned. */ + 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_next_backchain - Unwind one frame using s390 back chain + * @state: The unwind user state + * + * returns zero when successful, otherwise -EINVAL. + */ +int arch_unwind_user_next_backchain(struct unwind_user_state *state) +{ + struct stack_frame_user __user *sf; + unsigned long sp, ra; + + sf =3D (void __user *)state->sp; + + /* + * In topmost frame check whether IP in early prologue, RA and SP + * registers saved, and no new stack frame allocated. + */ + if (state->topmost) { + unsigned long ra_reg; + + if (__get_user(ra, (unsigned long __user *)&sf->gprs[8])) + return -EINVAL; + if (__get_user(sp, (unsigned long __user *)&sf->gprs[9])) + return -EINVAL; + if (unwind_user_get_ra_reg(&ra_reg)) + return -EINVAL; + if (ra =3D=3D ra_reg && sp =3D=3D state->sp) + goto done; + } + + if (__get_user(sp, (unsigned long __user *)&sf->back_chain)) + return -EINVAL; + if (!sp && ip_within_vdso(state->ip)) { + /* + * Assume non-standard vDSO user wrapper stack frame. + * See vDSO user wrapper code for details. + */ + 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->back_chain)) + return -EINVAL; + } else if (!sp) { + /* Assume outermost frame reached. */ + state->done =3D true; + return 0; + } else { + /* + * Assume IP past prologue and new stack frame allocated. + * Follow back chain, which then equals the SP at entry. + * Skips caller if wrong in topmost frame. + */ + sf =3D (void __user *)sp; + if (__get_user(ra, (unsigned long __user *)&sf->gprs[8])) + return -EINVAL; + /* Skip validation: ABI requires SP to be saved as well. */ + } + +done: + /* Validate SP and RA (ABI requires SP to be 8-byte aligned). */ + if (sp & 7 || ip_invalid(ra)) + return -EINVAL; + + state->ip =3D ra; + state->sp =3D sp; + state->fp =3D 0; /* Cannot unwind FP. */ + state->topmost =3D false; + + return 0; +} --=20 2.51.0