Skip to content
This repository has been archived by the owner on Feb 4, 2023. It is now read-only.

CONFIG_BPF_SYSCALL is undefined #10

Closed
Linuxuser4 opened this issue Aug 2, 2018 · 5 comments
Closed

CONFIG_BPF_SYSCALL is undefined #10

Linuxuser4 opened this issue Aug 2, 2018 · 5 comments

Comments

@Linuxuser4
Copy link

Hi,
I am trying to get adeb-BCC working on a Hikey970 android platform. This has 4.9 kernel flashed. I got the BCC compiled in adeb environment.
I built the kernel with required configurations enabled in kernel as per the page https://github.com/joelagnel/adeb/blob/master/BCC.md. I made sure CONFIG_BPF_SYSCALL is enabled by putting a kernel print.
But, any BCC tool I use including hello_world.py complains that CONFIG_BPF_SYSCALL is not enabled. Below is detailed log. Any pointers would be of great help !

root@localhost:/# /usr/share/bcc/examples/hello_world.py
In file included from :3:
/virtual/include/bcc/helpers.h:26:2: error: "CONFIG_BPF_SYSCALL is undefined, please check your .config or ask your Linux distro to enable this feature"
#error "CONFIG_BPF_SYSCALL is undefined, please check your .config or ask your Linux distro to enable this feature"
^
1 error generated.
Traceback (most recent call last):
File "/usr/share/bcc/examples/hello_world.py", line 12, in
BPF(text='int kprobe__sys_clone(void *ctx) { bpf_trace_printk("Hello, World!\n"); return 0; }').trace_print()
File "/usr/lib/python2.7/dist-packages/bcc/init.py", line 318, in init
raise Exception("Failed to compile BPF text")
Exception: Failed to compile BPF text
root@localhost:/#

@joelagnel
Copy link
Owner

joelagnel commented Aug 2, 2018 via email

@Linuxuser4
Copy link
Author

Linuxuser4 commented Aug 3, 2018

I realized the mistake. Original kernel headers on target did not have CONFIG_BPF_SYSCALL enabled. I then flashed new kernel with CONFIG_BPF_SYSCALL. I had failed to update the kernel headers using adeb prepare. I had to remove adeb and reinstall adeb with new kernel path. This makes sure new kernel headers are updated on target. Even though new kernel is flashed, header also needs to be updated in androdeb in target.

I could get filetop (and a few other) command(s) working, though hello_world.py hangs. If I try to quit, it displays following message. It may not be of much consequence, though I wished this basic command to work.
root@localhost:/bcc-master# /usr/share/bcc/examples/hello_world.py
^CTraceback (most recent call last):
File "/usr/share/bcc/examples/hello_world.py", line 12, in
BPF(text='int kprobe__sys_clone(void *ctx) { bpf_trace_printk("Hello, World!\n"); return 0; }').trace_print()
File "/usr/lib/python2.7/dist-packages/bcc/init.py", line 1119, in trace_print
line = self.trace_readline(nonblocking=False)
File "/usr/lib/python2.7/dist-packages/bcc/init.py", line 1099, in trace_readline
line = trace.readline(1024).rstrip()
KeyboardInterrupt
root@localhost:/bcc-master#

@Linuxuser4
Copy link
Author

Linuxuser4 commented Aug 3, 2018

Also, by default, bcc native compilation on target board failed. I made following 2 changes for successful compilation on target. Thought of letting you know:

  1. A softlink to stdc++ was required since compilation complained of missing stdc++ library.
    ln -s /usr/lib/gcc/aarch64-linux-gnu/7/libstdc++.so /usr/lib/libstdc++.so

  2. Two include paths needed to be provided to avoid missing header error. These were added in CMakeLists.txt in the base folder:
    include_directories(/usr/include/c++/7/)
    include_directories(/usr/include/aarch64-linux-gnu/c++/7/)

@joelagnel
Copy link
Owner

Feel free to follow up with this on BCC's issue list, or send a patch there if you feel something needs fixing there, your contribution there and here are appreciated! Closing this for now.

@CodeForeverZou
Copy link

CodeForeverZou commented Sep 3, 2021

uname -r get the system kernel version,
if different with the built kernel version.
you need to build the kernel which same with the 'uname -r'

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

No branches or pull requests

3 participants