From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) (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 70F063C343C for ; Fri, 3 Apr 2026 18:56:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775242563; cv=none; b=IKWG+dPiFWq2nIY3G6yeWCIKw+MXCrXSgC+vHc1UpZRn7SS+q6NAQ28vDnPcu3yeIR8avteQ2GNnapjvF0PBCkBZ7ex9Je28VqDbAXh2KZ/9cKzOB/jORa9LfDQjsI5Z9SerYvtsiD+xlD7aP0lOB7nIrfhko3Ti2hcNeqIe4Ns= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775242563; c=relaxed/simple; bh=q2NYEQxiA+6NCUkgbfeGnFvQwygkCxZdIkhPfKWWew8=; h=Mime-Version:Content-Type:Date:Message-Id:Subject:From:To:Cc: References:In-Reply-To; b=m7HnQKS/iezndYkuBd8VCeqGeErTtTDn9nlr5ZqhZyNPhjepREDiJo1SnHid+1H3h9c9lzUZllt7tBH8IF1h+hzflh3SoBYZT80qANLevfr8vsH1cXvzu4wy4x53XSfJkxsND0ZD2o0XQ5z0Dxy9BuEWaUEQSNvAd8WsvwCjfCg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=etsalapatis.com; spf=pass smtp.mailfrom=etsalapatis.com; dkim=pass (2048-bit key) header.d=etsalapatis-com.20251104.gappssmtp.com header.i=@etsalapatis-com.20251104.gappssmtp.com header.b=eRbhylVE; arc=none smtp.client-ip=209.85.214.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=etsalapatis.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=etsalapatis.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=etsalapatis-com.20251104.gappssmtp.com header.i=@etsalapatis-com.20251104.gappssmtp.com header.b="eRbhylVE" Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-2b2503753efso17706225ad.0 for ; Fri, 03 Apr 2026 11:56:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=etsalapatis-com.20251104.gappssmtp.com; s=20251104; t=1775242562; x=1775847362; darn=vger.kernel.org; h=in-reply-to:references:cc:to:from:subject:message-id:date :content-transfer-encoding:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=aUEap9ZtLAOWWOdMbJTcGPlnUuslrijse69P0jdZIjA=; b=eRbhylVEedFabLWpJLxklxa3ZSQWmw0PSuWti1svTxnRrQUhW7G3aOPhbYcb58w+RJ kI+pK9bmuPIKtcBdQMpFzZjLRZ9Jq+FyTdEQ1ktBVcWKPwbN9l+1HmFStMoLoD0feyYr lhHPKL33GANHZwSK/odJLbZabXhP0c5GuAcDGw9JbHTMbnaBZuvIipnedy42+R9lSNqX 23Zj8cUsSfjr06nLeW/1ujU2aa+ugu82ujqs4Nvtj1PbpzBGqad8DQ7IOQzz7OzFtgMA vGQffCW71vgEkJCSNakHmAW1DgnHJL4aPHvdMjIJRi87rSZCIch+z5t/Wrjfpo2kMFDa 6mDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775242562; x=1775847362; h=in-reply-to:references:cc:to:from:subject:message-id:date :content-transfer-encoding:mime-version:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=aUEap9ZtLAOWWOdMbJTcGPlnUuslrijse69P0jdZIjA=; b=dND+p4Y1IcVG3xViVF1AUyMNa5qm1ZekmqVM+508Qr9lVHWTyWtRhCIfHHAfsaKZ9t 2Nn8UHjs5aw9dY4okjFiNpFvvMFg1F1LBCW9+98L08EyZymZgcl9WKq7dN/1FZy+Ncqd RHZTd1m3MvxfSVX9hbpTpb1gSuXVWJINDH36xXNNnAvazL6peqeMkkz3WJpsy5iOkAyQ MrTZffwpnzxueoL6n1Zrytcv22R199C4ywT3/SM5R3Ovx/OPc52K5Q8Cvb6owCb7zbgF 5nFyphqOvFQB9olQK7Fk8yBZno2t8ruf9++KpMCmFtt6MbZ0SWVV8eQg5zsHsGpCKAeC 8AHA== X-Forwarded-Encrypted: i=1; AJvYcCV5pOrON0Hn+oWDsMDThtIJr/rbpSaYTx0oxuM418sY+qIGRN5s46Du+Rhq8ec7FXN1k1jCMoC3ymhhJOc=@vger.kernel.org X-Gm-Message-State: AOJu0YwAeVvz699NgWzcptkXQ0/Z+1nEI6Cvq0m8CKHpPmuT0u42sWN3 OHOJmRjVDnX38xSiERweytJ6w+3q+Wqn95gKS3RH0nE8N74yCwxCCQBqnb6G+xECaOk= X-Gm-Gg: AeBDieuS8zFAAXtCRYoVp3Wk63A3f9+cPvZod+g5S1UDIc5IzMRWQr7o2WsEzcnAjDa BTCa5COwMbTjavZ/lxKKKaM6V/ibQ2kd1cpQuWraiIgy7bvTgknFL1wDRylTnOUJLyg8Q+0MVxc VCYMdSX38rPERonxsZOToxVNsaY8t/9NDWTFq29PKDDMNdjox6ILF7jqKrC8dKZhVWgW8KHmBhg 12Tgd/jZqnXn8MziPjmwvpb04ic3CdyD3thtsjQBmxeOmq7bSK+04fCexLUwZp32bFcX7G4PN34 wsVIYY/eIjMel0DRdswZ0IOk8NLeCFAjy8f/trK9umUoLTkEKn3TtraO6nQoYwR4Bz8YTYo3Pv0 PgBO+K3SQKnhp98O8EJ6bXQsOD1Kr2x5yvkFLkkgXUqxW2J30c6/+AlNb3YemdVc7tvdReJIsqE 0IelrRPSM= X-Received: by 2002:a17:902:e78c:b0:2ae:c916:511 with SMTP id d9443c01a7336-2b2819173d3mr42659205ad.24.1775242561526; Fri, 03 Apr 2026 11:56:01 -0700 (PDT) Received: from localhost ([2604:3d08:487d:cd00::5517]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b27475ff56sm63177805ad.22.2026.04.03.11.56.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 03 Apr 2026 11:56:01 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Fri, 03 Apr 2026 14:56:00 -0400 Message-Id: Subject: Re: [PATCH bpf-next v12 5/5] bpf, arm64: Emit BTI for indirect jump target From: "Emil Tsalapatis" To: "Xu Kuohai" , , , Cc: "Alexei Starovoitov" , "Daniel Borkmann" , "Andrii Nakryiko" , "Martin KaFai Lau" , "Eduard Zingerman" , "Yonghong Song" , "Puranjay Mohan" , "Anton Protopopov" , =?utf-8?q?Alexis_Lothor=C3=A9?= , "Shahab Vahedi" , "Russell King" , "Tiezhu Yang" , "Hengqi Chen" , "Johan Almbladh" , "Paul Burton" , "Hari Bathini" , "Christophe Leroy" , "Naveen N Rao" , "Luke Nelson" , "Xi Wang" , =?utf-8?q?Bj=C3=B6rn_T=C3=B6pel?= , "Pu Lehui" , "Ilya Leoshkevich" , "Heiko Carstens" , "Vasily Gorbik" , "David S . Miller" , "Wang YanQing" X-Mailer: aerc 0.21.0-0-g5549850facc2 References: <20260403132811.753894-1-xukuohai@huaweicloud.com> <20260403132811.753894-6-xukuohai@huaweicloud.com> In-Reply-To: <20260403132811.753894-6-xukuohai@huaweicloud.com> On Fri Apr 3, 2026 at 9:28 AM EDT, Xu Kuohai wrote: > From: Xu Kuohai > > On CPUs that support BTI, the indirect jump selftest triggers a kernel > panic because there is no BTI instructions at the indirect jump targets. > > Fix it by emitting a BTI instruction for each indirect jump target. > > For reference, below is a sample panic log. > > Internal error: Oops - BTI: 0000000036000003 [#1] SMP Reviewed-by: Emil Tsalapatis > ... > Call trace: > bpf_prog_2e5f1c71c13ac3e0_big_jump_table+0x54/0xf8 (P) > bpf_prog_run_pin_on_cpu+0x140/0x468 > bpf_prog_test_run_syscall+0x280/0x3b8 > bpf_prog_test_run+0x22c/0x2c0 > > Fixes: f4a66cf1cb14 ("bpf: arm64: Add support for indirect jumps") > Reviewed-by: Anton Protopopov > Acked-by: Leon Hwang > Signed-off-by: Xu Kuohai > --- > arch/arm64/net/bpf_jit_comp.c | 17 ++++++++++------- > 1 file changed, 10 insertions(+), 7 deletions(-) > > diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.= c > index 7212ec89dfe3..aa5cd240cdda 100644 > --- a/arch/arm64/net/bpf_jit_comp.c > +++ b/arch/arm64/net/bpf_jit_comp.c > @@ -1198,8 +1198,8 @@ static int add_exception_handler(const struct bpf_i= nsn *insn, > * >0 - successfully JITed a 16-byte eBPF instruction. > * <0 - failed to JIT. > */ > -static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx, > - bool extra_pass) > +static int build_insn(const struct bpf_verifier_env *env, const struct b= pf_insn *insn, > + struct jit_ctx *ctx, bool extra_pass) > { > const u8 code =3D insn->code; > u8 dst =3D bpf2a64[insn->dst_reg]; > @@ -1224,6 +1224,9 @@ static int build_insn(const struct bpf_insn *insn, = struct jit_ctx *ctx, > int ret; > bool sign_extend; > =20 > + if (bpf_insn_is_indirect_target(env, ctx->prog, i)) > + emit_bti(A64_BTI_J, ctx); > + > switch (code) { > /* dst =3D src */ > case BPF_ALU | BPF_MOV | BPF_X: > @@ -1899,7 +1902,7 @@ static int build_insn(const struct bpf_insn *insn, = struct jit_ctx *ctx, > return 0; > } > =20 > -static int build_body(struct jit_ctx *ctx, bool extra_pass) > +static int build_body(struct bpf_verifier_env *env, struct jit_ctx *ctx,= bool extra_pass) > { > const struct bpf_prog *prog =3D ctx->prog; > int i; > @@ -1918,7 +1921,7 @@ static int build_body(struct jit_ctx *ctx, bool ext= ra_pass) > int ret; > =20 > ctx->offset[i] =3D ctx->idx; > - ret =3D build_insn(insn, ctx, extra_pass); > + ret =3D build_insn(env, insn, ctx, extra_pass); > if (ret > 0) { > i++; > ctx->offset[i] =3D ctx->idx; > @@ -2079,7 +2082,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_ver= ifier_env *env, struct bpf_pr > if (build_prologue(&ctx, was_classic)) > goto out_off; > =20 > - if (build_body(&ctx, extra_pass)) > + if (build_body(env, &ctx, extra_pass)) > goto out_off; > =20 > ctx.epilogue_offset =3D ctx.idx; > @@ -2127,7 +2130,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_ver= ifier_env *env, struct bpf_pr > /* Dont write body instructions to memory for now */ > ctx.write =3D false; > =20 > - if (build_body(&ctx, extra_pass)) > + if (build_body(env, &ctx, extra_pass)) > goto out_free_hdr; > =20 > ctx.epilogue_offset =3D ctx.idx; > @@ -2136,7 +2139,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_ver= ifier_env *env, struct bpf_pr > ctx.write =3D true; > =20 > /* Pass 3: Adjust jump offset and write final image */ > - if (build_body(&ctx, extra_pass) || > + if (build_body(env, &ctx, extra_pass) || > WARN_ON_ONCE(ctx.idx !=3D ctx.epilogue_offset)) > goto out_free_hdr; > =20