[llvm-dev] bpf compilation using clang
Sameeh Jubran via llvm-dev
llvm-dev at lists.llvm.org
Thu Sep 13 02:58:13 PDT 2018
Hi all,
I am trying to insert instructions into the bpf using the bpf syscall,
the instructions were generated using the following command line:
clang -I ~/Builds/bpf_rss/iproute2/include -Wall -target bpf -O2
-emit-llvm -c upstream/qemu/hw/net/rss_tap_bpf_program.c -o - | llc
-march=bpf -filetype=obj -o tap_bpf_program.o
and then were translated to bpf instructions using the BPFCparser tool
Every time I try to insert the array of instructions the verfier fails
with the following error:
back-edge from insn 363 to 364
or something similar even though the compilation succeeds.
I have multiple maps in my code and I translate only the code section
to bpf insns structure and insert it using the bpf syscall as follows:
memset(&attr, 0, sizeof(attr));
attr.prog_type = BPF_PROG_TYPE_SOCKET_FILTER;
attr.insn_cnt = ARRAY_SIZE(l3_l4_hash_insns);
attr.insns = (__u64) (unsigned long) (l3_l4_hash_insns);
attr.license = (__u64) (unsigned long) ("Dual BSD/GPL");
attr.log_buf = (__u64) (unsigned long) (buffer);
attr.log_level = 7;
attr.log_size = BUFF_LEN;
attr.kern_version = 0;
ret = sys_bpf(BPF_PROG_LOAD, &attr, sizeof(attr));
I am not sure how to debug this error since the instructions are in
binary and the precompiled source code doesn't seem to contain any
weird loops or goto instructions...
Is there a way to identify which line of source code is causing these errors?
Thanks!
More information about the llvm-dev
mailing list