• Andrii Nakryiko's avatar
    libbpf: Implement enum value-based CO-RE relocations · eacaaed7
    Andrii Nakryiko authored
    Implement two relocations of a new enumerator value-based CO-RE relocation
    kind: ENUMVAL_EXISTS and ENUMVAL_VALUE.
    
    First, ENUMVAL_EXISTS, allows to detect the presence of a named enumerator
    value in the target (kernel) BTF. This is useful to do BPF helper/map/program
    type support detection from BPF program side. bpf_core_enum_value_exists()
    macro helper is provided to simplify built-in usage.
    
    Second, ENUMVAL_VALUE, allows to capture enumerator integer value and relocate
    it according to the target BTF, if it changes. This is useful to have
    a guarantee against intentional or accidental re-ordering/re-numbering of some
    of the internal (non-UAPI) enumerations, where kernel developers don't care
    about UAPI backwards compatiblity concerns. bpf_core_enum_value() allows to
    capture this succinctly and use correct enum values in code.
    
    LLVM uses ldimm64 instruction to capture enumerator value-based relocations,
    so add support for ldimm64 instruction patching as well.
    Signed-off-by: default avatarAndrii Nakryiko <andriin@fb.com>
    Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
    Acked-by: default avatarYonghong Song <yhs@fb.com>
    Link: https://lore.kernel.org/bpf/20200819194519.3375898-5-andriin@fb.com
    eacaaed7
bpf_core_read.h 13.6 KB