{"id":2196705,"url":"http://patchwork.ozlabs.org/api/1.0/patches/2196705/?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-6-hbathini@linux.ibm.com>","date":"2026-02-16T06:56:39","name":"[5/5] powerpc64/bpf: fix handling of BPF stack in exception callback","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"0a8995f275211dc04e387d63b19ae55e8369f353","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-6-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":"success","checks":"http://patchwork.ozlabs.org/api/patches/2196705/checks/","tags":{},"headers":{"Return-Path":"\n <linuxppc-dev+bounces-16873-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=JfQ26m2D;\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-16873-incoming=patchwork.ozlabs.org@lists.ozlabs.org;\n receiver=patchwork.ozlabs.org)","lists.ozlabs.org;\n arc=none smtp.remote-ip=148.163.156.1","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=JfQ26m2D;\n\tdkim-atps=neutral","lists.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=linux.ibm.com\n (client-ip=148.163.156.1; helo=mx0a-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 4fDtrR6GdNz1xpl\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 16 Feb 2026 17:57:43 +1100 (AEDT)","from boromir.ozlabs.org (localhost [127.0.0.1])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 4fDtqq1kH2z3brt;\n\tMon, 16 Feb 2026 17:57:11 +1100 (AEDT)","from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com\n [148.163.156.1])\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 4fDtqp1Szwz3brL\n\tfor <linuxppc-dev@lists.ozlabs.org>; Mon, 16 Feb 2026 17:57:10 +1100 (AEDT)","from pps.filterd (m0356517.ppops.net [127.0.0.1])\n\tby mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id\n 61FMK7Nb3599349;\n\tMon, 16 Feb 2026 06:56:56 GMT","from ppma11.dal12v.mail.ibm.com\n (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219])\n\tby mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4caj6uef4c-1\n\t(version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT);\n\tMon, 16 Feb 2026 06:56:56 +0000 (GMT)","from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1])\n\tby ppma11.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id\n 61G3X1oA029129;\n\tMon, 16 Feb 2026 06:56:55 GMT","from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227])\n\tby ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 4cb631437e-1\n\t(version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT);\n\tMon, 16 Feb 2026 06:56:55 +0000","from smtpav04.fra02v.mail.ibm.com (smtpav04.fra02v.mail.ibm.com\n [10.20.54.103])\n\tby smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id\n 61G6upHB57606400\n\t(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK);\n\tMon, 16 Feb 2026 06:56:52 GMT","from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1])\n\tby IMSVA (Postfix) with ESMTP id CE4592004B;\n\tMon, 16 Feb 2026 06:56:51 +0000 (GMT)","from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1])\n\tby IMSVA (Postfix) with ESMTP id 0116520040;\n\tMon, 16 Feb 2026 06:56:50 +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:49 +0000 (GMT)"],"ARC-Seal":"i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1771225031;\n\tcv=none;\n b=dd8sfBYtt3Lg8cg7MsBMs72EXAyPJmMjswuFo/GFIO4JZW6yKHuaoBGg0v3YkeCTtStbZU5LNbPHCKkojxcGXmCE+liq4GGAKl5MKBhQSSJhi9WE45pLr2weU84XiSp7F3c7TEzsJkZSpL0yNJLlV6pFyULzeUot8Kn1uuIckbLBK2oA4nVFKLYcAm98vN6jIVzCy5sSm+OcEkvwJKfweKfLIHPf169IIidJpRzwWfh7TO8WifqGFIuc/CvtJq5b6eKCOU/2LeeigTC2qa3T0RnbH57TbhtEwDmL2DyMAHcqp3kJoCEV9hiYoYwr4DjFatAG5/gEruTHWfdl/3kC5g==","ARC-Message-Signature":"i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707;\n\tt=1771225031; c=relaxed/relaxed;\n\tbh=0ilvdESIvOCG3kvo+4Wme3H9202/aSYzmCUKPYJVAvA=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=YNDgo+n+pwqisvCxYLroRkL2QN9zHluDPgi73NHHUjN/cVbq34rFGI4dHv5HdF2fhXWLeNRlz8WjpIVl3EKrBaEzB1PyEvDlDKhb2ai9IeFGtVDhfb7LpTcPqE+IIsvREkEwArpT+2gyALztYPmFfilpdczq5zATstXxp8/stBNtv4gU26o6irtPqRarqvGXNoVfnF3hYWmNAeWrXotSEgUANjJydqqAo0wxwTXIpd3fBYIuh1HadwDTEG32dtjYNXMSeSNPHq9rXGGmvzS43icUVVXJ7XHCPxzPMXDXiy19EJViXzrQYJINhXCjq4ts0zyYIl9PXCu4XkULy9NDDg==","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=JfQ26m2D; dkim-atps=neutral;\n spf=pass (client-ip=148.163.156.1; helo=mx0a-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=0ilvdESIvOCG3kvo+\n\t4Wme3H9202/aSYzmCUKPYJVAvA=; b=JfQ26m2Dm6ErXt2ON/2n+u8aLjyKSiXv3\n\tm9ZURjwUoksC3c7LL+T3UiN8GrWBl7AtBwRyHo6oxP7IlcI+SfEkGWAIMk330BWH\n\t7vARbBGO6OTyckacXR9eiak8wv/ByWEY8epaN/bSiM3wbbfJP/k/CrFo/eUnU4Yc\n\teYOn3wHfpcN7ZGjIlyncRtVYizhNUkXm2CyTpcRGf0yf+7aO+eNQPXCq+yDXF7Uz\n\tE1pzDAmupz8B6GbXtgChVNvvSNFciUymmTy01s2kmpsQ2lCetoaqazu8cxGR3q2X\n\tJOgICBL03u0retrLiK2eM5pvQ7qe6eM+T9SaDhGzL7wXg6FGAqJoA==","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>, bot+bpf-ci@kernel.org","Subject":"[PATCH 5/5] powerpc64/bpf: fix handling of BPF stack in exception\n callback","Date":"Mon, 16 Feb 2026 12:26:39 +0530","Message-ID":"<20260216065639.1750181-6-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-Authority-Analysis":"v=2.4 cv=E+/AZKdl c=1 sm=1 tr=0 ts=6992bfb8 cx=c_pps\n a=aDMHemPKRhS1OARIsFnwRA==:117 a=aDMHemPKRhS1OARIsFnwRA==:17\n a=HzLeVaNsDn8A:10 a=VkNPw1HP01LnGYTKEx00:22 a=Mpw57Om8IfrbqaoTuvik:22\n a=GgsMoib0sEa3-_RKJdDe:22 a=VwQbUJbxAAAA:8 a=VnNF1IyMAAAA:8\n a=zlExV_OUcOsWLKDeu1IA:9","X-Proofpoint-Spam-Details-Enc":"AW1haW4tMjYwMjE2MDA1NCBTYWx0ZWRfX91JNXsbccf+Z\n YSZ7p+Lia+ksNxOBYwPvhEo08wGsFy6/jr4eI9zxZ8rddlHr8uQ8MpdRRSnlztdWsnHa1iA29UE\n zk3rophSbsQnSL+GGyzUwBhQBStv5pJUrj9EvPXdJYX98F5tfren9yEgAKy5JZNuiTaQx4jea0Y\n Qyy63nbkNlxmBWwb8kV9424klugpqMG/jSRM7uOCuqjCWb7Yz3YXpkrMvwxTNxlVgK00Hm2QXim\n n+jlPGFhWZGKnPjOJ6weMaPS063uKa85gMd97Chw++rzoDHF4b4Nh6SMoQ+78ckgkB0BjRUpS3f\n rtdIBCh5xFZic5jmqFlAhwufEeBgOaPQwYC7YcrldMuZUwrNoBVuxrgVIxum7HVGnGlQPOwo5Nf\n iFfpiGOEwj3dPOk9hxdF5zl0+kFtC4392zBjs4ksiqJoHnEWAm5l9sOt4igJx3Y7Y7T/Hm81J2a\n QjFt1j8SgTLB+nJX4jQ==","X-Proofpoint-ORIG-GUID":"UssT5T0Yis4W3D7Gi2gLozb4bDSLYcZn","X-Proofpoint-GUID":"UssT5T0Yis4W3D7Gi2gLozb4bDSLYcZn","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 lowpriorityscore=0 priorityscore=1501 malwarescore=0 phishscore=0 bulkscore=0\n suspectscore=0 spamscore=0 clxscore=1015 impostorscore=0 adultscore=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":"Exception callback reuses the stack frame of exception boundary. When\nexception boundary and exception callback programs have different BPF\nstack depth, the current stack unwind in exception callback will fail.\nAdjust the stack frame size of exception callback, in its prologue,\nif its BPF stack depth is different from that of exception boundary.\n\nReported-by: bot+bpf-ci@kernel.org\nCloses: https://lore.kernel.org/bpf/2a310e86a59eb4c44c3ac9e5647814469d9c955580c9c0f1b3d9ca4a44717a34@mail.kernel.org/\nFixes: 11d45eee9f42 (\"powerpc64/bpf: Additional NVR handling for bpf_throw\")\nSigned-off-by: Hari Bathini <hbathini@linux.ibm.com>\n---\n arch/powerpc/net/bpf_jit_comp64.c | 30 ++++++++++++++++++++++--------\n 1 file changed, 22 insertions(+), 8 deletions(-)","diff":"diff --git a/arch/powerpc/net/bpf_jit_comp64.c b/arch/powerpc/net/bpf_jit_comp64.c\nindex 5d4d2bb23cef..640b84409687 100644\n--- a/arch/powerpc/net/bpf_jit_comp64.c\n+++ b/arch/powerpc/net/bpf_jit_comp64.c\n@@ -32,14 +32,15 @@\n  *\n  *\t\t[\tprev sp\t\t] <-------------\n  *\t\t[    tail_call_info\t] 8\t\t|\n- *\t\t[   nv gpr save area\t] 6*8 + (12*8)\t|\n+ *\t\t[   nv gpr save area\t] 6*8\t\t|\n+ *\t\t[ addl. nv gpr save area] (12*8)\t| <--- exception boundary/callback program\n  *\t\t[    local_tmp_var\t] 24\t\t|\n  * fp (r31) -->\t[   ebpf stack space\t] upto 512\t|\n  *\t\t[     frame header\t] 32/112\t|\n  * sp (r1) --->\t[    stack pointer\t] --------------\n  *\n  * Additional (12*8) in 'nv gpr save area' only in case of\n- * exception boundary.\n+ * exception boundary/callback.\n  */\n \n /* BPF non-volatile registers save area size */\n@@ -128,12 +129,13 @@ static inline bool bpf_has_stack_frame(struct codegen_context *ctx)\n  *\t\t[\t  ...       \t] \t\t|\n  * sp (r1) --->\t[    stack pointer\t] --------------\n  *\t\t[    tail_call_info\t] 8\n- *\t\t[   nv gpr save area\t] 6*8 + (12*8)\n+ *\t\t[   nv gpr save area\t] 6*8\n+ *\t\t[ addl. nv gpr save area] (12*8) <--- exception boundary/callback program\n  *\t\t[    local_tmp_var\t] 24\n  *\t\t[   unused red zone\t] 224\n  *\n  * Additional (12*8) in 'nv gpr save area' only in case of\n- * exception boundary.\n+ * exception boundary/callback.\n  */\n static int bpf_jit_stack_local(struct codegen_context *ctx)\n {\n@@ -240,10 +242,6 @@ void bpf_jit_build_prologue(u32 *image, struct codegen_context *ctx)\n \n \tif (bpf_has_stack_frame(ctx) && !ctx->exception_cb) {\n \t\t/*\n-\t\t * exception_cb uses boundary frame after stack walk.\n-\t\t * It can simply use redzone, this optimization reduces\n-\t\t * stack walk loop by one level.\n-\t\t *\n \t\t * We need a stack frame, but we don't necessarily need to\n \t\t * save/restore LR unless we call other functions\n \t\t */\n@@ -287,6 +285,22 @@ void bpf_jit_build_prologue(u32 *image, struct codegen_context *ctx)\n \t\t * program(main prog) as third arg\n \t\t */\n \t\tEMIT(PPC_RAW_MR(_R1, _R5));\n+\t\t/*\n+\t\t * Exception callback reuses the stack frame of exception boundary.\n+\t\t * But BPF stack depth of exception callback and exception boundary\n+\t\t * don't have to be same. If BPF stack depth is different, adjust the\n+\t\t * stack frame size considering BPF stack depth of exception callback.\n+\t\t * The non-volatile register save area remains unchanged. These non-\n+\t\t * volatile registers are restored in exception callback's epilogue.\n+\t\t */\n+\t\tEMIT(PPC_RAW_LD(bpf_to_ppc(TMP_REG_1), _R5, 0));\n+\t\tEMIT(PPC_RAW_SUB(bpf_to_ppc(TMP_REG_2), _R1, bpf_to_ppc(TMP_REG_1)));\n+\t\tEMIT(PPC_RAW_ADDI(bpf_to_ppc(TMP_REG_2), bpf_to_ppc(TMP_REG_2),\n+\t\t\t-BPF_PPC_EXC_STACKFRAME));\n+\t\tEMIT(PPC_RAW_CMPLDI(bpf_to_ppc(TMP_REG_2), ctx->stack_size));\n+\t\tPPC_BCC_CONST_SHORT(COND_EQ, 12);\n+\t\tEMIT(PPC_RAW_MR(_R1, bpf_to_ppc(TMP_REG_1)));\n+\t\tEMIT(PPC_RAW_STDU(_R1, _R1, -(BPF_PPC_EXC_STACKFRAME + ctx->stack_size)));\n \t}\n \n \t/*\n","prefixes":["5/5"]}