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

bpf, mips: Fix build errors about __NR_bpf undeclared #2196

Closed
wants to merge 2 commits into from

Conversation

kernel-patches-bot
Copy link

Pull request for series with
subject: bpf, mips: Fix build errors about __NR_bpf undeclared
version: 1
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=585061

@kernel-patches-bot
Copy link
Author

Master branch: fa721d4
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=585061
version: 1

@kernel-patches-bot
Copy link
Author

At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=585061 expired. Closing PR.

@kernel-patches-bot
Copy link
Author

Master branch: fa721d4
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=585569
version: 2

@kernel-patches-bot
Copy link
Author

Master branch: e4f7ac9
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=585569
version: 2

@kernel-patches-bot
Copy link
Author

Master branch: 2fe256a
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=585569
version: 2

Nobody and others added 2 commits November 25, 2021 15:20
Add the __NR_bpf definitions to fix the following build errors for mips.

 $ cd tools/bpf/bpftool
 $ make
 [...]
 bpf.c:54:4: error: #error __NR_bpf not defined. libbpf does not support your arch.
  #  error __NR_bpf not defined. libbpf does not support your arch.
     ^~~~~
 bpf.c: In function ‘sys_bpf’:
 bpf.c:66:17: error: ‘__NR_bpf’ undeclared (first use in this function); did you mean ‘__NR_brk’?
   return syscall(__NR_bpf, cmd, attr, size);
                  ^~~~~~~~
                  __NR_brk
 [...]
 In file included from gen_loader.c:15:0:
 skel_internal.h: In function ‘skel_sys_bpf’:
 skel_internal.h:53:17: error: ‘__NR_bpf’ undeclared (first use in this function); did you mean ‘__NR_brk’?
   return syscall(__NR_bpf, cmd, attr, size);
                  ^~~~~~~~
                  __NR_brk

We can see the following generated definitions:

 $ grep -r "#define __NR_bpf" arch/mips
 arch/mips/include/generated/uapi/asm/unistd_o32.h:#define __NR_bpf (__NR_Linux + 355)
 arch/mips/include/generated/uapi/asm/unistd_n64.h:#define __NR_bpf (__NR_Linux + 315)
 arch/mips/include/generated/uapi/asm/unistd_n32.h:#define __NR_bpf (__NR_Linux + 319)

The __NR_Linux is defined in arch/mips/include/uapi/asm/unistd.h:

 $ grep -r "#define __NR_Linux" arch/mips
 arch/mips/include/uapi/asm/unistd.h:#define __NR_Linux	4000
 arch/mips/include/uapi/asm/unistd.h:#define __NR_Linux	5000
 arch/mips/include/uapi/asm/unistd.h:#define __NR_Linux	6000

That is to say, __NR_bpf is
4000 + 355 = 4355 for mips o32,
6000 + 319 = 6319 for mips n32,
5000 + 315 = 5315 for mips n64.

So use the GCC pre-defined macro _ABIO32, _ABIN32 and _ABI64 [1] to define
the corresponding __NR_bpf.

This patch is similar with commit bad1926 ("bpf, s390: fix build for
libbpf and selftest suite").

[1] https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/config/mips/mips.h#l549

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
@kernel-patches-bot
Copy link
Author

Master branch: 8f6f41f
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=585569
version: 2

@kernel-patches-bot
Copy link
Author

At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=585569 irrelevant now. Closing PR.

@kernel-patches-bot kernel-patches-bot deleted the series/585061=>bpf-next branch November 26, 2021 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant