[RFC PATCH bpf-next 0/2] BTF support for ksyms

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux