Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/1.0/patches/2196704/?format=api
{ "id": 2196704, "url": "http://patchwork.ozlabs.org/api/1.0/patches/2196704/?format=api", "project": { "id": 2, "url": "http://patchwork.ozlabs.org/api/1.0/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/" }, "msgid": "<20260216065639.1750181-5-hbathini@linux.ibm.com>", "date": "2026-02-16T06:56:38", "name": "[4/5] powerpc64/bpf: remove BPF redzone protection in trampoline stack", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "7aa2d87af079d30d9bcd0fce8c47753e69dd57b5", "submitter": { "id": 74073, "url": "http://patchwork.ozlabs.org/api/1.0/people/74073/?format=api", "name": "Hari Bathini", "email": "hbathini@linux.ibm.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/linuxppc-dev/patch/20260216065639.1750181-5-hbathini@linux.ibm.com/mbox/", "series": [ { "id": 492248, "url": "http://patchwork.ozlabs.org/api/1.0/series/492248/?format=api", "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/2196704/checks/", "tags": {}, "headers": { "Return-Path": "\n <linuxppc-dev+bounces-16872-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=Q5zPazu5;\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-16872-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=Q5zPazu5;\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 4fDtrH6k20z1xpl\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 16 Feb 2026 17:57:35 +1100 (AEDT)", "from boromir.ozlabs.org (localhost [127.0.0.1])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 4fDtqp04kTz3brB;\n\tMon, 16 Feb 2026 17:57:10 +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 4fDtqm6z89z2xlq\n\tfor <linuxppc-dev@lists.ozlabs.org>; Mon, 16 Feb 2026 17:57:08 +1100 (AEDT)", "from pps.filterd (m0360072.ppops.net [127.0.0.1])\n\tby mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id\n 61FDsE2H4098074;\n\tMon, 16 Feb 2026 06:56:54 GMT", "from ppma12.dal12v.mail.ibm.com\n (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220])\n\tby mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4cajcj6367-1\n\t(version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT);\n\tMon, 16 Feb 2026 06:56:54 +0000 (GMT)", "from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1])\n\tby ppma12.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id\n 61G6NTLO012683;\n\tMon, 16 Feb 2026 06:56:53 GMT", "from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230])\n\tby ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 4cb3crvg47-1\n\t(version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT);\n\tMon, 16 Feb 2026 06:56:53 +0000", "from smtpav04.fra02v.mail.ibm.com (smtpav04.fra02v.mail.ibm.com\n [10.20.54.103])\n\tby smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id\n 61G6unf325559316\n\t(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK);\n\tMon, 16 Feb 2026 06:56:49 GMT", "from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1])\n\tby IMSVA (Postfix) with ESMTP id 9AC292004E;\n\tMon, 16 Feb 2026 06:56:49 +0000 (GMT)", "from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1])\n\tby IMSVA (Postfix) with ESMTP id 098F920040;\n\tMon, 16 Feb 2026 06:56:48 +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:47 +0000 (GMT)" ], "ARC-Seal": "i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1771225029;\n\tcv=none;\n b=fiM+jy6oDEdiYvP3jbburlmZA/jlTq4OVyxwe4Yt/VVH0K+TX4B5M5DAp+0NMNqsTr1XmN0WaM/Gk75UHWVvgUtLh/Y5ZoyKoAhATd9SnTKNvXOrsmnEf9sWxM7raJPH/pZtbDqGYPitarKTzATLrX1zqmBTQA8hYcr9kHIOc+2sfS8wUblzGstQSeKgXtt1cLYQTpXEk6UPJY3oKembTze5IDuOyeAKm7fYn+9wU1XfRiQD3/1IC5puJEec7w5E9zIC0j1FAzRzIuMgojS86QFTva/xf8uZgaYu7lLhRxg6dMfX2zW8jyc/FoOPhcXXmIHWnsHL42U6wbUgQKo/jA==", "ARC-Message-Signature": "i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707;\n\tt=1771225029; c=relaxed/relaxed;\n\tbh=q2V+99nyaot7BphJZ8iTDLlxZs2yw+uT/Pev7jRFbfw=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=I8sb1NGJeM/FJPaOAdP88DPESAZk4sviYZytHw9X9Fpt+hasv0GydxshraiH3dOgJW2np0/DsqctTB6Kwf8SKuETeY5iS2HxM+31FTILHepApccS7SL3v6BR05joyw8ljfQpFf2binOUuROeZPWMAUVvMn/rl3UDFVxzghOuxVXaPXYzpWpXk+D4nH+Vmnq1pZqsAdde3QlIFhhaBVoSHjcOs2aDSibcVO65ndmFgp0OXDkOxEhzJFDMd1ECktriRATn0tcYvGFYwpbIjNTtKqA0TCDQqAskWSIQX42muzv8+i86ZxwQb3f93H+pofUATY7/5POPTJ7BZ7ZoyI64zQ==", "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=Q5zPazu5; 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=q2V+99nyaot7BphJZ\n\t8iTDLlxZs2yw+uT/Pev7jRFbfw=; b=Q5zPazu5GNbjProwDjiLwVV197tie6oAV\n\tpsz7WY1P+T+aYFGuKZM7e4O9KlJTe7nEfC94rzk+k4df3WIQ4A8oHsv3ykMCuD1n\n\tggt8jyz7jcYys4k1IFV5D/T1LwmkCRxkr09c1323GxtxTMJKzsMeDoE7KSgHDlAi\n\teb8upGjts5MSPjL82IG1mnur9V7tiE76Xx8rpj63S0merRmlcfzyAncvurLWyX8d\n\t5jypVy8f/l/+uLR3zM4crRkOhoDB4yddpHy9OCjY6c1XO2ihhafTGgtTQg1/KTLn\n\tQlSosIZb4wYlDLJ5W2M1htqLJByuwbWvYTGQVRJ26AIqAILzuyXEg==", "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>", "Subject": "[PATCH 4/5] powerpc64/bpf: remove BPF redzone protection in\n trampoline stack", "Date": "Mon, 16 Feb 2026 12:26:38 +0530", "Message-ID": "<20260216065639.1750181-5-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": "GD2UqYAReUkTm68UZDsy2D3__uPOmgep", "X-Authority-Analysis": "v=2.4 cv=Md9hep/f c=1 sm=1 tr=0 ts=6992bfb6 cx=c_pps\n a=bLidbwmWQ0KltjZqbj+ezA==:117 a=bLidbwmWQ0KltjZqbj+ezA==:17\n a=HzLeVaNsDn8A:10 a=VkNPw1HP01LnGYTKEx00:22 a=Mpw57Om8IfrbqaoTuvik:22\n a=GgsMoib0sEa3-_RKJdDe:22 a=VnNF1IyMAAAA:8 a=CS0pCN-D_OTInOCri3QA:9\n a=4dzhEfGzQiddGgL9:21", "X-Proofpoint-Spam-Details-Enc": "AW1haW4tMjYwMjE2MDA1NCBTYWx0ZWRfX8lhKwJJxUNhs\n 1+eHVKWeQACG9Jx6xq6tKTWycCER3xH+CLQXnZB8sI06BjJYGYYlOCz1+k1WPkdK4CKMR5W34cV\n P/ryo8n3EdZrnEcZ4CsNj6FH85PIxLCOz2PV2r+SdeQjH3OeQtEyMop8dZ6/4YAGgmqqjZ6R1D/\n mo0gDVVojN4Wfis90RQIR3VhBll2C3vZ2KvFx+aVbRCn/glks+x+iBCA9HVgXpYG+OfWye5REB2\n i4cc3EE6M9BdZKKrh2xxQFzkg8rirSgQL65Zys1I7tAZ6IpSvVTSvcW+0OphqnMtbydzsjzDd8o\n CMoGcSVsr4blqmyWz48N0y9ebzpNZHFFOY7pec+x9zc7eFjGiSOIyaEhz6dssGd66Nf0li7zOY2\n WS1GzT5za/bisXmGL0+9ssLfZBjmEuhLTeB9tmQQuUoPqbiyzHuxjLuTF+POPZYXf+kzwATspjP\n l788uTlZrudXKe1T3uA==", "X-Proofpoint-GUID": "GD2UqYAReUkTm68UZDsy2D3__uPOmgep", "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=1015 impostorscore=0 lowpriorityscore=0 spamscore=0 adultscore=0\n priorityscore=1501 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0\n classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0\n reason=mlx scancount=1 engine=8.22.0-2601150000 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": "Since bpf2bpf tailcall support is enabled for 64-bit powerpc with\nkernel commit 2ed2d8f6fb38 (\"powerpc64/bpf: Support tailcalls with\nsubprogs\"), 'tailcalls/tailcall_bpf2bpf_hierarchy_fexit' BPF selftest\nis triggering \"corrupted stack end detected inside scheduler\" with the\nconfig option CONFIG_SCHED_STACK_END_CHECK enabled. While reviewing\nthe stack layout for BPF trampoline, observed that the dummy frame is\ntrying to protect the redzone of BPF program. This is because tail\ncall info and NVRs save area are in redzone at the time of tailcall\nas the current BPF program stack frame is teared down before the\ntailcall. But saving this redzone in the dummy frame of trampoline\nis unnecessary because of the follow reasons:\n\n 1) Firstly, trampoline can be attached to BPF entry/main program\n or subprog. Prologue part of the BPF entry/main program, where\n the trampoline attachpoint is, is skipped during tailcall. So,\n protecting the redzone does not arise when the trampoline is\n not even triggered in this scenario.\n 2) In case of subprog, the caller's stackframe is already setup\n and the subprog's stackframe is yet to be setup. So, nothing\n on the redzone to be protected.\n\nAlso, using dummy frame in BPF trampoline, wastes critically scarce\nkernel stack space, especially in tailcall sequence, for marginal\nbenefit in stack unwinding. So, drop setting up the dummy frame.\nInstead, save return address in bpf trampoline frame and use it as\nappropriate. Pruning this unnecessary stack usage mitigates the\nlikelihood of stack overflow in scenarios where bpf2bpf tailcalls\nand fexit programs are mixed.\n\nReported-by: Saket Kumar Bhaskar <skb99@linux.ibm.com>\nFixes: 2ed2d8f6fb38 (\"powerpc64/bpf: Support tailcalls with subprogs\")\nSigned-off-by: Hari Bathini <hbathini@linux.ibm.com>\n---\n arch/powerpc/net/bpf_jit_comp.c | 84 ++++++++++++---------------------\n 1 file changed, 30 insertions(+), 54 deletions(-)", "diff": "diff --git a/arch/powerpc/net/bpf_jit_comp.c b/arch/powerpc/net/bpf_jit_comp.c\nindex 1ff8030faf1f..35cea97a1bcd 100644\n--- a/arch/powerpc/net/bpf_jit_comp.c\n+++ b/arch/powerpc/net/bpf_jit_comp.c\n@@ -638,15 +638,10 @@ static int invoke_bpf_mod_ret(u32 *image, u32 *ro_image, struct codegen_context\n * for the traced function (BPF subprog/callee) to fetch it.\n */\n static void bpf_trampoline_setup_tail_call_info(u32 *image, struct codegen_context *ctx,\n-\t\t\t\t\t\tint func_frame_offset,\n-\t\t\t\t\t\tint bpf_dummy_frame_size, int r4_off)\n+\t\t\t\t\t\tint bpf_frame_size, int r4_off)\n {\n \tif (IS_ENABLED(CONFIG_PPC64)) {\n-\t\t/*\n-\t\t * func_frame_offset = ...(1)\n-\t\t * bpf_dummy_frame_size + trampoline_frame_size\n-\t\t */\n-\t\tEMIT(PPC_RAW_LD(_R4, _R1, func_frame_offset));\n+\t\tEMIT(PPC_RAW_LD(_R4, _R1, bpf_frame_size));\n \t\t/* Refer to trampoline's Generated stack layout */\n \t\tEMIT(PPC_RAW_LD(_R3, _R4, -BPF_PPC_TAILCALL));\n \n@@ -657,21 +652,12 @@ static void bpf_trampoline_setup_tail_call_info(u32 *image, struct codegen_conte\n \t\tEMIT(PPC_RAW_CMPLWI(_R3, MAX_TAIL_CALL_CNT));\n \t\tPPC_BCC_CONST_SHORT(COND_GT, 8);\n \t\tEMIT(PPC_RAW_ADDI(_R3, _R4, -BPF_PPC_TAILCALL));\n+\n \t\t/*\n-\t\t * From ...(1) above:\n-\t\t * trampoline_frame_bottom = ...(2)\n-\t\t * func_frame_offset - bpf_dummy_frame_size\n-\t\t *\n-\t\t * Using ...(2) derived above:\n-\t\t * trampoline_tail_call_info_offset = ...(3)\n-\t\t * trampoline_frame_bottom - tailcallinfo_offset\n-\t\t *\n-\t\t * From ...(3):\n \t\t * Use trampoline_tail_call_info_offset to write reference of main's\n \t\t * tail_call_info in trampoline frame.\n \t\t */\n-\t\tEMIT(PPC_RAW_STL(_R3, _R1, (func_frame_offset - bpf_dummy_frame_size)\n-\t\t\t\t\t\t\t\t- BPF_PPC_TAILCALL));\n+\t\tEMIT(PPC_RAW_STL(_R3, _R1, bpf_frame_size - BPF_PPC_TAILCALL));\n \t} else {\n \t\t/* See bpf_jit_stack_offsetof() and BPF_PPC_TC */\n \t\tEMIT(PPC_RAW_LL(_R4, _R1, r4_off));\n@@ -679,7 +665,7 @@ static void bpf_trampoline_setup_tail_call_info(u32 *image, struct codegen_conte\n }\n \n static void bpf_trampoline_restore_tail_call_cnt(u32 *image, struct codegen_context *ctx,\n-\t\t\t\t\t\t int func_frame_offset, int r4_off)\n+\t\t\t\t\t\t int bpf_frame_size, int r4_off)\n {\n \tif (IS_ENABLED(CONFIG_PPC32)) {\n \t\t/*\n@@ -690,12 +676,12 @@ static void bpf_trampoline_restore_tail_call_cnt(u32 *image, struct codegen_cont\n \t}\n }\n \n-static void bpf_trampoline_save_args(u32 *image, struct codegen_context *ctx, int func_frame_offset,\n-\t\t\t\t int nr_regs, int regs_off)\n+static void bpf_trampoline_save_args(u32 *image, struct codegen_context *ctx,\n+\t\t\t\t int bpf_frame_size, int nr_regs, int regs_off)\n {\n \tint param_save_area_offset;\n \n-\tparam_save_area_offset = func_frame_offset; /* the two frames we alloted */\n+\tparam_save_area_offset = bpf_frame_size;\n \tparam_save_area_offset += STACK_FRAME_MIN_SIZE; /* param save area is past frame header */\n \n \tfor (int i = 0; i < nr_regs; i++) {\n@@ -718,11 +704,11 @@ static void bpf_trampoline_restore_args_regs(u32 *image, struct codegen_context\n \n /* Used when we call into the traced function. Replicate parameter save area */\n static void bpf_trampoline_restore_args_stack(u32 *image, struct codegen_context *ctx,\n-\t\t\t\t\t int func_frame_offset, int nr_regs, int regs_off)\n+\t\t\t\t\t int bpf_frame_size, int nr_regs, int regs_off)\n {\n \tint param_save_area_offset;\n \n-\tparam_save_area_offset = func_frame_offset; /* the two frames we alloted */\n+\tparam_save_area_offset = bpf_frame_size;\n \tparam_save_area_offset += STACK_FRAME_MIN_SIZE; /* param save area is past frame header */\n \n \tfor (int i = 8; i < nr_regs; i++) {\n@@ -739,10 +725,10 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, void *rw_im\n \t\t\t\t\t void *func_addr)\n {\n \tint regs_off, nregs_off, ip_off, run_ctx_off, retval_off, nvr_off, alt_lr_off, r4_off = 0;\n-\tint i, ret, nr_regs, bpf_frame_size = 0, bpf_dummy_frame_size = 0, func_frame_offset;\n \tstruct bpf_tramp_links *fmod_ret = &tlinks[BPF_TRAMP_MODIFY_RETURN];\n \tstruct bpf_tramp_links *fentry = &tlinks[BPF_TRAMP_FENTRY];\n \tstruct bpf_tramp_links *fexit = &tlinks[BPF_TRAMP_FEXIT];\n+\tint i, ret, nr_regs, retaddr_off, bpf_frame_size = 0;\n \tstruct codegen_context codegen_ctx, *ctx;\n \tu32 *image = (u32 *)rw_image;\n \tppc_inst_t branch_insn;\n@@ -768,16 +754,11 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, void *rw_im\n \t * Generated stack layout:\n \t *\n \t * func prev back chain [ back chain ]\n-\t * [ ]\n-\t * bpf prog redzone/tailcallcnt [ ... ] 64 bytes (64-bit powerpc)\n-\t * [ ] --\n-\t * LR save area [ r0 save (64-bit) ] | header\n-\t * [ r0 save (32-bit) ] |\n-\t * dummy frame for unwind [ back chain 1 ] --\n \t * [ tail_call_info ] optional - 64-bit powerpc\n \t * [ padding ] align stack frame\n \t * r4_off [ r4 (tailcallcnt) ] optional - 32-bit powerpc\n \t * alt_lr_off [ real lr (ool stub)] optional - actual lr\n+\t * retaddr_off [ return address ]\n \t * [ r26 ]\n \t * nvr_off [ r25 ] nvr save area\n \t * retval_off [ return value ]\n@@ -841,6 +822,10 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, void *rw_im\n \tnvr_off = bpf_frame_size;\n \tbpf_frame_size += 2 * SZL;\n \n+\t/* Save area for return address */\n+\tretaddr_off = bpf_frame_size;\n+\tbpf_frame_size += SZL;\n+\n \t/* Optional save area for actual LR in case of ool ftrace */\n \tif (IS_ENABLED(CONFIG_PPC_FTRACE_OUT_OF_LINE)) {\n \t\talt_lr_off = bpf_frame_size;\n@@ -867,16 +852,8 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, void *rw_im\n \t/* Padding to align stack frame, if any */\n \tbpf_frame_size = round_up(bpf_frame_size, SZL * 2);\n \n-\t/* Dummy frame size for proper unwind - includes 64-bytes red zone for 64-bit powerpc */\n-\tbpf_dummy_frame_size = STACK_FRAME_MIN_SIZE + 64;\n-\n-\t/* Offset to the traced function's stack frame */\n-\tfunc_frame_offset = bpf_dummy_frame_size + bpf_frame_size;\n-\n-\t/* Create dummy frame for unwind, store original return value */\n+\t/* Store original return value */\n \tEMIT(PPC_RAW_STL(_R0, _R1, PPC_LR_STKOFF));\n-\t/* Protect red zone where tail call count goes */\n-\tEMIT(PPC_RAW_STLU(_R1, _R1, -bpf_dummy_frame_size));\n \n \t/* Create our stack frame */\n \tEMIT(PPC_RAW_STLU(_R1, _R1, -bpf_frame_size));\n@@ -891,14 +868,14 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, void *rw_im\n \tif (IS_ENABLED(CONFIG_PPC32) && nr_regs < 2)\n \t\tEMIT(PPC_RAW_STL(_R4, _R1, r4_off));\n \n-\tbpf_trampoline_save_args(image, ctx, func_frame_offset, nr_regs, regs_off);\n+\tbpf_trampoline_save_args(image, ctx, bpf_frame_size, nr_regs, regs_off);\n \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 \telse\n-\t\tEMIT(PPC_RAW_STL(_R3, _R1, bpf_frame_size + PPC_LR_STKOFF));\n+\t\tEMIT(PPC_RAW_STL(_R3, _R1, retaddr_off));\n \n \t/*\n \t * Get IP address of the traced function.\n@@ -920,9 +897,9 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, void *rw_im\n \t\tEMIT(PPC_RAW_STL(_R3, _R1, ip_off));\n \n \tif (IS_ENABLED(CONFIG_PPC_FTRACE_OUT_OF_LINE)) {\n-\t\t/* Fake our LR for unwind */\n+\t\t/* Fake our LR for BPF_TRAMP_F_CALL_ORIG case */\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\tEMIT(PPC_RAW_STL(_R3, _R1, retaddr_off));\n \t}\n \n \t/* Save function arg count -- see bpf_get_func_arg_cnt() */\n@@ -961,20 +938,19 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, void *rw_im\n \t/* Call the traced function */\n \tif (flags & BPF_TRAMP_F_CALL_ORIG) {\n \t\t/*\n-\t\t * The address in LR save area points to the correct point in the original function\n+\t\t * retaddr on trampoline stack points to the correct point in the original function\n \t\t * with both PPC_FTRACE_OUT_OF_LINE as well as with traditional ftrace instruction\n \t\t * sequence\n \t\t */\n-\t\tEMIT(PPC_RAW_LL(_R3, _R1, bpf_frame_size + PPC_LR_STKOFF));\n+\t\tEMIT(PPC_RAW_LL(_R3, _R1, retaddr_off));\n \t\tEMIT(PPC_RAW_MTCTR(_R3));\n \n \t\t/* Replicate tail_call_cnt before calling the original BPF prog */\n \t\tif (flags & BPF_TRAMP_F_TAIL_CALL_CTX)\n-\t\t\tbpf_trampoline_setup_tail_call_info(image, ctx, func_frame_offset,\n-\t\t\t\t\t\t\t\tbpf_dummy_frame_size, r4_off);\n+\t\t\tbpf_trampoline_setup_tail_call_info(image, ctx, bpf_frame_size, r4_off);\n \n \t\t/* Restore args */\n-\t\tbpf_trampoline_restore_args_stack(image, ctx, func_frame_offset, nr_regs, regs_off);\n+\t\tbpf_trampoline_restore_args_stack(image, ctx, bpf_frame_size, nr_regs, regs_off);\n \n \t\t/* Restore TOC for 64-bit */\n \t\tif (IS_ENABLED(CONFIG_PPC64_ELF_ABI_V2) && !IS_ENABLED(CONFIG_PPC_KERNEL_PCREL))\n@@ -988,7 +964,7 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, void *rw_im\n \n \t\t/* Restore updated tail_call_cnt */\n \t\tif (flags & BPF_TRAMP_F_TAIL_CALL_CTX)\n-\t\t\tbpf_trampoline_restore_tail_call_cnt(image, ctx, func_frame_offset, r4_off);\n+\t\t\tbpf_trampoline_restore_tail_call_cnt(image, ctx, bpf_frame_size, r4_off);\n \n \t\t/* Reserve space to patch branch instruction to skip fexit progs */\n \t\tif (ro_image) /* image is NULL for dummy pass */\n@@ -1040,7 +1016,7 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, void *rw_im\n \t\tEMIT(PPC_RAW_LD(_R2, _R1, 24));\n \tif (flags & BPF_TRAMP_F_SKIP_FRAME) {\n \t\t/* Skip the traced function and return to parent */\n-\t\tEMIT(PPC_RAW_ADDI(_R1, _R1, func_frame_offset));\n+\t\tEMIT(PPC_RAW_ADDI(_R1, _R1, bpf_frame_size));\n \t\tEMIT(PPC_RAW_LL(_R0, _R1, PPC_LR_STKOFF));\n \t\tEMIT(PPC_RAW_MTLR(_R0));\n \t\tEMIT(PPC_RAW_BLR());\n@@ -1048,13 +1024,13 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, void *rw_im\n \t\tif (IS_ENABLED(CONFIG_PPC_FTRACE_OUT_OF_LINE)) {\n \t\t\tEMIT(PPC_RAW_LL(_R0, _R1, alt_lr_off));\n \t\t\tEMIT(PPC_RAW_MTLR(_R0));\n-\t\t\tEMIT(PPC_RAW_ADDI(_R1, _R1, func_frame_offset));\n+\t\t\tEMIT(PPC_RAW_ADDI(_R1, _R1, bpf_frame_size));\n \t\t\tEMIT(PPC_RAW_LL(_R0, _R1, PPC_LR_STKOFF));\n \t\t\tEMIT(PPC_RAW_BLR());\n \t\t} else {\n-\t\t\tEMIT(PPC_RAW_LL(_R0, _R1, bpf_frame_size + PPC_LR_STKOFF));\n+\t\t\tEMIT(PPC_RAW_LL(_R0, _R1, retaddr_off));\n \t\t\tEMIT(PPC_RAW_MTCTR(_R0));\n-\t\t\tEMIT(PPC_RAW_ADDI(_R1, _R1, func_frame_offset));\n+\t\t\tEMIT(PPC_RAW_ADDI(_R1, _R1, bpf_frame_size));\n \t\t\tEMIT(PPC_RAW_LL(_R0, _R1, PPC_LR_STKOFF));\n \t\t\tEMIT(PPC_RAW_MTLR(_R0));\n \t\t\tEMIT(PPC_RAW_BCTR());\n", "prefixes": [ "4/5" ] }