Hi Leon, kernel test robot noticed the following build errors: [auto build test ERROR on bpf-next/master] url: https://github.com/intel-lab-lkp/linux/commits/Leon-Hwang/bpf-Introduce-bpf_in_interrupt-kfunc/20250822-222727 base: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master patch link: https://lore.kernel.org/r/20250822141722.25318-2-leon.hwang%40linux.dev patch subject: [PATCH bpf-next 1/2] bpf: Introduce bpf_in_interrupt kfunc config: um-allyesconfig (https://download.01.org/0day-ci/archive/20250823/202508231629.nrRSoIUD-lkp@xxxxxxxxx/config) compiler: gcc-12 (Debian 12.2.0-14+deb12u1) 12.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250823/202508231629.nrRSoIUD-lkp@xxxxxxxxx/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@xxxxxxxxx> | Closes: https://lore.kernel.org/oe-kbuild-all/202508231629.nrRSoIUD-lkp@xxxxxxxxx/ All errors (new ones prefixed by >>): In file included from include/linux/bpf_verifier.h:9, from kernel/bpf/verifier.c:13: kernel/bpf/verifier.c: In function 'fixup_kfunc_call': >> kernel/bpf/verifier.c:21980:77: error: '__preempt_count' undeclared (first use in this function); did you mean 'preempt_count'? 21980 | insn_buf[0] = BPF_MOV64_IMM(BPF_REG_0, (u32)(unsigned long)&__preempt_count); | ^~~~~~~~~~~~~~~ include/linux/filter.h:211:26: note: in definition of macro 'BPF_MOV64_IMM' 211 | .imm = IMM }) | ^~~ kernel/bpf/verifier.c:21980:77: note: each undeclared identifier is reported only once for each function it appears in 21980 | insn_buf[0] = BPF_MOV64_IMM(BPF_REG_0, (u32)(unsigned long)&__preempt_count); | ^~~~~~~~~~~~~~~ include/linux/filter.h:211:26: note: in definition of macro 'BPF_MOV64_IMM' 211 | .imm = IMM }) | ^~~ vim +21980 kernel/bpf/verifier.c 21885 21886 static int fixup_kfunc_call(struct bpf_verifier_env *env, struct bpf_insn *insn, 21887 struct bpf_insn *insn_buf, int insn_idx, int *cnt) 21888 { 21889 const struct bpf_kfunc_desc *desc; 21890 21891 if (!insn->imm) { 21892 verbose(env, "invalid kernel function call not eliminated in verifier pass\n"); 21893 return -EINVAL; 21894 } 21895 21896 *cnt = 0; 21897 21898 /* insn->imm has the btf func_id. Replace it with an offset relative to 21899 * __bpf_call_base, unless the JIT needs to call functions that are 21900 * further than 32 bits away (bpf_jit_supports_far_kfunc_call()). 21901 */ 21902 desc = find_kfunc_desc(env->prog, insn->imm, insn->off); 21903 if (!desc) { 21904 verifier_bug(env, "kernel function descriptor not found for func_id %u", 21905 insn->imm); 21906 return -EFAULT; 21907 } 21908 21909 if (!bpf_jit_supports_far_kfunc_call()) 21910 insn->imm = BPF_CALL_IMM(desc->addr); 21911 if (insn->off) 21912 return 0; 21913 if (desc->func_id == special_kfunc_list[KF_bpf_obj_new_impl] || 21914 desc->func_id == special_kfunc_list[KF_bpf_percpu_obj_new_impl]) { 21915 struct btf_struct_meta *kptr_struct_meta = env->insn_aux_data[insn_idx].kptr_struct_meta; 21916 struct bpf_insn addr[2] = { BPF_LD_IMM64(BPF_REG_2, (long)kptr_struct_meta) }; 21917 u64 obj_new_size = env->insn_aux_data[insn_idx].obj_new_size; 21918 21919 if (desc->func_id == special_kfunc_list[KF_bpf_percpu_obj_new_impl] && kptr_struct_meta) { 21920 verifier_bug(env, "NULL kptr_struct_meta expected at insn_idx %d", 21921 insn_idx); 21922 return -EFAULT; 21923 } 21924 21925 insn_buf[0] = BPF_MOV64_IMM(BPF_REG_1, obj_new_size); 21926 insn_buf[1] = addr[0]; 21927 insn_buf[2] = addr[1]; 21928 insn_buf[3] = *insn; 21929 *cnt = 4; 21930 } else if (desc->func_id == special_kfunc_list[KF_bpf_obj_drop_impl] || 21931 desc->func_id == special_kfunc_list[KF_bpf_percpu_obj_drop_impl] || 21932 desc->func_id == special_kfunc_list[KF_bpf_refcount_acquire_impl]) { 21933 struct btf_struct_meta *kptr_struct_meta = env->insn_aux_data[insn_idx].kptr_struct_meta; 21934 struct bpf_insn addr[2] = { BPF_LD_IMM64(BPF_REG_2, (long)kptr_struct_meta) }; 21935 21936 if (desc->func_id == special_kfunc_list[KF_bpf_percpu_obj_drop_impl] && kptr_struct_meta) { 21937 verifier_bug(env, "NULL kptr_struct_meta expected at insn_idx %d", 21938 insn_idx); 21939 return -EFAULT; 21940 } 21941 21942 if (desc->func_id == special_kfunc_list[KF_bpf_refcount_acquire_impl] && 21943 !kptr_struct_meta) { 21944 verifier_bug(env, "kptr_struct_meta expected at insn_idx %d", 21945 insn_idx); 21946 return -EFAULT; 21947 } 21948 21949 insn_buf[0] = addr[0]; 21950 insn_buf[1] = addr[1]; 21951 insn_buf[2] = *insn; 21952 *cnt = 3; 21953 } else if (desc->func_id == special_kfunc_list[KF_bpf_list_push_back_impl] || 21954 desc->func_id == special_kfunc_list[KF_bpf_list_push_front_impl] || 21955 desc->func_id == special_kfunc_list[KF_bpf_rbtree_add_impl]) { 21956 struct btf_struct_meta *kptr_struct_meta = env->insn_aux_data[insn_idx].kptr_struct_meta; 21957 int struct_meta_reg = BPF_REG_3; 21958 int node_offset_reg = BPF_REG_4; 21959 21960 /* rbtree_add has extra 'less' arg, so args-to-fixup are in diff regs */ 21961 if (desc->func_id == special_kfunc_list[KF_bpf_rbtree_add_impl]) { 21962 struct_meta_reg = BPF_REG_4; 21963 node_offset_reg = BPF_REG_5; 21964 } 21965 21966 if (!kptr_struct_meta) { 21967 verifier_bug(env, "kptr_struct_meta expected at insn_idx %d", 21968 insn_idx); 21969 return -EFAULT; 21970 } 21971 21972 __fixup_collection_insert_kfunc(&env->insn_aux_data[insn_idx], struct_meta_reg, 21973 node_offset_reg, insn, insn_buf, cnt); 21974 } else if (desc->func_id == special_kfunc_list[KF_bpf_cast_to_kern_ctx] || 21975 desc->func_id == special_kfunc_list[KF_bpf_rdonly_cast]) { 21976 insn_buf[0] = BPF_MOV64_REG(BPF_REG_0, BPF_REG_1); 21977 *cnt = 1; 21978 } else if (desc->func_id == special_kfunc_list[KF_bpf_in_interrupt]) { 21979 #ifdef CONFIG_X86_64 21980 insn_buf[0] = BPF_MOV64_IMM(BPF_REG_0, (u32)(unsigned long)&__preempt_count); 21981 insn_buf[1] = BPF_MOV64_PERCPU_REG(BPF_REG_0, BPF_REG_0); 21982 insn_buf[2] = BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_0, 0); 21983 insn_buf[3] = BPF_ALU32_IMM(BPF_AND, BPF_REG_0, NMI_MASK | HARDIRQ_MASK | 21984 (IS_ENABLED(CONFIG_PREEMPT_RT) ? 0 : SOFTIRQ_MASK)); 21985 *cnt = 4; 21986 #endif 21987 } 21988 21989 if (env->insn_aux_data[insn_idx].arg_prog) { 21990 u32 regno = env->insn_aux_data[insn_idx].arg_prog; 21991 struct bpf_insn ld_addrs[2] = { BPF_LD_IMM64(regno, (long)env->prog->aux) }; 21992 int idx = *cnt; 21993 21994 insn_buf[idx++] = ld_addrs[0]; 21995 insn_buf[idx++] = ld_addrs[1]; 21996 insn_buf[idx++] = *insn; 21997 *cnt = idx; 21998 } 21999 return 0; 22000 } 22001 -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki