Skip to content

Commit 4cc0991

Browse files
liu-song-6Alexei Starovoitov
authored andcommitted
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. Fixes: 5763105 ("bpf: Introduce bpf_prog_pack allocator") Reported-by: Stephen Rothwell <[email protected]> Signed-off-by: Song Liu <[email protected]> Signed-off-by: Alexei Starovoitov <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent a5a358a commit 4cc0991

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

kernel/bpf/core.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ int bpf_jit_add_poke_descriptor(struct bpf_prog *prog,
827827
struct bpf_prog_pack {
828828
struct list_head list;
829829
void *ptr;
830-
unsigned long bitmap[BITS_TO_LONGS(BPF_PROG_CHUNK_COUNT)];
830+
unsigned long bitmap[];
831831
};
832832

833833
#define BPF_PROG_MAX_PACK_PROG_SIZE BPF_PROG_PACK_SIZE
@@ -840,7 +840,7 @@ static struct bpf_prog_pack *alloc_new_pack(void)
840840
{
841841
struct bpf_prog_pack *pack;
842842

843-
pack = kzalloc(sizeof(*pack), GFP_KERNEL);
843+
pack = kzalloc(sizeof(*pack) + BITS_TO_BYTES(BPF_PROG_CHUNK_COUNT), GFP_KERNEL);
844844
if (!pack)
845845
return NULL;
846846
pack->ptr = module_alloc(BPF_PROG_PACK_SIZE);

0 commit comments

Comments
 (0)