Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile error, kernel version 4.19 #220

Open
zhanglianjie-163 opened this issue May 31, 2021 · 7 comments
Open

Compile error, kernel version 4.19 #220

zhanglianjie-163 opened this issue May 31, 2021 · 7 comments
Assignees

Comments

@zhanglianjie-163
Copy link

What is the version of clang required? My clang version is clang-7 .

/home/zkf/workspace/x86-kernel/arch/x86/include/asm/atomic.h:125:2: error: 'asm goto' constructs are not supported yet GEN_UNARY_RMWcc(LOCK_PREFIX "decl", v->counter, "%0", e); ^ /home/zkf/workspace/x86-kernel/arch/x86/include/asm/rmwcc.h:42:2: note: expanded from macro 'GEN_UNARY_RMWcc' __GEN_RMWcc(op " " arg0, var, cc, __CLOBBERS_MEM()) ^ /home/zkf/workspace/x86-kernel/arch/x86/include/asm/rmwcc.h:13:2: note: expanded from macro '__GEN_RMWcc' asm_volatile_goto (fullop "; j" #cc " %l[cc_label]" \ ^ /home/zkf/workspace/x86-kernel/include/linux/compiler_types.h:155:37: note: expanded from macro 'asm_volatile_goto' #define asm_volatile_goto(x...) asm goto(x) ^ In file included from cachestat_kern.c:2: In file included from /home/zkf/workspace/x86-kernel/include/linux/bpf.h:12: In file included from /home/zkf/workspace/x86-kernel/include/linux/workqueue.h:9: In file included from /home/zkf/workspace/x86-kernel/include/linux/timer.h:6: In file included from /home/zkf/workspace/x86-kernel/include/linux/ktime.h:24: In file included from /home/zkf/workspace/x86-kernel/include/linux/time.h:6: In file included from /home/zkf/workspace/x86-kernel/include/linux/seqlock.h:36: In file included from /home/zkf/workspace/x86-kernel/include/linux/spinlock.h:51: In file included from /home/zkf/workspace/x86-kernel/include/linux/preempt.h:81: In file included from /home/zkf/workspace/x86-kernel/arch/x86/include/asm/preempt.h:7: In file included from /home/zkf/workspace/x86-kernel/include/linux/thread_info.h:38: In file included from /home/zkf/workspace/x86-kernel/arch/x86/include/asm/thread_info.h:53: In file included from /home/zkf/workspace/x86-kernel/arch/x86/include/asm/cpufeature.h:5: In file included from /home/zkf/workspace/x86-kernel/arch/x86/include/asm/processor.h:21: In file included from /home/zkf/workspace/x86-kernel/arch/x86/include/asm/msr.h:67: /home/zkf/workspace/x86-kernel/arch/x86/include/asm/atomic.h:139:2: error: 'asm goto' constructs are not supported yet GEN_UNARY_RMWcc(LOCK_PREFIX "incl", v->counter, "%0", e); ^ /home/zkf/workspace/x86-kernel/arch/x86/include/asm/rmwcc.h:42:2: note: expanded from macro 'GEN_UNARY_RMWcc' __GEN_RMWcc(op " " arg0, var, cc, __CLOBBERS_MEM()) ^ /home/zkf/workspace/x86-kernel/arch/x86/include/asm/rmwcc.h:13:2: note: expanded from macro '__GEN_RMWcc' asm_volatile_goto (fullop "; j" #cc " %l[cc_label]" \ ^ /home/zkf/workspace/x86-kernel/include/linux/compiler_types.h:155:37: note: expanded from macro 'asm_volatile_goto' #define asm_volatile_goto(x...) asm goto(x)

@zhanglianjie-163
Copy link
Author

图片

@thiagoftsm
Copy link
Contributor

Hello @lianjiezhang ,

Please, can you give us the distribution that you are running?
I took a look on our CentOS Docker image, and we are using clang 7.0.1, but to compile our eBPF programs on CentOS 7, we are using scl.

Best regards!

@thiagoftsm thiagoftsm self-assigned this May 31, 2021
@zhanglianjie-163
Copy link
Author

zhanglianjie-163 commented Jun 1, 2021

1. Kernel version information
#uname -a
Linux zkf-PC 4.19.0-desktop-amd64 #3014 SMP Tue Nov 17 18:26:27 CST 2020 x86_64 GNU/Linux
#cat /etc/debian_version
10.6

2. I used the following method to solve this problem
Add at the head of each kernel/*.c :
#ifdef asm_volatile_goto
#undef asm_volatile_goto
#define asm_volatile_goto(x...)
#endif
3. Run ./libexec/netdata/plugins.d/ebpf.plugin error

图片

@thiagoftsm Thank you.

@thiagoftsm
Copy link
Contributor

Great, we fixed the first step. Lets go for the next problem, because it looks like your kernel is not having the expected syscall name, please, can you check the name given for sync running the following command:

bash-5.1$ grep sys_sync /proc/kallsyms 
0000000000000000 T ksys_sync_helper
0000000000000000 T __ia32_sys_syncfs
0000000000000000 T __x64_sys_syncfs
0000000000000000 T ksys_sync
0000000000000000 t __do_sys_sync
0000000000000000 T __ia32_sys_sync
0000000000000000 T __x64_sys_sync
0000000000000000 T __x64_sys_sync_file_range
0000000000000000 T __x64_sys_sync_file_range2
0000000000000000 T __ia32_sys_sync_file_range
0000000000000000 T __ia32_sys_sync_file_range2
0000000000000000 T ksys_sync_file_range
0000000000000000 r __ksymtab_ksys_sync_helper
0000000000000000 r __kstrtab_ksys_sync_helper
0000000000000000 r __kstrtabns_ksys_sync_helper
0000000000000000 d _eil_addr___ia32_sys_sync_file_range2
0000000000000000 d _eil_addr___x64_sys_sync_file_range2
0000000000000000 d _eil_addr___ia32_sys_sync_file_range
0000000000000000 d _eil_addr___x64_sys_sync_file_range
0000000000000000 d _eil_addr___ia32_sys_syncfs
0000000000000000 d _eil_addr___x64_sys_syncfs
0000000000000000 d _eil_addr___ia32_sys_sync
0000000000000000 d _eil_addr___x64_sys_sync

@zhanglianjie-163
Copy link
Author

The following is the kernel traceable function and kernel bpf related configuration.

tracepoint:

zkf@zkf-PC:~/workspace$ grep -E '__x64_sys_sync$|do_sys_open|inet_csk_accept' /proc/kallsyms 
0000000000000000 T do_sys_open
0000000000000000 T __x64_sys_sync
0000000000000000 T inet_csk_accept
0000000000000000 r __ksymtab_inet_csk_accept
0000000000000000 r __kstrtab_inet_csk_accept
0000000000000000 t _eil_addr___x64_sys_sync
zkf@zkf-PC:~/workspace$ sudo bpftrace -l | grep -E '__x64_sys_sync$|do_sys_open|inet_csk_accept'
kprobe:do_sys_open
kprobe:inet_csk_accept

kernel configuration:

zkf@zkf-PC:~/workspace$ cat /boot/config-4.19.0-desktop-amd64 | grep -i bpf
CONFIG_CGROUP_BPF=y
CONFIG_BPF=y
CONFIG_BPF_SYSCALL=y
# CONFIG_BPF_JIT_ALWAYS_ON is not set
CONFIG_IPV6_SEG6_BPF=y
CONFIG_NETFILTER_XT_MATCH_BPF=m
# CONFIG_BPFILTER is not set
CONFIG_NET_CLS_BPF=m
CONFIG_NET_ACT_BPF=m
CONFIG_BPF_JIT=y
CONFIG_BPF_STREAM_PARSER=y
CONFIG_LWTUNNEL_BPF=y
CONFIG_HAVE_EBPF_JIT=y
CONFIG_BPF_EVENTS=y
# CONFIG_BPF_KPROBE_OVERRIDE is not set
CONFIG_TEST_BPF=m
zkf@zkf-PC:~/workspace$ cat /boot/config-4.19.0-desktop-amd64 | grep -i kprobe
CONFIG_KPROBES=y
CONFIG_KPROBES_ON_FTRACE=y
CONFIG_HAVE_KPROBES=y
CONFIG_HAVE_KPROBES_ON_FTRACE=y
CONFIG_KPROBE_EVENTS=y
# CONFIG_KPROBE_EVENTS_ON_NOTRACE is not set
# CONFIG_BPF_KPROBE_OVERRIDE is not set
# CONFIG_KPROBES_SANITY_TEST is not set

I guess it is caused by kernel configuration items or llvm compilation .

@thiagoftsm Thanks

@thiagoftsm
Copy link
Contributor

Hello @lianjiezhang ,

Firstly sorry for the delay, I was busy with a conference this week and I am also working to bring more features for eBPF.plugin .
In theory you have what is expected to run compiled, the problem looks like another. The message .. loading object file failed happens when the kernel tries to load the file, but it is rejected by the eBPF loader, because it probably found an event that is not expected, for example a code that is interpreted as a loop.

I have a Debian 10.9 running and I do not remember to have any error like this on it, I will take a look again in few hours, to be sure I did not miss nothing. Now is too late for me and I will stop to avoid identify problems that do not exist.

Have a nice day!

@zhanglianjie-163
Copy link
Author

It doesn't matter, I have two systems based on the Debian 10 version, one of which is normal, and there is no difference between the two versions of BPF-related kernel configuration.
Is there a stricter BPF bytecode verification configuration item in the kernel?
@thiagoftsm Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants