summaryrefslogtreecommitdiff
path: root/virt/lib
diff options
context:
space:
mode:
authorAndrii Nakryiko <andriin@fb.com>2020-01-13 10:31:41 +0300
committerAlexei Starovoitov <ast@kernel.org>2020-01-14 04:48:13 +0300
commit1cf5b23988ea0086a252a5c8b005b075f1e9b030 (patch)
tree8dabe0a326970a8b8a47ce8457b9530dad94f744 /virt/lib
parent2cc51d34d93c9cf76128da6535a2a0a38c9faddb (diff)
downloadlinux-1cf5b23988ea0086a252a5c8b005b075f1e9b030.tar.xz
bpftool: Apply preserve_access_index attribute to all types in BTF dump
This patch makes structs and unions, emitted through BTF dump, automatically CO-RE-relocatable (unless disabled with `#define BPF_NO_PRESERVE_ACCESS_INDEX`, specified before including generated header file). This effectivaly turns usual bpf_probe_read() call into equivalent of bpf_core_read(), by automatically applying builtin_preserve_access_index to any field accesses of types in generated C types header. This is especially useful for tp_btf/fentry/fexit BPF program types. They allow direct memory access, so BPF C code just uses straightfoward a->b->c access pattern to read data from kernel. But without kernel structs marked as CO-RE relocatable through preserve_access_index attribute, one has to enclose all the data reads into a special __builtin_preserve_access_index code block, like so: __builtin_preserve_access_index(({ x = p->pid; /* where p is struct task_struct *, for example */ })); This is very inconvenient and obscures the logic quite a bit. By marking all auto-generated types with preserve_access_index attribute the above code is reduced to just a clean and natural `x = p->pid;`. Signed-off-by: Andrii Nakryiko <andriin@fb.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://lore.kernel.org/bpf/20200113073143.1779940-5-andriin@fb.com
Diffstat (limited to 'virt/lib')
0 files changed, 0 insertions, 0 deletions