Skip to content

Commit fe50641

Browse files
Alexei StarovoitovMartin KaFai Lau
authored andcommitted
bpf: Tell bpf programs kernel's PAGE_SIZE
vmlinux BTF includes all kernel enums. Add __PAGE_SIZE = PAGE_SIZE enum, so that bpf programs that include vmlinux.h can easily access it. Acked-by: Kumar Kartikeya Dwivedi <[email protected]> Signed-off-by: Alexei Starovoitov <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Martin KaFai Lau <[email protected]>
1 parent 1576b07 commit fe50641

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

kernel/bpf/core.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,18 @@ void *bpf_internal_load_pointer_neg_helper(const struct sk_buff *skb, int k, uns
8888
return NULL;
8989
}
9090

91+
/* tell bpf programs that include vmlinux.h kernel's PAGE_SIZE */
92+
enum page_size_enum {
93+
__PAGE_SIZE = PAGE_SIZE
94+
};
95+
9196
struct bpf_prog *bpf_prog_alloc_no_stats(unsigned int size, gfp_t gfp_extra_flags)
9297
{
9398
gfp_t gfp_flags = bpf_memcg_flags(GFP_KERNEL | __GFP_ZERO | gfp_extra_flags);
9499
struct bpf_prog_aux *aux;
95100
struct bpf_prog *fp;
96101

97-
size = round_up(size, PAGE_SIZE);
102+
size = round_up(size, __PAGE_SIZE);
98103
fp = __vmalloc(size, gfp_flags);
99104
if (fp == NULL)
100105
return NULL;

0 commit comments

Comments
 (0)