diff options
| author | Martin KaFai Lau <martin.lau@kernel.org> | 2024-03-07 14:58:49 -0800 |
|---|---|---|
| committer | Martin KaFai Lau <martin.lau@kernel.org> | 2024-03-07 15:01:57 -0800 |
| commit | c7d4274e90a1e7aa43d11d2a16066cbbe610070e (patch) | |
| tree | afd0ca6870d3abf41b811e706c3f788057183e9b /kernel/bpf/syscall.c | |
| parent | e63985ecd22681c7f5975f2e8637187a326b6791 (diff) | |
| parent | fe5064158c561b807af5708c868f6c7cb5144e01 (diff) | |
Merge branch 'bpf: arena prerequisites'
Alexei Starovoitov says:
====================
These are bpf_arena prerequisite patches.
Useful on its own.
Alexei Starovoitov (5):
bpf: Allow kfuncs return 'void *'
bpf: Recognize '__map' suffix in kfunc arguments
bpf: Plumb get_unmapped_area() callback into bpf_map_ops
libbpf: Allow specifying 64-bit integers in map BTF.
bpf: Tell bpf programs kernel's PAGE_SIZE
====================
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
Diffstat (limited to 'kernel/bpf/syscall.c')
| -rw-r--r-- | kernel/bpf/syscall.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c index b2750b79ac80..f63f4da4db5e 100644 --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c @@ -937,6 +937,21 @@ static __poll_t bpf_map_poll(struct file *filp, struct poll_table_struct *pts) return EPOLLERR; } +static unsigned long bpf_get_unmapped_area(struct file *filp, unsigned long addr, + unsigned long len, unsigned long pgoff, + unsigned long flags) +{ + struct bpf_map *map = filp->private_data; + + if (map->ops->map_get_unmapped_area) + return map->ops->map_get_unmapped_area(filp, addr, len, pgoff, flags); +#ifdef CONFIG_MMU + return current->mm->get_unmapped_area(filp, addr, len, pgoff, flags); +#else + return addr; +#endif +} + const struct file_operations bpf_map_fops = { #ifdef CONFIG_PROC_FS .show_fdinfo = bpf_map_show_fdinfo, @@ -946,6 +961,7 @@ const struct file_operations bpf_map_fops = { .write = bpf_dummy_write, .mmap = bpf_map_mmap, .poll = bpf_map_poll, + .get_unmapped_area = bpf_get_unmapped_area, }; int bpf_map_new_fd(struct bpf_map *map, int flags) |
