On Mon, Jan 27, 2025 at 8:22 AM Leon Hwang <leon.hwang@xxxxxxxxx> wrote: > > + > +static int percpu_array_map_direct_value_meta(const struct bpf_map *map, > + u64 imm, u32 *off) > +{ > + struct bpf_array *array = container_of(map, struct bpf_array, map); > + u64 base = (u64) array->pptrs[0]; > + u64 range = array->elem_size; > + > + if (map->max_entries != 1) > + return -EOPNOTSUPP; > + if (imm < base || imm >= base + range) > + return -ENOENT; > + if (!bpf_jit_supports_percpu_insn()) > + return -EOPNOTSUPP; > + > + *off = imm - base; > + return 0; > +} Pls add a selftest for off != 0. I think the above should work, but this is not obvious. > > +#ifdef CONFIG_SMP > + if (insn->code == (BPF_LD | BPF_IMM | BPF_DW) && > + (insn->src_reg == BPF_PSEUDO_MAP_VALUE || > + insn->src_reg == BPF_PSEUDO_MAP_IDX_VALUE)) { Is there a selftest for BPF_PSEUDO_MAP_IDX_VALUE part ? I couldn't find it.