| Seq | Timestamp | Type | Name | Duration |
|---|---|---|---|---|
| 0/0 | 2026/07/07 17:15 | flow | patch-triage |
0mArgs:null Results: {
"EnableConfigs": [
"BPF_JIT"
],
"FocusSymbols": [
"prepare_bpf_tail_call_cnt",
"build_prologue",
"__build_epilogue",
"emit_bpf_tail_call"
],
"Reasoning": "The patch modifies the LoongArch BPF JIT compiler to optimize tail call count handling using branchless instructions. It alters the prologue, epilogue, and tail call emission logic, which is functional core kernel logic that should be fuzzed to ensure correct code generation.",
"WorthFuzzing": true
} |
| 1/1 | 2026/07/07 17:15 | action | read-patch-diff |
0mArgs:null Results: {
"PatchDiff": "commit 71339dbe598654463ef51b2b6fdfa83b9af1b2c0\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate: Tue Jul 7 17:15:13 2026 +0000\n\n syz-cluster: applied patch under review\n\ndiff --git a/arch/loongarch/include/asm/inst.h b/arch/loongarch/include/asm/inst.h\nindex 76b723590023d7..19feae166e1c18 100644\n--- a/arch/loongarch/include/asm/inst.h\n+++ b/arch/loongarch/include/asm/inst.h\n@@ -97,6 +97,7 @@ enum reg2i6_op {\n };\n \n enum reg2i12_op {\n+\tsltui_op\t= 0x09,\n \taddiw_op\t= 0x0a,\n \taddid_op\t= 0x0b,\n \tlu52id_op\t= 0x0c,\n@@ -153,6 +154,8 @@ enum reg3_op {\n \taddd_op\t\t= 0x21,\n \tsubw_op\t\t= 0x22,\n \tsubd_op\t\t= 0x23,\n+\tmaskeqz_op\t= 0x26,\n+\tmasknez_op\t= 0x27,\n \tnor_op\t\t= 0x28,\n \tand_op\t\t= 0x29,\n \tor_op\t\t= 0x2a,\n@@ -644,6 +647,7 @@ static inline void emit_##NAME(union loongarch_instruction *insn,\t\\\n \tinsn-\u003ereg2i12_format.rj = rj;\t\t\t\t\t\\\n }\n \n+DEF_EMIT_REG2I12_FORMAT(sltui, sltui_op)\n DEF_EMIT_REG2I12_FORMAT(addiw, addiw_op)\n DEF_EMIT_REG2I12_FORMAT(addid, addid_op)\n DEF_EMIT_REG2I12_FORMAT(lu52id, lu52id_op)\n@@ -749,6 +753,8 @@ DEF_EMIT_REG3_FORMAT(divd, divd_op)\n DEF_EMIT_REG3_FORMAT(modd, modd_op)\n DEF_EMIT_REG3_FORMAT(divdu, divdu_op)\n DEF_EMIT_REG3_FORMAT(moddu, moddu_op)\n+DEF_EMIT_REG3_FORMAT(maskeqz, maskeqz_op)\n+DEF_EMIT_REG3_FORMAT(masknez, masknez_op)\n DEF_EMIT_REG3_FORMAT(and, and_op)\n DEF_EMIT_REG3_FORMAT(or, or_op)\n DEF_EMIT_REG3_FORMAT(xor, xor_op)\ndiff --git a/arch/loongarch/net/bpf_jit.c b/arch/loongarch/net/bpf_jit.c\nindex 2738b4db116533..9e9d98b2181277 100644\n--- a/arch/loongarch/net/bpf_jit.c\n+++ b/arch/loongarch/net/bpf_jit.c\n@@ -52,50 +52,29 @@ static void prepare_bpf_tail_call_cnt(struct jit_ctx *ctx, int *store_offset)\n \tconst struct bpf_prog *prog = ctx-\u003eprog;\n \tconst bool is_main_prog = !bpf_is_subprog(prog);\n \n+\t*store_offset -= sizeof(long);\n \tif (is_main_prog) {\n-\t\t/*\n-\t\t * LOONGARCH_GPR_T3 = MAX_TAIL_CALL_CNT\n-\t\t * if (REG_TCC \u003e T3 )\n-\t\t *\tstd REG_TCC -\u003e LOONGARCH_GPR_SP + store_offset\n-\t\t * else\n-\t\t *\tstd REG_TCC -\u003e LOONGARCH_GPR_SP + store_offset\n-\t\t *\tREG_TCC = LOONGARCH_GPR_SP + store_offset\n-\t\t *\n-\t\t * std REG_TCC -\u003e LOONGARCH_GPR_SP + store_offset\n-\t\t *\n-\t\t * The purpose of this code is to first push the TCC into stack,\n-\t\t * and then push the address of TCC into stack.\n-\t\t * In cases where bpf2bpf and tailcall are used in combination,\n-\t\t * the value in REG_TCC may be a count or an address,\n-\t\t * these two cases need to be judged and handled separately.\n-\t\t */\n-\t\temit_insn(ctx, addid, LOONGARCH_GPR_T3, LOONGARCH_GPR_ZERO, MAX_TAIL_CALL_CNT);\n-\t\t*store_offset -= sizeof(long);\n-\n-\t\temit_cond_jmp(ctx, BPF_JGT, REG_TCC, LOONGARCH_GPR_T3, 4);\n-\n-\t\t/*\n-\t\t * If REG_TCC \u003c MAX_TAIL_CALL_CNT, the value in REG_TCC is a count,\n-\t\t * push tcc into stack\n-\t\t */\n+\t\t/* Save entrance TCC state (scalar count or kernel pointer) to local 'tcc' slot */\n \t\temit_insn(ctx, std, REG_TCC, LOONGARCH_GPR_SP, *store_offset);\n \n-\t\t/* Push the address of TCC into the REG_TCC */\n-\t\temit_insn(ctx, addid, REG_TCC, LOONGARCH_GPR_SP, *store_offset);\n-\n-\t\temit_uncond_jmp(ctx, 2);\n+\t\t/* Compute the absolute pointer to the local 'tcc' slot */\n+\t\temit_insn(ctx, addid, LOONGARCH_GPR_T7, LOONGARCH_GPR_SP, *store_offset);\n \n \t\t/*\n-\t\t * If REG_TCC \u003e MAX_TAIL_CALL_CNT, the value in REG_TCC is an address,\n-\t\t * push tcc_ptr into stack\n+\t\t * Branchless classification and blending:\n+\t\t * Combine interleaved inputs between a scalar count (0 to 33)\n+\t\t * and a kernel pointer address without runtime branching.\n \t\t */\n-\t\temit_insn(ctx, std, REG_TCC, LOONGARCH_GPR_SP, *store_offset);\n+\t\temit_insn(ctx, sltui, LOONGARCH_GPR_T8, REG_TCC, MAX_TAIL_CALL_CNT + 1);\n+\t\temit_insn(ctx, maskeqz, LOONGARCH_GPR_T7, LOONGARCH_GPR_T7, LOONGARCH_GPR_T8);\n+\t\temit_insn(ctx, masknez, REG_TCC, REG_TCC, LOONGARCH_GPR_T8);\n+\t\temit_insn(ctx, or, REG_TCC, REG_TCC, LOONGARCH_GPR_T7);\n \t} else {\n-\t\t*store_offset -= sizeof(long);\n+\t\t/* Subprograms: backup the verified TCC pointer inherited via REG_TCC */\n \t\temit_insn(ctx, std, REG_TCC, LOONGARCH_GPR_SP, *store_offset);\n \t}\n \n-\t/* Push tcc_ptr into stack */\n+\t/* Store the finalized TCC pointer value securely into the local 'tcc_ptr' slot */\n \t*store_offset -= sizeof(long);\n \temit_insn(ctx, std, REG_TCC, LOONGARCH_GPR_SP, *store_offset);\n }\n@@ -124,6 +103,9 @@ static void prepare_bpf_tail_call_cnt(struct jit_ctx *ctx, int *store_offset)\n * | tcc |\n * +-------------------------+\n * | tcc_ptr |\n+ * +-------------------------+\n+ * | arena |\n+ * | (optional) |\n * +-------------------------+ \u003c--BPF_REG_FP\n * | prog-\u003eaux-\u003estack_depth |\n * | (optional) |\n@@ -145,7 +127,7 @@ static void build_prologue(struct jit_ctx *ctx)\n \tstack_adjust += sizeof(long) * 2;\n \n \tif (ctx-\u003earena_vm_start)\n-\t\tstack_adjust += 8;\n+\t\tstack_adjust += sizeof(long);\n \n \tstack_adjust = round_up(stack_adjust, 16);\n \tstack_adjust += bpf_stack_adjust;\n@@ -194,13 +176,13 @@ static void build_prologue(struct jit_ctx *ctx)\n \tstore_offset -= sizeof(long);\n \temit_insn(ctx, std, LOONGARCH_GPR_S5, LOONGARCH_GPR_SP, store_offset);\n \n+\tprepare_bpf_tail_call_cnt(ctx, \u0026store_offset);\n+\n \tif (ctx-\u003earena_vm_start) {\n \t\tstore_offset -= sizeof(long);\n \t\temit_insn(ctx, std, REG_ARENA, LOONGARCH_GPR_SP, store_offset);\n \t}\n \n-\tprepare_bpf_tail_call_cnt(ctx, \u0026store_offset);\n-\n \temit_insn(ctx, addid, LOONGARCH_GPR_FP, LOONGARCH_GPR_SP, stack_adjust);\n \n \tif (bpf_stack_adjust)\n@@ -241,21 +223,18 @@ static void __build_epilogue(struct jit_ctx *ctx, bool is_tail_call)\n \tload_offset -= sizeof(long);\n \temit_insn(ctx, ldd, LOONGARCH_GPR_S5, LOONGARCH_GPR_SP, load_offset);\n \n+\t/* Only restore the TCC state into REG_TCC from the higher slot */\n+\tload_offset -= sizeof(long);\n+\temit_insn(ctx, ldd, REG_TCC, LOONGARCH_GPR_SP, load_offset);\n+\n+\t/* Skip the unused local 'tcc_ptr' slot to align with arena */\n+\tload_offset -= sizeof(long);\n+\n \tif (ctx-\u003earena_vm_start) {\n \t\tload_offset -= sizeof(long);\n \t\temit_insn(ctx, ldd, REG_ARENA, LOONGARCH_GPR_SP, load_offset);\n \t}\n \n-\t/*\n-\t * When push into the stack, follow the order of tcc then tcc_ptr.\n-\t * When pop from the stack, first pop tcc_ptr then followed by tcc.\n-\t */\n-\tload_offset -= 2 * sizeof(long);\n-\temit_insn(ctx, ldd, REG_TCC, LOONGARCH_GPR_SP, load_offset);\n-\n-\tload_offset += sizeof(long);\n-\temit_insn(ctx, ldd, REG_TCC, LOONGARCH_GPR_SP, load_offset);\n-\n \temit_insn(ctx, addid, LOONGARCH_GPR_SP, LOONGARCH_GPR_SP, stack_adjust);\n \n \tif (!is_tail_call) {\n@@ -290,17 +269,13 @@ bool bpf_jit_supports_far_kfunc_call(void)\n \n static int emit_bpf_tail_call(struct jit_ctx *ctx, int insn)\n {\n-\tint off, tc_ninsn = 0;\n+\tint off, jmp_offset;\n \tint tcc_ptr_off = BPF_TAIL_CALL_CNT_PTR_STACK_OFF(ctx-\u003estack_size);\n \tu8 a1 = LOONGARCH_GPR_A1;\n \tu8 a2 = LOONGARCH_GPR_A2;\n \tu8 t1 = LOONGARCH_GPR_T1;\n \tu8 t2 = LOONGARCH_GPR_T2;\n \tu8 t3 = LOONGARCH_GPR_T3;\n-\tconst int idx0 = ctx-\u003eidx;\n-\n-#define cur_offset (ctx-\u003eidx - idx0)\n-#define jmp_offset (tc_ninsn - (cur_offset))\n \n \t/*\n \t * a0: \u0026ctx\n@@ -310,12 +285,12 @@ static int emit_bpf_tail_call(struct jit_ctx *ctx, int insn)\n \t * if (index \u003e= array-\u003emap.max_entries)\n \t *\t goto out;\n \t */\n-\ttc_ninsn = insn ? ctx-\u003eoffset[insn+1] - ctx-\u003eoffset[insn] : ctx-\u003eoffset[0];\n \temit_zext_32(ctx, a2, true);\n \n \toff = offsetof(struct bpf_array, map.max_entries);\n \temit_insn(ctx, ldwu, t1, a1, off);\n \t/* bgeu $a2, $t1, jmp_offset */\n+\tjmp_offset = ctx-\u003eimage ? (ctx-\u003eoffset[insn + 1] - ctx-\u003eidx) : 0;\n \tif (emit_tailcall_jmp(ctx, BPF_JGE, a2, t1, jmp_offset) \u003c 0)\n \t\tgoto toofar;\n \n@@ -326,6 +301,7 @@ static int emit_bpf_tail_call(struct jit_ctx *ctx, int insn)\n \temit_insn(ctx, ldd, REG_TCC, LOONGARCH_GPR_SP, tcc_ptr_off);\n \temit_insn(ctx, ldd, t3, REG_TCC, 0);\n \temit_insn(ctx, addid, t2, LOONGARCH_GPR_ZERO, MAX_TAIL_CALL_CNT);\n+\tjmp_offset = ctx-\u003eimage ? (ctx-\u003eoffset[insn + 1] - ctx-\u003eidx) : 0;\n \tif (emit_tailcall_jmp(ctx, BPF_JSGE, t3, t2, jmp_offset) \u003c 0)\n \t\tgoto toofar;\n \n@@ -340,6 +316,7 @@ static int emit_bpf_tail_call(struct jit_ctx *ctx, int insn)\n \toff = offsetof(struct bpf_array, ptrs);\n \temit_insn(ctx, ldd, t2, t2, off);\n \t/* beq $t2, $zero, jmp_offset */\n+\tjmp_offset = ctx-\u003eimage ? (ctx-\u003eoffset[insn + 1] - ctx-\u003eidx) : 0;\n \tif (emit_tailcall_jmp(ctx, BPF_JEQ, t2, LOONGARCH_GPR_ZERO, jmp_offset) \u003c 0)\n \t\tgoto toofar;\n \n@@ -355,8 +332,6 @@ static int emit_bpf_tail_call(struct jit_ctx *ctx, int insn)\n toofar:\n \tpr_info_once(\"tail_call: jump too far\\n\");\n \treturn -1;\n-#undef cur_offset\n-#undef jmp_offset\n }\n \n static void emit_store_stack_imm64(struct jit_ctx *ctx, int reg, int stack_off, u64 imm64)\n"
} |
| 2/1 | 2026/07/07 17:15 | agent | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: {
"EnableConfigs": [
"BPF_JIT"
],
"FocusSymbols": [
"prepare_bpf_tail_call_cnt",
"build_prologue",
"__build_epilogue",
"emit_bpf_tail_call"
],
"Reasoning": "The patch modifies the LoongArch BPF JIT compiler to optimize tail call count handling using branchless instructions. It alters the prologue, epilogue, and tail call emission logic, which is functional core kernel logic that should be fuzzed to ensure correct code generation.",
"WorthFuzzing": true
}Instruction: You are an expert Linux kernel maintainer. Your job is to review a provided patch series and determine if it makes functional changes to the kernel that should be fuzzed. IMPORTANT: The changes have ALREADY been applied and committed as the HEAD commit in your workspace. Do NOT rely on your internal knowledge of the kernel. You must actively use your code access tools to examine the actual source code and confirm any assumptions. Return WorthFuzzing=false if the patch only contains: - Modifications to Documentation/, Kconfig files, or code comments. - Purely decorative changes, such as logging (e.g., pr_err, printk) or tracepoints. - Changes to numeric constants or macros that do not functionally alter execution flow. - Code paths that are impossible to reach in virtualized environments like GCE or QEMU, even when utilizing software-emulated hardware (e.g., usb gadget, mac80211_hwsim). If it modifies reachable core kernel logic, drivers, or architectures, use your code search tools to verify the code can be executed, then return WorthFuzzing=true. When returning WorthFuzzing=true, you MUST ALSO: 1. Extract any specific kernel functions that should be heavily fuzzed into FocusSymbols. Avoid listing generic hot-path functions to prevent skewed test distributions. 2. Identify any specific CONFIG_ options required to properly test this new/modified feature. Go and look into the Kconfig files and check for ifdefs around the code, do not make assumptions. Do not list too generic configs (we already have them enabled). Only list those that specifically cover the modified code. List them in the EnableConfigs output array, and DO NOT add a 'CONFIG_' prefix (e.g., return "NET_IPV4" instead of "CONFIG_NET_IPV4"). Prefer calling several tools at the same time to save round-trips. Use set-results tool to provide results of the analysis. It must be called exactly once before the final reply. Ignore results of this tool. Prompt: For your convenience, here is the diff of the changes:
commit 71339dbe598654463ef51b2b6fdfa83b9af1b2c0
Author: syz-cluster <triage@syzkaller.com>
Date: Tue Jul 7 17:15:13 2026 +0000
syz-cluster: applied patch under review
diff --git a/arch/loongarch/include/asm/inst.h b/arch/loongarch/include/asm/inst.h
index 76b723590023d7..19feae166e1c18 100644
--- a/arch/loongarch/include/asm/inst.h
+++ b/arch/loongarch/include/asm/inst.h
@@ -97,6 +97,7 @@ enum reg2i6_op {
};
enum reg2i12_op {
+ sltui_op = 0x09,
addiw_op = 0x0a,
addid_op = 0x0b,
lu52id_op = 0x0c,
@@ -153,6 +154,8 @@ enum reg3_op {
addd_op = 0x21,
subw_op = 0x22,
subd_op = 0x23,
+ maskeqz_op = 0x26,
+ masknez_op = 0x27,
nor_op = 0x28,
and_op = 0x29,
or_op = 0x2a,
@@ -644,6 +647,7 @@ static inline void emit_##NAME(union loongarch_instruction *insn, \
insn->reg2i12_format.rj = rj; \
}
+DEF_EMIT_REG2I12_FORMAT(sltui, sltui_op)
DEF_EMIT_REG2I12_FORMAT(addiw, addiw_op)
DEF_EMIT_REG2I12_FORMAT(addid, addid_op)
DEF_EMIT_REG2I12_FORMAT(lu52id, lu52id_op)
@@ -749,6 +753,8 @@ DEF_EMIT_REG3_FORMAT(divd, divd_op)
DEF_EMIT_REG3_FORMAT(modd, modd_op)
DEF_EMIT_REG3_FORMAT(divdu, divdu_op)
DEF_EMIT_REG3_FORMAT(moddu, moddu_op)
+DEF_EMIT_REG3_FORMAT(maskeqz, maskeqz_op)
+DEF_EMIT_REG3_FORMAT(masknez, masknez_op)
DEF_EMIT_REG3_FORMAT(and, and_op)
DEF_EMIT_REG3_FORMAT(or, or_op)
DEF_EMIT_REG3_FORMAT(xor, xor_op)
diff --git a/arch/loongarch/net/bpf_jit.c b/arch/loongarch/net/bpf_jit.c
index 2738b4db116533..9e9d98b2181277 100644
--- a/arch/loongarch/net/bpf_jit.c
+++ b/arch/loongarch/net/bpf_jit.c
@@ -52,50 +52,29 @@ static void prepare_bpf_tail_call_cnt(struct jit_ctx *ctx, int *store_offset)
const struct bpf_prog *prog = ctx->prog;
const bool is_main_prog = !bpf_is_subprog(prog);
+ *store_offset -= sizeof(long);
if (is_main_prog) {
- /*
- * LOONGARCH_GPR_T3 = MAX_TAIL_CALL_CNT
- * if (REG_TCC > T3 )
- * std REG_TCC -> LOONGARCH_GPR_SP + store_offset
- * else
- * std REG_TCC -> LOONGARCH_GPR_SP + store_offset
- * REG_TCC = LOONGARCH_GPR_SP + store_offset
- *
- * std REG_TCC -> LOONGARCH_GPR_SP + store_offset
- *
- * The purpose of this code is to first push the TCC into stack,
- * and then push the address of TCC into stack.
- * In cases where bpf2bpf and tailcall are used in combination,
- * the value in REG_TCC may be a count or an address,
- * these two cases need to be judged and handled separately.
- */
- emit_insn(ctx, addid, LOONGARCH_GPR_T3, LOONGARCH_GPR_ZERO, MAX_TAIL_CALL_CNT);
- *store_offset -= sizeof(long);
-
- emit_cond_jmp(ctx, BPF_JGT, REG_TCC, LOONGARCH_GPR_T3, 4);
-
- /*
- * If REG_TCC < MAX_TAIL_CALL_CNT, the value in REG_TCC is a count,
- * push tcc into stack
- */
+ /* Save entrance TCC state (scalar count or kernel pointer) to local 'tcc' slot */
emit_insn(ctx, std, REG_TCC, LOONGARCH_GPR_SP, *store_offset);
- /* Push the address of TCC into the REG_TCC */
- emit_insn(ctx, addid, REG_TCC, LOONGARCH_GPR_SP, *store_offset);
-
- emit_uncond_jmp(ctx, 2);
+ /* Compute the absolute pointer to the local 'tcc' slot */
+ emit_insn(ctx, addid, LOONGARCH_GPR_T7, LOONGARCH_GPR_SP, *store_offset);
/*
- * If REG_TCC > MAX_TAIL_CALL_CNT, the value in REG_TCC is an address,
- * push tcc_ptr into stack
+ * Branchless classification and blending:
+ * Combine interleaved inputs between a scalar count (0 to 33)
+ * and a kernel pointer address without runtime branching.
*/
- emit_insn(ctx, std, REG_TCC, LOONGARCH_GPR_SP, *store_offset);
+ emit_insn(ctx, sltui, LOONGARCH_GPR_T8, REG_TCC, MAX_TAIL_CALL_CNT + 1);
+ emit_insn(ctx, maskeqz, LOONGARCH_GPR_T7, LOONGARCH_GPR_T7, LOONGARCH_GPR_T8);
+ emit_insn(ctx, masknez, REG_TCC, REG_TCC, LOONGARCH_GPR_T8);
+ emit_insn(ctx, or, REG_TCC, REG_TCC, LOONGARCH_GPR_T7);
} else {
- *store_offset -= sizeof(long);
+ /* Subprograms: backup the verified TCC pointer inherited via REG_TCC */
emit_insn(ctx, std, REG_TCC, LOONGARCH_GPR_SP, *store_offset);
}
- /* Push tcc_ptr into stack */
+ /* Store the finalized TCC pointer value securely into the local 'tcc_ptr' slot */
*store_offset -= sizeof(long);
emit_insn(ctx, std, REG_TCC, LOONGARCH_GPR_SP, *store_offset);
}
@@ -124,6 +103,9 @@ static void prepare_bpf_tail_call_cnt(struct jit_ctx *ctx, int *store_offset)
* | tcc |
* +-------------------------+
* | tcc_ptr |
+ * +-------------------------+
+ * | arena |
+ * | (optional) |
* +-------------------------+ <--BPF_REG_FP
* | prog->aux->stack_depth |
* | (optional) |
@@ -145,7 +127,7 @@ static void build_prologue(struct jit_ctx *ctx)
stack_adjust += sizeof(long) * 2;
if (ctx->arena_vm_start)
- stack_adjust += 8;
+ stack_adjust += sizeof(long);
stack_adjust = round_up(stack_adjust, 16);
stack_adjust += bpf_stack_adjust;
@@ -194,13 +176,13 @@ static void build_prologue(struct jit_ctx *ctx)
store_offset -= sizeof(long);
emit_insn(ctx, std, LOONGARCH_GPR_S5, LOONGARCH_GPR_SP, store_offset);
+ prepare_bpf_tail_call_cnt(ctx, &store_offset);
+
if (ctx->arena_vm_start) {
store_offset -= sizeof(long);
emit_insn(ctx, std, REG_ARENA, LOONGARCH_GPR_SP, store_offset);
}
- prepare_bpf_tail_call_cnt(ctx, &store_offset);
-
emit_insn(ctx, addid, LOONGARCH_GPR_FP, LOONGARCH_GPR_SP, stack_adjust);
if (bpf_stack_adjust)
@@ -241,21 +223,18 @@ static void __build_epilogue(struct jit_ctx *ctx, bool is_tail_call)
load_offset -= sizeof(long);
emit_insn(ctx, ldd, LOONGARCH_GPR_S5, LOONGARCH_GPR_SP, load_offset);
+ /* Only restore the TCC state into REG_TCC from the higher slot */
+ load_offset -= sizeof(long);
+ emit_insn(ctx, ldd, REG_TCC, LOONGARCH_GPR_SP, load_offset);
+
+ /* Skip the unused local 'tcc_ptr' slot to align with arena */
+ load_offset -= sizeof(long);
+
if (ctx->arena_vm_start) {
load_offset -= sizeof(long);
emit_insn(ctx, ldd, REG_ARENA, LOONGARCH_GPR_SP, load_offset);
}
- /*
- * When push into the stack, follow the order of tcc then tcc_ptr.
- * When pop from the stack, first pop tcc_ptr then followed by tcc.
- */
- load_offset -= 2 * sizeof(long);
- emit_insn(ctx, ldd, REG_TCC, LOONGARCH_GPR_SP, load_offset);
-
- load_offset += sizeof(long);
- emit_insn(ctx, ldd, REG_TCC, LOONGARCH_GPR_SP, load_offset);
-
emit_insn(ctx, addid, LOONGARCH_GPR_SP, LOONGARCH_GPR_SP, stack_adjust);
if (!is_tail_call) {
@@ -290,17 +269,13 @@ bool bpf_jit_supports_far_kfunc_call(void)
static int emit_bpf_tail_call(struct jit_ctx *ctx, int insn)
{
- int off, tc_ninsn = 0;
+ int off, jmp_offset;
int tcc_ptr_off = BPF_TAIL_CALL_CNT_PTR_STACK_OFF(ctx->stack_size);
u8 a1 = LOONGARCH_GPR_A1;
u8 a2 = LOONGARCH_GPR_A2;
u8 t1 = LOONGARCH_GPR_T1;
u8 t2 = LOONGARCH_GPR_T2;
u8 t3 = LOONGARCH_GPR_T3;
- const int idx0 = ctx->idx;
-
-#define cur_offset (ctx->idx - idx0)
-#define jmp_offset (tc_ninsn - (cur_offset))
/*
* a0: &ctx
@@ -310,12 +285,12 @@ static int emit_bpf_tail_call(struct jit_ctx *ctx, int insn)
* if (index >= array->map.max_entries)
* goto out;
*/
- tc_ninsn = insn ? ctx->offset[insn+1] - ctx->offset[insn] : ctx->offset[0];
emit_zext_32(ctx, a2, true);
off = offsetof(struct bpf_array, map.max_entries);
emit_insn(ctx, ldwu, t1, a1, off);
/* bgeu $a2, $t1, jmp_offset */
+ jmp_offset = ctx->image ? (ctx->offset[insn + 1] - ctx->idx) : 0;
if (emit_tailcall_jmp(ctx, BPF_JGE, a2, t1, jmp_offset) < 0)
goto toofar;
@@ -326,6 +301,7 @@ static int emit_bpf_tail_call(struct jit_ctx *ctx, int insn)
emit_insn(ctx, ldd, REG_TCC, LOONGARCH_GPR_SP, tcc_ptr_off);
emit_insn(ctx, ldd, t3, REG_TCC, 0);
emit_insn(ctx, addid, t2, LOONGARCH_GPR_ZERO, MAX_TAIL_CALL_CNT);
+ jmp_offset = ctx->image ? (ctx->offset[insn + 1] - ctx->idx) : 0;
if (emit_tailcall_jmp(ctx, BPF_JSGE, t3, t2, jmp_offset) < 0)
goto toofar;
@@ -340,6 +316,7 @@ static int emit_bpf_tail_call(struct jit_ctx *ctx, int insn)
off = offsetof(struct bpf_array, ptrs);
emit_insn(ctx, ldd, t2, t2, off);
/* beq $t2, $zero, jmp_offset */
+ jmp_offset = ctx->image ? (ctx->offset[insn + 1] - ctx->idx) : 0;
if (emit_tailcall_jmp(ctx, BPF_JEQ, t2, LOONGARCH_GPR_ZERO, jmp_offset) < 0)
goto toofar;
@@ -355,8 +332,6 @@ static int emit_bpf_tail_call(struct jit_ctx *ctx, int insn)
toofar:
pr_info_once("tail_call: jump too far\n");
return -1;
-#undef cur_offset
-#undef jmp_offset
}
static void emit_store_stack_imm64(struct jit_ctx *ctx, int reg, int stack_off, u64 imm64)
|
| 3/2 | 2026/07/07 17:15 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 5457 output: 31 thoughts: 393 Thoughts: **LoongArch BPF JIT Patch Assessment** Okay, so I've got this patch affecting the LoongArch architecture, specifically modifying `arch/loongarch/include/asm/inst.h` and `arch/loongarch/net/bpf_jit.c`. It looks like new instruction formats, `sltui`, `maskeqz`, and `masknez`, have been added, which is interesting. This means they've also gone in and touched several key functions within the LoongArch BPF JIT compiler: `prepare_bpf_tail_call_cnt`, `build_prologue`, `__build_epilogue`, and `emit_bpf_tail_call`. Functionally, this is core kernel logic that impacts the BPF JIT on LoongArch. My immediate thought is, is this code reachable? BPF JIT, generally speaking, is certainly reachable, so that's not a concern. Given the architecture is LoongArch, the question shifts to whether our fuzzing setup can test this. Syzkaller doesn't usually focus on LoongArch in its main instances, but, it *can* be configured for LoongArch. It’s worth checking if we're configured. Next, is this worth fuzzing? Absolutely. This is functional core kernel logic related to the BPF JIT, so fuzzing should be considered. Let's list the functions that are being modified just to double-check: `prepare_bpf_tail_call_cnt`, `build_prologue`, `__build_epilogue`, and `emit_bpf_tail_call`. I need to confirm whether these are static or not within `arch/loongarch/net/bpf_jit.c` and what configs are necessary to build them. I expect it's likely dependent on `CONFIG_BPF_JIT` (which is typically enabled if BPF is enabled), and, of course, `CONFIG_LOONGARCH`. So, I'll quickly grep for `CONFIG_BPF_JIT` in `arch/loongarch/Kconfig` or `arch/loongarch/net/Makefile` to confirm the dependencies. |
| 4/2 | 2026/07/07 17:15 | tool | grepper |
0mArgs:{
"Expression": "BPF_JIT",
"PathPrefix": "arch/loongarch/"
}Results: {
"Output": "arch/loongarch/Kconfig=2=config LOONGARCH\n--\narch/loongarch/Kconfig-79-\tselect ARCH_USE_QUEUED_SPINLOCKS\narch/loongarch/Kconfig:80:\tselect ARCH_WANT_DEFAULT_BPF_JIT if HAVE_EBPF_JIT\narch/loongarch/Kconfig-81-\tselect ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT\n--\narch/loongarch/Kconfig-143-\tselect HAVE_DYNAMIC_FTRACE_WITH_REGS\narch/loongarch/Kconfig:144:\tselect HAVE_EBPF_JIT if 64BIT\narch/loongarch/Kconfig-145-\tselect HAVE_EFFICIENT_UNALIGNED_ACCESS if !ARCH_STRICT_ALIGN\n--\narch/loongarch/configs/loongson64_defconfig=7=CONFIG_BPF_SYSCALL=y\narch/loongarch/configs/loongson64_defconfig:8:CONFIG_BPF_JIT=y\narch/loongarch/configs/loongson64_defconfig-9-CONFIG_PREEMPT=y\n--\narch/loongarch/include/asm/extable.h=26=do {\t\t\t\t\t\t\t\\\n--\narch/loongarch/include/asm/extable.h-34-\narch/loongarch/include/asm/extable.h:35:#ifdef CONFIG_BPF_JIT\narch/loongarch/include/asm/extable.h-36-bool ex_handler_bpf(const struct exception_table_entry *ex, struct pt_regs *regs);\n--\narch/loongarch/include/asm/extable.h=39=bool ex_handler_bpf(const struct exception_table_entry *ex, struct pt_regs *regs)\n--\narch/loongarch/include/asm/extable.h-42-}\narch/loongarch/include/asm/extable.h:43:#endif /* !CONFIG_BPF_JIT */\narch/loongarch/include/asm/extable.h-44-\n--\narch/loongarch/net/Makefile-6-#\narch/loongarch/net/Makefile:7:obj-$(CONFIG_BPF_JIT) += bpf_jit.o\n--\narch/loongarch/net/bpf_jit.c=628=static int add_exception_handler(const struct bpf_insn *insn,\n--\narch/loongarch/net/bpf_jit.c-661-\t * Since the extable follows the program, the fixup offset is always\narch/loongarch/net/bpf_jit.c:662:\t * negative and limited to BPF_JIT_REGION_SIZE. Store a positive value\narch/loongarch/net/bpf_jit.c-663-\t * to keep things simple, and put the destination register in the upper\n"
} |
| 5/2 | 2026/07/07 17:15 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 7089 output: 42 thoughts: 106 Thoughts: **Analyzing BPF JIT Compilation for LoongArch** Okay, let's break this down. My initial focus is on the `BPF_JIT` configuration, and my attention is immediately drawn to a specific set of functions: `prepare_bpf_tail_call_cnt`, `build_prologue`, `__build_epilogue`, and `emit_bpf_tail_call`. Hmmm, these all seem to be static functions within `arch/loongarch/net/bpf_jit.c`. That gives me some context and tells me they're likely internal to the JIT compilation process for that architecture. I now need to understand how the compilation is invoked. I know the general structure, and my experience says the entry point is typically `bpf_int_jit_compile`. Let's confirm that's the one I need to look for, and then I can delve into the specifics of how these static functions are used within that overall flow. |
| 6/2 | 2026/07/07 17:15 | tool | grepper |
0mArgs:{
"Expression": "bpf_int_jit_compile",
"PathPrefix": "arch/loongarch/net/bpf_jit.c"
}Results: {
"Output": "arch/loongarch/net/bpf_jit.c=2157=int arch_bpf_trampoline_size(const struct btf_func_model *m, u32 flags,\n--\narch/loongarch/net/bpf_jit.c-2171-\narch/loongarch/net/bpf_jit.c:2172:struct bpf_prog *bpf_int_jit_compile(struct bpf_verifier_env *env, struct bpf_prog *prog)\narch/loongarch/net/bpf_jit.c-2173-{\n"
} |
| 7/2 | 2026/07/07 17:15 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 7604 output: 67 thoughts: 150 Thoughts: **LoongArch BPF JIT Patch Analysis** Okay, so I'm looking at this LoongArch BPF JIT code modification. The primary entry point, as far as I can see, is `bpf_int_jit_compile`. This patch seems functional, and given its nature, fuzzing it is definitely a good idea. I can immediately identify the key symbols to focus on. While I could specifically list `bpf_int_jit_compile`, syzkaller coverage should automatically pick up on the changes if they're hit. To ensure my understanding is complete, let's list the relevant functions that were actually modified in the patch. I've got: `prepare_bpf_tail_call_cnt`, `build_prologue`, `__build_epilogue`, and `emit_bpf_tail_call`. Hold on... I need to double-check something. Wasn't `__build_epilogue` a static function? Yes, I need to confirm its static nature. Better to be precise when outlining targets for fuzzing. This will affect how I approach testing this. |
| 8/2 | 2026/07/07 17:15 | tool | grepper |
0mArgs:{
"Expression": "(prepare_bpf_tail_call_cnt|build_prologue|__build_epilogue|emit_bpf_tail_call)",
"PathPrefix": "arch/loongarch/net/bpf_jit.c"
}Results: {
"Output": "arch/loongarch/net/bpf_jit.c=30=static const int regmap[] = {\n--\narch/loongarch/net/bpf_jit.c-49-\narch/loongarch/net/bpf_jit.c:50:static void prepare_bpf_tail_call_cnt(struct jit_ctx *ctx, int *store_offset)\narch/loongarch/net/bpf_jit.c-51-{\n--\narch/loongarch/net/bpf_jit.c-114- */\narch/loongarch/net/bpf_jit.c:115:static void build_prologue(struct jit_ctx *ctx)\narch/loongarch/net/bpf_jit.c-116-{\n--\narch/loongarch/net/bpf_jit.c-178-\narch/loongarch/net/bpf_jit.c:179:\tprepare_bpf_tail_call_cnt(ctx, \u0026store_offset);\narch/loongarch/net/bpf_jit.c-180-\n--\narch/loongarch/net/bpf_jit.c-196-\narch/loongarch/net/bpf_jit.c:197:static void __build_epilogue(struct jit_ctx *ctx, bool is_tail_call)\narch/loongarch/net/bpf_jit.c-198-{\n--\narch/loongarch/net/bpf_jit.c=255=static void build_epilogue(struct jit_ctx *ctx)\narch/loongarch/net/bpf_jit.c-256-{\narch/loongarch/net/bpf_jit.c:257:\t__build_epilogue(ctx, false);\narch/loongarch/net/bpf_jit.c-258-}\n--\narch/loongarch/net/bpf_jit.c=265=bool bpf_jit_supports_far_kfunc_call(void)\n--\narch/loongarch/net/bpf_jit.c-269-\narch/loongarch/net/bpf_jit.c:270:static int emit_bpf_tail_call(struct jit_ctx *ctx, int insn)\narch/loongarch/net/bpf_jit.c-271-{\n--\narch/loongarch/net/bpf_jit.c-327-\temit_insn(ctx, ldd, t3, t2, off);\narch/loongarch/net/bpf_jit.c:328:\t__build_epilogue(ctx, true);\narch/loongarch/net/bpf_jit.c-329-\n--\narch/loongarch/net/bpf_jit.c=690=static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx, bool extra_pass)\n--\narch/loongarch/net/bpf_jit.c-1188-\tcase BPF_JMP | BPF_TAIL_CALL:\narch/loongarch/net/bpf_jit.c:1189:\t\tif (emit_bpf_tail_call(ctx, i) \u003c 0)\narch/loongarch/net/bpf_jit.c-1190-\t\t\treturn -EINVAL;\n--\narch/loongarch/net/bpf_jit.c=2172=struct bpf_prog *bpf_int_jit_compile(struct bpf_verifier_env *env, struct bpf_prog *prog)\n--\narch/loongarch/net/bpf_jit.c-2216-\t/* 1. Initial fake pass to compute ctx-\u003eidx and set ctx-\u003eflags */\narch/loongarch/net/bpf_jit.c:2217:\tbuild_prologue(\u0026ctx);\narch/loongarch/net/bpf_jit.c-2218-\tif (build_body(\u0026ctx, extra_pass))\n--\narch/loongarch/net/bpf_jit.c-2255-\narch/loongarch/net/bpf_jit.c:2256:\tbuild_prologue(\u0026ctx);\narch/loongarch/net/bpf_jit.c-2257-\tif (build_body(\u0026ctx, extra_pass))\n"
} |
| 9/2 | 2026/07/07 17:15 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 9156 output: 132 thoughts: 463 Thoughts: **Analyzing the LoongArch BPF JIT Patch** Okay, let's break this down. My initial instinct is that the key functions to focus on here are `prepare_bpf_tail_call_cnt`, `build_prologue`, `__build_epilogue`, and `emit_bpf_tail_call`. These seem like the core building blocks for this tail call optimization within the BPF JIT. The configuration to enable here is clearly `BPF_JIT`, given the file modifications. Wait a minute, it looks like it modifies `arch/loongarch/include/asm/inst.h`. Ah, but that's just adding instruction definitions, not core logic. The meat of the changes is definitely in `bpf_jit.c`. So yeah, `BPF_JIT` is the right configuration. Let me just double-check, though, for any other relevant configs. `CONFIG_LOONGARCH` is implied, so no need to list that. The prompt said not to list overly generic configs. Only those that *specifically* cover the modified code. That means `BPF_JIT` is the only config to list here. The patch itself is optimizing the LoongArch BPF JIT compiler for tail call count handling by leveraging branchless instructions like `sltui`, `maskeqz`, and `masknez`. Essentially, it's modifying the prologue, epilogue, and tail call emission. That's *functional*, *core* kernel logic. This needs fuzzing, without a doubt, to make sure the JIT compiler is generating correct code and not introducing any nasty vulnerabilities. Right, time to construct the output. |
| 10/2 | 2026/07/07 17:15 | tool | set-results |
0mArgs:{
"EnableConfigs": [
"BPF_JIT"
],
"FocusSymbols": [
"prepare_bpf_tail_call_cnt",
"build_prologue",
"__build_epilogue",
"emit_bpf_tail_call"
],
"Reasoning": "The patch modifies the LoongArch BPF JIT compiler to optimize tail call count handling using branchless instructions. It alters the prologue, epilogue, and tail call emission logic, which is functional core kernel logic that should be fuzzed to ensure correct code generation.",
"WorthFuzzing": true
}Results: {
"EnableConfigs": [
"BPF_JIT"
],
"FocusSymbols": [
"prepare_bpf_tail_call_cnt",
"build_prologue",
"__build_epilogue",
"emit_bpf_tail_call"
],
"Reasoning": "The patch modifies the LoongArch BPF JIT compiler to optimize tail call count handling using branchless instructions. It alters the prologue, epilogue, and tail call emission logic, which is functional core kernel logic that should be fuzzed to ensure correct code generation.",
"WorthFuzzing": true
} |
| Total Calls | Total Tokens | Avg Tokens | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|
| Total Calls | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|