1. 02 May, 2017 40 commits
    • Linus Torvalds's avatar
      Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next · 8d65b08d
      Linus Torvalds authored
      Pull networking updates from David Millar:
       "Here are some highlights from the 2065 networking commits that
        happened this development cycle:
      
         1) XDP support for IXGBE (John Fastabend) and thunderx (Sunil Kowuri)
      
         2) Add a generic XDP driver, so that anyone can test XDP even if they
            lack a networking device whose driver has explicit XDP support
            (me).
      
         3) Sparc64 now has an eBPF JIT too (me)
      
         4) Add a BPF program testing framework via BPF_PROG_TEST_RUN (Alexei
            Starovoitov)
      
         5) Make netfitler network namespace teardown less expensive (Florian
            Westphal)
      
         6) Add symmetric hashing support to nft_hash (Laura Garcia Liebana)
      
         7) Implement NAPI and GRO in netvsc driver (Stephen Hemminger)
      
         8) Support TC flower offload statistics in mlxsw (Arkadi Sharshevsky)
      
         9) Multiqueue support in stmmac driver (Joao Pinto)
      
        10) Remove TCP timewait recycling, it never really could possibly work
            well in the real world and timestamp randomization really zaps any
            hint of usability this feature had (Soheil Hassas Yeganeh)
      
        11) Support level3 vs level4 ECMP route hashing in ipv4 (Nikolay
            Aleksandrov)
      
        12) Add socket busy poll support to epoll (Sridhar Samudrala)
      
        13) Netlink extended ACK support (Johannes Berg, Pablo Neira Ayuso,
            and several others)
      
        14) IPSEC hw offload infrastructure (Steffen Klassert)"
      
      * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next: (2065 commits)
        tipc: refactor function tipc_sk_recv_stream()
        tipc: refactor function tipc_sk_recvmsg()
        net: thunderx: Optimize page recycling for XDP
        net: thunderx: Support for XDP header adjustment
        net: thunderx: Add support for XDP_TX
        net: thunderx: Add support for XDP_DROP
        net: thunderx: Add basic XDP support
        net: thunderx: Cleanup receive buffer allocation
        net: thunderx: Optimize CQE_TX handling
        net: thunderx: Optimize RBDR descriptor handling
        net: thunderx: Support for page recycling
        ipx: call ipxitf_put() in ioctl error path
        net: sched: add helpers to handle extended actions
        qed*: Fix issues in the ptp filter config implementation.
        qede: Fix concurrency issue in PTP Tx path processing.
        stmmac: Add support for SIMATIC IOT2000 platform
        net: hns: fix ethtool_get_strings overflow in hns driver
        tcp: fix wraparound issue in tcp_lp
        bpf, arm64: fix jit branch offset related to ldimm64
        bpf, arm64: implement jiting of BPF_XADD
        ...
      8d65b08d
    • Linus Torvalds's avatar
      Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6 · 5a0387a8
      Linus Torvalds authored
      Pull crypto updates from Herbert Xu:
       "Here is the crypto update for 4.12:
      
        API:
         - Add batch registration for acomp/scomp
         - Change acomp testing to non-unique compressed result
         - Extend algorithm name limit to 128 bytes
         - Require setkey before accept(2) in algif_aead
      
        Algorithms:
         - Add support for deflate rfc1950 (zlib)
      
        Drivers:
         - Add accelerated crct10dif for powerpc
         - Add crc32 in stm32
         - Add sha384/sha512 in ccp
         - Add 3des/gcm(aes) for v5 devices in ccp
         - Add Queue Interface (QI) backend support in caam
         - Add new Exynos RNG driver
         - Add ThunderX ZIP driver
         - Add driver for hardware random generator on MT7623 SoC"
      
      * 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (101 commits)
        crypto: stm32 - Fix OF module alias information
        crypto: algif_aead - Require setkey before accept(2)
        crypto: scomp - add support for deflate rfc1950 (zlib)
        crypto: scomp - allow registration of multiple scomps
        crypto: ccp - Change ISR handler method for a v5 CCP
        crypto: ccp - Change ISR handler method for a v3 CCP
        crypto: crypto4xx - rename ce_ring_contol to ce_ring_control
        crypto: testmgr - Allow ecb(cipher_null) in FIPS mode
        Revert "crypto: arm64/sha - Add constant operand modifier to ASM_EXPORT"
        crypto: ccp - Disable interrupts early on unload
        crypto: ccp - Use only the relevant interrupt bits
        hwrng: mtk - Add driver for hardware random generator on MT7623 SoC
        dt-bindings: hwrng: Add Mediatek hardware random generator bindings
        crypto: crct10dif-vpmsum - Fix missing preempt_disable()
        crypto: testmgr - replace compression known answer test
        crypto: acomp - allow registration of multiple acomps
        hwrng: n2 - Use devm_kcalloc() in n2rng_probe()
        crypto: chcr - Fix error handling related to 'chcr_alloc_shash'
        padata: get_next is never NULL
        crypto: exynos - Add new Exynos RNG driver
        ...
      5a0387a8
    • David S. Miller's avatar
      Merge branch 'tipc-refactor-socket-receive-functions' · 5d15af67
      David S. Miller authored
      Jon Maloy says:
      
      ====================
      tipc: refactor socket receive functions
      
      We try to make the functions tipc_sk_recvmsg() and
      tipc_sk_recvstream() more readable.
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      5d15af67
    • Jon Paul Maloy's avatar
      tipc: refactor function tipc_sk_recv_stream() · ec8a09fb
      Jon Paul Maloy authored
      We try to make this function more readable by improving variable names
      and comments, using more stack variables, and doing some smaller changes
      to the logics. We also rename the function to make it consistent with
      naming conventions used elsewhere in the code.
      Reviewed-by: default avatarParthasarathy Bhuvaragan <parthasarathy.bhuvaragan@ericsson.com>
      Signed-off-by: default avatarJon Maloy <jon.maloy@ericsson.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      ec8a09fb
    • Jon Paul Maloy's avatar
      tipc: refactor function tipc_sk_recvmsg() · e9f8b101
      Jon Paul Maloy authored
      We try to make this function more readable by improving variable names
      and comments, plus some minor changes to the logics.
      Reviewed-by: default avatarParthasarathy Bhuvaragan <parthasarathy.bhuvaragan@ericsson.com>
      Signed-off-by: default avatarJon Maloy <jon.maloy@ericsson.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      e9f8b101
    • David S. Miller's avatar
      Merge branch 'thunderx-xdp' · b0e92279
      David S. Miller authored
      Sunil Goutham says:
      
      ====================
      net: thunderx: Adds XDP support
      
      This patch series adds support for XDP to ThunderX NIC driver
      which is used on CN88xx, CN81xx and CN83xx platforms.
      
      Patches 1-4 are performance improvement and cleanup patches
      which are done keeping XDP performance bottlenecks in view.
      Rest of the patches adds actual XDP support.
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      b0e92279
    • Sunil Goutham's avatar
      net: thunderx: Optimize page recycling for XDP · 77322538
      Sunil Goutham authored
      Driver follows a method of taking one extra reference on the
      page for recycling which is fine in usual packet path where
      each 64KB page is segmented into multiple receive buffers.
      
      But in XDP mode since there is just one receive buffer per
      page taking extra page reference itself becomes big bottleneck
      consuming ~50% of CPU cycles due to atomic operations.
      
      This patch adds a internal ref count in pgcache for each
      page and additional page references are taken in a batch
      instead of just one at a time. Internal i.e 'pgcache->ref_count'
      and page's i.e 'page->_refcount' counters are compared to check
      page's recyclability.
      Signed-off-by: default avatarSunil Goutham <sgoutham@cavium.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      77322538
    • Sunil Goutham's avatar
      net: thunderx: Support for XDP header adjustment · e3d06ff9
      Sunil Goutham authored
      When in XDP mode reserve XDP_PACKET_HEADROOM bytes at the start
      of receive buffer for XDP program to modify headers and adjust
      packet start. Additional code changes done to handle such packets.
      Signed-off-by: default avatarSunil Goutham <sgoutham@cavium.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      e3d06ff9
    • Sunil Goutham's avatar
      net: thunderx: Add support for XDP_TX · 16f2bccd
      Sunil Goutham authored
      Adds support for XDP_TX i.e transmits packet out of
      the XDP TX queue mapped to the corresponding Rx queue
      on which packet is received.
      
      Since SQ for XDP TX will be used only on a single cpu i.e
      SQ description creation and freeing, using atomic free count
      is not necessary and will become a bottleneck. Hence added
      a separate 'xdp_free_cnt' used for SQs designated for XDP
      to track descriptor free count.
      
      Changes also include
      - A new entry 'xdp_page' is added to save transmitted packet's
        page pointer for later cleanup.
      - XDP Tx SQ's doorbell is ringed once per NAPI instance.
      - Retrieving designated SQ for packets being sent out by stack
        via 'nicvf_xmit'.
      Signed-off-by: default avatarSunil Goutham <sgoutham@cavium.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      16f2bccd
    • Sunil Goutham's avatar
      net: thunderx: Add support for XDP_DROP · c56d91ce
      Sunil Goutham authored
      Adds support for XDP_DROP.
      Also since in XDP mode there is just a single buffer per page,
      made changes to recycle DMA mapping info as well along with pages.
      Signed-off-by: default avatarSunil Goutham <sgoutham@cavium.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      c56d91ce
    • Sunil Goutham's avatar
      net: thunderx: Add basic XDP support · 05c773f5
      Sunil Goutham authored
      Adds basic XDP support i.e attaching a BPF program to an
      interface. Also takes care of allocating separate Tx queues
      for XDP path and for network stack packet transmission.
      
      This patch doesn't support handling of any of the XDP actions,
      all are treated as XDP_PASS i.e packets will be handed over to
      the network stack.
      
      Changes also involve allocating one receive buffer per page in XDP
      mode and multiple in normal mode i.e when no BPF program is attached.
      Signed-off-by: default avatarSunil Goutham <sgoutham@cavium.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      05c773f5
    • Sunil Goutham's avatar
      net: thunderx: Cleanup receive buffer allocation · 927987f3
      Sunil Goutham authored
      Get rid of unnecessary double pointer references and type casting
      in receive buffer allocation code.
      Signed-off-by: default avatarSunil Goutham <sgoutham@cavium.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      927987f3
    • Sunil Goutham's avatar
      net: thunderx: Optimize CQE_TX handling · 0dada88b
      Sunil Goutham authored
      Optimized CQE handling with below changes
      - Feeing descriptors back to SQ in bulk i.e once per NAPI
        instance instead for every CQE_TX, this will reduce number
        of atomic updates to 'sq->free_cnt'.
      - Checking errors in CQE_TX and CQE_RX before calling appropriate
        fn()s to update error stats i.e reduce branching.
      
      Also removed debug messages in packet handling path which otherwise
      causes issues if DEBUG is enabled.
      Signed-off-by: default avatarSunil Goutham <sgoutham@cavium.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      0dada88b
    • Sunil Goutham's avatar
      net: thunderx: Optimize RBDR descriptor handling · 5e848e4c
      Sunil Goutham authored
      Receive buffer's physical address or iova will anyway not
      go beyond 49bits, since it is the max supported HW address.
      As per perf, updating bitfields i.e buf_addr:42 in RBDR
      descriptor entry consumes lots of cpu cycles, hence changed
      it to a 64bit field with alignment requirements taken care of.
      Signed-off-by: default avatarSunil Goutham <sgoutham@cavium.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      5e848e4c
    • Sunil Goutham's avatar
      net: thunderx: Support for page recycling · 5836b442
      Sunil Goutham authored
      Adds support for page recycling for allocating receive buffers
      to reduce cost of refilling RBDR ring. Also got rid of using
      compound pages when pagesize is 4K, only order-0 pages now.
      
      Only page is recycled, DMA mappings still needs to be done for
      every receive buffer allocated due to following constraints
      - Cannot have just one receive buffer per 64KB page.
      - There is just one buffer ring shared across 8 Rx queues, so
        buffers of same page can go to any Rx queue.
      - HW gives buffer address where packet has been DMA'ed and not
        the index into buffer ring.
      This makes it not possible to resue DMA mapping info. So unfortunately
      have to go through costly mapping route for every buffer.
      Signed-off-by: default avatarSunil Goutham <sgoutham@cavium.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      5836b442
    • Dan Carpenter's avatar
      ipx: call ipxitf_put() in ioctl error path · ee0d8d84
      Dan Carpenter authored
      We should call ipxitf_put() if the copy_to_user() fails.
      Reported-by: default avatar李强 <liqiang6-s@360.cn>
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      ee0d8d84
    • Jiri Pirko's avatar
      net: sched: add helpers to handle extended actions · 9da3242e
      Jiri Pirko authored
      Jump is now the only one using value action opcode. This is going to
      change soon. So introduce helpers to work with this. Convert TC_ACT_JUMP.
      
      This also fixes the TC_ACT_JUMP check, which is incorrectly done as a
      bit check, not a value check.
      
      Fixes: e0ee84de ("net sched actions: Complete the JUMPX opcode")
      Signed-off-by: default avatarJiri Pirko <jiri@mellanox.com>
      Acked-by: default avatarJamal Hadi Salim <jhs@mojatatu.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      9da3242e
    • David S. Miller's avatar
      Merge branch 'qed-PTP-fixes' · 5657f89a
      David S. Miller authored
      Sudarsana Reddy Kalluru says:
      
      ====================
      qed*: PTP bug fixes.
      
      The series addresses couple of issues in the PTP implementation.
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      5657f89a
    • sudarsana.kalluru@cavium.com's avatar
      qed*: Fix issues in the ptp filter config implementation. · 8d3f87d8
      sudarsana.kalluru@cavium.com authored
      PTP hardware filter configuration performed by the driver for a given
      user requested config is not correct for some of the PTP modes.
      Following changes are needed for PTP config-filter implementation.
       1. NIG_REG_TX_PTP_EN register - Bits 0/1/2 respectively enables
          TimeSync/"V1 frame format support"/"V2 frame format support" on
          the TX side. Set the associated bits based on the user request.
       2. ptp4l application fails to operate in Peer Delay mode. Following
          changes are needed to fix this,
          a. Driver should enable (set to 0) DA #1-related bits for IPv4,
             IPv6 and MAC destination addresses in these registers:
               NIG_REG_TX_LLH_PTP_RULE_MASK
               NIG_REG_LLH_PTP_RULE_MASK
          b. NIG_REG_LLH_PTP_PARAM_MASK/NIG_REG_TX_LLH_PTP_PARAM_MASK should
             be set to 0x0 in all modes.
      Signed-off-by: default avatarSudarsana Reddy Kalluru <Sudarsana.Kalluru@cavium.com>
      Signed-off-by: default avatarYuval Mintz <Yuval.Mintz@cavium.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      8d3f87d8
    • sudarsana.kalluru@cavium.com's avatar
      qede: Fix concurrency issue in PTP Tx path processing. · 461eec12
      sudarsana.kalluru@cavium.com authored
      PTP Tx timestamping data structures are not protected against the
      concurrent access in the Tx paths. Protecting the same using atomic
      bit locks.
      Signed-off-by: default avatarSudarsana Reddy Kalluru <Sudarsana.Kalluru@cavium.com>
      Signed-off-by: default avatarYuval Mintz <Yuval.Mintz@cavium.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      461eec12
    • Jan Kiszka's avatar
      stmmac: Add support for SIMATIC IOT2000 platform · 212c7fd6
      Jan Kiszka authored
      The IOT2000 is industrial controller platform, derived from the Intel
      Galileo Gen2 board. The variant IOT2020 comes with one LAN port, the
      IOT2040 has two of them. They can be told apart based on the board asset
      tag in the DMI table.
      
      Based on patch by Sascha Weisenberger.
      Signed-off-by: default avatarJan Kiszka <jan.kiszka@siemens.com>
      Signed-off-by: default avatarSascha Weisenberger <sascha.weisenberger@siemens.com>
      Reviewed-by: default avatarAndy Shevchenko <andy.shevchenko@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      212c7fd6
    • Timmy Li's avatar
      net: hns: fix ethtool_get_strings overflow in hns driver · 412b65d1
      Timmy Li authored
      hns_get_sset_count() returns HNS_NET_STATS_CNT and the data space allocated
      is not enough for ethtool_get_strings(), which will cause random memory
      corruption.
      
      When SLAB and DEBUG_SLAB are both enabled, memory corruptions like the
      the following can be observed without this patch:
      [   43.115200] Slab corruption (Not tainted): Acpi-ParseExt start=ffff801fb0b69030, len=80
      [   43.115206] Redzone: 0x9f911029d006462/0x5f78745f31657070.
      [   43.115208] Last user: [<5f7272655f746b70>](0x5f7272655f746b70)
      [   43.115214] 010: 70 70 65 31 5f 74 78 5f 70 6b 74 00 6b 6b 6b 6b  ppe1_tx_pkt.kkkk
      [   43.115217] 030: 70 70 65 31 5f 74 78 5f 70 6b 74 5f 6f 6b 00 6b  ppe1_tx_pkt_ok.k
      [   43.115218] Next obj: start=ffff801fb0b69098, len=80
      [   43.115220] Redzone: 0x706d655f6f666966/0x9f911029d74e35b.
      [   43.115229] Last user: [<ffff0000084b11b0>](acpi_os_release_object+0x28/0x38)
      [   43.115231] 000: 74 79 00 6b 6b 6b 6b 6b 70 70 65 31 5f 74 78 5f  ty.kkkkkppe1_tx_
      [   43.115232] 010: 70 6b 74 5f 65 72 72 5f 63 73 75 6d 5f 66 61 69  pkt_err_csum_fai
      Signed-off-by: default avatarTimmy Li <lixiaoping3@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      412b65d1
    • Eric Dumazet's avatar
      tcp: fix wraparound issue in tcp_lp · a9f11f96
      Eric Dumazet authored
      Be careful when comparing tcp_time_stamp to some u32 quantity,
      otherwise result can be surprising.
      
      Fixes: 7c106d7e ("[TCP]: TCP Low Priority congestion control")
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      a9f11f96
    • Daniel Borkmann's avatar
      bpf, arm64: fix jit branch offset related to ldimm64 · ddc665a4
      Daniel Borkmann authored
      When the instruction right before the branch destination is
      a 64 bit load immediate, we currently calculate the wrong
      jump offset in the ctx->offset[] array as we only account
      one instruction slot for the 64 bit load immediate although
      it uses two BPF instructions. Fix it up by setting the offset
      into the right slot after we incremented the index.
      
      Before (ldimm64 test 1):
      
        [...]
        00000020:  52800007  mov w7, #0x0 // #0
        00000024:  d2800060  mov x0, #0x3 // #3
        00000028:  d2800041  mov x1, #0x2 // #2
        0000002c:  eb01001f  cmp x0, x1
        00000030:  54ffff82  b.cs 0x00000020
        00000034:  d29fffe7  mov x7, #0xffff // #65535
        00000038:  f2bfffe7  movk x7, #0xffff, lsl #16
        0000003c:  f2dfffe7  movk x7, #0xffff, lsl #32
        00000040:  f2ffffe7  movk x7, #0xffff, lsl #48
        00000044:  d29dddc7  mov x7, #0xeeee // #61166
        00000048:  f2bdddc7  movk x7, #0xeeee, lsl #16
        0000004c:  f2ddddc7  movk x7, #0xeeee, lsl #32
        00000050:  f2fdddc7  movk x7, #0xeeee, lsl #48
        [...]
      
      After (ldimm64 test 1):
      
        [...]
        00000020:  52800007  mov w7, #0x0 // #0
        00000024:  d2800060  mov x0, #0x3 // #3
        00000028:  d2800041  mov x1, #0x2 // #2
        0000002c:  eb01001f  cmp x0, x1
        00000030:  540000a2  b.cs 0x00000044
        00000034:  d29fffe7  mov x7, #0xffff // #65535
        00000038:  f2bfffe7  movk x7, #0xffff, lsl #16
        0000003c:  f2dfffe7  movk x7, #0xffff, lsl #32
        00000040:  f2ffffe7  movk x7, #0xffff, lsl #48
        00000044:  d29dddc7  mov x7, #0xeeee // #61166
        00000048:  f2bdddc7  movk x7, #0xeeee, lsl #16
        0000004c:  f2ddddc7  movk x7, #0xeeee, lsl #32
        00000050:  f2fdddc7  movk x7, #0xeeee, lsl #48
        [...]
      
      Also, add a couple of test cases to make sure JITs pass
      this test. Tested on Cavium ThunderX ARMv8. The added
      test cases all pass after the fix.
      
      Fixes: 8eee539d ("arm64: bpf: fix out-of-bounds read in bpf2a64_offset()")
      Reported-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Cc: Xi Wang <xi.wang@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      ddc665a4
    • Daniel Borkmann's avatar
      bpf, arm64: implement jiting of BPF_XADD · 85f68fe8
      Daniel Borkmann authored
      This work adds BPF_XADD for BPF_W/BPF_DW to the arm64 JIT and therefore
      completes JITing of all BPF instructions, meaning we can thus also remove
      the 'notyet' label and do not need to fall back to the interpreter when
      BPF_XADD is used in a program!
      
      This now also brings arm64 JIT in line with x86_64, s390x, ppc64, sparc64,
      where all current eBPF features are supported.
      
      BPF_W example from test_bpf:
      
        .u.insns_int = {
          BPF_ALU32_IMM(BPF_MOV, R0, 0x12),
          BPF_ST_MEM(BPF_W, R10, -40, 0x10),
          BPF_STX_XADD(BPF_W, R10, R0, -40),
          BPF_LDX_MEM(BPF_W, R0, R10, -40),
          BPF_EXIT_INSN(),
        },
      
        [...]
        00000020:  52800247  mov w7, #0x12 // #18
        00000024:  928004eb  mov x11, #0xffffffffffffffd8 // #-40
        00000028:  d280020a  mov x10, #0x10 // #16
        0000002c:  b82b6b2a  str w10, [x25,x11]
        // start of xadd mapping:
        00000030:  928004ea  mov x10, #0xffffffffffffffd8 // #-40
        00000034:  8b19014a  add x10, x10, x25
        00000038:  f9800151  prfm pstl1strm, [x10]
        0000003c:  885f7d4b  ldxr w11, [x10]
        00000040:  0b07016b  add w11, w11, w7
        00000044:  880b7d4b  stxr w11, w11, [x10]
        00000048:  35ffffab  cbnz w11, 0x0000003c
        // end of xadd mapping:
        [...]
      
      BPF_DW example from test_bpf:
      
        .u.insns_int = {
          BPF_ALU32_IMM(BPF_MOV, R0, 0x12),
          BPF_ST_MEM(BPF_DW, R10, -40, 0x10),
          BPF_STX_XADD(BPF_DW, R10, R0, -40),
          BPF_LDX_MEM(BPF_DW, R0, R10, -40),
          BPF_EXIT_INSN(),
        },
      
        [...]
        00000020:  52800247  mov w7,  #0x12 // #18
        00000024:  928004eb  mov x11, #0xffffffffffffffd8 // #-40
        00000028:  d280020a  mov x10, #0x10 // #16
        0000002c:  f82b6b2a  str x10, [x25,x11]
        // start of xadd mapping:
        00000030:  928004ea  mov x10, #0xffffffffffffffd8 // #-40
        00000034:  8b19014a  add x10, x10, x25
        00000038:  f9800151  prfm pstl1strm, [x10]
        0000003c:  c85f7d4b  ldxr x11, [x10]
        00000040:  8b07016b  add x11, x11, x7
        00000044:  c80b7d4b  stxr w11, x11, [x10]
        00000048:  35ffffab  cbnz w11, 0x0000003c
        // end of xadd mapping:
        [...]
      
      Tested on Cavium ThunderX ARMv8, test suite results after the patch:
      
        No JIT:   [ 3751.855362] test_bpf: Summary: 311 PASSED, 0 FAILED, [0/303 JIT'ed]
        With JIT: [ 3573.759527] test_bpf: Summary: 311 PASSED, 0 FAILED, [303/303 JIT'ed]
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      85f68fe8
    • Linus Torvalds's avatar
      Merge branch 'work.compat' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs · 204f144c
      Linus Torvalds authored
      Pull fs/compat.c cleanups from Al Viro:
       "More moving of compat syscalls from fs/compat.c to fs/*.c where the
        native counterparts live.
      
        And death to compat_sys_getdents64() - the only architecture that used
        to need it was ia64, and _that_ has lost biarch support quite a few
        years ago"
      
      * 'work.compat' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
        fs/compat.c: trim unused includes
        move compat_rw_copy_check_uvector() over to fs/read_write.c
        fhandle: move compat syscalls from compat.c
        open: move compat syscalls from compat.c
        stat: move compat syscalls from compat.c
        fcntl: move compat syscalls from compat.c
        readdir: move compat syscalls from compat.c
        statfs: move compat syscalls from compat.c
        utimes: move compat syscalls from compat.c
        move compat select-related syscalls to fs/select.c
        Remove compat_sys_getdents64()
      204f144c
    • Linus Torvalds's avatar
      Merge branch 'work.splice' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs · da7b66ff
      Linus Torvalds authored
      Pull splice updates from Al Viro:
       "These actually missed the last cycle; the branch itself is from last
        December"
      
      * 'work.splice' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
        make nr_pages calculation in default_file_splice_read() a bit less ugly
        splice/tee/vmsplice: validate flags
        splice_pipe_desc: kill ->flags
        remove spd_release_page()
      da7b66ff
    • Linus Torvalds's avatar
      Merge branch 'work.iov_iter' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs · 5b13475a
      Linus Torvalds authored
      Pull iov_iter updates from Al Viro:
       "Cleanups that sat in -next + -stable fodder that has just missed 4.11.
      
        There's more iov_iter work in my local tree, but I'd prefer to push
        the stuff that had been in -next first"
      
      * 'work.iov_iter' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
        iov_iter: don't revert iov buffer if csum error
        generic_file_read_iter(): make use of iov_iter_revert()
        generic_file_direct_write(): make use of iov_iter_revert()
        orangefs: use iov_iter_revert()
        sctp: switch to copy_from_iter_full()
        net/9p: switch to copy_from_iter_full()
        switch memcpy_from_msg() to copy_from_iter_full()
        rds: make use of iov_iter_revert()
      5b13475a
    • Linus Torvalds's avatar
      Merge branch 'for-next' of git://git.samba.org/sfrench/cifs-2.6 · 6fd4e7f7
      Linus Torvalds authored
      Pull CIFS fixes from Steve French:
       "Three cifs/smb3 fixes - including two for stable"
      
      * 'for-next' of git://git.samba.org/sfrench/cifs-2.6:
        cifs: don't check for failure from mempool_alloc()
        Do not return number of bytes written for ioctl CIFS_IOC_COPYCHUNK_FILE
        Fix match_prepath()
      6fd4e7f7
    • Linus Torvalds's avatar
      Merge tag 'usercopy-v4.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux · 5958cc49
      Linus Torvalds authored
      Pull hardened usercopy updates from Kees Cook:
       "A couple hardened usercopy changes:
      
         - drop now unneeded is_vmalloc_or_module() check (Laura Abbott)
      
         - use enum instead of literals for stack frame API (Sahara)"
      
      * tag 'usercopy-v4.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux:
        mm/usercopy: Drop extra is_vmalloc_or_module() check
        usercopy: Move enum for arch_within_stack_frames()
      5958cc49
    • Linus Torvalds's avatar
      Merge tag 'pstore-v4.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux · 2575be8a
      Linus Torvalds authored
      Pull pstore updates from Kees Cook:
       "This has a large internal refactoring along with several smaller
        fixes.
      
         - constify compression structures; Bhumika Goyal
      
         - restore powerpc dumping; Ankit Kumar
      
         - fix more bugs in the rarely exercises module unloading logic
      
         - reorganize filesystem locking to fix problems noticed by lockdep
      
         - refactor internal pstore APIs to make development and review
           easier:
            - improve error reporting
            - add kernel-doc structure and function comments
            - avoid insane argument passing by using a common record
              structure"
      
      * tag 'pstore-v4.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux: (23 commits)
        pstore: Solve lockdep warning by moving inode locks
        pstore: Fix flags to enable dumps on powerpc
        pstore: Remove unused vmalloc.h in pmsg
        pstore: simplify write_user_compat()
        pstore: Remove write_buf() callback
        pstore: Replace arguments for write_buf_user() API
        pstore: Replace arguments for write_buf() API
        pstore: Replace arguments for erase() API
        pstore: Do not duplicate record metadata
        pstore: Allocate records on heap instead of stack
        pstore: Pass record contents instead of copying
        pstore: Always allocate buffer for decompression
        pstore: Replace arguments for write() API
        pstore: Replace arguments for read() API
        pstore: Switch pstore_mkfile to pass record
        pstore: Move record decompression to function
        pstore: Extract common arguments into structure
        pstore: Add kernel-doc for struct pstore_info
        pstore: Improve register_pstore() error reporting
        pstore: Avoid race in module unloading
        ...
      2575be8a
    • Linus Torvalds's avatar
      Merge tag 'docs-4.12' of git://git.lwn.net/linux · c58d4055
      Linus Torvalds authored
      Pull documentation update from Jonathan Corbet:
       "A reasonably busy cycle for documentation this time around. There is a
        new guide for user-space API documents, rather sparsely populated at
        the moment, but it's a start. Markus improved the infrastructure for
        converting diagrams. Mauro has converted much of the USB documentation
        over to RST. Plus the usual set of fixes, improvements, and tweaks.
      
        There's a bit more than the usual amount of reaching out of
        Documentation/ to fix comments elsewhere in the tree; I have acks for
        those where I could get them"
      
      * tag 'docs-4.12' of git://git.lwn.net/linux: (74 commits)
        docs: Fix a couple typos
        docs: Fix a spelling error in vfio-mediated-device.txt
        docs: Fix a spelling error in ioctl-number.txt
        MAINTAINERS: update file entry for HSI subsystem
        Documentation: allow installing man pages to a user defined directory
        Doc/PM: Sync with intel_powerclamp code behavior
        zr364xx.rst: usb/devices is now at /sys/kernel/debug/
        usb.rst: move documentation from proc_usb_info.txt to USB ReST book
        convert philips.txt to ReST and add to media docs
        docs-rst: usb: update old usbfs-related documentation
        arm: Documentation: update a path name
        docs: process/4.Coding.rst: Fix a couple of document refs
        docs-rst: fix usb cross-references
        usb: gadget.h: be consistent at kernel doc macros
        usb: composite.h: fix two warnings when building docs
        usb: get rid of some ReST doc build errors
        usb.rst: get rid of some Sphinx errors
        usb/URB.txt: convert to ReST and update it
        usb/persist.txt: convert to ReST and add to driver-api book
        usb/hotplug.txt: convert to ReST and add to driver-api book
        ...
      c58d4055
    • Linus Torvalds's avatar
      Merge tag 'm68k-for-v4.12-tag1' of git://git.kernel.org/pub/scm/linux/kernel/git/geert/linux-m68k · ceb198bb
      Linus Torvalds authored
      Pull m68k updates from Geert Uytterhoeven:
      
        - more kernel message modernizations and cleanups
      
        - Mac and Nubus improvements and cleanups.
      
      * tag 'm68k-for-v4.12-tag1' of git://git.kernel.org/pub/scm/linux/kernel/git/geert/linux-m68k:
        nubus: Add MVC and VSC video card definitions
        nubus: Clean up whitespace
        nubus: Clean up printk calls
        nubus: Fix nubus_rewinddir
        m68k/mac: Clarify IOP message alloc/free confusion
        m68k/mac: Adopt platform_device_register_simple()
        m68k/mac: Modernize printing of kernel messages
        m68k/mac: IOP - Modernize printing of kernel messages
      ceb198bb
    • Linus Torvalds's avatar
      Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux · b68e7e95
      Linus Torvalds authored
      Pull s390 updates from Martin Schwidefsky:
      
       - three merges for KVM/s390 with changes for vfio-ccw and cpacf. The
         patches are included in the KVM tree as well, let git sort it out.
      
       - add the new 'trng' random number generator
      
       - provide the secure key verification API for the pkey interface
      
       - introduce the z13 cpu counters to perf
      
       - add a new system call to set up the guarded storage facility
      
       - simplify TASK_SIZE and arch_get_unmapped_area
      
       - export the raw STSI data related to CPU topology to user space
      
       - ... and the usual churn of bug-fixes and cleanups.
      
      * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux: (74 commits)
        s390/crypt: use the correct module alias for paes_s390.
        s390/cpacf: Introduce kma instruction
        s390/cpacf: query instructions use unique parameters for compatibility with KMA
        s390/trng: Introduce s390 TRNG device driver.
        s390/crypto: Provide s390 specific arch random functionality.
        s390/crypto: Add new subfunctions to the cpacf PRNO function.
        s390/crypto: Renaming PPNO to PRNO.
        s390/pageattr: avoid unnecessary page table splitting
        s390/mm: simplify arch_get_unmapped_area[_topdown]
        s390/mm: make TASK_SIZE independent from the number of page table levels
        s390/gs: add regset for the guarded storage broadcast control block
        s390/kvm: Add use_cmma field to mm_context_t
        s390/kvm: Add PGSTE manipulation functions
        vfio: ccw: improve error handling for vfio_ccw_mdev_remove
        vfio: ccw: remove unnecessary NULL checks of a pointer
        s390/spinlock: remove compare and delay instruction
        s390/spinlock: use atomic primitives for spinlocks
        s390/cpumf: simplify detection of guest samples
        s390/pci: remove forward declaration
        s390/pci: increase the PCI_NR_FUNCTIONS default
        ...
      b68e7e95
    • David S. Miller's avatar
      Merge branch 'bpf-test-prog-fixes' · a481649e
      David S. Miller authored
      I say:
      
      ====================
      Fix some bpf program testing framework bugs
      
      This series fixes two issue:
      
      1) Accidental user pointer dereference in bpf_test_finish()
      
      2) The packet data given to the test programs is not aligned correctly
      
      The first issue is fixed simply because we have a kernel side copy
      of the datastructure in question already.  And the second bug is
      a simple matter of applying NET_IP_ALIGN where needed.
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      a481649e
    • David Miller's avatar
      bpf: Align packet data properly in program testing framework. · 586f8525
      David Miller authored
      Make sure we apply NET_IP_ALIGN when reserving headroom for SKB
      and XDP test runs, just like a real driver would.
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Acked-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      586f8525
    • David Miller's avatar
      bpf: Do not dereference user pointer in bpf_test_finish(). · 78e52272
      David Miller authored
      Instead, pass the kattr in which has a kernel side copy of this
      data structure from userspace already.
      
      Fix based upon a suggestion from Alexei Starovoitov.
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Acked-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      78e52272
    • David S. Miller's avatar
      selftests: bpf: Use bpf_endian.h in test_xdp.c · 4e9c3a66
      David S. Miller authored
      This fixes the testcase on big-endian.
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      4e9c3a66
    • Jakub Kicinski's avatar
      xdp: fix parameter kdoc for extack · b5d60989
      Jakub Kicinski authored
      Fix kdoc parameter spelling from extact to extack.
      Signed-off-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      b5d60989
    • Daniel Borkmann's avatar
      bpf, samples: fix build warning in cookie_uid_helper_example · eb6211d3
      Daniel Borkmann authored
      Fix the following warnings triggered by 51570a5a ("A Sample of
      using socket cookie and uid for traffic monitoring"):
      
        In file included from /home/foo/net-next/samples/bpf/cookie_uid_helper_example.c:54:0:
        /home/foo/net-next/samples/bpf/cookie_uid_helper_example.c: In function 'prog_load':
        /home/foo/net-next/samples/bpf/cookie_uid_helper_example.c:119:27: warning: overflow in implicit constant conversion [-Woverflow]
           -32 + offsetof(struct stats, uid)),
                                 ^
        /home/foo/net-next/samples/bpf/libbpf.h:135:12: note: in definition of macro 'BPF_STX_MEM'
         .off   = OFF,     \
                  ^
        /home/foo/net-next/samples/bpf/cookie_uid_helper_example.c:121:27: warning: overflow in implicit constant conversion [-Woverflow]
           -32 + offsetof(struct stats, packets), 1),
                                 ^
        /home/foo/net-next/samples/bpf/libbpf.h:155:12: note: in definition of macro 'BPF_ST_MEM'
         .off   = OFF,     \
                  ^
        /home/foo/net-next/samples/bpf/cookie_uid_helper_example.c:129:27: warning: overflow in implicit constant conversion [-Woverflow]
           -32 + offsetof(struct stats, bytes)),
                                 ^
        /home/foo/net-next/samples/bpf/libbpf.h:135:12: note: in definition of macro 'BPF_STX_MEM'
         .off   = OFF,     \
                  ^
        HOSTLD  /home/foo/net-next/samples/bpf/per_socket_stats_example
      
      Fixes: 51570a5a ("A Sample of using socket cookie and uid for traffic monitoring")
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      eb6211d3