From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from 69-171-232-180.mail-mxout.facebook.com (69-171-232-180.mail-mxout.facebook.com [69.171.232.180]) (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 10EF29475 for ; Sun, 12 Apr 2026 05:00:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=69.171.232.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775970035; cv=none; b=Nl+z0T3yH75McO2GWGt69p+7i7mCaay/v1+LYBrHQIUs9UUQjJum1WYNTGzuJ9DRxzyLiMeBIh3Gu2fATjBzDfclxAOaYahIsxnk+pwrWN7EXrn0jKrjE3LbLhUCPnf644B8HsXMvY3t8903ZcSd6GoQIclFyzqxfLunsiV6TD0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775970035; c=relaxed/simple; bh=08orbhsxKqc2lYwKR4Tgr4zNT+pe8qaShFPg6JXN48g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ry8bF8ZMedhTp1TV+oml7wpRnm9XVUmAjtwIJCb/xsPEDoOREzDxQ9CYBoAulKtVGZ7/PqWCQF935JuXs6pIMBowgu+RcNjiMXYSqPRgT8s4RySBWmjmizzL+pzKJjQNefCJJof8dodb0+sqtaY5xdOA3jDlnMiHTXA2Dbe475U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.dev; spf=fail smtp.mailfrom=linux.dev; arc=none smtp.client-ip=69.171.232.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=linux.dev Received: by devvm16039.vll0.facebook.com (Postfix, from userid 128203) id EFC413B021C48; Sat, 11 Apr 2026 22:00:20 -0700 (PDT) From: Yonghong Song To: bpf@vger.kernel.org Cc: Alexei Starovoitov , Andrii Nakryiko , Daniel Borkmann , "Jose E . Marchesi" , kernel-team@fb.com, Martin KaFai Lau Subject: [PATCH bpf-next v4 14/18] bpf: Enable stack argument support for x86_64 Date: Sat, 11 Apr 2026 22:00:20 -0700 Message-ID: <20260412050020.267635-1-yonghong.song@linux.dev> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260412045826.254200-1-yonghong.song@linux.dev> References: <20260412045826.254200-1-yonghong.song@linux.dev> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Add stack argument support for x86_64. Signed-off-by: Yonghong Song --- arch/x86/net/bpf_jit_comp.c | 5 +++++ include/linux/filter.h | 1 + kernel/bpf/btf.c | 9 ++++++++- kernel/bpf/core.c | 5 +++++ kernel/bpf/verifier.c | 5 +++++ 5 files changed, 24 insertions(+), 1 deletion(-) diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c index e9b78040d703..32864dbc2c4e 100644 --- a/arch/x86/net/bpf_jit_comp.c +++ b/arch/x86/net/bpf_jit_comp.c @@ -3937,6 +3937,11 @@ bool bpf_jit_supports_kfunc_call(void) return true; } =20 +bool bpf_jit_supports_stack_args(void) +{ + return true; +} + void *bpf_arch_text_copy(void *dst, void *src, size_t len) { if (text_poke_copy(dst, src, len) =3D=3D NULL) diff --git a/include/linux/filter.h b/include/linux/filter.h index 68f018dd4b9c..a5035fb80a6b 100644 --- a/include/linux/filter.h +++ b/include/linux/filter.h @@ -1160,6 +1160,7 @@ bool bpf_jit_inlines_helper_call(s32 imm); bool bpf_jit_supports_subprog_tailcalls(void); bool bpf_jit_supports_percpu_insn(void); bool bpf_jit_supports_kfunc_call(void); +bool bpf_jit_supports_stack_args(void); bool bpf_jit_supports_far_kfunc_call(void); bool bpf_jit_supports_exceptions(void); bool bpf_jit_supports_ptr_xchg(void); diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c index c5f3aa05d5a3..1cbe0f2b0e41 100644 --- a/kernel/bpf/btf.c +++ b/kernel/bpf/btf.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -7897,8 +7898,14 @@ int btf_prepare_func_args(struct bpf_verifier_env = *env, int subprog) tname, nargs, MAX_BPF_FUNC_REG_ARGS); return -EINVAL; } - if (nargs > MAX_BPF_FUNC_REG_ARGS) + if (nargs > MAX_BPF_FUNC_REG_ARGS) { + if (!bpf_jit_supports_stack_args()) { + bpf_log(log, "JIT does not support function %s() with %d args\n", + tname, nargs); + return -ENOTSUPP; + } sub->incoming_stack_arg_depth =3D (nargs - MAX_BPF_FUNC_REG_ARGS) * BP= F_REG_SIZE; + } =20 /* check that function is void or returns int, exception cb also requir= es this */ t =3D btf_type_by_id(btf, t->type); diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c index 1bd8a19d7b61..124ebeb9baf9 100644 --- a/kernel/bpf/core.c +++ b/kernel/bpf/core.c @@ -3158,6 +3158,11 @@ bool __weak bpf_jit_supports_kfunc_call(void) return false; } =20 +bool __weak bpf_jit_supports_stack_args(void) +{ + return false; +} + bool __weak bpf_jit_supports_far_kfunc_call(void) { return false; diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index 206ffbd9596d..91c5f2942194 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -13863,6 +13863,11 @@ static int check_kfunc_args(struct bpf_verifier_= env *env, struct bpf_kfunc_call_ MAX_BPF_FUNC_ARGS); return -EINVAL; } + if (nargs > MAX_BPF_FUNC_REG_ARGS && !bpf_jit_supports_stack_args()) { + verbose(env, "JIT does not support kfunc %s() with %d args\n", + func_name, nargs); + return -ENOTSUPP; + } =20 /* Check that BTF function arguments match actual types that the * verifier sees. --=20 2.52.0