From patchwork Fri Feb 4 04:19:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Leoshkevich X-Patchwork-Id: 12734770 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 E7025C433FE for ; Fri, 4 Feb 2022 04:20:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242842AbiBDEUd (ORCPT ); Thu, 3 Feb 2022 23:20:33 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:62282 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232223AbiBDEU3 (ORCPT ); Thu, 3 Feb 2022 23:20:29 -0500 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 21441eE9028363; Fri, 4 Feb 2022 04:20: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=Ja3OC2q3TDApsQm4GnQZqFA0Yp1B1OYhdYj+AGkaqKY=; b=KcGJwmiTd6i42o+w0wxSESZ+1y79QgmTiJV0ABLTn0qYQaiTZwWDyVny1K9HcBeVWclf E0pfrowaWqGaOCo5jDOL4slHx2+sZyMEQCIxZgej/oXs8BPol4Ei9WLM3RJwA/cPHy3T aQ65sxh3oS8/rAbWy9jWUJFVollonrWDiKLnKRXzgzFNAyhKU1fqk/FQq/CcBTP3lFBo EikDkwsDLClIcqT95BotkKC+5e23aQREBoU/A8uc/Xd6M22gyeB+MXEH3Xx5/sqc+3j2 HVHwjj7K1bcPhXa24kKzq/dk0ejkf5/wAJNXWeeJhsy+DT0Tr9EpXgHmDZPpP+JFAPMV 6A== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 3e0vrrg8v8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 04:20:06 +0000 Received: from m0098414.ppops.net (m0098414.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 2144K6PG029819; Fri, 4 Feb 2022 04:20:06 GMT Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0b-001b2d01.pphosted.com with ESMTP id 3e0vrrg8uq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 04:20:06 +0000 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 2144DbAN019588; Fri, 4 Feb 2022 04:20:04 GMT Received: from b06avi18626390.portsmouth.uk.ibm.com (b06avi18626390.portsmouth.uk.ibm.com [9.149.26.192]) by ppma03ams.nl.ibm.com with ESMTP id 3e0r0sh58t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 04:20:04 +0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2144A4tc45875546 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 4 Feb 2022 04:10:04 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E92F0A4055; Fri, 4 Feb 2022 04:19:58 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 54FDCA4040; Fri, 4 Feb 2022 04:19:58 +0000 (GMT) Received: from heavy.lan (unknown [9.171.78.41]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 4 Feb 2022 04:19:58 +0000 (GMT) From: Ilya Leoshkevich To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Alexander Gordeev , Catalin Marinas , Michael Ellerman , Paul Walmsley Cc: bpf@vger.kernel.org, Ilya Leoshkevich Subject: [PATCH bpf-next v2 01/10] arm64/bpf: Add orig_x0 to user_pt_regs Date: Fri, 4 Feb 2022 05:19:46 +0100 Message-Id: <20220204041955.1958263-2-iii@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220204041955.1958263-1-iii@linux.ibm.com> References: <20220204041955.1958263-1-iii@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: ldkQRlB6T9oa2nRS7LE-PDHro68mSAzx X-Proofpoint-ORIG-GUID: Qcp83zqBMww_JgmFTRc5DCIRNFCy2lML 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-04_01,2022-02-03_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 spamscore=0 mlxlogscore=978 priorityscore=1501 phishscore=0 suspectscore=0 impostorscore=0 bulkscore=0 clxscore=1015 malwarescore=0 adultscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202040019 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net orig_x0 is needed in order to access the first syscall argument from eBPF programs. Signed-off-by: Ilya Leoshkevich --- arch/arm64/include/asm/ptrace.h | 2 +- arch/arm64/include/uapi/asm/ptrace.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/arm64/include/asm/ptrace.h b/arch/arm64/include/asm/ptrace.h index 41b332c054ab..1be22f7870f8 100644 --- a/arch/arm64/include/asm/ptrace.h +++ b/arch/arm64/include/asm/ptrace.h @@ -183,9 +183,9 @@ struct pt_regs { u64 sp; u64 pc; u64 pstate; + u64 orig_x0; }; }; - u64 orig_x0; #ifdef __AARCH64EB__ u32 unused2; s32 syscallno; diff --git a/arch/arm64/include/uapi/asm/ptrace.h b/arch/arm64/include/uapi/asm/ptrace.h index 758ae984ff97..3c118c5b0893 100644 --- a/arch/arm64/include/uapi/asm/ptrace.h +++ b/arch/arm64/include/uapi/asm/ptrace.h @@ -90,6 +90,7 @@ struct user_pt_regs { __u64 sp; __u64 pc; __u64 pstate; + __u64 orig_x0; }; struct user_fpsimd_state { From patchwork Fri Feb 4 04:19:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Leoshkevich X-Patchwork-Id: 12734772 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 324F0C433EF for ; Fri, 4 Feb 2022 04:20:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232223AbiBDEUd (ORCPT ); Thu, 3 Feb 2022 23:20:33 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:55496 "EHLO mx0b-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356925AbiBDEUa (ORCPT ); Thu, 3 Feb 2022 23:20:30 -0500 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 21436O4X017326; Fri, 4 Feb 2022 04:20:06 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=UmNP3qCGoC+YUEQLAXP1k5C0+R8+ZzfMDoEUna51Cqw=; b=K/8I4RHUxEg8RXl9C4JCuGgVD48PPgi9hG4uudORwQXfS3qcG//YPej7zQt9Q4YXOGVa OGGpXpMl/gIxKcs9ZJlbjUYMzY8Ye4qTy3fislRXf6NMpKP66/2Vt8Hhw+5Mia2wyrlG bNOrq8y9Zq2a7WUVpjAzshTvsIkiQa0YKntaQ5x533D9SolhhcCDfEdoSbiO2CWm0f8c hD380sx1hVDhrJ8ADyphoAu/rVFmt+q8rZuwjAnmvrSEIhkTwiURUj++Zj1Jj0Erbcpw smYUD1/FF9pIsz6aylY10qTv2L4bsmQ7XCXP30otn87/NJBsb3FAaz8xIhAuwS1PMMPY tg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3e0qx8vrd7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 04:20:05 +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 2144G3eB012116; Fri, 4 Feb 2022 04:20:05 GMT Received: from ppma06fra.de.ibm.com (48.49.7a9f.ip4.static.sl-reverse.com [159.122.73.72]) by mx0a-001b2d01.pphosted.com with ESMTP id 3e0qx8vrcu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 04:20:05 +0000 Received: from pps.filterd (ppma06fra.de.ibm.com [127.0.0.1]) by ppma06fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 2144DTQV021513; Fri, 4 Feb 2022 04:20:03 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma06fra.de.ibm.com with ESMTP id 3e0r0y92pc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 04:20:03 +0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2144K0AZ42402300 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 4 Feb 2022 04:20:00 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 04B2BA404D; Fri, 4 Feb 2022 04:20:00 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6ADEBA405D; Fri, 4 Feb 2022 04:19:59 +0000 (GMT) Received: from heavy.lan (unknown [9.171.78.41]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 4 Feb 2022 04:19:59 +0000 (GMT) From: Ilya Leoshkevich To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Alexander Gordeev , Catalin Marinas , Michael Ellerman , Paul Walmsley Cc: bpf@vger.kernel.org, Ilya Leoshkevich Subject: [PATCH bpf-next v2 02/10] s390/bpf: Add orig_gpr2 to user_pt_regs Date: Fri, 4 Feb 2022 05:19:47 +0100 Message-Id: <20220204041955.1958263-3-iii@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220204041955.1958263-1-iii@linux.ibm.com> References: <20220204041955.1958263-1-iii@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: Y6V4Vq2EQ8o4NBQTATmW4Mtgu6buTBAl X-Proofpoint-ORIG-GUID: yE6abGUx2by8wwfJCodrPKdlbooNN1Fp 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-04_01,2022-02-03_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 suspectscore=0 lowpriorityscore=0 mlxscore=0 adultscore=0 phishscore=0 malwarescore=0 impostorscore=0 spamscore=0 priorityscore=1501 bulkscore=0 mlxlogscore=944 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202040019 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net user_pt_regs is used by eBPF in order to access userspace registers - see commit 466698e654e8 ("s390/bpf: correct broken uapi for BPF_PROG_TYPE_PERF_EVENT program type"). In order to access the first syscall argument from eBPF programs, we need to export orig_gpr2. args member is not in use since commit 56e62a737028 ("s390: convert to generic entry"), so move orig_gpr2 in its place. Signed-off-by: Ilya Leoshkevich --- arch/s390/include/asm/ptrace.h | 3 +-- arch/s390/include/uapi/asm/ptrace.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/arch/s390/include/asm/ptrace.h b/arch/s390/include/asm/ptrace.h index 4ffa8e7f0ed3..0278bacd61be 100644 --- a/arch/s390/include/asm/ptrace.h +++ b/arch/s390/include/asm/ptrace.h @@ -80,12 +80,11 @@ struct pt_regs { union { user_pt_regs user_regs; struct { - unsigned long args[1]; + unsigned long orig_gpr2; psw_t psw; unsigned long gprs[NUM_GPRS]; }; }; - unsigned long orig_gpr2; union { struct { unsigned int int_code; diff --git a/arch/s390/include/uapi/asm/ptrace.h b/arch/s390/include/uapi/asm/ptrace.h index ad64d673b5e6..d0cc737b8151 100644 --- a/arch/s390/include/uapi/asm/ptrace.h +++ b/arch/s390/include/uapi/asm/ptrace.h @@ -292,7 +292,7 @@ typedef struct { * the in-kernel pt_regs structure to user space. */ typedef struct { - unsigned long args[1]; + unsigned long orig_gpr2; psw_t psw; unsigned long gprs[NUM_GPRS]; } user_pt_regs; From patchwork Fri Feb 4 04:19:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Leoshkevich X-Patchwork-Id: 12734775 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 796A1C433F5 for ; Fri, 4 Feb 2022 04:20:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356925AbiBDEUh (ORCPT ); Thu, 3 Feb 2022 23:20:37 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:17706 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356924AbiBDEUh (ORCPT ); Thu, 3 Feb 2022 23:20:37 -0500 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 21404DVw029386; Fri, 4 Feb 2022 04:20: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=+LjoE0NZmu4eTgC5xdsneOk1/jfO4/mdoy6UnZQR+Ic=; b=dtfkSRKbIXj2eEi97b9H9GiRf187rIqnHlWEjd7qjAJTxNSWkFLTglM/OmwA48xAo7Ck hIUAxxwQku/A8ddLklgMqFddd2ZgOWbmEQgLw/aWrubi9a9NcbaPMSrd2YhVknIbrInZ 46lm81++deiTHQXfVGHorDN+sERP3qx7ohr/LldBvD6ewwCGYVh0o3Xij6u2/Q9boRCM MbCpIMaWXsEyg/isckJVWlpqa3qRfOJykbPdJfDkqgiQ30KLdYde1Wzrbs5KoBGXbmPA Llh2vcgS8L8uSiB7WBkW12d7BaS2Hd8vkU/ykm8eBh66DpywY5GWF/h5vnOWTJavGpmv eA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3e0qx2vq4p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 04:20:07 +0000 Received: from m0098399.ppops.net (m0098399.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 2143lK6o029165; Fri, 4 Feb 2022 04:20:07 GMT Received: from ppma06fra.de.ibm.com (48.49.7a9f.ip4.static.sl-reverse.com [159.122.73.72]) by mx0a-001b2d01.pphosted.com with ESMTP id 3e0qx2vq3t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 04:20:07 +0000 Received: from pps.filterd (ppma06fra.de.ibm.com [127.0.0.1]) by ppma06fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 2144DTQW021513; Fri, 4 Feb 2022 04:20:04 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma06fra.de.ibm.com with ESMTP id 3e0r0y92pe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 04:20:04 +0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2144K1Dl39322096 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 4 Feb 2022 04:20:01 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0D066A4055; Fri, 4 Feb 2022 04:20:01 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7B284A4051; Fri, 4 Feb 2022 04:20:00 +0000 (GMT) Received: from heavy.lan (unknown [9.171.78.41]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 4 Feb 2022 04:20:00 +0000 (GMT) From: Ilya Leoshkevich To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Alexander Gordeev , Catalin Marinas , Michael Ellerman , Paul Walmsley Cc: bpf@vger.kernel.org, Ilya Leoshkevich Subject: [PATCH bpf-next v2 03/10] selftests/bpf: Fix an endianness issue in bpf_syscall_macro test Date: Fri, 4 Feb 2022 05:19:48 +0100 Message-Id: <20220204041955.1958263-4-iii@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220204041955.1958263-1-iii@linux.ibm.com> References: <20220204041955.1958263-1-iii@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: M3JAOWDWGGsQpneh5-eneqqDUfib5hCz X-Proofpoint-GUID: ORp3c9-ZIZS3RfgP9WuS4UJ_YUDPyvMV 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-04_01,2022-02-03_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 suspectscore=0 mlxlogscore=999 priorityscore=1501 malwarescore=0 bulkscore=0 impostorscore=0 spamscore=0 phishscore=0 adultscore=0 clxscore=1015 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202040019 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net bpf_syscall_macro reads a long argument into an int variable, which produces a wrong value on big-endian systems. Fix by reading the argument into an intermediate long variable first. Fixes: 77fc0330dfe5 ("selftests/bpf: Add a test to confirm PT_REGS_PARM4_SYSCALL") Signed-off-by: Ilya Leoshkevich --- tools/testing/selftests/bpf/progs/bpf_syscall_macro.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/bpf/progs/bpf_syscall_macro.c b/tools/testing/selftests/bpf/progs/bpf_syscall_macro.c index c8e60220cda8..f5c6ef2ff6d1 100644 --- a/tools/testing/selftests/bpf/progs/bpf_syscall_macro.c +++ b/tools/testing/selftests/bpf/progs/bpf_syscall_macro.c @@ -28,6 +28,7 @@ int BPF_KPROBE(handle_sys_prctl) { struct pt_regs *real_regs; pid_t pid = bpf_get_current_pid_tgid() >> 32; + unsigned long tmp; if (pid != filter_pid) return 0; @@ -35,7 +36,9 @@ int BPF_KPROBE(handle_sys_prctl) real_regs = (struct pt_regs *)PT_REGS_PARM1(ctx); /* test for PT_REGS_PARM */ - bpf_probe_read_kernel(&arg1, sizeof(arg1), &PT_REGS_PARM1_SYSCALL(real_regs)); + + bpf_probe_read_kernel(&tmp, sizeof(tmp), &PT_REGS_PARM1_SYSCALL(real_regs)); + arg1 = tmp; bpf_probe_read_kernel(&arg2, sizeof(arg2), &PT_REGS_PARM2_SYSCALL(real_regs)); bpf_probe_read_kernel(&arg3, sizeof(arg3), &PT_REGS_PARM3_SYSCALL(real_regs)); bpf_probe_read_kernel(&arg4_cx, sizeof(arg4_cx), &PT_REGS_PARM4(real_regs)); From patchwork Fri Feb 4 04:19: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: 12734774 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 DF955C433FE for ; Fri, 4 Feb 2022 04:20:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356927AbiBDEUh (ORCPT ); Thu, 3 Feb 2022 23:20:37 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:56546 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356925AbiBDEUg (ORCPT ); Thu, 3 Feb 2022 23:20:36 -0500 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 2143OKjR010594; Fri, 4 Feb 2022 04:20: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=egM1L1sH7Nic6f1M2/NzF/5uEkXzgIz7BNjGTk0Ehvo=; b=nUciH+h3/yIR2sKMBR6MBx7wmee+8QopU6LXYSdZZat6T7U9yjHe1XRPqlO32NyqC/ry vu4eJBlqdaW5A3afkrZU06XHRdcmGqdsyGJl5GLB+JSR9D2fHmgCvnB7QA1kpzecP+fN HAc5fndjd5fWZDShp1+xD0xZhNNnATVnwVH+ei23Zkdi80tGC8khDvN2ZbgDODt1vhfr VYiwVtLvu+vudBG+I2UUrUOHNkuj287ChnzkGeCtfEHgnJ5XzQLWKGNkN7WTsVDla7Jr FJ11UPI26mMBc2iS5r+w8pIfZNYmxHO/PSMRh2J8NaKQv71ykkuA19XtHruYWLheGzWy Vw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3e0r1a4p86-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 04:20:08 +0000 Received: from m0098404.ppops.net (m0098404.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 2144J29p027405; Fri, 4 Feb 2022 04:20:08 GMT Received: from ppma04fra.de.ibm.com (6a.4a.5195.ip4.static.sl-reverse.com [149.81.74.106]) by mx0a-001b2d01.pphosted.com with ESMTP id 3e0r1a4p7f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 04:20:07 +0000 Received: from pps.filterd (ppma04fra.de.ibm.com [127.0.0.1]) by ppma04fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 2144D9ri014359; Fri, 4 Feb 2022 04:20:05 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma04fra.de.ibm.com with ESMTP id 3e0r0u13by-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 04:20:05 +0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2144K2bN38863172 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 4 Feb 2022 04:20:02 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 18107A4040; Fri, 4 Feb 2022 04:20:02 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 71161A404D; Fri, 4 Feb 2022 04:20:01 +0000 (GMT) Received: from heavy.lan (unknown [9.171.78.41]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 4 Feb 2022 04:20:01 +0000 (GMT) From: Ilya Leoshkevich To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Alexander Gordeev , Catalin Marinas , Michael Ellerman , Paul Walmsley Cc: bpf@vger.kernel.org, Ilya Leoshkevich Subject: [PATCH bpf-next v2 04/10] libbpf: Add __PT_PARM1_REG_SYSCALL macro Date: Fri, 4 Feb 2022 05:19:49 +0100 Message-Id: <20220204041955.1958263-5-iii@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220204041955.1958263-1-iii@linux.ibm.com> References: <20220204041955.1958263-1-iii@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 4sEgNPO0JdbzCP3OuMlkHswz1Eq5_5bs X-Proofpoint-ORIG-GUID: WOxiVD20uDuc-VWnMFSBWQqFv6uXZ6_y 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-04_01,2022-02-03_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 clxscore=1015 priorityscore=1501 phishscore=0 malwarescore=0 adultscore=0 mlxscore=0 lowpriorityscore=0 mlxlogscore=999 suspectscore=0 impostorscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202040019 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net Some architectures have a special way to access the first syscall argument. There already exists __PT_PARM4_REG_SYSCALL for the fourth argument, so define a similar macro for the first one. Signed-off-by: Ilya Leoshkevich --- tools/lib/bpf/bpf_tracing.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/lib/bpf/bpf_tracing.h b/tools/lib/bpf/bpf_tracing.h index 032ba809f3e5..30f0964f8c9e 100644 --- a/tools/lib/bpf/bpf_tracing.h +++ b/tools/lib/bpf/bpf_tracing.h @@ -265,7 +265,11 @@ struct pt_regs; #endif +#ifdef __PT_PARM1_REG_SYSCALL +#define PT_REGS_PARM1_SYSCALL(x) (__PT_REGS_CAST(x)->__PT_PARM1_REG_SYSCALL) +#else /* __PT_PARM1_REG_SYSCALL */ #define PT_REGS_PARM1_SYSCALL(x) PT_REGS_PARM1(x) +#endif #define PT_REGS_PARM2_SYSCALL(x) PT_REGS_PARM2(x) #define PT_REGS_PARM3_SYSCALL(x) PT_REGS_PARM3(x) #ifdef __PT_PARM4_REG_SYSCALL @@ -275,7 +279,11 @@ struct pt_regs; #endif #define PT_REGS_PARM5_SYSCALL(x) PT_REGS_PARM5(x) +#ifdef __PT_PARM1_REG_SYSCALL +#define PT_REGS_PARM1_CORE_SYSCALL(x) BPF_CORE_READ(__PT_REGS_CAST(x), __PT_PARM1_REG_SYSCALL) +#else /* __PT_PARM1_REG_SYSCALL */ #define PT_REGS_PARM1_CORE_SYSCALL(x) PT_REGS_PARM1_CORE(x) +#endif #define PT_REGS_PARM2_CORE_SYSCALL(x) PT_REGS_PARM2_CORE(x) #define PT_REGS_PARM3_CORE_SYSCALL(x) PT_REGS_PARM3_CORE(x) #ifdef __PT_PARM4_REG_SYSCALL From patchwork Fri Feb 4 04:19: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: 12734773 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 806A7C433EF for ; Fri, 4 Feb 2022 04:20:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356926AbiBDEUg (ORCPT ); Thu, 3 Feb 2022 23:20:36 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:13658 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356924AbiBDEUg (ORCPT ); Thu, 3 Feb 2022 23:20:36 -0500 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 2140cHb5005760; Fri, 4 Feb 2022 04:20:11 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=ygOiSm6MhzrgR2TBkzch1RM1YEmSu5YGG87uEsHyJqk=; b=aWZ4Y48IWAeQAgjP0+sOyxPM7duGJBFVplT6hXAL/tuLHY+NzmMBp+wr8XR4Kkt3HIAs WW0PeRUJ813VB2Wl2Z+NtnHMCGmuhgGcIAMY/Hh5wAzbRoL+3cShTSWcqO+nM6YE++q1 AbBEH30bV9OMH26JVlZa6zYw+XB/HF6rboFDG338xu6TlJrZOCJhDpH7jKMkzqj/H7a4 TkxGdy2Z7Gt8V5sGbY3LyuZIm91I/7l1bvCZqj9kC+o8dEXiQ4eq9v6ZvqIfUtS6oxiJ X+po1ormAJ0vFvjWahCmNmoauK4lqnkEk0a3p9+hjy5NjtxnlfEuNAqWOAcI/47ulM/p aw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3e0r124hd9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 04:20:11 +0000 Received: from m0098393.ppops.net (m0098393.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 21440Ioa019397; Fri, 4 Feb 2022 04:20:10 GMT Received: from ppma01fra.de.ibm.com (46.49.7a9f.ip4.static.sl-reverse.com [159.122.73.70]) by mx0a-001b2d01.pphosted.com with ESMTP id 3e0r124hcp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 04:20:10 +0000 Received: from pps.filterd (ppma01fra.de.ibm.com [127.0.0.1]) by ppma01fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 2144Da4I014603; Fri, 4 Feb 2022 04:20:08 GMT Received: from b06avi18878370.portsmouth.uk.ibm.com (b06avi18878370.portsmouth.uk.ibm.com [9.149.26.194]) by ppma01fra.de.ibm.com with ESMTP id 3e0r11h2yd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 04:20:07 +0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2144K32b39387446 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 4 Feb 2022 04:20:03 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 091CFA4055; Fri, 4 Feb 2022 04:20:03 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6C5D4A404D; Fri, 4 Feb 2022 04:20:02 +0000 (GMT) Received: from heavy.lan (unknown [9.171.78.41]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 4 Feb 2022 04:20:02 +0000 (GMT) From: Ilya Leoshkevich To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Alexander Gordeev , Catalin Marinas , Michael Ellerman , Paul Walmsley Cc: bpf@vger.kernel.org, Ilya Leoshkevich Subject: [PATCH bpf-next v2 05/10] libbpf: Add PT_REGS_SYSCALL macro Date: Fri, 4 Feb 2022 05:19:50 +0100 Message-Id: <20220204041955.1958263-6-iii@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220204041955.1958263-1-iii@linux.ibm.com> References: <20220204041955.1958263-1-iii@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: VaZDNVvbDn2AJ_wsEbh3NoQusH5f8o6J X-Proofpoint-ORIG-GUID: C3IKHdXEkJ9n5Hx7hZt8IW5kP3gIROoX 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-04_01,2022-02-03_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 impostorscore=0 malwarescore=0 mlxlogscore=936 lowpriorityscore=0 clxscore=1015 bulkscore=0 priorityscore=1501 suspectscore=0 adultscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202040019 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net Some architectures pass a pointer to struct pt_regs to syscall handlers, others unpack it into individual function parameters. Introduce a macro to describe what a particular arch does, using `passing pt_regs *` as a default. Signed-off-by: Ilya Leoshkevich --- tools/lib/bpf/bpf_tracing.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tools/lib/bpf/bpf_tracing.h b/tools/lib/bpf/bpf_tracing.h index 30f0964f8c9e..400a4f002f77 100644 --- a/tools/lib/bpf/bpf_tracing.h +++ b/tools/lib/bpf/bpf_tracing.h @@ -334,6 +334,15 @@ struct pt_regs; #endif /* defined(bpf_target_defined) */ +/* + * When invoked from a syscall handler kprobe, returns a pointer to a + * struct pt_regs containing syscall arguments and suitable for passing to + * PT_REGS_PARMn_SYSCALL() and PT_REGS_PARMn_CORE_SYSCALL(). + */ +#ifndef PT_REGS_SYSCALL +#define PT_REGS_SYSCALL(ctx) ((struct pt_regs *)PT_REGS_PARM1(ctx)) +#endif + #ifndef ___bpf_concat #define ___bpf_concat(a, b) a ## b #endif From patchwork Fri Feb 4 04:19:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Leoshkevich X-Patchwork-Id: 12734771 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 8993DC4332F for ; Fri, 4 Feb 2022 04:20:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356923AbiBDEUd (ORCPT ); Thu, 3 Feb 2022 23:20:33 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:64452 "EHLO mx0b-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356926AbiBDEUc (ORCPT ); Thu, 3 Feb 2022 23:20:32 -0500 Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 21437v6a030414; Fri, 4 Feb 2022 04:20:09 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=G1u+zkhIcUzNm2RfvwqjkGquCDFstiKEFk83F8NbMmA=; b=Z0VeSWxBtuKJCQt8NKJV464zmXt50qi3TF1p3I7DQtisDH/5wAYmuDYPFpuDtm0sTMfb fRbp71ITTZ9llGDvHGnWXTplyxXNKYabA8Ce38iHZzvqmQgZVHMl9C8cCW9o7YVWKkj5 P19+pqjb/sOrpJDxped1DpIqdJlDkuQrULd+sz/CVjJv2C7seexvfihDlFU6+OEmHtvB LmoDMrLXx7ZCcUdPlCZ4s7F2xkH66fUKEzsQKX+XdBPt3bGCeKMi8NSm0c9QaZuZdGWg mLR7xbOrWeekOCYRozHKQew28ilViXg/FOJIYvkTGu5aIgA1NYwJtlH7CR3KfB9Ijh/F wQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3e0qx0vqxn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 04:20:09 +0000 Received: from m0127361.ppops.net (m0127361.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 214408Ev025538; Fri, 4 Feb 2022 04:20:09 GMT Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com with ESMTP id 3e0qx0vqx6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 04:20:09 +0000 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 2144BV4o011749; Fri, 4 Feb 2022 04:20:07 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma04ams.nl.ibm.com with ESMTP id 3e0r109503-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 04:20:07 +0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2144K4mf37945808 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 4 Feb 2022 04:20:04 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 28DCDA404D; Fri, 4 Feb 2022 04:20:04 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6C197A4040; Fri, 4 Feb 2022 04:20:03 +0000 (GMT) Received: from heavy.lan (unknown [9.171.78.41]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 4 Feb 2022 04:20:03 +0000 (GMT) From: Ilya Leoshkevich To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Alexander Gordeev , Catalin Marinas , Michael Ellerman , Paul Walmsley Cc: bpf@vger.kernel.org, Ilya Leoshkevich Subject: [PATCH bpf-next v2 06/10] selftests/bpf: Use PT_REGS_SYSCALL in bpf_syscall_macro Date: Fri, 4 Feb 2022 05:19:51 +0100 Message-Id: <20220204041955.1958263-7-iii@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220204041955.1958263-1-iii@linux.ibm.com> References: <20220204041955.1958263-1-iii@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: yjJUzohGzkh3ZMLkMOVMiM6aFRL_Fpbo X-Proofpoint-ORIG-GUID: 8VJpve8fWGP8fHhRSrpHuyWYVydaVey8 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-04_01,2022-02-03_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 clxscore=1015 phishscore=0 lowpriorityscore=0 suspectscore=0 mlxscore=0 bulkscore=0 spamscore=0 mlxlogscore=999 impostorscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202040019 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net Ensure that PT_REGS_SYSCALL works correctly. Signed-off-by: Ilya Leoshkevich --- tools/testing/selftests/bpf/progs/bpf_syscall_macro.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/bpf/progs/bpf_syscall_macro.c b/tools/testing/selftests/bpf/progs/bpf_syscall_macro.c index f5c6ef2ff6d1..826cc6e433de 100644 --- a/tools/testing/selftests/bpf/progs/bpf_syscall_macro.c +++ b/tools/testing/selftests/bpf/progs/bpf_syscall_macro.c @@ -33,7 +33,7 @@ int BPF_KPROBE(handle_sys_prctl) if (pid != filter_pid) return 0; - real_regs = (struct pt_regs *)PT_REGS_PARM1(ctx); + real_regs = PT_REGS_SYSCALL(ctx); /* test for PT_REGS_PARM */ From patchwork Fri Feb 4 04:19:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Leoshkevich X-Patchwork-Id: 12734777 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 4BA4BC4332F for ; Fri, 4 Feb 2022 04:20:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356932AbiBDEUj (ORCPT ); Thu, 3 Feb 2022 23:20:39 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:14768 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356924AbiBDEUj (ORCPT ); Thu, 3 Feb 2022 23:20:39 -0500 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 2143buSO006602; Fri, 4 Feb 2022 04:20:14 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=bzk1GaOJXCcc0BGy+kCmvuGnBcWRbJV8zMo9OxM8Nnw=; b=E+yiIk/e/yzeRKujlcQ+wNxNnxf1p8HQyRqhwrMv8z9uUv88ReCAIUbSbB6B7/LPwlBK e60DO3oN/cJmVmrsT9DEd3mHuy98kyKrbsTIKjvogs0nyJR3oxYg1/pm5F5pttlX/knF Bmbb9+qlISk6Sdpd/i3UiXGX5L6j2wS8+D18WmazBSZc1928p/g+91PMko4D4/51wmeL 0B1YV1s4Tv3NbuBl7Ni5KTAHjCpaTP5nYT8FhIUmangGIOz7uFaVRUIIfiBYqzoMiflP HyHlk7ezYiebuzlx6TEU3RYBbb7TeblxSKomBBBXQDVD1Bmvgjqkqp7GK1C1dWycsvwi BQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3e0qx0chw4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 04:20:13 +0000 Received: from m0098409.ppops.net (m0098409.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 21440BSe007501; Fri, 4 Feb 2022 04:20:13 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 3e0qx0chve-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 04:20:13 +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 2144DHfB012212; Fri, 4 Feb 2022 04:20:11 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma06ams.nl.ibm.com with ESMTP id 3e0r0u15gk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 04:20:10 +0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2144K5EE25952654 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 4 Feb 2022 04:20:05 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 186B0A4053; Fri, 4 Feb 2022 04:20:05 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7D234A404D; Fri, 4 Feb 2022 04:20:04 +0000 (GMT) Received: from heavy.lan (unknown [9.171.78.41]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 4 Feb 2022 04:20:04 +0000 (GMT) From: Ilya Leoshkevich To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Alexander Gordeev , Catalin Marinas , Michael Ellerman , Paul Walmsley Cc: bpf@vger.kernel.org, Ilya Leoshkevich Subject: [PATCH bpf-next v2 07/10] libbpf: Fix accessing the first syscall argument on arm64 Date: Fri, 4 Feb 2022 05:19:52 +0100 Message-Id: <20220204041955.1958263-8-iii@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220204041955.1958263-1-iii@linux.ibm.com> References: <20220204041955.1958263-1-iii@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: Ld6hkt9-urXzjIXAh7oQOG_iuki_AoBQ X-Proofpoint-ORIG-GUID: tWNn4Ukv2iIWNwEWSwpAFXCFzcZ01JNO 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-04_01,2022-02-03_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 clxscore=1015 mlxlogscore=999 suspectscore=0 spamscore=0 malwarescore=0 phishscore=0 priorityscore=1501 impostorscore=0 adultscore=0 mlxscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202040019 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net On arm64, the first syscall argument should be accessed via orig_x0 (see arch/arm64/include/asm/syscall.h). Currently regs[0] is used instead, leading to bpf_syscall_macro test failure. Fixes: d084df3b7a4c ("libbpf: Fix the incorrect register read for syscalls on x86_64") Reported-by: Heiko Carstens Signed-off-by: Ilya Leoshkevich --- tools/lib/bpf/bpf_tracing.h | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/lib/bpf/bpf_tracing.h b/tools/lib/bpf/bpf_tracing.h index 400a4f002f77..4a990111d9a8 100644 --- a/tools/lib/bpf/bpf_tracing.h +++ b/tools/lib/bpf/bpf_tracing.h @@ -145,6 +145,7 @@ /* arm64 provides struct user_pt_regs instead of struct pt_regs to userspace */ #define __PT_REGS_CAST(x) ((const struct user_pt_regs *)(x)) #define __PT_PARM1_REG regs[0] +#define __PT_PARM1_REG_SYSCALL orig_x0 #define __PT_PARM2_REG regs[1] #define __PT_PARM3_REG regs[2] #define __PT_PARM4_REG regs[3] From patchwork Fri Feb 4 04:19:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Leoshkevich X-Patchwork-Id: 12734776 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 67CBEC433EF for ; Fri, 4 Feb 2022 04:20:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356929AbiBDEUi (ORCPT ); Thu, 3 Feb 2022 23:20:38 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:60156 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356924AbiBDEUh (ORCPT ); Thu, 3 Feb 2022 23:20:37 -0500 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 21433afn021266; Fri, 4 Feb 2022 04:20:12 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=i5TVDgE12ALeM1ADvCXiO3hmfgZFRsbfVEtzFujqGLk=; b=UQGH/YTvVoSmMjYniOt7AhUs/6nx4XQjY7uzBH1r4n0oGp/0Lght1+P7SXJsZTDm0fbU ohVazDrHRL1Wvv2mCZ1kvyXV0Z2lKrDX2nwD3c4RiQYmH3y8oo4rEOVBauKUr0psXDjW lIbcoppU65eW1zVHudvMVYupN0/kfcej2Cn8BlPO5I4bAVaGuxH7nMR5NN+tbw1oHt+O s6dP72nua93LQlb7ejx5NUkPT5iUAxHJPRwhHDcoXoCKkHg3o5iacTQq03SQURsVLM7+ YP6GGn94+evemVCNz+F3OMiu+YDoeEbUzILW3QlBTdMQfiPKbuUOsPFH8hxI3ToJuCwg zQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3e0qx3mjav-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 04:20:12 +0000 Received: from m0098394.ppops.net (m0098394.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 2144KBfe015056; Fri, 4 Feb 2022 04:20:11 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 3e0qx3mja6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 04:20:11 +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 2144DPwA003260; Fri, 4 Feb 2022 04:20:09 GMT Received: from b06avi18626390.portsmouth.uk.ibm.com (b06avi18626390.portsmouth.uk.ibm.com [9.149.26.192]) by ppma05fra.de.ibm.com with ESMTP id 3e0r0x130p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 04:20:09 +0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2144ABFv49676728 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 4 Feb 2022 04:10:11 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 20FF4A4057; Fri, 4 Feb 2022 04:20:06 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 862C9A4053; Fri, 4 Feb 2022 04:20:05 +0000 (GMT) Received: from heavy.lan (unknown [9.171.78.41]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 4 Feb 2022 04:20:05 +0000 (GMT) From: Ilya Leoshkevich To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Alexander Gordeev , Catalin Marinas , Michael Ellerman , Paul Walmsley Cc: bpf@vger.kernel.org, Ilya Leoshkevich Subject: [PATCH bpf-next v2 08/10] libbpf: Fix accessing syscall arguments on powerpc Date: Fri, 4 Feb 2022 05:19:53 +0100 Message-Id: <20220204041955.1958263-9-iii@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220204041955.1958263-1-iii@linux.ibm.com> References: <20220204041955.1958263-1-iii@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 2tkkwuAwj_EEeEAGfgkKqDhCUqg9DPKZ X-Proofpoint-GUID: UxlXgRviP5q3sMwZaMuk04TwtdHkFtY4 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-04_01,2022-02-03_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 lowpriorityscore=0 phishscore=0 clxscore=1015 impostorscore=0 adultscore=0 mlxscore=0 spamscore=0 suspectscore=0 malwarescore=0 priorityscore=1501 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202040019 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net powerpc's syscall handlers get "unpacked" arguments instead of a struct pt_regs pointer. Indicate this to libbpf using PT_REGS_SYSCALL macro. Fixes: d084df3b7a4c ("libbpf: Fix the incorrect register read for syscalls on x86_64") Reported-by: Heiko Carstens Signed-off-by: Ilya Leoshkevich --- tools/lib/bpf/bpf_tracing.h | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/lib/bpf/bpf_tracing.h b/tools/lib/bpf/bpf_tracing.h index 4a990111d9a8..c21aaecd711b 100644 --- a/tools/lib/bpf/bpf_tracing.h +++ b/tools/lib/bpf/bpf_tracing.h @@ -181,6 +181,7 @@ #define __PT_RC_REG gpr[3] #define __PT_SP_REG sp #define __PT_IP_REG nip +#define PT_REGS_SYSCALL(ctx) ctx #elif defined(bpf_target_sparc) From patchwork Fri Feb 4 04:19:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Leoshkevich X-Patchwork-Id: 12734778 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 A8DFBC43217 for ; Fri, 4 Feb 2022 04:20:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356930AbiBDEUk (ORCPT ); Thu, 3 Feb 2022 23:20:40 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:7356 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356928AbiBDEUj (ORCPT ); Thu, 3 Feb 2022 23:20:39 -0500 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 2143bv7w006660; Fri, 4 Feb 2022 04:20:13 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=+sbxQ7AfgdSlyHyScmXyR82/HruWSV6MLNp/y17hX08=; b=HCN83ZVKFg92qsNMMFrjNapTOp48t/QKMFjJbgM9Yam7P9AljujwbovVmEn0s9Zy+ruR w4zER8c758cip+GRc7gm8n85/lqusONY7vL5FXi22cDhN4G228vEDqzJcGkssJ3KKvFW 03Zbp+CGcmyttFJwogED8YzwSclRA6id/oQMDT5LdmGsgY7Vi+kfMqcIBlRuQiv1dk// TgH24gKonw/ULD6ep+yDWA1t8rMx8vguavX+mt+UbG+59p2JWdgVrHCU6Sy5WZApxaAz NXjFJKnnpEKTJRuES/4gfP0cMvUduROqJ3/t9WuTZKuLT0G2Jlfc8S4WQgnmVpf1mTTQ +g== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3e0qx0chvt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 04:20:13 +0000 Received: from m0098409.ppops.net (m0098409.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 2144GZcN005966; Fri, 4 Feb 2022 04:20:12 GMT Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 3e0qx0chv6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 04:20:12 +0000 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 2144DaQm019564; Fri, 4 Feb 2022 04:20:10 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma03ams.nl.ibm.com with ESMTP id 3e0r0sh598-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 04:20:10 +0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2144K7rp41812266 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 4 Feb 2022 04:20:07 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 184C3A4059; Fri, 4 Feb 2022 04:20:07 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 827B8A4055; Fri, 4 Feb 2022 04:20:06 +0000 (GMT) Received: from heavy.lan (unknown [9.171.78.41]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 4 Feb 2022 04:20:06 +0000 (GMT) From: Ilya Leoshkevich To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Alexander Gordeev , Catalin Marinas , Michael Ellerman , Paul Walmsley Cc: bpf@vger.kernel.org, Ilya Leoshkevich Subject: [PATCH bpf-next v2 09/10] libbpf: Fix accessing syscall arguments on riscv Date: Fri, 4 Feb 2022 05:19:54 +0100 Message-Id: <20220204041955.1958263-10-iii@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220204041955.1958263-1-iii@linux.ibm.com> References: <20220204041955.1958263-1-iii@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: kDursPlDGsRE1UOMUXaPXHJ89TkiYNbm X-Proofpoint-ORIG-GUID: geFN2gAwtrwhvKCXmDOAGNg2NWuNIaw8 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-04_01,2022-02-03_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 clxscore=1015 mlxlogscore=999 suspectscore=0 spamscore=0 malwarescore=0 phishscore=0 priorityscore=1501 impostorscore=0 adultscore=0 mlxscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202040019 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net riscv's syscall handlers get "unpacked" arguments instead of a struct pt_regs pointer. Indicate this to libbpf using PT_REGS_SYSCALL macro. Fixes: d084df3b7a4c ("libbpf: Fix the incorrect register read for syscalls on x86_64") Reported-by: Heiko Carstens Signed-off-by: Ilya Leoshkevich --- tools/lib/bpf/bpf_tracing.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/lib/bpf/bpf_tracing.h b/tools/lib/bpf/bpf_tracing.h index c21aaecd711b..2b707aff0763 100644 --- a/tools/lib/bpf/bpf_tracing.h +++ b/tools/lib/bpf/bpf_tracing.h @@ -213,7 +213,8 @@ #define __PT_FP_REG fp #define __PT_RC_REG a5 #define __PT_SP_REG sp -#define __PT_IP_REG epc +#define __PT_IP_REG pc +#define PT_REGS_SYSCALL(ctx) ctx #endif From patchwork Fri Feb 4 04:19:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Leoshkevich X-Patchwork-Id: 12734779 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 36107C433EF for ; Fri, 4 Feb 2022 04:20:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356928AbiBDEUk (ORCPT ); Thu, 3 Feb 2022 23:20:40 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:8022 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356924AbiBDEUj (ORCPT ); Thu, 3 Feb 2022 23:20:39 -0500 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 21427tP6005773; Fri, 4 Feb 2022 04:20:15 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=uEyhAjVdTpD9T1GwdUEz+48C/abQo8lX7eZtGm3DP4Y=; b=YCUY6yH88+tXSgeRy+bwVUEYkeu2ohT52XULiuZrMZt3C3qx7kwpQ5rMciLz6qP2ERow 7cO96yoZw1p3wSL6U3e1+c9YeT0AiNsaEpLiIgN3hOV6Te/ZfZWD2gB7begTgF2xf1ow iBZlIXQSiPsZ6gbUNZO35GOTg/aBBt3Vms09SsoqoWGZ4zUwL+V0yU4NAEWHQCH2/9XO EIZU8Gdyigk3L7vYc1bzCG4kDVdfo+uF1rgDOzL1Y2/akTGh7wx1Zcny8cq/3o705t+Y habycK4AsJh6eUQQ2+NGrw0lvf/tlbHEilhru6FTt2LLKKA+g+fSBlpy4AsvZIERpEQY YQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3e0qx3vp7a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 04:20:14 +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 2144FD8H035058; Fri, 4 Feb 2022 04:20:14 GMT Received: from ppma03fra.de.ibm.com (6b.4a.5195.ip4.static.sl-reverse.com [149.81.74.107]) by mx0a-001b2d01.pphosted.com with ESMTP id 3e0qx3vp6m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 04:20:14 +0000 Received: from pps.filterd (ppma03fra.de.ibm.com [127.0.0.1]) by ppma03fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 2144CkCW012073; Fri, 4 Feb 2022 04:20:12 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma03fra.de.ibm.com with ESMTP id 3e0r0n1389-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 04:20:11 +0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2144K8S540632820 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 4 Feb 2022 04:20:08 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 64329A4059; Fri, 4 Feb 2022 04:20:08 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C10C6A404D; Fri, 4 Feb 2022 04:20:07 +0000 (GMT) Received: from heavy.lan (unknown [9.171.78.41]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 4 Feb 2022 04:20:07 +0000 (GMT) From: Ilya Leoshkevich To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Alexander Gordeev , Catalin Marinas , Michael Ellerman , Paul Walmsley Cc: bpf@vger.kernel.org, Ilya Leoshkevich , Andrii Nakryiko Subject: [PATCH bpf-next v2 10/10] libbpf: Fix accessing the first syscall argument on s390 Date: Fri, 4 Feb 2022 05:19:55 +0100 Message-Id: <20220204041955.1958263-11-iii@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220204041955.1958263-1-iii@linux.ibm.com> References: <20220204041955.1958263-1-iii@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: CQUJj81ikcV8C6HTYTE23uKtv_nKFZjv X-Proofpoint-ORIG-GUID: AxaABTUdk6cQfAJ3KHgtffJL7aQlkl2N 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-04_01,2022-02-03_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 adultscore=0 bulkscore=0 phishscore=0 spamscore=0 mlxscore=0 priorityscore=1501 mlxlogscore=999 malwarescore=0 suspectscore=0 lowpriorityscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202040019 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net On s390, the first syscall argument should be accessed via orig_gpr2 (see arch/s390/include/asm/syscall.h). Currently gpr[2] is used instead, leading to bpf_syscall_macro test failure. Fixes: d084df3b7a4c ("libbpf: Fix the incorrect register read for syscalls on x86_64") Reported-by: Andrii Nakryiko Signed-off-by: Ilya Leoshkevich --- tools/lib/bpf/bpf_tracing.h | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/lib/bpf/bpf_tracing.h b/tools/lib/bpf/bpf_tracing.h index 2b707aff0763..cca62633f32c 100644 --- a/tools/lib/bpf/bpf_tracing.h +++ b/tools/lib/bpf/bpf_tracing.h @@ -117,6 +117,7 @@ /* s390 provides user_pt_regs instead of struct pt_regs to userspace */ #define __PT_REGS_CAST(x) ((const user_pt_regs *)(x)) #define __PT_PARM1_REG gprs[2] +#define __PT_PARM1_REG_SYSCALL orig_gpr2 #define __PT_PARM2_REG gprs[3] #define __PT_PARM3_REG gprs[4] #define __PT_PARM4_REG gprs[5]