summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorAlexei Starovoitov <ast@kernel.org>2026-04-23 17:54:51 +0300
committerAlexei Starovoitov <ast@kernel.org>2026-04-23 17:54:51 +0300
commitfd30cf86e1194ab067661a0ab3e0769a5600848b (patch)
treea5a4705146c809d8bfafb593bb81a218c7dc686a /include/linux
parent7f843c0584f438c1cc8cbe798ca8ab4207e67509 (diff)
parent4439328d3878c97fdf5ddec828a43ea07c388452 (diff)
downloadlinux-fd30cf86e1194ab067661a0ab3e0769a5600848b.tar.xz
Merge branch 'bpf-prepare-to-support-stack-arguments'
Yonghong Song says: ==================== bpf: Prepare to support stack arguments The patch set prepares to support stack arguments for bpf functions and kfuncs. The major changes include: - Avoid redundant calculation of bpf_reg_state. For stack arguments, there exists no corresponding register number. - Refactor check_kfunc_mem_size_reg() to have bpf_reg_state's for both mem_reg and size_reg. - Allow verifier logs to print stack arguments if there is no corresponding register. Please see individual patches for details. Changelogs: v2 -> v3: - v2: https://lore.kernel.org/bpf/20260422054149.3124342-1-yonghong.song@linux.dev/ - Fix a mark_chain_precision issue by rewriting helper reg_from_argno(). v1 -> v2: - v1: https://lore.kernel.org/bpf/20260421171927.3507554-1-yonghong.song@linux.dev/ - Major change to patch 7. In v1, the argno has type u32 to represent registers and arguments. This works but error prone as u32 is too easy to mess and leak. This version uses a struct type to represent argno which makes things more explicit and easy to reason. ==================== Link: https://patch.msgid.link/20260423033425.2536883-1-yonghong.song@linux.dev Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/bpf.h5
-rw-r--r--include/linux/bpf_verifier.h1
-rw-r--r--include/linux/filter.h5
3 files changed, 9 insertions, 2 deletions
diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index d3aea3931b85..715b6df9c403 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -1151,6 +1151,11 @@ struct bpf_prog_offload {
/* The longest tracepoint has 12 args.
* See include/trace/bpf_probe.h
+ *
+ * Also reuse this macro for maximum number of arguments a BPF function
+ * or a kfunc can have. Args 1-5 are passed in registers, args 6-12 via
+ * stack arg slots. The JIT may map some stack arg slots to registers based
+ * on the native calling convention (e.g., arg 6 to R9 on x86-64).
*/
#define MAX_BPF_FUNC_ARGS 12
diff --git a/include/linux/bpf_verifier.h b/include/linux/bpf_verifier.h
index b148f816f25b..d5b4303315dd 100644
--- a/include/linux/bpf_verifier.h
+++ b/include/linux/bpf_verifier.h
@@ -913,6 +913,7 @@ struct bpf_verifier_env {
* e.g., in reg_type_str() to generate reg_type string
*/
char tmp_str_buf[TMP_STR_BUF_LEN];
+ char tmp_arg_name[32];
struct bpf_insn insn_buf[INSN_BUF_SIZE];
struct bpf_insn epilogue_buf[INSN_BUF_SIZE];
struct bpf_scc_callchain callchain_buf;
diff --git a/include/linux/filter.h b/include/linux/filter.h
index 1ec6d5ba64cc..b77d0b06db6e 100644
--- a/include/linux/filter.h
+++ b/include/linux/filter.h
@@ -58,8 +58,9 @@ struct ctl_table_header;
#define BPF_REG_H BPF_REG_9 /* hlen, callee-saved */
/* Kernel hidden auxiliary/helper register. */
-#define BPF_REG_AX MAX_BPF_REG
-#define MAX_BPF_EXT_REG (MAX_BPF_REG + 1)
+#define BPF_REG_PARAMS MAX_BPF_REG
+#define BPF_REG_AX (MAX_BPF_REG + 1)
+#define MAX_BPF_EXT_REG (MAX_BPF_REG + 2)
#define MAX_BPF_JIT_REG MAX_BPF_EXT_REG
/* unused opcode to mark special call to bpf_tail_call() helper */