From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DCB46386C0A; Thu, 6 Aug 2026 17:24:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786037092; cv=none; b=uf6EfRO3YoxAfbRYZ8oHKqdorze4oYwG6FhfE4uxcTJUj5dlS7qZrAYIMqjK+RiRPlWvkbI0mz589RY5WUWiqYcYf3wwZ7f06dVNTEJqvpH4RS2MKVA3NHHMklS/EDFgErRqY3M8jSOUbrROfBipaSna5f6U4loZcIsCugNtCpA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786037092; c=relaxed/simple; bh=TT7wQ3njXli4zup7IBJq/VNMFyU++u2QFU6839FauTs=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Jou1CK4QQJae2sxr9GwUVkC/0XcYRFM/ZB2RnCetyHZpw31P3kcLuZuBN+EwwMyRGtIqFGE1E9iVnUlVUV6cxY6JuSp/IUN8eqZpYsmINl/I9IDa7UfJMp8/K5sLjDXBPzZXYXPG2hS7qMJoSvgji3sxyHoRR+4lRvF8QPRUT8M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=AgO/aNbm; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="AgO/aNbm" Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 676HIJhZ3199737; Thu, 6 Aug 2026 17:24:49 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pp1; bh=KAlIcr YTRBfhUKyGl/zvlgpGbOodyQfw3ja+BaDE6iA=; b=AgO/aNbmIs8rPql888zUsa 8OJJUxepASLBBzE8NpE3T90tlvVISW4ZkAevTKNDiXgUxGb4Emk/ulc8QChcWdXe WJP73sXFmysVLz5lODwKOOpAtIWMX0oGruBfTMC2AmyQpFRn30lWvtKJ3yoWqoeC Lw80XpQekMN6EmRuxllDOJrcWH3afryUub3n9sHv/lS7uojBE4idDXHyly17PSBp 3YYAoTfm2xIQEQymM7sY+A9N8jqOqV7uGwSBtEIL/6a1w8muwwYdPFVcjJYHwXRf xbCTkDP5kEO3z+CQBz/hq3O82YcZhCljJSdV2Z1OuDJkio7FDWWSwfFH2uSov+Hg == Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4fs67j16fg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 06 Aug 2026 17:24:49 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 676HBIxf014129; Thu, 6 Aug 2026 17:24:48 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 4fsu4qva8j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 06 Aug 2026 17:24:48 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 676HOlGv49152312 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 6 Aug 2026 17:24:47 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E4C0920043; Thu, 6 Aug 2026 17:24:46 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4AABA2005A; Thu, 6 Aug 2026 17:24:44 +0000 (GMT) Received: from [9.124.215.184] (unknown [9.124.215.184]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 6 Aug 2026 17:24:44 +0000 (GMT) Message-ID: Date: Thu, 6 Aug 2026 22:54:42 +0530 Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v10 5/8] powerpc64/bpf: fix compare instruction emitted for tailcall To: Saket Kumar Bhaskar , bpf@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Cc: maddy@linux.ibm.com, ast@kernel.org, andrii@kernel.org, daniel@iogearbox.net, shuah@kernel.org, linux-kselftest@vger.kernel.org, stable@vger.kernel.org, venkat88@linux.ibm.com, yeswanth@linux.ibm.com References: <43017d115c0398b22284c38b2a30d53753560f7d.1785906979.git.skb99@linux.ibm.com> Content-Language: en-US From: Hari Bathini In-Reply-To: <43017d115c0398b22284c38b2a30d53753560f7d.1785906979.git.skb99@linux.ibm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: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X-Proofpoint-GUID: 2v58RAjMtePAuUi1upVH2YaIfR0RmV2l X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-06_01,2026-08-06_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 impostorscore=0 clxscore=1015 priorityscore=1501 suspectscore=0 malwarescore=0 adultscore=0 lowpriorityscore=0 phishscore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608060135 On 05/08/26 11:37 am, Saket Kumar Bhaskar wrote: > From: Abhishek Dubey > > The tail_call_info field can contain either a scalar counter > value or a 64-bit pointer to the counter, using a 32-bit > compare (cmplwi) only checks the lower 32 bits, which can lead > to incorrect comparisions when location of counter is near 4GB > boundary. Use instruction cmpldi/cmplwi for accurate comparision > in corresponding cases. > > Reported-by: sashiko-bot@kernel.org > Closes: https://lore.kernel.org/bpf/20260517191450.85AE6C2BCB8@smtp.kernel.org/ > Fixes: 2ed2d8f6fb38 ("powerpc64/bpf: Support tailcalls with subprogs") Acked-by: Hari Bathini Signed-off-by: Abhishek Dubey > Signed-off-by: Saket Kumar Bhaskar > Tested-by: Yeswanth Krishna Tellakula > --- > arch/powerpc/net/bpf_jit.h | 6 ++++++ > arch/powerpc/net/bpf_jit_comp.c | 2 +- > arch/powerpc/net/bpf_jit_comp64.c | 8 ++++---- > 3 files changed, 11 insertions(+), 5 deletions(-) > > diff --git a/arch/powerpc/net/bpf_jit.h b/arch/powerpc/net/bpf_jit.h > index 6632de9871dd..af510da12d8e 100644 > --- a/arch/powerpc/net/bpf_jit.h > +++ b/arch/powerpc/net/bpf_jit.h > @@ -188,6 +188,12 @@ struct codegen_context { > > #define bpf_to_ppc(r) (ctx->b2p[r]) > > +#ifdef CONFIG_PPC64 > +#define PPC_RAW_CMPLLI(a, i) PPC_RAW_CMPLDI(a, i) > +#else > +#define PPC_RAW_CMPLLI(a, i) PPC_RAW_CMPLWI(a, i) > +#endif > + > #ifdef CONFIG_PPC32 > #define BPF_FIXUP_LEN 3 /* Three instructions => 12 bytes */ > #else > diff --git a/arch/powerpc/net/bpf_jit_comp.c b/arch/powerpc/net/bpf_jit_comp.c > index 5d559d613f3a..8be5ded13a4a 100644 > --- a/arch/powerpc/net/bpf_jit_comp.c > +++ b/arch/powerpc/net/bpf_jit_comp.c > @@ -768,7 +768,7 @@ static void bpf_trampoline_setup_tail_call_info(u32 *image, struct codegen_conte > * Setting the tail_call_info in trampoline's frame > * depending on if previous frame had value or reference. > */ > - EMIT(PPC_RAW_CMPLWI(_R3, MAX_TAIL_CALL_CNT)); > + EMIT(PPC_RAW_CMPLLI(_R3, MAX_TAIL_CALL_CNT)); > PPC_BCC_CONST_SHORT(COND_GT, 8); > EMIT(PPC_RAW_ADDI(_R3, _R4, -BPF_PPC_TAILCALL)); > > diff --git a/arch/powerpc/net/bpf_jit_comp64.c b/arch/powerpc/net/bpf_jit_comp64.c > index 951eb10ca1f6..e80312171aa7 100644 > --- a/arch/powerpc/net/bpf_jit_comp64.c > +++ b/arch/powerpc/net/bpf_jit_comp64.c > @@ -276,7 +276,7 @@ void bpf_jit_build_prologue(u32 *image, struct codegen_context *ctx) > */ > EMIT(PPC_RAW_LD(bpf_to_ppc(TMP_REG_2), _R1, 0)); > EMIT(PPC_RAW_LD(bpf_to_ppc(TMP_REG_1), bpf_to_ppc(TMP_REG_2), -(BPF_PPC_TAILCALL))); > - EMIT(PPC_RAW_CMPLWI(bpf_to_ppc(TMP_REG_1), MAX_TAIL_CALL_CNT)); > + EMIT(PPC_RAW_CMPLDI(bpf_to_ppc(TMP_REG_1), MAX_TAIL_CALL_CNT)); > PPC_BCC_CONST_SHORT(COND_GT, 8); > EMIT(PPC_RAW_ADDI(bpf_to_ppc(TMP_REG_1), bpf_to_ppc(TMP_REG_2), > -(BPF_PPC_TAILCALL))); > @@ -662,7 +662,7 @@ static int bpf_jit_emit_tail_call(u32 *image, struct codegen_context *ctx, u32 o > PPC_BCC_SHORT(COND_GE, out); > > EMIT(PPC_RAW_LD(bpf_to_ppc(TMP_REG_1), _R1, bpf_jit_stack_tailcallinfo_offset(ctx))); > - EMIT(PPC_RAW_CMPLWI(bpf_to_ppc(TMP_REG_1), MAX_TAIL_CALL_CNT)); > + EMIT(PPC_RAW_CMPLDI(bpf_to_ppc(TMP_REG_1), MAX_TAIL_CALL_CNT)); > PPC_BCC_CONST_SHORT(COND_LE, 8); > > /* dereference TMP_REG_1 */ > @@ -672,7 +672,7 @@ static int bpf_jit_emit_tail_call(u32 *image, struct codegen_context *ctx, u32 o > * if (tail_call_info == MAX_TAIL_CALL_CNT) > * goto out; > */ > - EMIT(PPC_RAW_CMPLWI(bpf_to_ppc(TMP_REG_1), MAX_TAIL_CALL_CNT)); > + EMIT(PPC_RAW_CMPLDI(bpf_to_ppc(TMP_REG_1), MAX_TAIL_CALL_CNT)); > PPC_BCC_SHORT(COND_EQ, out); > > /* > @@ -707,7 +707,7 @@ static int bpf_jit_emit_tail_call(u32 *image, struct codegen_context *ctx, u32 o > * tail_call_info. > */ > EMIT(PPC_RAW_LD(bpf_to_ppc(TMP_REG_2), _R1, bpf_jit_stack_tailcallinfo_offset(ctx))); > - EMIT(PPC_RAW_CMPLWI(bpf_to_ppc(TMP_REG_2), MAX_TAIL_CALL_CNT)); > + EMIT(PPC_RAW_CMPLDI(bpf_to_ppc(TMP_REG_2), MAX_TAIL_CALL_CNT)); > PPC_BCC_CONST_SHORT(COND_GT, 8); > > /* First get address of tail_call_info */