bpf: fix bpf_prog_pack build for ppc64_defconfig
Subsystems (4)
Song Liu
reviewerPATCH v2 1/1 bpf: fix bpf_prog_pack build for ppc64_defconfig
bpf_prog_pack causes build error with powerpc ppc64_defconfig:
kernel/bpf/core.c:830:23: error: variably modified 'bitmap' at file scope
830 | unsigned long bitmap[BITS_TO_LONGS(BPF_PROG_CHUNK_COUNT)];
| ^~~~~~
This is because the marco expands as:
unsigned long bitmap[((((((1UL) << (16 + __pte_index_size)) / (1 << 6))) \
+ ((sizeof(long) * 8)) - 1) / ((sizeof(long) * 8)))];
where __pte_index_size is a global variable.
Fix it by turning bitmap into a 0-length array.
---
v2: add information about the build failure.
--- kernel/bpf/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/bpf/core.c +2 -2
@@ -827,7 +827,7 @@ int bpf_jit_add_poke_descriptor(struct bpf_prog *prog,struct bpf_prog_pack {struct list_head list;void *ptr; -unsigned long bitmap[BITS_TO_LONGS (BPF_PROG_CHUNK_COUNT )]; +unsigned long bitmap[]; };#define BPF_PROG_MAX_PACK_PROG_SIZE BPF_PROG_PACK_SIZE
@@ -840,7 +840,7 @@ static struct bpf_prog_pack *alloc_new_pack(void) {struct bpf_prog_pack *pack; - pack =kzalloc (sizeof (*pack),GFP_KERNEL ); + pack =kzalloc (sizeof (*pack) +BITS_TO_BYTES (BPF_PROG_CHUNK_COUNT ),GFP_KERNEL );if (!pack)return NULL ; pack->ptr =module_alloc (BPF_PROG_PACK_SIZE );
Signature · 1 line
2.30.2
This patch was applied to bpf/bpf-next.git (master) by Alexei Starovoitov <[email protected]>:
Hello:
This patch was applied to bpf/bpf-next.git (master) by Alexei Starovoitov <[email protected]>:
Quoted 9 lines · On Thu, 10 Feb 2022 18:49:39 -0800 you wrote:
bpf_prog_packcauses build error with powerpcppc64_defconfig:
kernel/bpf/core.c:830:23: error: variably modified 'bitmap' at file scope
830 | unsigned long bitmap[BITS_TO_LONGS(BPF_PROG_CHUNK_COUNT)];
| ^~~~~~This is because the marco expands as:
[...]
Here is the summary with links:
- [v2,bpf-next] bpf: fix bpf_prog_pack build for ppc64_defconfig
https://git.kernel.org/bpf/bpf-next/c/4cc0991abd39
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html