Commit 8d94f13
bpf: Recognize '__map' suffix in kfunc arguments
Recognize 'void *p__map' kfunc argument as 'struct bpf_map *p__map'.
It allows kfunc to have 'void *' argument for maps, since bpf progs
will call them as:
struct {
__uint(type, BPF_MAP_TYPE_ARENA);
...
} arena SEC(".maps");
bpf_kfunc_with_map(... &arena ...);
Underneath libbpf will load CONST_PTR_TO_MAP into the register via ld_imm64
insn. If kfunc was defined with 'struct bpf_map *' it would pass the
verifier as well, but bpf prog would need to type cast the argument
(void *)&arena, which is not clean.
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 88d1d4a commit 8d94f13
1 file changed
+16
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10752 | 10752 | | |
10753 | 10753 | | |
10754 | 10754 | | |
| 10755 | + | |
| 10756 | + | |
| 10757 | + | |
| 10758 | + | |
| 10759 | + | |
10755 | 10760 | | |
10756 | 10761 | | |
10757 | 10762 | | |
| |||
10921 | 10926 | | |
10922 | 10927 | | |
10923 | 10928 | | |
| 10929 | + | |
10924 | 10930 | | |
10925 | 10931 | | |
10926 | 10932 | | |
| |||
11074 | 11080 | | |
11075 | 11081 | | |
11076 | 11082 | | |
| 11083 | + | |
| 11084 | + | |
| 11085 | + | |
11077 | 11086 | | |
11078 | 11087 | | |
11079 | 11088 | | |
| |||
11674 | 11683 | | |
11675 | 11684 | | |
11676 | 11685 | | |
| 11686 | + | |
11677 | 11687 | | |
11678 | 11688 | | |
11679 | 11689 | | |
| |||
11890 | 11900 | | |
11891 | 11901 | | |
11892 | 11902 | | |
| 11903 | + | |
| 11904 | + | |
| 11905 | + | |
| 11906 | + | |
| 11907 | + | |
| 11908 | + | |
11893 | 11909 | | |
11894 | 11910 | | |
11895 | 11911 | | |
| |||
0 commit comments