{"id":2196702,"url":"http://patchwork.ozlabs.org/api/1.0/patches/2196702/?format=json","project":{"id":2,"url":"http://patchwork.ozlabs.org/api/1.0/projects/2/?format=json","name":"Linux PPC development","link_name":"linuxppc-dev","list_id":"linuxppc-dev.lists.ozlabs.org","list_email":"linuxppc-dev@lists.ozlabs.org","web_url":"https://github.com/linuxppc/wiki/wiki","scm_url":"https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git","webscm_url":"https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/"},"msgid":"<20260216065639.1750181-3-hbathini@linux.ibm.com>","date":"2026-02-16T06:56:36","name":"[2/5] powerpc64/bpf: fix the address returned by bpf_get_func_ip","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"7ad2bfd93858c9e425f983e3bc6778745880d11b","submitter":{"id":74073,"url":"http://patchwork.ozlabs.org/api/1.0/people/74073/?format=json","name":"Hari Bathini","email":"hbathini@linux.ibm.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linuxppc-dev/patch/20260216065639.1750181-3-hbathini@linux.ibm.com/mbox/","series":[{"id":492248,"url":"http://patchwork.ozlabs.org/api/1.0/series/492248/?format=json","date":"2026-02-16T06:56:34","name":"powerpc64/bpf: various fixes","version":1,"mbox":"http://patchwork.ozlabs.org/series/492248/mbox/"}],"check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2196702/checks/","tags":{},"headers":{"Return-Path":"\n <linuxppc-dev+bounces-16870-incoming=patchwork.ozlabs.org@lists.ozlabs.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linuxppc-dev@lists.ozlabs.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256\n header.s=pp1 header.b=n7nHu35x;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org\n (client-ip=2404:9400:21b9:f100::1; helo=lists.ozlabs.org;\n envelope-from=linuxppc-dev+bounces-16870-incoming=patchwork.ozlabs.org@lists.ozlabs.org;\n receiver=patchwork.ozlabs.org)","lists.ozlabs.org;\n arc=none smtp.remote-ip=148.163.158.5","lists.ozlabs.org;\n dmarc=pass (p=none dis=none) header.from=linux.ibm.com","lists.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256\n header.s=pp1 header.b=n7nHu35x;\n\tdkim-atps=neutral","lists.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=linux.ibm.com\n (client-ip=148.163.158.5; helo=mx0b-001b2d01.pphosted.com;\n envelope-from=hbathini@linux.ibm.com; receiver=lists.ozlabs.org)"],"Received":["from lists.ozlabs.org (lists.ozlabs.org\n [IPv6:2404:9400:21b9:f100::1])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fDtr01GYJz1xpl\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 16 Feb 2026 17:57:20 +1100 (AEDT)","from boromir.ozlabs.org (localhost [127.0.0.1])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 4fDtql1CZTz3bnx;\n\tMon, 16 Feb 2026 17:57:07 +1100 (AEDT)","from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com\n [148.163.158.5])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature RSA-PSS (2048 bits) server-digest\n SHA256)\n\t(No client certificate requested)\n\tby lists.ozlabs.org (Postfix) with ESMTPS id 4fDtqk2MM8z2xN4\n\tfor <linuxppc-dev@lists.ozlabs.org>; Mon, 16 Feb 2026 17:57:06 +1100 (AEDT)","from pps.filterd (m0356516.ppops.net [127.0.0.1])\n\tby mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id\n 61FCZloe2534882;\n\tMon, 16 Feb 2026 06:56:50 GMT","from ppma13.dal12v.mail.ibm.com\n (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221])\n\tby mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4caj63x3wk-1\n\t(version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT);\n\tMon, 16 Feb 2026 06:56:50 +0000 (GMT)","from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1])\n\tby ppma13.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id\n 61G32vEd002838;\n\tMon, 16 Feb 2026 06:56:49 GMT","from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226])\n\tby ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 4cb5kj45h9-1\n\t(version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT);\n\tMon, 16 Feb 2026 06:56:49 +0000","from smtpav04.fra02v.mail.ibm.com (smtpav04.fra02v.mail.ibm.com\n [10.20.54.103])\n\tby smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id\n 61G6ujHZ38338836\n\t(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK);\n\tMon, 16 Feb 2026 06:56:45 GMT","from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1])\n\tby IMSVA (Postfix) with ESMTP id BD9A820040;\n\tMon, 16 Feb 2026 06:56:45 +0000 (GMT)","from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1])\n\tby IMSVA (Postfix) with ESMTP id 02FA520043;\n\tMon, 16 Feb 2026 06:56:44 +0000 (GMT)","from li-bd3f974c-2712-11b2-a85c-df1cec4d728e.in.ibm.com (unknown\n [9.78.106.17])\n\tby smtpav04.fra02v.mail.ibm.com (Postfix) with ESMTP;\n\tMon, 16 Feb 2026 06:56:43 +0000 (GMT)"],"ARC-Seal":"i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1771225027;\n\tcv=none;\n b=N0BQdTaCfQWT7g9qkKjk/75EOUQ1sq48Nr1pX+FB3pSOn2Cxc3ytXDNon5hW+RiTszAMg5tkWTVvrw/e/wM/K17hPav9mdRt1FBVofC0giNJPaf4sPZ96cRgrcaFeX8h/Z9umEN9YruDEfxuLlzmThqi+LdJGEgCpiEQgFaxyvy4pqau+bDkXgjkzkbqr/EOwT7Vb3ExCVEjukEl0XehL0oajvQ2Vjom6Awjx4xi7PTsyVlJlccGckgHPp/Ifi0xWRPL7EOkvDu/NnHm3SYxSCbXGj+iFYoQwQArbRhlD3xVnivxVWMTB9DbPpFfve68zC+wD7OsiIWJJjGXVoI4UQ==","ARC-Message-Signature":"i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707;\n\tt=1771225027; c=relaxed/relaxed;\n\tbh=2XX0R9TtZrIBWJXgKI/YKmAKnVgu8iZtTRCdZ43Gui4=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=Qqy9QWdICzTMV6ayEg5NL7MtXw4xWDE1C1SlA3sIxfDv9Bfg0E3xeiGCcTtTnjHLnjBksqWOnln3HUgVH3RMwH68hnQciNVus2Vbbhes7MxGgftVoaLl2uhoozM28gMuJitcs3+BK1Cenq/Vu8x/QxtPoVzs6gM0kK/VO4N1jd4Vz+sIoD6T8z8F30yOlETudPscjigL4T17BOYpS+Ysr9wx1bAqQlbuuGOTdRtoxvp0N8Kf8nil3T5VWJNQbi35PU5t0OXvRuXDI3knxt93ubhArjM3+/l6/EVPnoBbE8Oh1aj7MUVlfjnwgRiBtIyO7iy73WJbjGgbSbegJbFpdA==","ARC-Authentication-Results":"i=1; lists.ozlabs.org;\n dmarc=pass (p=none dis=none) header.from=linux.ibm.com;\n dkim=pass (2048-bit key;\n unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256\n header.s=pp1 header.b=n7nHu35x; dkim-atps=neutral;\n spf=pass (client-ip=148.163.158.5; helo=mx0b-001b2d01.pphosted.com;\n envelope-from=hbathini@linux.ibm.com;\n receiver=lists.ozlabs.org) smtp.mailfrom=linux.ibm.com","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc\n\t:content-transfer-encoding:date:from:in-reply-to:message-id\n\t:mime-version:references:subject:to; s=pp1; bh=2XX0R9TtZrIBWJXgK\n\tI/YKmAKnVgu8iZtTRCdZ43Gui4=; b=n7nHu35xIL5ZnNFc/5bSfc6UbN66tO7eK\n\tIweFt55+6LEEwtg5NYjkKp20mKSQSQBl0dgUQlYV/SYUDcnvPxq3ftJv2LOEx1XS\n\tVWgrhmNnA79Y+23nw3mhIcHVEmW0lRprZtS43SUfhZTpqVZTzaJHt1ZYZa2yweP9\n\t44v4876zeIPMbCZnCQraAqglkJ4tlW6Xv0A2ErIyU2nhaDoqohqaXZJiictgHf+9\n\tib5L8ezOhoYjgy+heD02q6KgieJHc3CpyGAY2j3yGb0jVdKu54+zOX/8f3/xFwmm\n\ttRIRdVuiGh1Oxr/tYZOWPInRAhdkPTrtYQ3zuKCOG61lZ/NpBta7A==","From":"Hari Bathini <hbathini@linux.ibm.com>","To":"linuxppc-dev <linuxppc-dev@lists.ozlabs.org>","Cc":"bpf@vger.kernel.org, Alexei Starovoitov <ast@kernel.org>,\n        Daniel Borkmann <daniel@iogearbox.net>,\n        Andrii Nakryiko <andrii@kernel.org>,\n        Saket Kumar Bhaskar <skb99@linux.ibm.com>,\n        Abhishek Dubey <adubey@linux.ibm.com>, stable@vger.kernel.org","Subject":"[PATCH 2/5] powerpc64/bpf: fix the address returned by\n bpf_get_func_ip","Date":"Mon, 16 Feb 2026 12:26:36 +0530","Message-ID":"<20260216065639.1750181-3-hbathini@linux.ibm.com>","X-Mailer":"git-send-email 2.53.0","In-Reply-To":"<20260216065639.1750181-1-hbathini@linux.ibm.com>","References":"<20260216065639.1750181-1-hbathini@linux.ibm.com>","X-Mailing-List":"linuxppc-dev@lists.ozlabs.org","List-Id":"<linuxppc-dev.lists.ozlabs.org>","List-Help":"<mailto:linuxppc-dev+help@lists.ozlabs.org>","List-Owner":"<mailto:linuxppc-dev+owner@lists.ozlabs.org>","List-Post":"<mailto:linuxppc-dev@lists.ozlabs.org>","List-Archive":"<https://lore.kernel.org/linuxppc-dev/>,\n  <https://lists.ozlabs.org/pipermail/linuxppc-dev/>","List-Subscribe":"<mailto:linuxppc-dev+subscribe@lists.ozlabs.org>,\n  <mailto:linuxppc-dev+subscribe-digest@lists.ozlabs.org>,\n  <mailto:linuxppc-dev+subscribe-nomail@lists.ozlabs.org>","List-Unsubscribe":"<mailto:linuxppc-dev+unsubscribe@lists.ozlabs.org>","Precedence":"list","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","X-TM-AS-GCONF":"00","X-Proofpoint-ORIG-GUID":"s-Hs2wh5xqKazuuC3CIC-OGV1YGxtEXq","X-Proofpoint-Spam-Details-Enc":"AW1haW4tMjYwMjE2MDA1NCBTYWx0ZWRfX63se1cveZzgM\n adpG9gnLyx8a1l3IPGVCzPPhPbGd4cuiYT0LV0oUgR819E3PkTD2c0M0Q6cKDUogZ7FIPHh788h\n iTQGQik3kDTKPR7D+hJhbavfJ7rGhy2oBsKOEB+sB4epnzdbHFraTV3zaYRl2KK1bnm2gpYaM55\n si3QErh080PMCdwIqn/JwWUQb27G185ZJIHmLLMMMDUW39YDZHeM8fqTpDMQO5L97+8WXtFKVQ1\n BW6qLQXaBBuXVT5ZulLa0ePG2T3FbNsrRrZ7w/UEJ5/a6kn6vg4HiZHrlcvVbLnJMJenmRvmIv2\n rNuaJBeY1f4WUn8le1RXMjS3b8/9I5gzSGjBpM6/8I6F+6+jIlsjS9q3fQudfnOj2hyzkA1j54Q\n pbvnWivLXH5OxzK+F6iMnr+wkci4CM/7rzHCFaK/gEzIkZ6j7tMc8FTVPZPT7NBXaR6DD+w1/X5\n On6+qgQYb2IEGVgzQ1w==","X-Proofpoint-GUID":"s-Hs2wh5xqKazuuC3CIC-OGV1YGxtEXq","X-Authority-Analysis":"v=2.4 cv=U+mfzOru c=1 sm=1 tr=0 ts=6992bfb2 cx=c_pps\n a=AfN7/Ok6k8XGzOShvHwTGQ==:117 a=AfN7/Ok6k8XGzOShvHwTGQ==:17\n a=HzLeVaNsDn8A:10 a=VkNPw1HP01LnGYTKEx00:22 a=Mpw57Om8IfrbqaoTuvik:22\n a=GgsMoib0sEa3-_RKJdDe:22 a=VnNF1IyMAAAA:8 a=VwQbUJbxAAAA:8\n a=SO5buJ7TJInmnl-hmdUA:9","X-Proofpoint-Virus-Version":"vendor=baseguard\n engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.51,FMLib:17.12.100.49\n definitions=2026-02-16_03,2026-02-13_01,2025-10-01_01","X-Proofpoint-Spam-Details":"rule=outbound_notspam policy=outbound score=0\n clxscore=1011 bulkscore=0 impostorscore=0 malwarescore=0 spamscore=0\n adultscore=0 phishscore=0 lowpriorityscore=0 priorityscore=1501\n suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc=\n route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000\n definitions=main-2602160054","X-Spam-Status":"No, score=-0.7 required=3.0 tests=DKIM_SIGNED,DKIM_VALID,\n\tRCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,\n\tSPF_PASS autolearn=disabled version=4.0.1 OzLabs 8","X-Spam-Checker-Version":"SpamAssassin 4.0.1 (2024-03-25) on lists.ozlabs.org"},"content":"bpf_get_func_ip() helper function returns the address of the traced\nfunction. It relies on the IP address stored at ctx - 16 by the bpf\ntrampoline. On 64-bit powerpc, this address is recovered from LR\naccounting for OOL trampoline. But the address stored here was off\nby 4-bytes. Ensure the address is the actual start of the traced\nfunction.\n\nReported-by: Abhishek Dubey <adubey@linux.ibm.com>\nFixes: d243b62b7bd3 (\"powerpc64/bpf: Add support for bpf trampolines\")\nCc: stable@vger.kernel.org\nSigned-off-by: Hari Bathini <hbathini@linux.ibm.com>\n---\n arch/powerpc/net/bpf_jit_comp.c | 21 +++++++++++++--------\n 1 file changed, 13 insertions(+), 8 deletions(-)","diff":"diff --git a/arch/powerpc/net/bpf_jit_comp.c b/arch/powerpc/net/bpf_jit_comp.c\nindex 987cd9fb0f37..fb6cc1f832a8 100644\n--- a/arch/powerpc/net/bpf_jit_comp.c\n+++ b/arch/powerpc/net/bpf_jit_comp.c\n@@ -786,8 +786,8 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, void *rw_im\n \t *                              [ reg argN          ]\n \t *                              [ ...               ]\n \t *       regs_off               [ reg_arg1          ] prog ctx context\n-\t *       nregs_off              [ args count        ]\n-\t *       ip_off                 [ traced function   ]\n+\t *       nregs_off              [ args count        ] ((u64 *)prog_ctx)[-1]\n+\t *       ip_off                 [ traced function   ] ((u64 *)prog_ctx)[-2]\n \t *                              [ ...               ]\n \t *       run_ctx_off            [ bpf_tramp_run_ctx ]\n \t *                              [ reg argN          ]\n@@ -895,7 +895,7 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, void *rw_im\n \n \tbpf_trampoline_save_args(image, ctx, func_frame_offset, nr_regs, regs_off);\n \n-\t/* Save our return address */\n+\t/* Save our LR/return address */\n \tEMIT(PPC_RAW_MFLR(_R3));\n \tif (IS_ENABLED(CONFIG_PPC_FTRACE_OUT_OF_LINE))\n \t\tEMIT(PPC_RAW_STL(_R3, _R1, alt_lr_off));\n@@ -903,24 +903,29 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, void *rw_im\n \t\tEMIT(PPC_RAW_STL(_R3, _R1, bpf_frame_size + PPC_LR_STKOFF));\n \n \t/*\n-\t * Save ip address of the traced function.\n-\t * We could recover this from LR, but we will need to address for OOL trampoline,\n-\t * and optional GEP area.\n+\t * Get IP address of the traced function.\n+\t * In case of CONFIG_PPC_FTRACE_OUT_OF_LINE or BPF program, LR\n+\t * points to the instruction after the 'bl' instruction in the OOL stub.\n+\t * Refer to ftrace_init_ool_stub() and bpf_arch_text_poke() for OOL stub\n+\t * of kernel functions and bpf programs respectively.\n+\t * Recover kernel function/bpf program address from the unconditional\n+\t * branch instruction at the end of OOL stub.\n \t */\n \tif (IS_ENABLED(CONFIG_PPC_FTRACE_OUT_OF_LINE) || flags & BPF_TRAMP_F_IP_ARG) {\n \t\tEMIT(PPC_RAW_LWZ(_R4, _R3, 4));\n \t\tEMIT(PPC_RAW_SLWI(_R4, _R4, 6));\n \t\tEMIT(PPC_RAW_SRAWI(_R4, _R4, 6));\n \t\tEMIT(PPC_RAW_ADD(_R3, _R3, _R4));\n-\t\tEMIT(PPC_RAW_ADDI(_R3, _R3, 4));\n \t}\n \n \tif (flags & BPF_TRAMP_F_IP_ARG)\n \t\tEMIT(PPC_RAW_STL(_R3, _R1, ip_off));\n \n-\tif (IS_ENABLED(CONFIG_PPC_FTRACE_OUT_OF_LINE))\n+\tif (IS_ENABLED(CONFIG_PPC_FTRACE_OUT_OF_LINE)) {\n \t\t/* Fake our LR for unwind */\n+\t\tEMIT(PPC_RAW_ADDI(_R3, _R3, 4));\n \t\tEMIT(PPC_RAW_STL(_R3, _R1, bpf_frame_size + PPC_LR_STKOFF));\n+\t}\n \n \t/* Save function arg count -- see bpf_get_func_arg_cnt() */\n \tEMIT(PPC_RAW_LI(_R3, nr_regs));\n","prefixes":["2/5"]}