I want the value in the bpf hash map be a struct, but it doesn't work. who knows if this is allowed by BPF? code like blow.
also, I have the second question, how can I call a kernel function in the bpf program?
typedef struct my_value {
u64 ts;
unsigned char opcode;
unsigned int pages;
pid_t pid;
} MY_VAL;
struct {
__uint(type, BPF_MAP_TYPE_HASH);
__uint(max_entries, 8192);
//__type(key, pid_t);
__type(key, u64);
__type(value, MY_VAL);
} _start SEC(".maps");
when I use
struct my_value e;
e.pages= 10;
u64 pate = 0x456;
bpf_map_update_elem(&_start, &pate, &e, BPF_ANY);
there is error :
79: (85) call bpf_map_update_elem#2 invalid indirect read from stack off -32+0 size 8 processed 51 insns (limit 1000000) max_states_per_insn 0 total_states 3 peak_states 3 mark_read 1
bpf_map_update_elem()orbpf_trace_printk().