From patchwork Sun Feb 6 14:53:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Leoshkevich X-Patchwork-Id: 12736590 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BFC93C433EF for ; Sun, 6 Feb 2022 15:12:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243378AbiBFPM1 (ORCPT ); Sun, 6 Feb 2022 10:12:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231978AbiBFPM1 (ORCPT ); Sun, 6 Feb 2022 10:12:27 -0500 X-Greylist: delayed 1077 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Sun, 06 Feb 2022 07:12:26 PST Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68E53C06173B for ; Sun, 6 Feb 2022 07:12:25 -0800 (PST) Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 216EQq32008001; Sun, 6 Feb 2022 14:54:07 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=pFHuJ+woiU4TtW3bwhgnb1aDkw50enHp7sB7RAC6Ghs=; b=lX41Uj+WCOeiB7G9+uCwsVIviaQdy5ZtCFidi+LqO9xfTi00BbedGx+Mml71yBp3ZXGo R6EGrAlCYNhsPkLfr0zLsxyXaz7rSRhaMZWxLhxq743WNQFoF1VEMti0EUH9Di+Pro3h ebrpIFWOGqgzrgtxmXADlDRivLXOzySkgrABZrmvxNcsZvyKJlwEyn/67GJRRLW/2k0b qVyfsdil9pRC++CS2W+ayJsEsNZYsh2JDid8Uv5ulQvS1VY16V9IQa1b8VFhpVMf3yAl nNa5cqz1m+OWm/jmjABtCebybPOce00sOxQSi+xtZCGh09xoU2wQwhcIkcvwHs2YbrH6 9A== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3e22vk1461-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 06 Feb 2022 14:54:06 +0000 Received: from m0098417.ppops.net (m0098417.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 216Es6m7004770; Sun, 6 Feb 2022 14:54:06 GMT Received: from ppma05fra.de.ibm.com (6c.4a.5195.ip4.static.sl-reverse.com [149.81.74.108]) by mx0a-001b2d01.pphosted.com with ESMTP id 3e22vk145p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 06 Feb 2022 14:54:06 +0000 Received: from pps.filterd (ppma05fra.de.ibm.com [127.0.0.1]) by ppma05fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 216Emn5a031205; Sun, 6 Feb 2022 14:54:04 GMT Received: from b06avi18878370.portsmouth.uk.ibm.com (b06avi18878370.portsmouth.uk.ibm.com [9.149.26.194]) by ppma05fra.de.ibm.com with ESMTP id 3e1gv9nm1w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 06 Feb 2022 14:54:04 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 216Es1dm45744554 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 6 Feb 2022 14:54:01 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3976411C050; Sun, 6 Feb 2022 14:54:01 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B878A11C04A; Sun, 6 Feb 2022 14:54:00 +0000 (GMT) Received: from heavy.lan (unknown [9.171.78.41]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Sun, 6 Feb 2022 14:54:00 +0000 (GMT) From: Ilya Leoshkevich To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Alexander Gordeev , Catalin Marinas Cc: bpf@vger.kernel.org, Ilya Leoshkevich Subject: [PATCH bpf-next 1/2] s390/bpf: Introduce user_pt_regs_v2 Date: Sun, 6 Feb 2022 15:53:49 +0100 Message-Id: <20220206145350.2069779-2-iii@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220206145350.2069779-1-iii@linux.ibm.com> References: <20220206145350.2069779-1-iii@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: uOqfLGjwAE4Hzk2JEGpSx0ahKU6Jz4ZT X-Proofpoint-ORIG-GUID: rVa8qETv7VRa8FkDu_-tYNtet-iGeCVB X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-06_04,2022-02-03_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 bulkscore=0 lowpriorityscore=0 mlxscore=0 impostorscore=0 phishscore=0 suspectscore=0 priorityscore=1501 adultscore=0 malwarescore=0 spamscore=0 mlxlogscore=898 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202060108 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net Extending user_pt_regs breaks struct bpf_perf_event_data ABI, so instead of exposing orig_gpr2 through it, create its copy with orig_gpr2 at the end and use it in libbpf. The existing members are copy-pasted, so now there are 3 copies in total. It might be tempting to add a user_pt_regs member to user_pt_regs_v2 instead, however, there is no guarantee that then user_pt_regs_v2.orig_gpr2 would be at the same offset as pt_regs.orig_gpr2. Fixes: 61f88e88f263 ("s390/bpf: Add orig_gpr2 to user_pt_regs") Signed-off-by: Ilya Leoshkevich --- arch/s390/include/asm/ptrace.h | 1 + arch/s390/include/uapi/asm/ptrace.h | 10 ++++++++-- tools/lib/bpf/bpf_tracing.h | 4 ++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/arch/s390/include/asm/ptrace.h b/arch/s390/include/asm/ptrace.h index c8698e643904..1a08f36395e5 100644 --- a/arch/s390/include/asm/ptrace.h +++ b/arch/s390/include/asm/ptrace.h @@ -79,6 +79,7 @@ enum { struct pt_regs { union { user_pt_regs user_regs; + user_pt_regs_v2 user_regs_v2; struct { unsigned long args[1]; psw_t psw; diff --git a/arch/s390/include/uapi/asm/ptrace.h b/arch/s390/include/uapi/asm/ptrace.h index b3dec603f507..b9405b8f0d47 100644 --- a/arch/s390/include/uapi/asm/ptrace.h +++ b/arch/s390/include/uapi/asm/ptrace.h @@ -288,16 +288,22 @@ typedef struct { } s390_regs; /* - * The user_pt_regs structure exports the beginning of + * The user_pt_regs and user_pt_regs_v2 structures export the beginning of * the in-kernel pt_regs structure to user space. */ typedef struct { unsigned long args[1]; psw_t psw; unsigned long gprs[NUM_GPRS]; - unsigned long orig_gpr2; } user_pt_regs; +typedef struct { + unsigned long args[1]; + psw_t psw; + unsigned long gprs[NUM_GPRS]; + unsigned long orig_gpr2; +} user_pt_regs_v2; + /* * Now for the user space program event recording (trace) definitions. * The following structures are used only for the ptrace interface, don't diff --git a/tools/lib/bpf/bpf_tracing.h b/tools/lib/bpf/bpf_tracing.h index cf980e54d331..76abbc5ff2e8 100644 --- a/tools/lib/bpf/bpf_tracing.h +++ b/tools/lib/bpf/bpf_tracing.h @@ -114,8 +114,8 @@ #elif defined(bpf_target_s390) -/* s390 provides user_pt_regs instead of struct pt_regs to userspace */ -#define __PT_REGS_CAST(x) ((const user_pt_regs *)(x)) +/* s390 provides user_pt_regs_v2 instead of struct pt_regs to userspace */ +#define __PT_REGS_CAST(x) ((const user_pt_regs_v2 *)(x)) #define __PT_PARM1_REG gprs[2] #define __PT_PARM1_REG_SYSCALL orig_gpr2 #define __PT_PARM2_REG gprs[3] From patchwork Sun Feb 6 14:53:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Leoshkevich X-Patchwork-Id: 12736596 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A6783C433EF for ; Sun, 6 Feb 2022 15:40:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244058AbiBFPk0 (ORCPT ); Sun, 6 Feb 2022 10:40:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244116AbiBFPkV (ORCPT ); Sun, 6 Feb 2022 10:40:21 -0500 X-Greylist: delayed 2753 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Sun, 06 Feb 2022 07:40:20 PST Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F195C06173B for ; Sun, 6 Feb 2022 07:40:20 -0800 (PST) Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 216E5rZ8009779; Sun, 6 Feb 2022 14:54:08 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=1qv3fNnWzE6B3dGpU4fMclN37R45mMlEFSevTh2YBXg=; b=hisemLqbtnSPwmGof/89wiSU489TvEpxXf/hG4BOhiLBLq4LBlnJTpFWJ2V7wFeNKwZi WbbswExal0m/R+DLJW2l+U/udTgeUDvMWYdqGoyDsipCSVvbgqJMRgcOA74PxSRWkUMe spJmJyghkSndVJsFGe7OMTF+YSugiL3EpuL3NzwLQsxYsyvToATqqM4RB06vbEpeVteG ErA5nfddo37twuZHL9VpHimVtAgCCJM6n78JtGgChrcuAM0eOtRY9HLUbI6/+lBHzk73 J8/eTHWHL3JA/Lk43DVqWghbYnIe9srsqC5QWRj6tPamoqzDXKF/tX1UiaYQ6rgPwKrK LQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3e22q098ub-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 06 Feb 2022 14:54:08 +0000 Received: from m0187473.ppops.net (m0187473.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 216EjKwJ008114; Sun, 6 Feb 2022 14:54:08 GMT Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com with ESMTP id 3e22q098u1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 06 Feb 2022 14:54:07 +0000 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 216ElfXS006946; Sun, 6 Feb 2022 14:54:05 GMT Received: from b06avi18626390.portsmouth.uk.ibm.com (b06avi18626390.portsmouth.uk.ibm.com [9.149.26.192]) by ppma06ams.nl.ibm.com with ESMTP id 3e1ggje33f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 06 Feb 2022 14:54:05 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 216Ei1uq45744412 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 6 Feb 2022 14:44:01 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 34D3811C04C; Sun, 6 Feb 2022 14:54:02 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B0B6B11C04A; Sun, 6 Feb 2022 14:54:01 +0000 (GMT) Received: from heavy.lan (unknown [9.171.78.41]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Sun, 6 Feb 2022 14:54:01 +0000 (GMT) From: Ilya Leoshkevich To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Alexander Gordeev , Catalin Marinas Cc: bpf@vger.kernel.org, Ilya Leoshkevich Subject: [PATCH bpf-next 2/2] arm64/bpf: Introduce struct user_pt_regs_v2 Date: Sun, 6 Feb 2022 15:53:50 +0100 Message-Id: <20220206145350.2069779-3-iii@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220206145350.2069779-1-iii@linux.ibm.com> References: <20220206145350.2069779-1-iii@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: rkAT_ewP3t8mLPhc7AMTvX0ZNa_wuiX9 X-Proofpoint-ORIG-GUID: _Hc9QUoR-bkox_mp7zBypUGq5pKbkZeB X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-06_04,2022-02-03_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 malwarescore=0 suspectscore=0 priorityscore=1501 mlxlogscore=999 clxscore=1015 adultscore=0 bulkscore=0 mlxscore=0 spamscore=0 impostorscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202060108 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net Extending struct user_pt_regs breaks struct bpf_perf_event_data ABI, so instead of exposing orig_x0 through it, create its copy with orig_x0 at the end and use it in libbpf. The existing members are copy-pasted, so now there are 3 copies in total. It might be tempting to add a user_pt_regs member to user_pt_regs_v2 instead, however, there is no guarantee that then user_pt_regs_v2.orig_x0 would be at the same offset as pt_regs.orig_gpr2. Fixes: d473f4062165 ("arm64/bpf: Add orig_x0 to user_pt_regs") Signed-off-by: Ilya Leoshkevich --- arch/arm64/include/asm/ptrace.h | 1 + arch/arm64/include/uapi/asm/ptrace.h | 7 +++++++ tools/lib/bpf/bpf_tracing.h | 6 ++++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/arch/arm64/include/asm/ptrace.h b/arch/arm64/include/asm/ptrace.h index 1be22f7870f8..c5e098af5b70 100644 --- a/arch/arm64/include/asm/ptrace.h +++ b/arch/arm64/include/asm/ptrace.h @@ -178,6 +178,7 @@ static inline unsigned long pstate_to_compat_psr(const unsigned long pstate) struct pt_regs { union { struct user_pt_regs user_regs; + struct user_pt_regs_v2 user_regs_v2; struct { u64 regs[31]; u64 sp; diff --git a/arch/arm64/include/uapi/asm/ptrace.h b/arch/arm64/include/uapi/asm/ptrace.h index 3c118c5b0893..ab7a2f0cdca8 100644 --- a/arch/arm64/include/uapi/asm/ptrace.h +++ b/arch/arm64/include/uapi/asm/ptrace.h @@ -90,6 +90,13 @@ struct user_pt_regs { __u64 sp; __u64 pc; __u64 pstate; +}; + +struct user_pt_regs_v2 { + __u64 regs[31]; + __u64 sp; + __u64 pc; + __u64 pstate; __u64 orig_x0; }; diff --git a/tools/lib/bpf/bpf_tracing.h b/tools/lib/bpf/bpf_tracing.h index 76abbc5ff2e8..284cc4d6954e 100644 --- a/tools/lib/bpf/bpf_tracing.h +++ b/tools/lib/bpf/bpf_tracing.h @@ -143,8 +143,10 @@ #elif defined(bpf_target_arm64) -/* arm64 provides struct user_pt_regs instead of struct pt_regs to userspace */ -#define __PT_REGS_CAST(x) ((const struct user_pt_regs *)(x)) +/* + * arm64 provides struct user_pt_regs_v2 instead of struct pt_regs to userspace + */ +#define __PT_REGS_CAST(x) ((const struct user_pt_regs_v2 *)(x)) #define __PT_PARM1_REG regs[0] #define __PT_PARM1_REG_SYSCALL orig_x0 #define __PT_PARM2_REG regs[1]