On Wed, Mar 24, 2021 at 06:51:42PM -0700, Martin KaFai Lau wrote: > ref_tname = btf_name_by_offset(btf, ref_t->name_off); > - if (btf_get_prog_ctx_type(log, btf, t, env->prog->type, i)) { > + if (btf_is_kernel(btf)) { > + const struct btf_type *reg_ref_t; > + const struct btf *reg_btf; > + const char *reg_ref_tname; > + u32 reg_ref_id; > + > + if (!btf_type_is_struct(ref_t)) { > + bpf_log(log, "kernel function %s args#%d pointer type %s %s is not supported\n", > + func_name, i, btf_type_str(ref_t), > + ref_tname); > + return -EINVAL; > + } Looks great. Applied to bpf-next. Please follow up: - the argument restriction of scalar and ptr_to_btf_id above should be easy to overcome. I think either if (ptr_to_mem_ok) bit will be able to handle it or ptr_to_btf_id can point to int/long type. I hope some minor refactoring of these two cases will make kfunc calling more usable. And since the code will be common would be great to add ptr_to_btf_id support to global funcs as well. Currently ptr to struct is ptr_to_mem, so all types inside the struct are just memory. - please update selftest/bpf/README.rst with llvm diff url that added support for extern funcs in BTF. - please update bpf_design_QA.rst to make it clear that kfunc calling is not an ABI. The kernel functions protos will change and progs will be rejected by the verifier. Pretty much what is already in this commit log. Just copy paste into the doc, so it doesn't get lost in git history.