From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 23E301B4244 for ; Sat, 14 Mar 2026 01:29:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773451779; cv=none; b=jbX2/tUrM8FaD73KC3ij0vKpSUJJeIso7MHMhD6s4d9WsxeDs8mMDZ2WlYLRLXXZs34hKNBiR8plJg5wpDC3XSQWdNiAvC/6Y569hjVUzE0RqOLJZpO1SMvnOUUyshwGGDy2BtxZswBLLIWXaw7HHVPUNtqI/HDOSoF2qNgA7DY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773451779; c=relaxed/simple; bh=joHvCo3Mef3lidTNmKFQXs+zuz68Ddv2REm0xsdd24w=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=mM7XNdfZLguUCsRsExHb7dKUSNKxp9RUSDKJMlhoqPWdUTIFoeK3Ulu6PdCycowiHpTQjTstKfXawkTmoAabXmPgBA2BL731gu72PuzSwlFSEWpL+4WKqmQEf4u+wpj1LsyuQrlvn339RbVz9fQuLoieqzV5EMyF/+F7WkMJSTw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Re4Ido98; arc=none smtp.client-ip=209.85.216.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Re4Ido98" Received: by mail-pj1-f50.google.com with SMTP id 98e67ed59e1d1-35a07ed3ebdso1335604a91.1 for ; Fri, 13 Mar 2026 18:29:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773451777; x=1774056577; darn=vger.kernel.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject :date:message-id:reply-to; bh=7EmrSuHvutIrDBDAGlQ6buLIUtau7tLM1U33dA0uIH0=; b=Re4Ido98JXTAFfYrWIaY3DC16EXt+KJGfQPojW1m9PHjIi/Gx9rdLbKReJ7dEKM6sk ouzyDtQPIPHZMANla7gk3p05kz89Rzwop5rYC2PSdDuci9+0KgCc7ksPOVdLMdyXJQ7E 4qQCb/x7yq0dWnoL85/jarSx2Y7k4zZGojkvyCy9lzxB8hlk9BzUN5MiAithFecooXaD 8rGd1CJ5SGF4jJOY/yPoQIWm0XrQixroUYI+lK9EEbD3z3Wm95Y8E67Pb3OpktIS526+ xTEPnxxJWNU45if72/5qK+CyU3/rt4hn33CRO/PQuPJCG37fu4uiN6tvm1+tQb6pTPBe 3Jrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773451777; x=1774056577; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=7EmrSuHvutIrDBDAGlQ6buLIUtau7tLM1U33dA0uIH0=; b=LB+QMxKCOCSTCpHzqQ3VbUmfwskhhYwECG1eO6eEXwcy7hvQJChYFLQCxSliqmzpmR qs4Ik4VrlHNr40FXGEhc06UwiKENNf+JhtaC6yFCl9kgb1ldfmsAJ8699ZN+cjYvEpbM AAs/1lerqRBBS7VttH7jhaCIU2Xs6Rvyy7lUlu+no5PIuYHX9DupIDgOm19cn5cy2DQD 1BtIAMpU6tmMUvJJtANXDX40C1PssCEAwF1LqYVigd1K6yYphDl2cSvYCBtjxe+wnZiS XB2h8Y55M8Zi6scY3PTXpU6cMUveqUOyuilBuBJZt17bxqPMldB321oxVmpw6wmJtdOW KQnA== X-Forwarded-Encrypted: i=1; AJvYcCUZYqM4pjRHzqKXZjX4GPg+nluGOby4x7CwgwDWmw0lA72Cu3XL6vBz1Yc9MoYudlu2KnmAy+yev8OVRKs=@vger.kernel.org X-Gm-Message-State: AOJu0YzpU/HrGedxp5JBd+m3ZH1OISUW08WIFrUHx7AyUg5Sc0RkNN9l PvjkxK8QADyB7BQick51ide9LEQPNq9NV51X72mweVKGzkZB1fu0xr7N X-Gm-Gg: ATEYQzypzQivFsGKK8muXpzhH6Y53Deyp0TgMBnOEcRU7PWJVlMeQ1nxw7kNrFWEGvT ct+XYL/raK35cSOpWGKDXWmVQV0S2mP5R9UGLZ7VdJiyQljdny/DNBcnwEA9faGHjc+n1qAUbVM beptvlRydn45uZAccWPagF6d/bePpyFacQcK49XtGwVPIpYuOrv+y2ZFRliSpz1L2Ct/0/lXVjD WACyoC1NixDnxODBrHgQalYMxgq1Dpp1jPnDS5PTokZcVjc1Gpy32FVxD0XSv3vEHbfq7NlgL7M E0uPWG8Bi2GP+uv8WwofS6HEg18Bx2aBsHuP6/JXNfzN12ODf0gEaKBjB7TSBw0kYJ/ISsQeSGj jz5Uzvl6sHbhVNm0WQUOcYrTdD3YnUK42EocXGnlQKC9mMAu6jyLh+l08CpoN0VcO+vC02fUjep oWIJDKtQtP+0OK93XLfQace14FGgyMKhLWkafDUeHnY6BnIo4ZJ3I= X-Received: by 2002:a17:90b:2683:b0:359:8d2e:6f79 with SMTP id 98e67ed59e1d1-35a21f6874bmr5053778a91.14.1773451777422; Fri, 13 Mar 2026 18:29:37 -0700 (PDT) Received: from [192.168.0.56] ([38.34.87.7]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-35a02fc8465sm9531222a91.9.2026.03.13.18.29.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Mar 2026 18:29:37 -0700 (PDT) Message-ID: <4e4c3be9bfca85c5343834b5d6b1d6283fd6a1f5.camel@gmail.com> Subject: Re: [PATCH bpf-next v9 1/5] bpf: Move constants blinding out of arch-specific JITs From: Eduard Zingerman To: Xu Kuohai , bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Yonghong Song , Puranjay Mohan , Anton Protopopov , Alexis =?ISO-8859-1?Q?Lothor=E9?= , Shahab Vahedi , Russell King , Tiezhu Yang , Hengqi Chen , Johan Almbladh , Paul Burton , Hari Bathini , Christophe Leroy , Naveen N Rao , Luke Nelson , Xi Wang , =?ISO-8859-1?Q?Bj=F6rn_T=F6pel?= , Pu Lehui , Ilya Leoshkevich , Heiko Carstens , Vasily Gorbik , "David S . Miller" , Wang YanQing Date: Fri, 13 Mar 2026 18:29:33 -0700 In-Reply-To: <20260312170255.3427799-2-xukuohai@huaweicloud.com> References: <20260312170255.3427799-1-xukuohai@huaweicloud.com> <20260312170255.3427799-2-xukuohai@huaweicloud.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.58.1 (3.58.1-1.fc43) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Fri, 2026-03-13 at 01:02 +0800, Xu Kuohai wrote: [...] > diff --git a/arch/arc/net/bpf_jit_core.c b/arch/arc/net/bpf_jit_core.c > index 1421eeced0f5..973ceae48675 100644 > --- a/arch/arc/net/bpf_jit_core.c > +++ b/arch/arc/net/bpf_jit_core.c [...] > @@ -229,12 +211,19 @@ static void jit_ctx_cleanup(struct jit_context *ctx= ) > =C2=A0 ctx->bpf2insn_valid =3D false; > =C2=A0 > =C2=A0 /* Freeing "bpf_header" is enough. "jit.buf" is a sub-array of it.= */ > - if (!ctx->success && ctx->bpf_header) { > - bpf_jit_binary_free(ctx->bpf_header); > - ctx->bpf_header =3D NULL; > - ctx->jit.buf=C2=A0=C2=A0=C2=A0 =3D NULL; > - ctx->jit.index=C2=A0 =3D 0; > - ctx->jit.len=C2=A0=C2=A0=C2=A0 =3D 0; > + if (!ctx->success) { > + if (ctx->bpf_header) { > + bpf_jit_binary_free(ctx->bpf_header); > + ctx->bpf_header =3D NULL; > + ctx->jit.buf=C2=A0=C2=A0=C2=A0 =3D NULL; > + ctx->jit.index=C2=A0 =3D 0; > + ctx->jit.len=C2=A0=C2=A0=C2=A0 =3D 0; > + } > + if (ctx->is_extra_pass) { Nit: The idea is that for !ctx->is_extra_pass ctx->prog->bpf_func !=3D NULL only when ctx->success is true, right? Maybe just drop the condition? > + ctx->prog->bpf_func =3D NULL; > + ctx->prog->jited =3D 0; > + ctx->prog->jited_len =3D 0; > + } > =C2=A0 } > =C2=A0 > =C2=A0 ctx->emit =3D false; > diff --git a/arch/arm/net/bpf_jit_32.c b/arch/arm/net/bpf_jit_32.c > index deeb8f292454..e6b1bb2de627 100644 > --- a/arch/arm/net/bpf_jit_32.c > +++ b/arch/arm/net/bpf_jit_32.c > @@ -2144,9 +2144,7 @@ bool bpf_jit_needs_zext(void) > =C2=A0 > =C2=A0struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog) > =C2=A0{ > - struct bpf_prog *tmp, *orig_prog =3D prog; > =C2=A0 struct bpf_binary_header *header; > - bool tmp_blinded =3D false; > =C2=A0 struct jit_ctx ctx; > =C2=A0 unsigned int tmp_idx; > =C2=A0 unsigned int image_size; The code in arch/arc is modified to do `... ctx->prog->jited =3D 0; ...`, but for arm32 there is no such modification. Why is that so? [...] > diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.= c > index adf84962d579..cd5a72fff500 100644 > --- a/arch/arm64/net/bpf_jit_comp.c > +++ b/arch/arm64/net/bpf_jit_comp.c > @@ -2009,14 +2009,12 @@ struct arm64_jit_data { [...] > @@ -2245,13 +2211,15 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_p= rog *prog) > =C2=A0 kfree(jit_data); > =C2=A0 prog->aux->jit_data =3D NULL; > =C2=A0 } > -out: > - if (tmp_blinded) > - bpf_jit_prog_release_other(prog, prog =3D=3D orig_prog ? > - =C2=A0=C2=A0 tmp : orig_prog); > + > =C2=A0 return prog; > =C2=A0 > =C2=A0out_free_hdr: > + if (extra_pass) { > + prog->bpf_func =3D NULL; > + prog->jited =3D 0; > + prog->jited_len =3D 0; > + } Just for my understanding, is the following correct? - Previously, a call bpf_jit_blind_constants() always cloned the prog. - Jits only set prog->jited to true upon successful compilation. - On error exit jits restored the original prog with it's prog->jited =3D= =3D 0. What happened in case of an extra pass? I'd expect that in case of an extra pass prog->jited would be true even before program is cloned by blind_constants() (and that's what arc code uses to figure out if the current pass is an extra pass). If so, old code would preserve prog->jited as true even in case of extra pass failure. Is that true or am I confused? Just trying to understand why this patch has to deal with the above snippet at all. In case it is indeed necessary, it seems the logic should be similar for all jits, is there a way to push this snippet to some common code? E.g. in verifier.c where the extra pass is initiated. [...]