1. 28 Apr, 2022 3 commits
    • Dylan Hung's avatar
      net: mdio: add reset control for Aspeed MDIO · 15853622
      Dylan Hung authored
      Add reset assertion/deassertion for Aspeed MDIO.  There are 4 MDIO
      controllers embedded in Aspeed AST2600 SOC and share one reset control
      register SCU50[3].  To work with old DT blobs which don't have the reset
      property, devm_reset_control_get_optional_shared is used in this change.
      Signed-off-by: default avatarDylan Hung <dylan_hung@aspeedtech.com>
      Reviewed-by: default avatarPhilipp Zabel <p.zabel@pengutronix.de>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Reviewed-by: default avatarAndrew Jeffery <andrew@aj.id.au>
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      15853622
    • Dylan Hung's avatar
      dt-bindings: net: add reset property for aspeed, ast2600-mdio binding · 65e42ad9
      Dylan Hung authored
      The AST2600 MDIO bus controller has a reset control bit and must be
      deasserted before manipulating the MDIO controller. By default, the
      hardware asserts the reset so the driver only need to deassert it.
      
      Regarding to the old DT blobs which don't have reset property in them,
      the reset deassertion is usually done by the bootloader so the reset
      property is optional to work with them.
      Signed-off-by: default avatarDylan Hung <dylan_hung@aspeedtech.com>
      Reviewed-by: default avatarKrzysztof Kozlowski <krzk@kernel.org>
      Reviewed-by: default avatarAndrew Jeffery <andrew@aj.id.au>
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      65e42ad9
    • Jakub Kicinski's avatar
      Merge https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next · 50c6afab
      Jakub Kicinski authored
      Daniel Borkmann says:
      
      ====================
      pull-request: bpf-next 2022-04-27
      
      We've added 85 non-merge commits during the last 18 day(s) which contain
      a total of 163 files changed, 4499 insertions(+), 1521 deletions(-).
      
      The main changes are:
      
      1) Teach libbpf to enhance BPF verifier log with human-readable and relevant
         information about failed CO-RE relocations, from Andrii Nakryiko.
      
      2) Add typed pointer support in BPF maps and enable it for unreferenced pointers
         (via probe read) and referenced ones that can be passed to in-kernel helpers,
         from Kumar Kartikeya Dwivedi.
      
      3) Improve xsk to break NAPI loop when rx queue gets full to allow for forward
         progress to consume descriptors, from Maciej Fijalkowski & Björn Töpel.
      
      4) Fix a small RCU read-side race in BPF_PROG_RUN routines which dereferenced
         the effective prog array before the rcu_read_lock, from Stanislav Fomichev.
      
      5) Implement BPF atomic operations for RV64 JIT, and add libbpf parsing logic
         for USDT arguments under riscv{32,64}, from Pu Lehui.
      
      6) Implement libbpf parsing of USDT arguments under aarch64, from Alan Maguire.
      
      7) Enable bpftool build for musl and remove nftw with FTW_ACTIONRETVAL usage
         so it can be shipped under Alpine which is musl-based, from Dominique Martinet.
      
      8) Clean up {sk,task,inode} local storage trace RCU handling as they do not
         need to use call_rcu_tasks_trace() barrier, from KP Singh.
      
      9) Improve libbpf API documentation and fix error return handling of various
         API functions, from Grant Seltzer.
      
      10) Enlarge offset check for bpf_skb_{load,store}_bytes() helpers given data
          length of frags + frag_list may surpass old offset limit, from Liu Jian.
      
      11) Various improvements to prog_tests in area of logging, test execution
          and by-name subtest selection, from Mykola Lysenko.
      
      12) Simplify map_btf_id generation for all map types by moving this process
          to build time with help of resolve_btfids infra, from Menglong Dong.
      
      13) Fix a libbpf bug in probing when falling back to legacy bpf_probe_read*()
          helpers; the probing caused always to use old helpers, from Runqing Yang.
      
      14) Add support for ARCompact and ARCv2 platforms for libbpf's PT_REGS
          tracing macros, from Vladimir Isaev.
      
      15) Cleanup BPF selftests to remove old & unneeded rlimit code given kernel
          switched to memcg-based memory accouting a while ago, from Yafang Shao.
      
      16) Refactor of BPF sysctl handlers to move them to BPF core, from Yan Zhu.
      
      17) Fix BPF selftests in two occasions to work around regressions caused by latest
          LLVM to unblock CI until their fixes are worked out, from Yonghong Song.
      
      18) Misc cleanups all over the place, from various others.
      
      * https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next: (85 commits)
        selftests/bpf: Add libbpf's log fixup logic selftests
        libbpf: Fix up verifier log for unguarded failed CO-RE relos
        libbpf: Simplify bpf_core_parse_spec() signature
        libbpf: Refactor CO-RE relo human description formatting routine
        libbpf: Record subprog-resolved CO-RE relocations unconditionally
        selftests/bpf: Add CO-RE relos and SEC("?...") to linked_funcs selftests
        libbpf: Avoid joining .BTF.ext data with BPF programs by section name
        libbpf: Fix logic for finding matching program for CO-RE relocation
        libbpf: Drop unhelpful "program too large" guess
        libbpf: Fix anonymous type check in CO-RE logic
        bpf: Compute map_btf_id during build time
        selftests/bpf: Add test for strict BTF type check
        selftests/bpf: Add verifier tests for kptr
        selftests/bpf: Add C tests for kptr
        libbpf: Add kptr type tag macros to bpf_helpers.h
        bpf: Make BTF type match stricter for release arguments
        bpf: Teach verifier about kptr_get kfunc helpers
        bpf: Wire up freeing of referenced kptr
        bpf: Populate pairs of btf_id and destructor kfunc in btf
        bpf: Adapt copy_map_value for multiple offset case
        ...
      ====================
      
      Link: https://lore.kernel.org/r/20220427224758.20976-1-daniel@iogearbox.netSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      50c6afab
  2. 27 Apr, 2022 28 commits
  3. 26 Apr, 2022 9 commits
    • Alexei Starovoitov's avatar
      Merge branch 'Teach libbpf to "fix up" BPF verifier log' · d54d06a4
      Alexei Starovoitov authored
      Andrii Nakryiko says:
      
      ====================
      
      This patch set teaches libbpf to enhance BPF verifier log with human-readable
      and relevant information about failed CO-RE relocation. Patch #9 is the main
      one with the new logic. See relevant commit messages for some more details.
      
      All the other patches are either fixing various bugs detected
      while working on this feature, most prominently a bug with libbpf not handling
      CO-RE relocations for SEC("?...") programs, or are refactoring libbpf
      internals to allow for easier reuse of CO-RE relo lookup and formatting logic.
      ====================
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      d54d06a4
    • Andrii Nakryiko's avatar
      selftests/bpf: Add libbpf's log fixup logic selftests · ea4128eb
      Andrii Nakryiko authored
      Add tests validating that libbpf is indeed patching up BPF verifier log
      with CO-RE relocation details. Also test partial and full truncation
      scenarios.
      
      This test might be a bit fragile due to changing BPF verifier log
      format. If that proves to be frequently breaking, we can simplify tests
      or remove the truncation subtests. But for now it seems useful to test
      it in those conditions that are otherwise rarely occuring in practice.
      
      Also test CO-RE relo failure in a subprog as that excercises subprogram CO-RE
      relocation mapping logic which doesn't work out of the box without extra
      relo storage previously done only for gen_loader case.
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/20220426004511.2691730-11-andrii@kernel.org
      ea4128eb
    • Andrii Nakryiko's avatar
      libbpf: Fix up verifier log for unguarded failed CO-RE relos · 9fdc4273
      Andrii Nakryiko authored
      Teach libbpf to post-process BPF verifier log on BPF program load
      failure and detect known error patterns to provide user with more
      context.
      
      Currently there is one such common situation: an "unguarded" failed BPF
      CO-RE relocation. While failing CO-RE relocation is expected, it is
      expected to be property guarded in BPF code such that BPF verifier
      always eliminates BPF instructions corresponding to such failed CO-RE
      relos as dead code. In cases when user failed to take such precautions,
      BPF verifier provides the best log it can:
      
        123: (85) call unknown#195896080
        invalid func unknown#195896080
      
      Such incomprehensible log error is due to libbpf "poisoning" BPF
      instruction that corresponds to failed CO-RE relocation by replacing it
      with invalid `call 0xbad2310` instruction (195896080 == 0xbad2310 reads
      "bad relo" if you squint hard enough).
      
      Luckily, libbpf has all the necessary information to look up CO-RE
      relocation that failed and provide more human-readable description of
      what's going on:
      
        5: <invalid CO-RE relocation>
        failed to resolve CO-RE relocation <byte_off> [6] struct task_struct___bad.fake_field_subprog (0:2 @ offset 8)
      
      This hopefully makes it much easier to understand what's wrong with
      user's BPF program without googling magic constants.
      
      This BPF verifier log fixup is setup to be extensible and is going to be
      used for at least one other upcoming feature of libbpf in follow up patches.
      Libbpf is parsing lines of BPF verifier log starting from the very end.
      Currently it processes up to 10 lines of code looking for familiar
      patterns. This avoids wasting lots of CPU processing huge verifier logs
      (especially for log_level=2 verbosity level). Actual verification error
      should normally be found in last few lines, so this should work
      reliably.
      
      If libbpf needs to expand log beyond available log_buf_size, it
      truncates the end of the verifier log. Given verifier log normally ends
      with something like:
      
        processed 2 insns (limit 1000000) max_states_per_insn 0 total_states 0 peak_states 0 mark_read 0
      
      ... truncating this on program load error isn't too bad (end user can
      always increase log size, if it needs to get complete log).
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/20220426004511.2691730-10-andrii@kernel.org
      9fdc4273
    • Andrii Nakryiko's avatar
      libbpf: Simplify bpf_core_parse_spec() signature · 14032f26
      Andrii Nakryiko authored
      Simplify bpf_core_parse_spec() signature to take struct bpf_core_relo as
      an input instead of requiring callers to decompose them into type_id,
      relo, spec_str, etc. This makes using and reusing this helper easier.
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/20220426004511.2691730-9-andrii@kernel.org
      14032f26
    • Andrii Nakryiko's avatar
      libbpf: Refactor CO-RE relo human description formatting routine · b58af63a
      Andrii Nakryiko authored
      Refactor how CO-RE relocation is formatted. Now it dumps human-readable
      representation, currently used by libbpf in either debug or error
      message output during CO-RE relocation resolution process, into provided
      buffer. This approach allows for better reuse of this functionality
      outside of CO-RE relocation resolution, which we'll use in next patch
      for providing better error message for BPF verifier rejecting BPF
      program due to unguarded failed CO-RE relocation.
      
      It also gets rid of annoying "stitching" of libbpf_print() calls, which
      was the only place where we did this.
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/20220426004511.2691730-8-andrii@kernel.org
      b58af63a
    • Andrii Nakryiko's avatar
      libbpf: Record subprog-resolved CO-RE relocations unconditionally · 185cfe83
      Andrii Nakryiko authored
      Previously, libbpf recorded CO-RE relocations with insns_idx resolved
      according to finalized subprog locations (which are appended at the end
      of entry BPF program) to simplify the job of light skeleton generator.
      
      This is necessary because once subprogs' instructions are appended to
      main entry BPF program all the subprog instruction indices are shifted
      and that shift is different for each entry (main) BPF program, so it's
      generally impossible to map final absolute insn_idx of the finalized BPF
      program to their original locations inside subprograms.
      
      This information is now going to be used not only during light skeleton
      generation, but also to map absolute instruction index to subprog's
      instruction and its corresponding CO-RE relocation. So start recording
      these relocations always, not just when obj->gen_loader is set.
      
      This information is going to be freed at the end of bpf_object__load()
      step, as before (but this can change in the future if there will be
      a need for this information post load step).
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/20220426004511.2691730-7-andrii@kernel.org
      185cfe83
    • Andrii Nakryiko's avatar
      selftests/bpf: Add CO-RE relos and SEC("?...") to linked_funcs selftests · b82bb1ff
      Andrii Nakryiko authored
      Enhance linked_funcs selftest with two tricky features that might not
      obviously work correctly together. We add CO-RE relocations to entry BPF
      programs and mark those programs as non-autoloadable with SEC("?...")
      annotation. This makes sure that libbpf itself handles .BTF.ext CO-RE
      relocation data matching correctly for SEC("?...") programs, as well as
      ensures that BPF static linker handles this correctly (this was the case
      before, no changes are necessary, but it wasn't explicitly tested).
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/20220426004511.2691730-6-andrii@kernel.org
      b82bb1ff
    • Andrii Nakryiko's avatar
      libbpf: Avoid joining .BTF.ext data with BPF programs by section name · 11d5daa8
      Andrii Nakryiko authored
      Instead of using ELF section names as a joining key between .BTF.ext and
      corresponding BPF programs, pre-build .BTF.ext section number to ELF
      section index mapping during bpf_object__open() and use it later for
      matching .BTF.ext information (func/line info or CO-RE relocations) to
      their respective BPF programs and subprograms.
      
      This simplifies corresponding joining logic and let's libbpf do
      manipulations with BPF program's ELF sections like dropping leading '?'
      character for non-autoloaded programs. Original joining logic in
      bpf_object__relocate_core() (see relevant comment that's now removed)
      was never elegant, so it's a good improvement regardless. But it also
      avoids unnecessary internal assumptions about preserving original ELF
      section name as BPF program's section name (which was broken when
      SEC("?abc") support was added).
      
      Fixes: a3820c48 ("libbpf: Support opting out from autoloading BPF programs declaratively")
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/20220426004511.2691730-5-andrii@kernel.org
      11d5daa8
    • Andrii Nakryiko's avatar
      libbpf: Fix logic for finding matching program for CO-RE relocation · 966a7509
      Andrii Nakryiko authored
      Fix the bug in bpf_object__relocate_core() which can lead to finding
      invalid matching BPF program when processing CO-RE relocation. IF
      matching program is not found, last encountered program will be assumed
      to be correct program and thus error detection won't detect the problem.
      
      Fixes: 9c82a63c ("libbpf: Fix CO-RE relocs against .text section")
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/20220426004511.2691730-4-andrii@kernel.org
      966a7509