1. 18 Mar, 2021 12 commits
    • Andrii Nakryiko's avatar
      libbpf: Add BPF static linker BTF and BTF.ext support · 8fd27bf6
      Andrii Nakryiko authored
      Add .BTF and .BTF.ext static linking logic.
      
      When multiple BPF object files are linked together, their respective .BTF and
      .BTF.ext sections are merged together. BTF types are not just concatenated,
      but also deduplicated. .BTF.ext data is grouped by type (func info, line info,
      core_relos) and target section names, and then all the records are
      concatenated together, preserving their relative order. All the BTF type ID
      references and string offsets are updated as necessary, to take into account
      possibly deduplicated strings and types.
      
      BTF DATASEC types are handled specially. Their respective var_secinfos are
      accumulated separately in special per-section data and then final DATASEC
      types are emitted at the very end during bpf_linker__finalize() operation,
      just before emitting final ELF output file.
      
      BTF data can also provide "section annotations" for some extern variables.
      Such concept is missing in ELF, but BTF will have DATASEC types for such
      special extern datasections (e.g., .kconfig, .ksyms). Such sections are called
      "ephemeral" internally. Internally linker will keep metadata for each such
      section, collecting variables information, but those sections won't be emitted
      into the final ELF file.
      
      Also, given LLVM/Clang during compilation emits BTF DATASECS that are
      incomplete, missing section size and variable offsets for static variables,
      BPF static linker will initially fix up such DATASECs, using ELF symbols data.
      The final DATASECs will preserve section sizes and all variable offsets. This
      is handled correctly by libbpf already, so won't cause any new issues. On the
      other hand, it's actually a nice property to have a complete BTF data without
      runtime adjustments done during bpf_object__open() by libbpf. In that sense,
      BPF static linker is also a BTF normalizer.
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/20210318194036.3521577-8-andrii@kernel.org
      8fd27bf6
    • Andrii Nakryiko's avatar
      libbpf: Add BPF static linker APIs · faf6ed32
      Andrii Nakryiko authored
      Introduce BPF static linker APIs to libbpf. BPF static linker allows to
      perform static linking of multiple BPF object files into a single combined
      resulting object file, preserving all the BPF programs, maps, global
      variables, etc.
      
      Data sections (.bss, .data, .rodata, .maps, maps, etc) with the same name are
      concatenated together. Similarly, code sections are also concatenated. All the
      symbols and ELF relocations are also concatenated in their respective ELF
      sections and are adjusted accordingly to the new object file layout.
      
      Static variables and functions are handled correctly as well, adjusting BPF
      instructions offsets to reflect new variable/function offset within the
      combined ELF section. Such relocations are referencing STT_SECTION symbols and
      that stays intact.
      
      Data sections in different files can have different alignment requirements, so
      that is taken care of as well, adjusting sizes and offsets as necessary to
      satisfy both old and new alignment requirements.
      
      DWARF data sections are stripped out, currently. As well as LLLVM_ADDRSIG
      section, which is ignored by libbpf in bpf_object__open() anyways. So, in
      a way, BPF static linker is an analogue to `llvm-strip -g`, which is a pretty
      nice property, especially if resulting .o file is then used to generate BPF
      skeleton.
      
      Original string sections are ignored and instead we construct our own set of
      unique strings using libbpf-internal `struct strset` API.
      
      To reduce the size of the patch, all the .BTF and .BTF.ext processing was
      moved into a separate patch.
      
      The high-level API consists of just 4 functions:
        - bpf_linker__new() creates an instance of BPF static linker. It accepts
          output filename and (currently empty) options struct;
        - bpf_linker__add_file() takes input filename and appends it to the already
          processed ELF data; it can be called multiple times, one for each BPF
          ELF object file that needs to be linked in;
        - bpf_linker__finalize() needs to be called to dump final ELF contents into
          the output file, specified when bpf_linker was created; after
          bpf_linker__finalize() is called, no more bpf_linker__add_file() and
          bpf_linker__finalize() calls are allowed, they will return error;
        - regardless of whether bpf_linker__finalize() was called or not,
          bpf_linker__free() will free up all the used resources.
      
      Currently, BPF static linker doesn't resolve cross-object file references
      (extern variables and/or functions). This will be added in the follow up patch
      set.
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/20210318194036.3521577-7-andrii@kernel.org
      faf6ed32
    • Andrii Nakryiko's avatar
      libbpf: Add generic BTF type shallow copy API · 9af44bc5
      Andrii Nakryiko authored
      Add btf__add_type() API that performs shallow copy of a given BTF type from
      the source BTF into the destination BTF. All the information and type IDs are
      preserved, but all the strings encountered are added into the destination BTF
      and corresponding offsets are rewritten. BTF type IDs are assumed to be
      correct or such that will be (somehow) modified afterwards.
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/20210318194036.3521577-6-andrii@kernel.org
      9af44bc5
    • Andrii Nakryiko's avatar
      libbpf: Extract internal set-of-strings datastructure APIs · 90d76d3e
      Andrii Nakryiko authored
      Extract BTF logic for maintaining a set of strings data structure, used for
      BTF strings section construction in writable mode, into separate re-usable
      API. This data structure is going to be used by bpf_linker to maintains ELF
      STRTAB section, which has the same layout as BTF strings section.
      Suggested-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/20210318194036.3521577-5-andrii@kernel.org
      90d76d3e
    • Andrii Nakryiko's avatar
      libbpf: Rename internal memory-management helpers · 3b029e06
      Andrii Nakryiko authored
      Rename btf_add_mem() and btf_ensure_mem() helpers that abstract away details
      of dynamically resizable memory to use libbpf_ prefix, as they are not
      BTF-specific. No functional changes.
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/20210318194036.3521577-4-andrii@kernel.org
      3b029e06
    • Andrii Nakryiko's avatar
      libbpf: Generalize BTF and BTF.ext type ID and strings iteration · f36e99a4
      Andrii Nakryiko authored
      Extract and generalize the logic to iterate BTF type ID and string offset
      fields within BTF types and .BTF.ext data. Expose this internally in libbpf
      for re-use by bpf_linker.
      
      Additionally, complete strings deduplication handling for BTF.ext (e.g., CO-RE
      access strings), which was previously missing. There previously was no
      case of deduplicating .BTF.ext data, but bpf_linker is going to use it.
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/20210318194036.3521577-3-andrii@kernel.org
      f36e99a4
    • Andrii Nakryiko's avatar
      libbpf: Expose btf_type_by_id() internally · e14ef4bf
      Andrii Nakryiko authored
      btf_type_by_id() is internal-only convenience API returning non-const pointer
      to struct btf_type. Expose it outside of btf.c for re-use.
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/20210318194036.3521577-2-andrii@kernel.org
      e14ef4bf
    • Lorenzo Bianconi's avatar
      bpf, devmap: Move drop error path to devmap for XDP_REDIRECT · fdc13979
      Lorenzo Bianconi authored
      We want to change the current ndo_xdp_xmit drop semantics because it will
      allow us to implement better queue overflow handling. This is working
      towards the larger goal of a XDP TX queue-hook. Move XDP_REDIRECT error
      path handling from each XDP ethernet driver to devmap code. According to
      the new APIs, the driver running the ndo_xdp_xmit pointer, will break tx
      loop whenever the hw reports a tx error and it will just return to devmap
      caller the number of successfully transmitted frames. It will be devmap
      responsibility to free dropped frames.
      
      Move each XDP ndo_xdp_xmit capable driver to the new APIs:
      
      - veth
      - virtio-net
      - mvneta
      - mvpp2
      - socionext
      - amazon ena
      - bnxt
      - freescale (dpaa2, dpaa)
      - xen-frontend
      - qede
      - ice
      - igb
      - ixgbe
      - i40e
      - mlx5
      - ti (cpsw, cpsw-new)
      - tun
      - sfc
      Signed-off-by: default avatarLorenzo Bianconi <lorenzo@kernel.org>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Reviewed-by: default avatarIoana Ciornei <ioana.ciornei@nxp.com>
      Reviewed-by: default avatarIlias Apalodimas <ilias.apalodimas@linaro.org>
      Reviewed-by: default avatarCamelia Groza <camelia.groza@nxp.com>
      Acked-by: default avatarEdward Cree <ecree.xilinx@gmail.com>
      Acked-by: default avatarJesper Dangaard Brouer <brouer@redhat.com>
      Acked-by: default avatarShay Agroskin <shayagr@amazon.com>
      Link: https://lore.kernel.org/bpf/ed670de24f951cfd77590decf0229a0ad7fd12f6.1615201152.git.lorenzo@kernel.org
      fdc13979
    • Alexei Starovoitov's avatar
      Merge branch 'Provide NULL and KERNEL_VERSION macros in bpf_helpers.h' · 6b282765
      Alexei Starovoitov authored
      Andrii Nakryiko says:
      
      ====================
      
      Provide NULL and KERNEL_VERSION macros in bpf_helpers.h. Patch #2 removes such
      custom NULL definition from one of the selftests.
      
      v2->v3:
        - instead of vmlinux.h, do this in bpf_helpers.h;
        - added KERNEL_VERSION, which comes up periodically as well;
        - I dropped strict compilation patches for now, because we run into new
          warnings (e.g., not checking read() result) in kernel-patches CI, which
          I can't even reproduce locally. Also -Wdiscarded-qualifiers pragma for
          jit_disasm.c is not supported by Clang, it needs to be
          -Wincompatible-pointer-types-discards-qualifiers for Clang; we don't have
          to deal with that in this patch set;
      v1->v2:
        - fix few typos and wrong copy/paste;
        - fix #pragma push -> pop.
      ====================
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      6b282765
    • Andrii Nakryiko's avatar
      selftests/bpf: drop custom NULL #define in skb_pkt_end selftest · c53a3355
      Andrii Nakryiko authored
      Now that bpftool generates NULL definition as part of vmlinux.h, drop custom
      NULL definition in skb_pkt_end.c.
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Link: https://lore.kernel.org/r/20210317200510.1354627-3-andrii@kernel.orgSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      c53a3355
    • Andrii Nakryiko's avatar
      libbpf: provide NULL and KERNEL_VERSION macros in bpf_helpers.h · 9ae2c26e
      Andrii Nakryiko authored
      Given that vmlinux.h is not compatible with headers like stddef.h, NULL poses
      an annoying problem: it is defined as #define, so is not captured in BTF, so
      is not emitted into vmlinux.h. This leads to users either sticking to explicit
      0, or defining their own NULL (as progs/skb_pkt_end.c does).
      
      But it's easy for bpf_helpers.h to provide (conditionally) NULL definition.
      Similarly, KERNEL_VERSION is another commonly missed macro that came up
      multiple times. So this patch adds both of them, along with offsetof(), that
      also is typically defined in stddef.h, just like NULL.
      
      This might cause compilation warning for existing BPF applications defining
      their own NULL and/or KERNEL_VERSION already:
      
        progs/skb_pkt_end.c:7:9: warning: 'NULL' macro redefined [-Wmacro-redefined]
        #define NULL 0
                ^
        /tmp/linux/tools/testing/selftests/bpf/tools/include/vmlinux.h:4:9: note: previous definition is here
        #define NULL ((void *)0)
      	  ^
      
      It is trivial to fix, though, so long-term benefits outweight temporary
      inconveniences.
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Link: https://lore.kernel.org/r/20210317200510.1354627-2-andrii@kernel.orgSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      9ae2c26e
    • Yonghong Song's avatar
      bpf: net: Emit anonymous enum with BPF_TCP_CLOSE value explicitly · 97a19caf
      Yonghong Song authored
      The selftest failed to compile with clang-built bpf-next.
      Adding LLVM=1 to your vmlinux and selftest build will use clang.
      The error message is:
        progs/test_sk_storage_tracing.c:38:18: error: use of undeclared identifier 'BPF_TCP_CLOSE'
                if (newstate == BPF_TCP_CLOSE)
                                ^
        1 error generated.
        make: *** [Makefile:423: /bpf-next/tools/testing/selftests/bpf/test_sk_storage_tracing.o] Error 1
      
      The reason for the failure is that BPF_TCP_CLOSE, a value of
      an anonymous enum defined in uapi bpf.h, is not defined in
      vmlinux.h. gcc does not have this problem. Since vmlinux.h
      is derived from BTF which is derived from vmlinux DWARF,
      that means gcc-produced vmlinux DWARF has BPF_TCP_CLOSE
      while llvm-produced vmlinux DWARF does not have.
      
      BPF_TCP_CLOSE is referenced in net/ipv4/tcp.c as
        BUILD_BUG_ON((int)BPF_TCP_CLOSE != (int)TCP_CLOSE);
      The following test mimics the above BUILD_BUG_ON, preprocessed
      with clang compiler, and shows gcc DWARF contains BPF_TCP_CLOSE while
      llvm DWARF does not.
      
        $ cat t.c
        enum {
          BPF_TCP_ESTABLISHED = 1,
          BPF_TCP_CLOSE = 7,
        };
        enum {
          TCP_ESTABLISHED = 1,
          TCP_CLOSE = 7,
        };
      
        int test() {
          do {
            extern void __compiletime_assert_767(void) ;
            if ((int)BPF_TCP_CLOSE != (int)TCP_CLOSE) __compiletime_assert_767();
          } while (0);
          return 0;
        }
        $ clang t.c -O2 -c -g && llvm-dwarfdump t.o | grep BPF_TCP_CLOSE
        $ gcc t.c -O2 -c -g && llvm-dwarfdump t.o | grep BPF_TCP_CLOSE
                          DW_AT_name    ("BPF_TCP_CLOSE")
      
      Further checking clang code find clang actually tried to
      evaluate condition at compile time. If it is definitely
      true/false, it will perform optimization and the whole if condition
      will be removed before generating IR/debuginfo.
      
      This patch explicited add an expression after the
      above mentioned BUILD_BUG_ON in net/ipv4/tcp.c like
        (void)BPF_TCP_ESTABLISHED
      to enable generation of debuginfo for the anonymous
      enum which also includes BPF_TCP_CLOSE.
      Signed-off-by: default avatarYonghong Song <yhs@fb.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/20210317174132.589276-1-yhs@fb.com
      97a19caf
  2. 16 Mar, 2021 13 commits
  3. 15 Mar, 2021 1 commit
  4. 10 Mar, 2021 14 commits
    • Andrii Nakryiko's avatar
      Merge branch 'libbpf/xsk cleanups' · 1211f4e9
      Andrii Nakryiko authored
      Björn Töpel says:
      
      ====================
      
      This series removes a header dependency from xsk.h, and moves
      libbpf_util.h into xsk.h.
      
      More details in each commit!
      
      Thank you,
      Björn
      ====================
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      1211f4e9
    • Björn Töpel's avatar
      libbpf: xsk: Move barriers from libbpf_util.h to xsk.h · 7e8bbe24
      Björn Töpel authored
      The only user of libbpf_util.h is xsk.h. Move the barriers to xsk.h,
      and remove libbpf_util.h. The barriers are used as an implementation
      detail, and should not be considered part of the stable API.
      Signed-off-by: default avatarBjörn Töpel <bjorn.topel@intel.com>
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Link: https://lore.kernel.org/bpf/20210310080929.641212-3-bjorn.topel@gmail.com
      7e8bbe24
    • Björn Töpel's avatar
      libbpf: xsk: Remove linux/compiler.h header · 2882c48b
      Björn Töpel authored
      In commit 291471dd ("libbpf, xsk: Add libbpf_smp_store_release
      libbpf_smp_load_acquire") linux/compiler.h was added as a dependency
      to xsk.h, which is the user-facing API. This makes it harder for
      userspace application to consume the library. Here the header
      inclusion is removed, and instead {READ,WRITE}_ONCE() is added
      explicitly.
      Signed-off-by: default avatarBjörn Töpel <bjorn.topel@intel.com>
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Link: https://lore.kernel.org/bpf/20210310080929.641212-2-bjorn.topel@gmail.com
      2882c48b
    • Jiapeng Chong's avatar
      bpf: Fix warning comparing pointer to 0 · a9c80b03
      Jiapeng Chong authored
      Fix the following coccicheck warning:
      
      ./tools/testing/selftests/bpf/progs/fentry_test.c:67:12-13: WARNING
      comparing pointer to 0.
      Reported-by: default avatarAbaci Robot <abaci@linux.alibaba.com>
      Signed-off-by: default avatarJiapeng Chong <jiapeng.chong@linux.alibaba.com>
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Link: https://lore.kernel.org/bpf/1615360714-30381-1-git-send-email-jiapeng.chong@linux.alibaba.com
      a9c80b03
    • Jiapeng Chong's avatar
      selftests/bpf: Fix warning comparing pointer to 0 · 04ea63e3
      Jiapeng Chong authored
      Fix the following coccicheck warning:
      
      ./tools/testing/selftests/bpf/progs/test_global_func10.c:17:12-13:
      WARNING comparing pointer to 0.
      Reported-by: default avatarAbaci Robot <abaci@linux.alibaba.com>
      Signed-off-by: default avatarJiapeng Chong <jiapeng.chong@linux.alibaba.com>
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Link: https://lore.kernel.org/bpf/1615357366-97612-1-git-send-email-jiapeng.chong@linux.alibaba.com
      04ea63e3
    • David S. Miller's avatar
      Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next · c1acda98
      David S. Miller authored
      Alexei Starovoitov says:
      
      ====================
      pull-request: bpf-next 2021-03-09
      
      The following pull-request contains BPF updates for your *net-next* tree.
      
      We've added 90 non-merge commits during the last 17 day(s) which contain
      a total of 114 files changed, 5158 insertions(+), 1288 deletions(-).
      
      The main changes are:
      
      1) Faster bpf_redirect_map(), from Björn.
      
      2) skmsg cleanup, from Cong.
      
      3) Support for floating point types in BTF, from Ilya.
      
      4) Documentation for sys_bpf commands, from Joe.
      
      5) Support for sk_lookup in bpf_prog_test_run, form Lorenz.
      
      6) Enable task local storage for tracing programs, from Song.
      
      7) bpf_for_each_map_elem() helper, from Yonghong.
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      c1acda98
    • Linus Torvalds's avatar
      Merge git://git.kernel.org:/pub/scm/linux/kernel/git/netdev/net · 05a59d79
      Linus Torvalds authored
      Pull networking fixes from David Miller:
      
       1) Fix transmissions in dynamic SMPS mode in ath9k, from Felix Fietkau.
      
       2) TX skb error handling fix in mt76 driver, also from Felix.
      
       3) Fix BPF_FETCH atomic in x86 JIT, from Brendan Jackman.
      
       4) Avoid double free of percpu pointers when freeing a cloned bpf prog.
          From Cong Wang.
      
       5) Use correct printf format for dma_addr_t in ath11k, from Geert
          Uytterhoeven.
      
       6) Fix resolve_btfids build with older toolchains, from Kun-Chuan
          Hsieh.
      
       7) Don't report truncated frames to mac80211 in mt76 driver, from
          Lorenzop Bianconi.
      
       8) Fix watcdog timeout on suspend/resume of stmmac, from Joakim Zhang.
      
       9) mscc ocelot needs NET_DEVLINK selct in Kconfig, from Arnd Bergmann.
      
      10) Fix sign comparison bug in TCP_ZEROCOPY_RECEIVE getsockopt(), from
          Arjun Roy.
      
      11) Ignore routes with deleted nexthop object in mlxsw, from Ido
          Schimmel.
      
      12) Need to undo tcp early demux lookup sometimes in nf_nat, from
          Florian Westphal.
      
      13) Fix gro aggregation for udp encaps with zero csum, from Daniel
          Borkmann.
      
      14) Make sure to always use imp*_ndo_send when necessaey, from Jason A.
          Donenfeld.
      
      15) Fix TRSCER masks in sh_eth driver from Sergey Shtylyov.
      
      16) prevent overly huge skb allocationsd in qrtr, from Pavel Skripkin.
      
      17) Prevent rx ring copnsumer index loss of sync in enetc, from Vladimir
          Oltean.
      
      18) Make sure textsearch copntrol block is large enough, from Wilem de
          Bruijn.
      
      19) Revert MAC changes to r8152 leading to instability, from Hates Wang.
      
      20) Advance iov in 9p even for empty reads, from Jissheng Zhang.
      
      21) Double hook unregister in nftables, from PabloNeira Ayuso.
      
      22) Fix memleak in ixgbe, fropm Dinghao Liu.
      
      23) Avoid dups in pkt scheduler class dumps, from Maximilian Heyne.
      
      24) Various mptcp fixes from Florian Westphal, Paolo Abeni, and Geliang
          Tang.
      
      25) Fix DOI refcount bugs in cipso, from Paul Moore.
      
      26) One too many irqsave in ibmvnic, from Junlin Yang.
      
      27) Fix infinite loop with MPLS gso segmenting via virtio_net, from
          Balazs Nemeth.
      
      * git://git.kernel.org:/pub/scm/linux/kernel/git/netdev/net: (164 commits)
        s390/qeth: fix notification for pending buffers during teardown
        s390/qeth: schedule TX NAPI on QAOB completion
        s390/qeth: improve completion of pending TX buffers
        s390/qeth: fix memory leak after failed TX Buffer allocation
        net: avoid infinite loop in mpls_gso_segment when mpls_hlen == 0
        net: check if protocol extracted by virtio_net_hdr_set_proto is correct
        net: dsa: xrs700x: check if partner is same as port in hsr join
        net: lapbether: Remove netif_start_queue / netif_stop_queue
        atm: idt77252: fix null-ptr-dereference
        atm: uPD98402: fix incorrect allocation
        atm: fix a typo in the struct description
        net: qrtr: fix error return code of qrtr_sendmsg()
        mptcp: fix length of ADD_ADDR with port sub-option
        net: bonding: fix error return code of bond_neigh_init()
        net: enetc: allow hardware timestamping on TX queues with tc-etf enabled
        net: enetc: set MAC RX FIFO to recommended value
        net: davicom: Use platform_get_irq_optional()
        net: davicom: Fix regulator not turned off on driver removal
        net: davicom: Fix regulator not turned off on failed probe
        net: dsa: fix switchdev objects on bridge master mistakenly being applied on ports
        ...
      05a59d79
    • Linus Torvalds's avatar
      Merge git://git.kernel.org:/pub/scm/linux/kernel/git/davem/sparc · 6a30bedf
      Linus Torvalds authored
      Pull sparc fixes from David Miller:
       "Fix opcode filtering for exceptions, and clean up defconfig"
      
      * git://git.kernel.org:/pub/scm/linux/kernel/git/davem/sparc:
        sparc: sparc64_defconfig: remove duplicate CONFIGs
        sparc64: Fix opcode filtering in handling of no fault loads
      6a30bedf
    • Corentin Labbe's avatar
      sparc: sparc64_defconfig: remove duplicate CONFIGs · 69264b4a
      Corentin Labbe authored
      After my patch there is CONFIG_ATA defined twice.
      Remove the duplicate one.
      Same problem for CONFIG_HAPPYMEAL, except I added as builtin for boot
      test with NFS.
      Reported-by: default avatarStephen Rothwell <sfr@canb.auug.org.au>
      Fixes: a57cdeb3 ("sparc: sparc64_defconfig: add necessary configs for qemu")
      Signed-off-by: default avatarCorentin Labbe <clabbe@baylibre.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      69264b4a
    • Rob Gardner's avatar
      sparc64: Fix opcode filtering in handling of no fault loads · e5e8b80d
      Rob Gardner authored
      is_no_fault_exception() has two bugs which were discovered via random
      opcode testing with stress-ng. Both are caused by improper filtering
      of opcodes.
      
      The first bug can be triggered by a floating point store with a no-fault
      ASI, for instance "sta %f0, [%g0] #ASI_PNF", opcode C1A01040.
      
      The code first tests op3[5] (0x1000000), which denotes a floating
      point instruction, and then tests op3[2] (0x200000), which denotes a
      store instruction. But these bits are not mutually exclusive, and the
      above mentioned opcode has both bits set. The intent is to filter out
      stores, so the test for stores must be done first in order to have
      any effect.
      
      The second bug can be triggered by a floating point load with one of
      the invalid ASI values 0x8e or 0x8f, which pass this check in
      is_no_fault_exception():
           if ((asi & 0xf2) == ASI_PNF)
      
      An example instruction is "ldqa [%l7 + %o7] #ASI 0x8f, %f38",
      opcode CF95D1EF. Asi values greater than 0x8b (ASI_SNFL) are fatal
      in handle_ldf_stq(), and is_no_fault_exception() must not allow these
      invalid asi values to make it that far.
      
      In both of these cases, handle_ldf_stq() reacts by calling
      sun4v_data_access_exception() or spitfire_data_access_exception(),
      which call is_no_fault_exception() and results in an infinite
      recursion.
      Signed-off-by: default avatarRob Gardner <rob.gardner@oracle.com>
      Tested-by: default avatarAnatoly Pugachev <matorola@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      e5e8b80d
    • David S. Miller's avatar
      Merge branch 's390-qeth-fixes' · 85154557
      David S. Miller authored
      Julian Wiedmann says:
      
      ====================
      s390/qeth: fixes 2021-03-09
      
      please apply the following patch series to netdev's net tree.
      
      This brings one fix for a memleak in an error path of the setup code.
      Also several fixes for dealing with pending TX buffers - two for old
      bugs in their completion handling, and one recent regression in a
      teardown path.
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      85154557
    • Julian Wiedmann's avatar
      s390/qeth: fix notification for pending buffers during teardown · 7eefda7f
      Julian Wiedmann authored
      The cited commit reworked the state machine for pending TX buffers.
      In qeth_iqd_tx_complete() it turned PENDING into a transient state, and
      uses NEED_QAOB for buffers that get parked while waiting for their QAOB
      completion.
      
      But it missed to adjust the check in qeth_tx_complete_buf(). So if
      qeth_tx_complete_pending_bufs() is called during teardown to drain
      the parked TX buffers, we no longer raise a notification for af_iucv.
      
      Instead of updating the checked state, just move this code into
      qeth_tx_complete_pending_bufs() itself. This also gets rid of the
      special-case in the common TX completion path.
      
      Fixes: 8908f36d ("s390/qeth: fix af_iucv notification race")
      Signed-off-by: default avatarJulian Wiedmann <jwi@linux.ibm.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      7eefda7f
    • Julian Wiedmann's avatar
      s390/qeth: schedule TX NAPI on QAOB completion · 3e83d467
      Julian Wiedmann authored
      When a QAOB notifies us that a pending TX buffer has been delivered, the
      actual TX completion processing by qeth_tx_complete_pending_bufs()
      is done within the context of a TX NAPI instance. We shouldn't rely on
      this instance being scheduled by some other TX event, but just do it
      ourselves.
      
      qeth_qdio_handle_aob() is called from qeth_poll(), ie. our main NAPI
      instance. To avoid touching the TX queue's NAPI instance
      before/after it is (un-)registered, reorder the code in qeth_open()
      and qeth_stop() accordingly.
      
      Fixes: 0da9581d ("qeth: exploit asynchronous delivery of storage blocks")
      Signed-off-by: default avatarJulian Wiedmann <jwi@linux.ibm.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      3e83d467
    • Julian Wiedmann's avatar
      s390/qeth: improve completion of pending TX buffers · c20383ad
      Julian Wiedmann authored
      The current design attaches a pending TX buffer to a custom
      single-linked list, which is anchored at the buffer's slot on the
      TX ring. The buffer is then checked for final completion whenever
      this slot is processed during a subsequent TX NAPI poll cycle.
      
      But if there's insufficient traffic on the ring, we might never make
      enough progress to get back to this ring slot and discover the pending
      buffer's final TX completion. In particular if this missing TX
      completion blocks the application from sending further traffic.
      
      So convert the custom single-linked list code to a per-queue list_head,
      and scan this list on every TX NAPI cycle.
      
      Fixes: 0da9581d ("qeth: exploit asynchronous delivery of storage blocks")
      Signed-off-by: default avatarJulian Wiedmann <jwi@linux.ibm.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      c20383ad