All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH bpf-next 0/2] BTF support for ksyms
@ 2020-07-15 21:43 Hao Luo
  2020-07-15 21:43 ` [RFC PATCH bpf-next 1/2] bpf: BTF support for __ksym externs Hao Luo
  2020-07-15 21:43 ` [RFC PATCH bpf-next 2/2] selftests/bpf: Test __ksym externs with BTF Hao Luo
  0 siblings, 2 replies; 9+ messages in thread
From: Hao Luo @ 2020-07-15 21:43 UTC (permalink / raw)
  To: netdev, bpf, linux-kernel, linux-kselftest
  Cc: Shuah Khan, Alexei Starovoitov, Andrii Nakryiko, John Fastabend,
	Daniel Borkmann, Martin KaFai Lau, Song Liu, Yonghong Song,
	KP Singh, Stanislav Fomichev, Quentin Monnet, Hao Luo

This patch series extends the previously add __ksym externs with btf
info.

Right now the __ksym externs are treated as pure 64-bit scalar value.
Libbpf replaces ld_imm64 insn of __ksym by its kernel address at load
time. This patch series extend those extern with their btf info. Note
that btf support for __ksym must come with the btf that has VARs encoded
to work properly. Therefore, these patches are tested against a btf
generated by a patched pahole, whose change will available in released
pahole soon.

There are a couple of design choices that I would like feedbacks from
bpf/btf experts.

 1. Because the newly added pseudo_btf_id needs to carry both a kernel
    address (64 bits) and a btf id (32 bits), I used the 'off' fields
    of ld_imm insn to carry btf id. I wonder if this breaks anything or
    if there is a better idea.
 2. Since only a subset of vars are going to be encoded into the new
    btf, if a ksym that doesn't find its btf id, it doesn't get
    converted into pseudo_btf_id. It is still treated as pure scalar
    value. But we require kernel btf to be loaded in libbpf if there is
    any ksym in the bpf prog.

This is RFC as it requires pahole changes that encode kernel vars into
btf.

Hao Luo (2):
  bpf: BTF support for __ksym externs
  selftests/bpf: Test __ksym externs with BTF

 include/uapi/linux/bpf.h                      | 37 ++++++++++----
 kernel/bpf/verifier.c                         | 26 ++++++++--
 tools/include/uapi/linux/bpf.h                | 37 ++++++++++----
 tools/lib/bpf/libbpf.c                        | 50 ++++++++++++++++++-
 .../testing/selftests/bpf/prog_tests/ksyms.c  |  2 +
 .../testing/selftests/bpf/progs/test_ksyms.c  | 14 ++++++
 6 files changed, 143 insertions(+), 23 deletions(-)

-- 
2.27.0.389.gc38d7665816-goog


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2020-07-21 16:45 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-15 21:43 [RFC PATCH bpf-next 0/2] BTF support for ksyms Hao Luo
2020-07-15 21:43 ` [RFC PATCH bpf-next 1/2] bpf: BTF support for __ksym externs Hao Luo
2020-07-20  5:22   ` Andrii Nakryiko
2020-07-20 17:03     ` Hao Luo
2020-07-15 21:43 ` [RFC PATCH bpf-next 2/2] selftests/bpf: Test __ksym externs with BTF Hao Luo
2020-07-20  5:28   ` Andrii Nakryiko
2020-07-20 20:28     ` Hao Luo
2020-07-21  2:37       ` Andrii Nakryiko
2020-07-21 16:45         ` Hao Luo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.