get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/2219235/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 2219235,
    "url": "http://patchwork.ozlabs.org/api/patches/2219235/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/linuxppc-dev/patch/20260402161026.289827-1-skb99@linux.ibm.com/",
    "project": {
        "id": 2,
        "url": "http://patchwork.ozlabs.org/api/projects/2/?format=api",
        "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/",
        "list_archive_url": "https://lore.kernel.org/linuxppc-dev/",
        "list_archive_url_format": "https://lore.kernel.org/linuxppc-dev/{}/",
        "commit_url_format": "https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/commit/?id={}"
    },
    "msgid": "<20260402161026.289827-1-skb99@linux.ibm.com>",
    "list_archive_url": "https://lore.kernel.org/linuxppc-dev/20260402161026.289827-1-skb99@linux.ibm.com/",
    "date": "2026-04-02T16:10:26",
    "name": "[v2] powerpc64/bpf: Add powerpc64 JIT support for timed may_goto",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "e08482933791c4d83feb95c459b2261a7c8d61a8",
    "submitter": {
        "id": 90461,
        "url": "http://patchwork.ozlabs.org/api/people/90461/?format=api",
        "name": "Saket Kumar Bhaskar",
        "email": "skb99@linux.ibm.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/linuxppc-dev/patch/20260402161026.289827-1-skb99@linux.ibm.com/mbox/",
    "series": [
        {
            "id": 498508,
            "url": "http://patchwork.ozlabs.org/api/series/498508/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=498508",
            "date": "2026-04-02T16:10:26",
            "name": "[v2] powerpc64/bpf: Add powerpc64 JIT support for timed may_goto",
            "version": 2,
            "mbox": "http://patchwork.ozlabs.org/series/498508/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/2219235/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/2219235/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "\n <linuxppc-dev+bounces-19225-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=TzQdfsV7;\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-19225-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=TzQdfsV7;\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=skb99@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 server-signature ECDSA (secp384r1 raw public key)\n server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fmn0T3n81z1yGH\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 03 Apr 2026 03:11:20 +1100 (AEDT)",
            "from boromir.ozlabs.org (localhost [127.0.0.1])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 4fmn0R6WBwz2ySk;\n\tFri, 03 Apr 2026 03:11:19 +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 4fmn0Q5qWfz2xc8\n\tfor <linuxppc-dev@lists.ozlabs.org>; Fri, 03 Apr 2026 03:11:17 +1100 (AEDT)",
            "from pps.filterd (m0353725.ppops.net [127.0.0.1])\n\tby mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id\n 632ATbj63127127;\n\tThu, 2 Apr 2026 16:10:38 GMT",
            "from ppma22.wdc07v.mail.ibm.com\n (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92])\n\tby mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4d65dcmnap-1\n\t(version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT);\n\tThu, 02 Apr 2026 16:10:37 +0000 (GMT)",
            "from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1])\n\tby ppma22.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id\n 632G8aWb005757;\n\tThu, 2 Apr 2026 16:10:37 GMT",
            "from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226])\n\tby ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4d6spyasfk-1\n\t(version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT);\n\tThu, 02 Apr 2026 16:10:37 +0000",
            "from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com\n [10.20.54.104])\n\tby smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id\n 632GAXwk46006638\n\t(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK);\n\tThu, 2 Apr 2026 16:10:33 GMT",
            "from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1])\n\tby IMSVA (Postfix) with ESMTP id 0851D20043;\n\tThu,  2 Apr 2026 16:10:33 +0000 (GMT)",
            "from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1])\n\tby IMSVA (Postfix) with ESMTP id B6E1B2004F;\n\tThu,  2 Apr 2026 16:10:27 +0000 (GMT)",
            "from li-1cb9f04c-2ae1-11b2-a85c-a8a0a83790a8.ibm.com.com (unknown\n [9.124.211.168])\n\tby smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTP;\n\tThu,  2 Apr 2026 16:10:27 +0000 (GMT)"
        ],
        "ARC-Seal": "i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1775146279;\n\tcv=none;\n b=mPk1if+htWFOWR5/TerF/ZxHviVBJZXNm/hUlbOgCsm7Ioyf+lzBjiUMSwev6RokZykr2OZ7q7+LmJvlTxMOzwI52Z6Vpl4pYbHVQCCKU1KoHPpK4p88p5m103rBYBEG96fJc8nWn0UyiDO6ugWUHiAPchweq0OpMR71czYmptynU/U76QcZnkHe7d7yEs+ac8mn5u4d76OtehPZtGCdoao48ENIqyx4IiGhHffxD0VkzQ1TVHksP/6712gqpQIe5rnQCCWK6ZPRukRrVWMtegau9hTv0KLfF0z19Q5UNEROAQC6mHyQLtWLESJTfRY7YzAzMMNBRsy4xvCJUNxFOg==",
        "ARC-Message-Signature": "i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707;\n\tt=1775146279; c=relaxed/relaxed;\n\tbh=n9r5Ppcix6CONLD3jPGx3p9uEwOXiuqnf4e5g2ttXT8=;\n\th=From:To:Cc:Subject:Date:Message-ID:MIME-Version;\n b=TdMdNUmCP4o6JeHJNSxvv0O+uB4/Nd1GaNkhCvu38jyYTzhiF6wxFgwtrGrL2Pp1IhHqdDqNz6u99VZ4SgeFb8QwCwZ4gZH/yQVWwM8cTT0H5DHVh5vtaORTbinAd7RbN/uKUXerCUOkV9/biTNfbj94TEWJkmQB3WSE0ZUs8qRICJY1iKym6ea5pY9B9QGYBWZv+VpVVg2V/pIDQVdOun01EvI2CL7QBCF2xCi6vk6gNx4BzuRRNqw/UObbOn/kX8THffK0VNig96RzS6EcCKCO0ne5oxp6iK1Dkjw3tHHvqowpUqXxxqmp2mgwzFRuOCb96B+Qa2bUst217JJj1w==",
        "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=TzQdfsV7; dkim-atps=neutral;\n spf=pass (client-ip=148.163.158.5; helo=mx0b-001b2d01.pphosted.com;\n envelope-from=skb99@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:message-id:mime-version\n\t:subject:to; s=pp1; bh=n9r5Ppcix6CONLD3jPGx3p9uEwOXiuqnf4e5g2ttX\n\tT8=; b=TzQdfsV7ubEws3BVdm30Lk9qFEIcoEWtTIeitGmi/p1NDtnOfEov++dQ1\n\tBSo628QLIYM1Q4OBNjU+ah5WTEBfjmR0os+Iq7TvjyXxIsbMIioDjyyugUGahMeE\n\t4w0jmjIsFv5PponuNYBLPjFh8HDsQlqb5ZfATvdeeIg99s9vneperDbKBvKcEfL6\n\t/WmnrMLZBobCJXQo4RNQ8XHKa1+r+bxpAgtmynm8E2COO3KkXPWxjKjaXssriMNo\n\tQ7uXn02whcMXLyyJueX+mJCGGGMBCJA5VvefNIVJYCOwrudtdSvJMxMdj5++VEYp\n\tFOtwidTkzE6RTrMryz4umdKfTbqdA==",
        "From": "Saket Kumar Bhaskar <skb99@linux.ibm.com>",
        "To": "linux-kernel@vger.kernel.org, bpf@vger.kernel.org,\n        linuxppc-dev@lists.ozlabs.org",
        "Cc": "hbathini@linux.ibm.com, sachinpb@linux.ibm.com, venkat88@linux.ibm.com,\n        andrii@kernel.org, eddyz87@gmail.com, ast@kernel.org,\n        daniel@iogearbox.net, martin.lau@linux.dev, song@kernel.org,\n        yonghong.song@linux.dev, john.fastabend@gmail.com, kpsingh@kernel.org,\n        sdf@fomichev.me, haoluo@google.com, jolsa@kernel.org,\n        chleroy@kernel.org, maddy@linux.ibm.com, mpe@ellerman.id.au,\n        adubey@linux.ibm.com",
        "Subject": "[PATCH v2] powerpc64/bpf: Add powerpc64 JIT support for timed\n may_goto",
        "Date": "Thu,  2 Apr 2026 21:40:26 +0530",
        "Message-ID": "<20260402161026.289827-1-skb99@linux.ibm.com>",
        "X-Mailer": "git-send-email 2.52.0",
        "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-Reinject": "loops=2 maxloops=12",
        "X-Authority-Analysis": "v=2.4 cv=RsjI7SmK c=1 sm=1 tr=0 ts=69ce94fe cx=c_pps\n a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==:17\n a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22\n a=V8glGbnc2Ofi9Qvn3v5h:22 a=VwQbUJbxAAAA:8 a=VnNF1IyMAAAA:8\n a=7RCMQfSFa8QzyXN4T_sA:9",
        "X-Proofpoint-GUID": "UiAiKqQg_nExyoU79T8MxlTXgUIWuTxW",
        "X-Proofpoint-Spam-Details-Enc": "AW1haW4tMjYwNDAyMDE0MiBTYWx0ZWRfXynUbWgs6ZODT\n r2YyA4wn7CO6Kqd5NmJv0MRuAz6TTrTPFWDe+3dQdh/io+PnQ+L1J31dX6ZadYMo/t26TEjfVVb\n c1c4jRN4Edo3lwWKKgfYFRuGfAAsRAWiH6SwkM981jLsjeTh7Z9/W95yqmdZnk5VkolBTHnG+p/\n kHveawfz4LSJshDwiZR+8aNOwvTVNzWs9oy/0hnGvuLtZBFYmeeCTjs0v3NCCBUlmib2TtwHQu9\n QSQ09HtIDjN8j1qGE/lihtFM4ltRiBuwNg72Gc84/TPT99LuxnRBBNDQXzt1NFk8adNiPGAl9ey\n eMLEUVpQy5PP1ENgUZgycQ1seezt027WYkwWjEWf852Bvl3KujMh7yQrr+6hAedup6fxCtWHNMe\n 2h4RYBaSsneh/hjt3Y8nO1kwmwCOUs8g+l/rAohjKpL4sW+ZQ//bBF1lM0pCMj2yp7v8RfImG/X\n vBloK2KUil2/HdCogXw==",
        "X-Proofpoint-ORIG-GUID": "WD3zAGWoBtPZKyVEvIcr9tVsOI4Y-V6K",
        "X-Proofpoint-Virus-Version": "vendor=baseguard\n engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49\n definitions=2026-04-02_02,2026-04-02_03,2025-10-01_01",
        "X-Proofpoint-Spam-Details": "rule=outbound_notspam policy=outbound score=0\n impostorscore=0 bulkscore=0 priorityscore=1501 lowpriorityscore=0\n suspectscore=0 malwarescore=0 spamscore=0 clxscore=1015 phishscore=0\n adultscore=0 classifier=typeunknown authscore=0 authtc= authcc=\n route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2603050001\n definitions=main-2604020142",
        "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": "When verifier sees a timed may_goto instruction, it emits a call to\narch_bpf_timed_may_goto() with a stack offset in BPF_REG_AX\n(powerpc64 R12) and expects the refreshed count value to be returned\nin the same register. The verifier doesn't save or restore any registers\nbefore emitting this call.\n\narch_bpf_timed_may_goto() should act as a trampoline to call\nbpf_check_timed_may_goto() with powerpc64 ELF ABI calling convention.\n\nTo support this custom calling convention, implement\narch_bpf_timed_may_goto() in assembly and make sure BPF caller saved\nregisters are preserved, then call bpf_check_timed_may_goto with\nthe powerpc64 ABI calling convention where first argument and return\nvalue both are in R3. Finally, move the result back into BPF_REG_AX(R12)\nbefore returning.\n\nAlso, introduce bpf_jit_emit_func_call() that computes the offset from\nkernel_toc_addr(), validates that the target and emits the ADDIS/ADDI\nsequence to load the function address before performing the indirect\nbranch via MTCTR/BCTRL. The existing code in bpf_jit_emit_func_call_rel()\nis refactored to use this function.\n\nSigned-off-by: Saket Kumar Bhaskar <skb99@linux.ibm.com>\n---\nThis patch has been rebased on top of these 3 patches on powerpc-next in\nthe following sequence:\n1. https://lore.kernel.org/bpf/20260401103215.104438-1-adubey@linux.ibm.com/\n2. https://lore.kernel.org/bpf/20260401141043.41513-1-adubey@linux.ibm.com/\n3. https://lore.kernel.org/bpf/20260401152133.42544-1-adubey@linux.ibm.com/\n\nChanges since v1:\n- Compile bpf_timed_may_goto.o conditionally for PPC64. (Hari)\n- Moved reladdr at the beginning of the function. (Hari)\n- Added error check for bpf_jit_emit_func_call() in\n  bpf_jit_build_body(). (Hari)\n- Save registers after 32 bytes as MIN_FRAME_SIZE is 32 bytes for\n  powerpc ABIv2. (Hari)\n---\n arch/powerpc/net/Makefile             |  4 ++\n arch/powerpc/net/bpf_jit_comp.c       |  5 +++\n arch/powerpc/net/bpf_jit_comp64.c     | 62 ++++++++++++++++++++++-----\n arch/powerpc/net/bpf_timed_may_goto.S | 57 ++++++++++++++++++++++++\n 4 files changed, 117 insertions(+), 11 deletions(-)\n create mode 100644 arch/powerpc/net/bpf_timed_may_goto.S",
    "diff": "diff --git a/arch/powerpc/net/Makefile b/arch/powerpc/net/Makefile\nindex 8e60af32e51e..87395d7e2672 100644\n--- a/arch/powerpc/net/Makefile\n+++ b/arch/powerpc/net/Makefile\n@@ -3,3 +3,7 @@\n # Arch-specific network modules\n #\n obj-$(CONFIG_BPF_JIT) += bpf_jit_comp.o bpf_jit_comp$(BITS).o\n+\n+ifdef CONFIG_PPC64\n++obj-$(CONFIG_BPF_JIT) += bpf_timed_may_goto.o\n+endif\ndiff --git a/arch/powerpc/net/bpf_jit_comp.c b/arch/powerpc/net/bpf_jit_comp.c\nindex 50103b3794fb..9b2b456b0765 100644\n--- a/arch/powerpc/net/bpf_jit_comp.c\n+++ b/arch/powerpc/net/bpf_jit_comp.c\n@@ -537,6 +537,11 @@ bool bpf_jit_supports_subprog_tailcalls(void)\n \treturn IS_ENABLED(CONFIG_PPC64);\n }\n \n+bool bpf_jit_supports_timed_may_goto(void)\n+{\n+\treturn IS_ENABLED(CONFIG_PPC64);\n+}\n+\n bool bpf_jit_supports_kfunc_call(void)\n {\n \treturn IS_ENABLED(CONFIG_PPC64);\ndiff --git a/arch/powerpc/net/bpf_jit_comp64.c b/arch/powerpc/net/bpf_jit_comp64.c\nindex db364d9083e7..dab106cae22b 100644\n--- a/arch/powerpc/net/bpf_jit_comp64.c\n+++ b/arch/powerpc/net/bpf_jit_comp64.c\n@@ -451,10 +451,28 @@ void arch_bpf_stack_walk(bool (*consume_fn)(void *, u64, u64, u64), void *cookie\n \t}\n }\n \n+static int bpf_jit_emit_func_call(u32 *image, struct codegen_context *ctx, u64 func_addr, int reg)\n+{\n+\tlong reladdr = func_addr - kernel_toc_addr();\n+\n+\tif (reladdr > 0x7FFFFFFF || reladdr < -(0x80000000L)) {\n+\t\tpr_err(\"eBPF: address of %ps out of range of kernel_toc.\\n\", (void *)func_addr);\n+\t\treturn -ERANGE;\n+\t}\n+\n+\tEMIT(PPC_RAW_ADDIS(reg, _R2, PPC_HA(reladdr)));\n+\tEMIT(PPC_RAW_ADDI(reg, reg, PPC_LO(reladdr)));\n+\tEMIT(PPC_RAW_MTCTR(reg));\n+\tEMIT(PPC_RAW_BCTRL());\n+\n+\treturn 0;\n+}\n+\n int bpf_jit_emit_func_call_rel(u32 *image, u32 *fimage, struct codegen_context *ctx, u64 func)\n {\n \tunsigned long func_addr = func ? ppc_function_entry((void *)func) : 0;\n-\tlong reladdr;\n+\tlong __maybe_unused reladdr;\n+\tint ret;\n \n \t/* bpf to bpf call, func is not known in the initial pass. Emit 5 nops as a placeholder */\n \tif (!func) {\n@@ -507,16 +525,9 @@ int bpf_jit_emit_func_call_rel(u32 *image, u32 *fimage, struct codegen_context *\n \tEMIT(PPC_RAW_BCTRL());\n #else\n \tif (core_kernel_text(func_addr)) {\n-\t\treladdr = func_addr - kernel_toc_addr();\n-\t\tif (reladdr > 0x7FFFFFFF || reladdr < -(0x80000000L)) {\n-\t\t\tpr_err(\"eBPF: address of %ps out of range of kernel_toc.\\n\", (void *)func);\n-\t\t\treturn -ERANGE;\n-\t\t}\n-\n-\t\tEMIT(PPC_RAW_ADDIS(_R12, _R2, PPC_HA(reladdr)));\n-\t\tEMIT(PPC_RAW_ADDI(_R12, _R12, PPC_LO(reladdr)));\n-\t\tEMIT(PPC_RAW_MTCTR(_R12));\n-\t\tEMIT(PPC_RAW_BCTRL());\n+\t\tret = bpf_jit_emit_func_call(image, ctx, func_addr, _R12);\n+\t\tif (ret)\n+\t\t\treturn ret;\n \t} else {\n \t\tif (IS_ENABLED(CONFIG_PPC64_ELF_ABI_V1)) {\n \t\t\t/* func points to the function descriptor */\n@@ -1755,6 +1766,35 @@ int bpf_jit_build_body(struct bpf_prog *fp, u32 *image, u32 *fimage, struct code\n \t\t\tif (ret < 0)\n \t\t\t\treturn ret;\n \n+\t\t\t/*\n+\t\t\t * Call to arch_bpf_timed_may_goto() is emitted by the\n+\t\t\t * verifier and called with custom calling convention with\n+\t\t\t * first argument and return value in BPF_REG_AX (_R12).\n+\t\t\t *\n+\t\t\t * The generic helper or bpf function call emission path\n+\t\t\t * may use the same scratch register as BPF_REG_AX to\n+\t\t\t * materialize the target address. This would clobber AX\n+\t\t\t * and break timed may_goto semantics.\n+\t\t\t *\n+\t\t\t * Emit a minimal indirect call sequence here using a temp\n+\t\t\t * register and skip the normal post-call return-value move.\n+\t\t\t */\n+\n+\t\t\tif (func_addr == (u64)arch_bpf_timed_may_goto) {\n+\t\t\t\tret = 0;\n+\t\t\t\tif (!IS_ENABLED(CONFIG_PPC_KERNEL_PCREL))\n+\t\t\t\t\tret = bpf_jit_emit_func_call(image, ctx, func_addr,\n+\t\t\t\t\t\t\t\t     tmp1_reg);\n+\n+\t\t\t\tif (ret || IS_ENABLED(CONFIG_PPC_KERNEL_PCREL)) {\n+\t\t\t\t\tPPC_LI_ADDR(tmp1_reg, func_addr);\n+\t\t\t\t\tEMIT(PPC_RAW_MTCTR(tmp1_reg));\n+\t\t\t\t\tEMIT(PPC_RAW_BCTRL());\n+\t\t\t\t}\n+\n+\t\t\t\tbreak;\n+\t\t\t}\n+\n \t\t\t/* Take care of powerpc ABI requirements before kfunc call */\n \t\t\tif (insn[i].src_reg == BPF_PSEUDO_KFUNC_CALL) {\n \t\t\t\tif (prepare_for_kfunc_call(fp, image, ctx, &insn[i]))\ndiff --git a/arch/powerpc/net/bpf_timed_may_goto.S b/arch/powerpc/net/bpf_timed_may_goto.S\nnew file mode 100644\nindex 000000000000..6fd8b1c9f4ac\n--- /dev/null\n+++ b/arch/powerpc/net/bpf_timed_may_goto.S\n@@ -0,0 +1,57 @@\n+/* SPDX-License-Identifier: GPL-2.0 */\n+/* Copyright (c) 2025 IBM Corporation, Saket Kumar Bhaskar <skb99@linux.ibm.com> */\n+\n+#include <linux/linkage.h>\n+#include <asm/ppc_asm.h>\n+\n+/*\n+ * arch_bpf_timed_may_goto() trampoline for powerpc64\n+ *\n+ * Custom BPF convention (verifier/JIT):\n+ *\t- input:  stack offset in BPF_REG_AX (r12)\n+ *\t- output: updated count in BPF_REG_AX (r12)\n+ *\n+ * Call bpf_check_timed_may_goto(ptr) with normal powerpc64 ABI:\n+ * \t- r3 = ptr, return in r3\n+ *\n+ * Preserve BPF regs R0-R5 (mapping: r8, r3-r7).\n+ */\n+\n+SYM_FUNC_START(arch_bpf_timed_may_goto)\n+\t/* Prologue: save LR, allocate frame */\n+\tmflr    r0\n+\tstd     r0, 16(r1)\n+\tstdu    r1, -112(r1)\n+\n+\t/* Save BPF registers R0 - R5 (r8, r3-r7) */\n+\tstd     r3, 32(r1)\n+\tstd     r4, 40(r1)\n+\tstd     r5, 48(r1)\n+\tstd     r6, 56(r1)\n+\tstd     r7, 64(r1)\n+\tstd     r8, 72(r1)\n+\n+\t/*\n+\t * r3 = BPF_REG_FP + BPF_REG_AX\n+\t * BPF_REG_FP is r31; BPF_REG_AX is r12 (stack offset in bytes).\n+\t */\n+\tadd     r3, r31, r12\n+\tbl      bpf_check_timed_may_goto\n+\n+\t/* Put return value back into AX */\n+\tmr      r12, r3\n+\n+\t/* Restore BPF registers R0 - R5 (r8, r3-r7) */\n+\tld      r3, 32(r1)\n+\tld      r4, 40(r1)\n+\tld      r5, 48(r1)\n+\tld      r6, 56(r1)\n+\tld      r7, 64(r1)\n+\tld      r8, 72(r1)\n+\n+\t/* Epilogue: pop frame, restore LR, return */\n+\taddi    r1, r1, 112\n+\tld      r0, 16(r1)\n+\tmtlr    r0\n+\tblr\n+SYM_FUNC_END(arch_bpf_timed_may_goto)\n",
    "prefixes": [
        "v2"
    ]
}