From nobody Mon Dec 1 21:30:56 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 6BCD030DD00; Mon, 1 Dec 2025 12:54:47 +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=1764593689; cv=none; b=j+1QSH9C4dwGRz5VYyXnzvFQJt4gZf9E3NSBednQvaTcnG2HdC4ij3N+4Ic0kPy6F94IXN1oO4WS9QJ2ujLjppjkaPh0+PmlLfr1BpPKHbOo4o5svv64y2mSdLZ/JtsuhLvAAR0zH6zk6lbCFN7oR3AWfzqLPiYnRM8I0TrjID0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764593689; c=relaxed/simple; bh=J4PyjTWZZy4AMR0cCiyLgwuuJeCOaxRSVWHewOd8ldY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ac/tA8Wn7p+gv4b2Nb49ijK82f49hvVTeZhMYzi1OAqUt+egc9lKI10FhcWZAvYzWeEaVCLXNRV7YA8S2v8D+0gU7oQdnb3pdkbRA3Zix8xPKnu4nWK5EeisKXtDG1fi8DebYdpjJMnpYc0sMOZrylJDPRbswfNc74ikxHYPVAE= 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=ePpeZwwI; 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="ePpeZwwI" 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 5B192Hvw031345; Mon, 1 Dec 2025 12:54:23 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=rpg5SPvkgel8a3b1b /FIgAvz7SBPHHvdD/JLyQb5oIY=; b=ePpeZwwIlhO0w2fu4S2QQ+VD1IHziEPpC HVqasVAXzLPmS4l4KBmKGs6mvV1ILGlXaY0kp2zoqR6TT3fXK6oByWB79tY0yKfw dlELBV8tsCIIqEu+VVjCaqAiRcQrm9CusOAKtW8jsAXuYOMXJL5+yfaWngi7zhG8 HLK814Cbf1z/ViZvYLVljpqLoohvaIe0T+m0nzOioXdPsYGgIteKscucmRF8EAd4 yTLIBG6kZo1bDxKjZBL3kapctqv0HsUr7V5QMLJeJn56upk6qst+lp32Ny0IkWMM ZhzxSe415nxnIQ0fqf06FxJ6+PuNqG8mzz/Q7Fs+YsRePsLLyif6Q== 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 4aqp8pq6ta-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 01 Dec 2025 12:54:23 +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 5B1AJSaR003853; Mon, 1 Dec 2025 12:54:22 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 4ardcje74a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 01 Dec 2025 12:54:22 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5B1CsJ3U49611124 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 1 Dec 2025 12:54:19 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F186E20043; Mon, 1 Dec 2025 12:54:18 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AB88E2004D; Mon, 1 Dec 2025 12:54:18 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 1 Dec 2025 12:54:18 +0000 (GMT) From: Jens Remus To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, x86@kernel.org, Steven Rostedt , Peter Zijlstra Cc: Jens Remus , Josh Poimboeuf , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Mathieu Desnoyers , Indu Bhagat , "Jose E. Marchesi" , Heiko Carstens , Vasily Gorbik , Ilya Leoshkevich Subject: [PATCH v2 1/3] unwind_user: Enhance comments on get CFA, FP, and RA Date: Mon, 1 Dec 2025 13:54:14 +0100 Message-ID: <20251201125416.1239568-2-jremus@linux.ibm.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251201125416.1239568-1-jremus@linux.ibm.com> References: <20251201125416.1239568-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: AW1haW4tMjUxMTI5MDAwMCBTYWx0ZWRfXw6oZBCN9gdcL eu43bH7BgVtoCaMRgfyqcvK5Om/dxPbe8wMzlzNy6nYxNtjwNzx5oOgD23Zm2zKgTzmxVQXkIhA oNlw7sDnw+dyyLoYck3gEsMfssljus6NuYZ4wA0fQB3y5FnsffMvRIxKKIq3MJ6GyeE02zxgDkA mgrkxIz20eVl+uN43MTFtUpuhog1GdiDfcIFxi4615cb9TRnty5qjPwa/AB9YVokZDKZVk28ibb o+KNUL15zWI30AFjhK5NUNaBY3lgBF+RR2ldfmsdTIwB7fQ52iPpAgZJJV2XlJ2m77Cp3Ek4Nz5 XRnom+FHJiw4Ajxaq/I10bg/MfJhCOi0j4ujJZCsS2xcKQ1bNij2oM+eIjuIm1fedyq3bXYamHJ 15bLDO04DRHU9b10HuMc+YOy0+zj7g== X-Authority-Analysis: v=2.4 cv=dIerWeZb c=1 sm=1 tr=0 ts=692d8fff cx=c_pps a=AfN7/Ok6k8XGzOShvHwTGQ==:117 a=AfN7/Ok6k8XGzOShvHwTGQ==:17 a=wP3pNCr1ah4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=VnNF1IyMAAAA:8 a=GRZQj7fo7pb9Qcd1f_cA:9 X-Proofpoint-ORIG-GUID: 4j_gxdZkdQ-70Rizih90eveM5qMcnj94 X-Proofpoint-GUID: 4j_gxdZkdQ-70Rizih90eveM5qMcnj94 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-11-28_08,2025-11-27_02,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" 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 39e270789444..0ca434f86e73 100644 --- a/kernel/unwind/user.c +++ b/kernel/unwind/user.c @@ -31,6 +31,7 @@ static int unwind_user_next_common(struct unwind_user_sta= te *state, { unsigned long cfa, fp, ra; =20 + /* Get the Canonical Frame Address (CFA) */ if (frame->use_fp) { if (state->fp < state->sp) return -EINVAL; @@ -38,11 +39,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 @@ -50,10 +49,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 Mon Dec 1 21:30:56 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 BE54A30DD00; Mon, 1 Dec 2025 12:54:57 +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=1764593699; cv=none; b=KHhD8qM5AVSuDEBZDxW0dyodRPRrQSniSuffsgqn1vgVM2eblBtOF0X9YmmgtGNyTNPGouYzyiqVbp3/kZfrObc8TSb/UDyqs7AT0XykgS5pbQ/lYISmI2ODWcSFQmOXxTYn3Y59Jjx3LfsL/2zGYeYFHjAgbywWf7ckHCCixc0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764593699; c=relaxed/simple; bh=YK2+e+li4DwmSYpreN89JRePxJfIhSXQuRbGgpwaXxo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uXo5i55a9C0rANb6rMKjTAqqw0D2VouU07XzhIRbNLcmGyRD6wJoaSCaxJZtX/S51x35FqP93psZ0TBNyUXoeEaEFackPJTl4sxPzmw/Ap5ftr+/8ayx8lpbxAQVwrQqX7CBgukwO8zQl4KNdJVujA0va0Yzvd80Ocw+FxVJUl0= 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=A3kYw1Ar; 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="A3kYw1Ar" 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 5B175ExH003477; Mon, 1 Dec 2025 12:54:24 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=9e/g6zDE7foN3dYee FMnVHSDJwzVUqZPVmHPFREias0=; b=A3kYw1Arce0ECoAbzZJW6PxajYj4VHrDn pSHlfM/S0WuUE0p1iiPhLcdakackSIP9ismfCFUPVFvejkzMWTRqx9JHwF2BuBbr OGmkhzTUGUn1Tye12s2Bt8sfDM9B53T7YsXxNr36Qc4hPGignoNMQkJGyilHHW+R /vMfI8XLT5JQt1bv1pbxcWiRckirdAsRQyvk+HokGQePKm40PVOkcPzL2bgdhDX9 quGPqtopqaqjpzG6kj2/CezomJk58k2loolArWABxZsizrBLGpMvu3N+lZmdsK1H C9a6EaraD+DYytSPXYNSKlC6wzekAjbcQzRz2jVc/xfaq6uDRh/hw== 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 4aqrj9f4yt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 01 Dec 2025 12:54:24 +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 5B1AHGF5029328; Mon, 1 Dec 2025 12:54:23 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 4ardv165fy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 01 Dec 2025 12:54:23 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5B1CsJgO49611126 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 1 Dec 2025 12:54:19 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4824820043; Mon, 1 Dec 2025 12:54:19 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 03C822004B; Mon, 1 Dec 2025 12:54:19 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 1 Dec 2025 12:54:18 +0000 (GMT) From: Jens Remus To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, x86@kernel.org, Steven Rostedt , Peter Zijlstra Cc: Jens Remus , Josh Poimboeuf , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Mathieu Desnoyers , Indu Bhagat , "Jose E. Marchesi" , Heiko Carstens , Vasily Gorbik , Ilya Leoshkevich Subject: [PATCH v2 2/3] unwind_user/fp: Use dummies instead of ifdef Date: Mon, 1 Dec 2025 13:54:15 +0100 Message-ID: <20251201125416.1239568-3-jremus@linux.ibm.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251201125416.1239568-1-jremus@linux.ibm.com> References: <20251201125416.1239568-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: r4CodtcTOkQ4t1deejzYrMvv54IMRBiC X-Proofpoint-ORIG-GUID: r4CodtcTOkQ4t1deejzYrMvv54IMRBiC X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMTI5MDAyMCBTYWx0ZWRfX0t2BOGyIz5Fw k+t4AAchNgKZMSWeW3YDCKBzdaxZTZsDva8Kv/yg0fwJTuAWSvTEUwzpMS4VAmBuYNbtYZqZaJm 6DmtRvSbnj89oXgIbNNhdn93VhcnhaxuKsBUhKbIYMWdQ3sxaCw5HNJrU2ay7BZyWxVyyI7YLxf 8kgkLpTdJ64vuoNUcg3EpT6dZAxfzmNdnP6ELHJYbGl2ANXiwQcpJKRVagOmERnOKVB8USimH4/ pChU5A0p54ourbxifuMape1G8I9awivkIGQJDeTD6W9PXgj/BVMHD52dLX9ZdOk8fpbgEUUI6Oe UNM/IH7MLXNXKclu8JgvVaq8G54vGiLSJKpFSUJDcDDhl7eizkRLe/gCcv9bndEZkNgTJ+Nw/0e ZR7atW9it6ktMcPM0wrkrUGepCbdwg== X-Authority-Analysis: v=2.4 cv=dYGNHHXe c=1 sm=1 tr=0 ts=692d9000 cx=c_pps a=aDMHemPKRhS1OARIsFnwRA==:117 a=aDMHemPKRhS1OARIsFnwRA==:17 a=wP3pNCr1ah4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=VnNF1IyMAAAA:8 a=pRS0VBzutSDFB64YrXgA: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-11-28_08,2025-11-27_02,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" 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 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 12064284bc4e..971ffe937d50 100644 --- a/arch/x86/include/asm/unwind_user.h +++ b/arch/x86/include/asm/unwind_user.h @@ -35,6 +35,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..e3e65c2955cf 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 /* !CONFIG_HAVE_UNWIND_USER_FP */ + +#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 0ca434f86e73..90ab3c1a205e 100644 --- a/kernel/unwind/user.c +++ b/kernel/unwind/user.c @@ -67,7 +67,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)) { @@ -81,9 +80,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(struct unwind_user_state *state) --=20 2.51.0 From nobody Mon Dec 1 21:30:56 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 6DB5430C372; Mon, 1 Dec 2025 12:54:58 +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=1764593699; cv=none; b=OcZYi/XKI2Kru3YbatYZwK49USLh5sv2v2IDtqpDYk269oYmggyd8vTUiwoQuOSvxbysEenhRjpuk2b4ZRFsaclR4V9T4b48fMu95MUUiv1O3rmzQ0/4g/OWH/iMmBqtjMdq9m12pT/Ls7nSX+IE8fKTGeyYHccKLI4fr9T+MI8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764593699; c=relaxed/simple; bh=+IjpNszmC6izWxL7EJv2qbrRxvopvddxR3SE6ucnsJ0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XlujFE2gBzQnRhv+DPWDjoznOIgx6VMsMhOoGVsyJPK4v9lVkI4ax3Yy4i0P2YftG1/Q8MJZPy4N1JPeoESoUF7FTzK4UutSRpBT9Ie/5g2moId50E0wTdBIv57hTF6AkmEkxHvTVX5Btan2PV8R5mM6O/rqBYvQj1XJhwiQukE= 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=XJKMes2+; 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="XJKMes2+" 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 5B18GHnX008018; Mon, 1 Dec 2025 12:54:29 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=up2QFoBk2TXh38F/D siKDh1hJYwb60yrb1wGwxwf9Eg=; b=XJKMes2+A54q6fSAfcgcJm0R4Z30bLL9C 7WdUm9k8djTsb7HftI0hFuuguSC94ki8AeZgThMBIIUkGdvNOhpbEOLZcoV1rQ7O PkBAGdVkaf55jsZiO6NKtn3vZh+28MxfPFx88vMv6OiHxJm3B6z1vAq01/0KMDet 0PdeK9ESnLbWvFHSvi7/1Hyb2eWQgpnq/DusGJfD2m0hAiCiWYdw4PPd9K95ibkh kZsu0twHiXhPpnzdG/BlWFpi37N45z/KS6vfRTGGCy/aW3VpKl+5ixeZSs6mAP5p bprsi24DwvALIWy/aBYONEKYocKlzUlQqCKiwYSp4ZJ3xsn250uYQ== 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 4aqrj9f4yu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 01 Dec 2025 12:54:28 +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 5B1CoCl0008558; Mon, 1 Dec 2025 12:54:23 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4arc5mpdha-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 01 Dec 2025 12:54:23 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5B1CsJgH41288026 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 1 Dec 2025 12:54:19 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 91CF320043; Mon, 1 Dec 2025 12:54:19 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4DE752004D; Mon, 1 Dec 2025 12:54:19 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 1 Dec 2025 12:54:19 +0000 (GMT) From: Jens Remus To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, x86@kernel.org, Steven Rostedt , Peter Zijlstra Cc: Jens Remus , Josh Poimboeuf , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Mathieu Desnoyers , Indu Bhagat , "Jose E. Marchesi" , Heiko Carstens , Vasily Gorbik , Ilya Leoshkevich Subject: [PATCH v2 3/3] x86/unwind_user: Guard unwind_user_word_size() by UNWIND_USER Date: Mon, 1 Dec 2025 13:54:16 +0100 Message-ID: <20251201125416.1239568-4-jremus@linux.ibm.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251201125416.1239568-1-jremus@linux.ibm.com> References: <20251201125416.1239568-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: ux6Jur0DqRBvn2KZr78y_3DE9OB7S3gr X-Proofpoint-ORIG-GUID: ux6Jur0DqRBvn2KZr78y_3DE9OB7S3gr X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMTI5MDAyMCBTYWx0ZWRfX1iCwIiFM29T7 vFvCQ31ZdZhzioQZBI9DW+MFuganRxfbrzoEiLKfCFtIw72RBsrRsc/lYgetnhFdexhs8ZXHnh5 RdnkfUWoSX+0cwJloNwFJ0P8jglDgs4nYWAp+AvSkEjRQme5KkFdx/gHc4rVUIkY3K7Y9jVy/CI PITMAgCk8aNjD5hzFaL2UFalwdTeEizAz7dyVOIvPycMQW8S0JezglqjUOBCbqMtb0dfkXLNArG q/8biuGUDzr7iAXTfqFh2aELbRaydWwtNeKCx9ngyL4SVuuJHb139u/2DwJ3cdTlyjW9Xe50ut4 boyOh+LL9IjsNCiE7X356VW1lVllbNu/peeyS009kqqgKgQmPQhnYL0DBaTIKTCdj+j0+bOumQf sY/+MAFpWNRRqyv0iOOTASXfCD9uKA== X-Authority-Analysis: v=2.4 cv=dYGNHHXe c=1 sm=1 tr=0 ts=692d9004 cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==:17 a=wP3pNCr1ah4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=VnNF1IyMAAAA:8 a=LIcl9UMsB3m1Xa-0CCYA: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-11-28_08,2025-11-27_02,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" 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 --- arch/x86/include/asm/unwind_user.h | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/arch/x86/include/asm/unwind_user.h b/arch/x86/include/asm/unwi= nd_user.h index 971ffe937d50..e1137eb67ab2 100644 --- a/arch/x86/include/asm/unwind_user.h +++ b/arch/x86/include/asm/unwind_user.h @@ -2,6 +2,22 @@ #ifndef _ASM_X86_UNWIND_USER_H #define _ASM_X86_UNWIND_USER_H =20 +#ifdef CONFIG_UNWIND_USER + +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 =20 #include @@ -19,18 +35,6 @@ .fp_off =3D 0, \ .use_fp =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