Add missing linux/bpf_common.h
Subsystems (3)
PATCH 1/1 Add missing linux/bpf_common.h
Copy from [1], needed by bpf.h.
--- include/linux/bpf_common.h | 57 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 include/linux/bpf_common.h
include/linux/bpf_common.h new file +57 -0
@@ -0,0 +1,57 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef _UAPI__LINUX_BPF_COMMON_H__ +#define _UAPI__LINUX_BPF_COMMON_H__ + +/* Instruction classes */ +#define BPF_CLASS (code) ((code) & 0x07) +#define BPF_LD 0x00 +#define BPF_LDX 0x01 +#define BPF_ST 0x02 +#define BPF_STX 0x03 +#define BPF_ALU 0x04 +#define BPF_JMP 0x05 +#define BPF_RET 0x06 +#define BPF_MISC 0x07 + +/* ld/ldx fields */ +#define BPF_SIZE (code) ((code) & 0x18) +#define BPF_W 0x00/* 32-bit */ +#define BPF_H 0x08/* 16-bit */ +#define BPF_B 0x10/* 8-bit */ +/* eBPF BPF_DW 0x18 64-bit */ +#define BPF_MODE (code) ((code) & 0xe0) +#define BPF_IMM 0x00 +#define BPF_ABS 0x20 +#define BPF_IND 0x40 +#define BPF_MEM 0x60 +#define BPF_LEN 0x80 +#define BPF_MSH 0xa0 + +/* alu/jmp fields */ +#define BPF_OP (code) ((code) & 0xf0) +#define BPF_ADD 0x00 +#define BPF_SUB 0x10 +#define BPF_MUL 0x20 +#define BPF_DIV 0x30 +#define BPF_OR 0x40 +#define BPF_AND 0x50 +#define BPF_LSH 0x60 +#define BPF_RSH 0x70 +#define BPF_NEG 0x80 +#define BPF_MOD 0x90 +#define BPF_XOR 0xa0 + +#define BPF_JA 0x00 +#define BPF_JEQ 0x10 +#define BPF_JGT 0x20 +#define BPF_JGE 0x30 +#define BPF_JSET 0x40 +#define BPF_SRC (code) ((code) & 0x08) +#define BPF_K 0x00 +#define BPF_X 0x08 + +#ifndef BPF_MAXINSNS +#define BPF_MAXINSNS 4096 +#endif + +#endif /* _UAPI__LINUX_BPF_COMMON_H__ */
Signature · 1 line
2.19.1
Quoted 3 lines · Peter Seiderer
Copy from [1], needed by
bpf.h.
So bpf.h does include this file, but we don't use anything from it in v4l-utils.
This include file is for the original BPF, which has been around for a long time. So why is this include file missing, i.e. what problem are you trying to solve?
Lastely, the file should be included in the sync-with-kernel target so it does not get out of sync -- should it really be necessary to add the file.
Sean
Quoted 72 lines
Signed-off-by Peter Seiderer <[email protected]>--- include/linux/bpf_common.h | 57 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 include/linux/bpf_common.hinclude/linux/bpf_common.h new file +57
-0@@ -0,0 +1,57 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef _UAPI__LINUX_BPF_COMMON_H__ +#define _UAPI__LINUX_BPF_COMMON_H__ + +/* Instruction classes */ +#define BPF_CLASS (code) ((code) & 0x07) +#define BPF_LD 0x00 +#define BPF_LDX 0x01 +#define BPF_ST 0x02 +#define BPF_STX 0x03 +#define BPF_ALU 0x04 +#define BPF_JMP 0x05 +#define BPF_RET 0x06 +#define BPF_MISC 0x07 + +/* ld/ldx fields */ +#define BPF_SIZE (code) ((code) & 0x18) +#define BPF_W 0x00/* 32-bit */ +#define BPF_H 0x08/* 16-bit */ +#define BPF_B 0x10/* 8-bit */ +/* eBPF BPF_DW 0x18 64-bit */ +#define BPF_MODE (code) ((code) & 0xe0) +#define BPF_IMM 0x00 +#define BPF_ABS 0x20 +#define BPF_IND 0x40 +#define BPF_MEM 0x60 +#define BPF_LEN 0x80 +#define BPF_MSH 0xa0 + +/* alu/jmp fields */ +#define BPF_OP (code) ((code) & 0xf0) +#define BPF_ADD 0x00 +#define BPF_SUB 0x10 +#define BPF_MUL 0x20 +#define BPF_DIV 0x30 +#define BPF_OR 0x40 +#define BPF_AND 0x50 +#define BPF_LSH 0x60 +#define BPF_RSH 0x70 +#define BPF_NEG 0x80 +#define BPF_MOD 0x90 +#define BPF_XOR 0xa0 + +#define BPF_JA 0x00 +#define BPF_JEQ 0x10 +#define BPF_JGT 0x20 +#define BPF_JGE 0x30 +#define BPF_JSET 0x40 +#define BPF_SRC (code) ((code) & 0x08) +#define BPF_K 0x00 +#define BPF_X 0x08 + +#ifndef BPF_MAXINSNS +#define BPF_MAXINSNS 4096 +#endif + +#endif /* _UAPI__LINUX_BPF_COMMON_H__ */ Signature · 1 line
2.19.1
Hello Sean,
Quoted 8 lines · Sean Young
Quoted 3 lines · Peter Seiderer
Copy from [1], needed by
bpf.h.So
bpf.hdoes include this file, but we don't use anything from it in v4l-utils.
Maybe alternative fix is to remove the include (or not if your want the headers to be in sync with the kernel ones, but then they should be complete enough to be used for compile)?
Quoted 3 lines
This include file is for the original BPF, which has been around for a long time. So why is this include file missing, i.e. what problem are you trying to solve?
A buildroot autobuild failure (see [1] for details) with older toolchains not providing this header...
Quoted 4 lines
Lastely, the file should be included in the sync-with-kernel target so it does not get out of sync -- should it really be necessary to add the file.
O.k, can do it on next patch iteration...
Regards,
Peter
[1] http://lists.busybox.net/pipermail/buildroot/2018-November/234840.html
Quoted 76 lines
Sean
Quoted 72 lines
Signed-off-by Peter Seiderer <[email protected]>--- include/linux/bpf_common.h | 57 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 include/linux/bpf_common.hinclude/linux/bpf_common.h new file +57
-1@@ -0,0 +1,57 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef _UAPI__LINUX_BPF_COMMON_H__ +#define _UAPI__LINUX_BPF_COMMON_H__ + +/* Instruction classes */ +#define BPF_CLASS (code) ((code) & 0x07) +#define BPF_LD 0x00 +#define BPF_LDX 0x01 +#define BPF_ST 0x02 +#define BPF_STX 0x03 +#define BPF_ALU 0x04 +#define BPF_JMP 0x05 +#define BPF_RET 0x06 +#define BPF_MISC 0x07 + +/* ld/ldx fields */ +#define BPF_SIZE (code) ((code) & 0x18) +#define BPF_W 0x00/* 32-bit */ +#define BPF_H 0x08/* 16-bit */ +#define BPF_B 0x10/* 8-bit */ +/* eBPF BPF_DW 0x18 64-bit */ +#define BPF_MODE (code) ((code) & 0xe0) +#define BPF_IMM 0x00 +#define BPF_ABS 0x20 +#define BPF_IND 0x40 +#define BPF_MEM 0x60 +#define BPF_LEN 0x80 +#define BPF_MSH 0xa0 + +/* alu/jmp fields */ +#define BPF_OP (code) ((code) & 0xf0) +#define BPF_ADD 0x00 +#define BPF_SUB 0x10 +#define BPF_MUL 0x20 +#define BPF_DIV 0x30 +#define BPF_OR 0x40 +#define BPF_AND 0x50 +#define BPF_LSH 0x60 +#define BPF_RSH 0x70 +#define BPF_NEG 0x80 +#define BPF_MOD 0x90 +#define BPF_XOR 0xa0 + +#define BPF_JA 0x00 +#define BPF_JEQ 0x10 +#define BPF_JGT 0x20 +#define BPF_JGE 0x30 +#define BPF_JSET 0x40 +#define BPF_SRC (code) ((code) & 0x08) +#define BPF_K 0x00 +#define BPF_X 0x08 + +#ifndef BPF_MAXINSNS +#define BPF_MAXINSNS 4096 +#endif + +#endif /* _UAPI__LINUX_BPF_COMMON_H__ */ --2.19.1
Hi Peter,
Quoted 27 lines · Peter Seiderer
Quoted 8 lines · Sean Young
Quoted 3 lines · Peter Seiderer
Copy from [1], needed by
bpf.h.So
bpf.hdoes include this file, but we don't use anything from it in v4l-utils.Maybe alternative fix is to remove the include (or not if your want the headers to be in sync with the kernel ones, but then they should be complete enough to be used for compile)?
Quoted 3 lines
This include file is for the original BPF, which has been around for a long time. So why is this include file missing, i.e. what problem are you trying to solve?
A buildroot autobuild failure (see [1] for details) with older toolchains not providing this header...
Quoted 4 lines
Lastely, the file should be included in the sync-with-kernel target so it does not get out of sync -- should it really be necessary to add the file.
Quoted 6 lines
O.k, can do it on next patch iteration...
Regards,
Peter[1] http://lists.busybox.net/pipermail/buildroot/2018-November/234840.html
So here libelf was not detected, hence ir-keytable should have been built without BPF support, but it is still including bpf.h despite it not being used.
I've just sent a patch for better support for building without BPF, see here:
https://patchwork.linuxtv.org/patch/52841/
Would you mind seeing if that works for you?
Thanks,
Sean
Hello Sean,
Quoted 41 lines · Sean Young
Hi Peter,
Quoted 27 lines · Peter Seiderer
Quoted 8 lines · Sean Young
Quoted 3 lines · Peter Seiderer
Copy from [1], needed by
bpf.h.So
bpf.hdoes include this file, but we don't use anything from it in v4l-utils.Maybe alternative fix is to remove the include (or not if your want the headers to be in sync with the kernel ones, but then they should be complete enough to be used for compile)?
Quoted 3 lines
This include file is for the original BPF, which has been around for a long time. So why is this include file missing, i.e. what problem are you trying to solve?
A buildroot autobuild failure (see [1] for details) with older toolchains not providing this header...
Quoted 4 lines
Lastely, the file should be included in the sync-with-kernel target so it does not get out of sync -- should it really be necessary to add the file.
Quoted 6 lines
O.k, can do it on next patch iteration...
Regards,
Peter[1] http://lists.busybox.net/pipermail/buildroot/2018-November/234840.html
So here libelf was not detected, hence ir-keytable should have been built without BPF support, but it is still including
bpf.hdespite it not being used.
Quoted 6 lines
I've just sent a patch for better support for building without BPF, see here:
https://patchwork.linuxtv.org/patch/52841/Would you mind seeing if that works for you?
Thanks, works for the buildroot use case (disabling bpf support unconditionally)...
The reason to provide copies of the linux kernel headers in v4l-utils is to be independent of old(-er) headers provided by toolchains?
If so a copy of bpf_common.h is still needed (and the fallback, for out of linux kernel usage, define for __NR_bpf in bpf.h enhanced for all supported archs)?
Regards,
Peter
Quoted 5 lines
Thanks,
Sean
Hi Peter,
Quoted 9 lines · Peter Seiderer
Thanks, works for the buildroot use case (disabling bpf support unconditionally)...
The reason to provide copies of the linux kernel headers in v4l-utils is to be independent of old(-er) headers provided by toolchains?
If so a copy of
bpf_common.his still needed (and the fallback, for out of linux kernel usage, define for__NR_bpfinbpf.henhanced for all supported archs)?
I have seen this problem on debian 7. Why do we care about compiling on something that ancient?
Sean
Hello Sean,
Quoted 9 lines · Sean Young
Hi Peter,
Quoted 6 lines · Peter Seiderer
Thanks, works for the buildroot use case (disabling bpf support unconditionally)...
The reason to provide copies of the linux kernel headers in v4l-utils is to be independent of old(-er) headers provided by toolchains?
Quoted 6 lines
Quoted 3 lines
If so a copy of
bpf_common.his still needed (and the fallback, for out of linux kernel usage, define for__NR_bpfinbpf.henhanced for all supported archs)?I have seen this problem on debian 7. Why do we care about compiling on something that ancient?
It is not about compiling on what system, it is about which toolchain is used (for cross-compile), and the initial failure comes from the buildroot [1] embedded system autobuild tests...
Personally I do not care about these toolchains (but the buildroot people think it is worth to do automatic build tests with them) and can live with the disabling of the bpf support....
Regards,
Peter
Quoted 3 lines
Sean