Skip to content
Snippets Groups Projects
  1. Dec 02, 2022
  2. Dec 01, 2022
    • Florian Westphal's avatar
      inet: ping: use hlist_nulls rcu iterator during lookup · c25b7a7a
      Florian Westphal authored and Paolo Abeni's avatar Paolo Abeni committed
      
      ping_lookup() does not acquire the table spinlock, so iteration should
      use hlist_nulls_for_each_entry_rcu().
      
      Spotted during code review.
      
      Fixes: dbca1596 ("ping: convert to RCU lookups, get rid of rwlock")
      Cc: Eric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
      Link: https://lore.kernel.org/r/20221129140644.28525-1-fw@strlen.de
      
      
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      c25b7a7a
    • Jason Gunthorpe's avatar
      iommufd: Data structure to provide IOVA to PFN mapping · 51fe6141
      Jason Gunthorpe authored
      This is the remainder of the IOAS data structure. Provide an object called
      an io_pagetable that is composed of iopt_areas pointing at iopt_pages,
      along with a list of iommu_domains that mirror the IOVA to PFN map.
      
      At the top this is a simple interval tree of iopt_areas indicating the map
      of IOVA to iopt_pages. An xarray keeps track of a list of domains. Based
      on the attached domains there is a minimum alignment for areas (which may
      be smaller than PAGE_SIZE), an interval tree of reserved IOVA that can't
      be mapped and an IOVA of allowed IOVA that can always be mappable.
      
      The concept of an 'access' refers to something like a VFIO mdev that is
      accessing the IOVA and using a 'struct page *' for CPU based access.
      
      Externally an API is provided that matches the requirements of the IOCTL
      interface for map/unmap and domain attachment.
      
      The API provides a 'copy' primitive to establish a new IOVA map in a
      different IOAS from an existing mapping by re-using the iopt_pages. This
      is the basic mechanism to provide single pinning.
      
      This is designed to support a pre-registration flow where userspace would
      setup an dummy IOAS with no domains, map in memory and then establish an
      access to pin all PFNs into the xarray.
      
      Copy can then be used to create new IOVA mappings in a different IOAS,
      with iommu_domains attached. Upon copy the PFNs will be read out of the
      xarray and mapped into the iommu_domains, avoiding any pin_user_pages()
      overheads.
      
      Link: https://lore.kernel.org/r/10-v6-a196d26f289e+11787-iommufd_jgg@nvidia.com
      
      
      Tested-by: default avatarNicolin Chen <nicolinc@nvidia.com>
      Tested-by: default avatarYi Liu <yi.l.liu@intel.com>
      Tested-by: default avatarLixiao Yang <lixiao.yang@intel.com>
      Tested-by: default avatarMatthew Rosato <mjrosato@linux.ibm.com>
      Reviewed-by: default avatarKevin Tian <kevin.tian@intel.com>
      Signed-off-by: default avatarYi Liu <yi.l.liu@intel.com>
      Signed-off-by: default avatarNicolin Chen <nicolinc@nvidia.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
      51fe6141
    • Jason Gunthorpe's avatar
      iommufd: PFN handling for iopt_pages · f394576e
      Jason Gunthorpe authored
      The top of the data structure provides an IO Address Space (IOAS) that is
      similar to a VFIO container. The IOAS allows map/unmap of memory into
      ranges of IOVA called iopt_areas. Multiple IOMMU domains (IO page tables)
      and in-kernel accesses (like VFIO mdevs) can be attached to the IOAS to
      access the PFNs that those IOVA areas cover.
      
      The IO Address Space (IOAS) datastructure is composed of:
       - struct io_pagetable holding the IOVA map
       - struct iopt_areas representing populated portions of IOVA
       - struct iopt_pages representing the storage of PFNs
       - struct iommu_domain representing each IO page table in the system IOMMU
       - struct iopt_pages_access representing in-kernel accesses of PFNs (ie
         VFIO mdevs)
       - struct xarray pinned_pfns holding a list of pages pinned by in-kernel
         accesses
      
      This patch introduces the lowest part of the datastructure - the movement
      of PFNs in a tiered storage scheme:
       1) iopt_pages::pinned_pfns xarray
       2) Multiple iommu_domains
       3) The origin of the PFNs, i.e. the userspace pointer
      
      PFN have to be copied between all combinations of tiers, depending on the
      configuration.
      
      The interface is an iterator called a 'pfn_reader' which determines which
      tier each PFN is stored and loads it into a list of PFNs held in a struct
      pfn_batch.
      
      Each step of the iterator will fill up the pfn_batch, then the caller can
      use the pfn_batch to send the PFNs to the required destination. Repeating
      this loop will read all the PFNs in an IOVA range.
      
      The pfn_reader and pfn_batch also keep track of the pinned page accounting.
      
      While PFNs are always stored and accessed as full PAGE_SIZE units the
      iommu_domain tier can store with a sub-page offset/length to support
      IOMMUs with a smaller IOPTE size than PAGE_SIZE.
      
      Link: https://lore.kernel.org/r/8-v6-a196d26f289e+11787-iommufd_jgg@nvidia.com
      
      
      Reviewed-by: default avatarKevin Tian <kevin.tian@intel.com>
      Tested-by: default avatarNicolin Chen <nicolinc@nvidia.com>
      Tested-by: default avatarYi Liu <yi.l.liu@intel.com>
      Tested-by: default avatarLixiao Yang <lixiao.yang@intel.com>
      Tested-by: default avatarMatthew Rosato <mjrosato@linux.ibm.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
      f394576e
  3. Nov 29, 2022
  4. Jul 19, 2022
  5. May 20, 2022
  6. Dec 16, 2021
  7. May 12, 2021
  8. Feb 17, 2021
    • Ben Widawsky's avatar
      cxl/mem: Add basic IOCTL interface · 583fa5e7
      Ben Widawsky authored
      
      Add a straightforward IOCTL that provides a mechanism for userspace to
      query the supported memory device commands. CXL commands as they appear
      to userspace are described as part of the UAPI kerneldoc. The command
      list returned via this IOCTL will contain the full set of commands that
      the driver supports, however, some of those commands may not be
      available for use by userspace.
      
      Memory device commands first appear in the CXL 2.0 specification. They
      are submitted through a mailbox mechanism specified in the CXL 2.0
      specification.
      
      The send command allows userspace to issue mailbox commands directly to
      the hardware. The list of available commands to send are the output of
      the query command. The driver verifies basic properties of the command
      and possibly inspect the input (or output) payload to determine whether
      or not the command is allowed (or might taint the kernel).
      
      Reported-by: kernel test robot <lkp@intel.com> # bug in earlier revision
      Reported-by: default avatarStephen Rothwell <sfr@canb.auug.org.au>
      Signed-off-by: default avatarBen Widawsky <ben.widawsky@intel.com>
      Reviewed-by: Dan Williams <dan.j.williams@intel.com> (v2)
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Link: https://lore.kernel.org/r/20210217040958.1354670-5-ben.widawsky@intel.com
      
      
      Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
      583fa5e7
  9. Jan 29, 2021
  10. Oct 14, 2020
    • Mike Rapoport's avatar
      memblock: use separate iterators for memory and reserved regions · cc6de168
      Mike Rapoport authored
      
      for_each_memblock() is used to iterate over memblock.memory in a few
      places that use data from memblock_region rather than the memory ranges.
      
      Introduce separate for_each_mem_region() and
      for_each_reserved_mem_region() to improve encapsulation of memblock
      internals from its users.
      
      Signed-off-by: default avatarMike Rapoport <rppt@linux.ibm.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Reviewed-by: default avatarBaoquan He <bhe@redhat.com>
      Acked-by: Ingo Molnar <mingo@kernel.org>			[x86]
      Acked-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>	[MIPS]
      Acked-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>	[.clang-format]
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Daniel Axtens <dja@axtens.net>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Emil Renner Berthing <kernel@esmil.dk>
      Cc: Hari Bathini <hbathini@linux.ibm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>
      Cc: Marek Szyprowski <m.szyprowski@samsung.com>
      Cc: Max Filippov <jcmvbkbc@gmail.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Michal Simek <monstr@monstr.eu>
      Cc: Palmer Dabbelt <palmer@dabbelt.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Paul Walmsley <paul.walmsley@sifive.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Stafford Horne <shorne@gmail.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Link: https://lkml.kernel.org/r/20200818151634.14343-18-rppt@kernel.org
      
      
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      cc6de168
    • Mike Rapoport's avatar
      memblock: implement for_each_reserved_mem_region() using __next_mem_region() · 9f3d5eaa
      Mike Rapoport authored
      
      Iteration over memblock.reserved with for_each_reserved_mem_region() used
      __next_reserved_mem_region() that implemented a subset of
      __next_mem_region().
      
      Use __for_each_mem_range() and, essentially, __next_mem_region() with
      appropriate parameters to reduce code duplication.
      
      While on it, rename for_each_reserved_mem_region() to
      for_each_reserved_mem_range() for consistency.
      
      Signed-off-by: default avatarMike Rapoport <rppt@linux.ibm.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Acked-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>	[.clang-format]
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Baoquan He <bhe@redhat.com>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Daniel Axtens <dja@axtens.net>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Emil Renner Berthing <kernel@esmil.dk>
      Cc: Hari Bathini <hbathini@linux.ibm.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>
      Cc: Marek Szyprowski <m.szyprowski@samsung.com>
      Cc: Max Filippov <jcmvbkbc@gmail.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Michal Simek <monstr@monstr.eu>
      Cc: Palmer Dabbelt <palmer@dabbelt.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Paul Walmsley <paul.walmsley@sifive.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Stafford Horne <shorne@gmail.com>
      Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Link: https://lkml.kernel.org/r/20200818151634.14343-17-rppt@kernel.org
      
      
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      9f3d5eaa
    • Mike Rapoport's avatar
      memblock: reduce number of parameters in for_each_mem_range() · 6e245ad4
      Mike Rapoport authored
      
      Currently for_each_mem_range() and for_each_mem_range_rev() iterators are
      the most generic way to traverse memblock regions.  As such, they have 8
      parameters and they are hardly convenient to users.  Most users choose to
      utilize one of their wrappers and the only user that actually needs most
      of the parameters is memblock itself.
      
      To avoid yet another naming for memblock iterators, rename the existing
      for_each_mem_range[_rev]() to __for_each_mem_range[_rev]() and add a new
      for_each_mem_range[_rev]() wrappers with only index, start and end
      parameters.
      
      The new wrapper nicely fits into init_unavailable_mem() and will be used
      in upcoming changes to simplify memblock traversals.
      
      Signed-off-by: default avatarMike Rapoport <rppt@linux.ibm.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Acked-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>	[MIPS]
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Baoquan He <bhe@redhat.com>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Daniel Axtens <dja@axtens.net>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Emil Renner Berthing <kernel@esmil.dk>
      Cc: Hari Bathini <hbathini@linux.ibm.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>
      Cc: Marek Szyprowski <m.szyprowski@samsung.com>
      Cc: Max Filippov <jcmvbkbc@gmail.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Michal Simek <monstr@monstr.eu>
      Cc: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
      Cc: Palmer Dabbelt <palmer@dabbelt.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Paul Walmsley <paul.walmsley@sifive.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Stafford Horne <shorne@gmail.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Link: https://lkml.kernel.org/r/20200818151634.14343-11-rppt@kernel.org
      
      
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      6e245ad4
  11. Sep 09, 2020
  12. Sep 01, 2020
  13. May 25, 2020
  14. Apr 18, 2020
  15. Mar 06, 2020
  16. Aug 31, 2019
  17. Apr 12, 2019
  18. Mar 21, 2019
  19. Feb 19, 2019
  20. Feb 11, 2019
    • Jason Gunthorpe's avatar
      lib/scatterlist: Provide a DMA page iterator · d901b276
      Jason Gunthorpe authored
      
      Commit 2db76d7c ("lib/scatterlist: sg_page_iter: support sg lists w/o
      backing pages") introduced the sg_page_iter_dma_address() function without
      providing a way to use it in the general case. If the sg_dma_len() is not
      equal to the sg length callers cannot safely use the
      for_each_sg_page/sg_page_iter_dma_address combination.
      
      Resolve this API mistake by providing a DMA specific iterator,
      for_each_sg_dma_page(), that uses the right length so
      sg_page_iter_dma_address() works as expected with all sglists.
      
      A new iterator type is introduced to provide compile-time safety against
      wrongly mixing accessors and iterators.
      
      Acked-by: Christoph Hellwig <hch@lst.de> (for scatterlist)
      Acked-by: default avatarThomas Hellstrom <thellstrom@vmware.com>
      Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com> (ipu3-cio2)
      Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
      d901b276
  21. Feb 04, 2019
  22. Jan 19, 2019
  23. Oct 21, 2018
  24. Aug 01, 2018
  25. Apr 11, 2018
    • Miguel Ojeda's avatar
      clang-format: add configuration file · d4ef8d3f
      Miguel Ojeda authored
      clang-format is a tool to format C/C++/...  code according to a set of
      rules and heuristics.  Like most tools, it is not perfect nor covers
      every single case, but it is good enough to be helpful.
      
      In particular, it is useful for quickly re-formatting blocks of code
      automatically, for reviewing full files in order to spot coding style
      mistakes, typos and possible improvements.  It is also handy for sorting
      ``#includes``, for aligning variables and macros, for reflowing text and
      other similar tasks.  It also serves as a teaching tool/guide for
      newcomers.
      
      The tool itself has been already included in the repositories of popular
      Linux distributions for a long time.  The rules in this file are
      intended for clang-format >= 4, which is easily available in most
      distributions.
      
      This commit adds the configuration file that contains the rules that the
      tool uses to know how to format the code according to the kernel coding
      style.  This gives us several advantages:
      
        * clang-format works out of the box with reasonable defaults;
          avoiding that everyone has to re-do the configuration.
      
        * Everyone agrees (eventually) on what is the most useful default
          configuration for most of the kernel.
      
        * If it becomes commonplace among kernel developers, clang-format
          may feel compelled to support us better. They already recognize
          the Linux kernel and its style in their documentation and in one
          of the style sub-options.
      
      Some of clang-format's features relevant for the kernel are:
      
        * Uses clang's tooling support behind the scenes to parse and rewrite
          the code. It is not based on ad-hoc regexps.
      
        * Supports reasonably well the Linux kernel coding style.
      
        * Fast enough to be used at the press of a key.
      
        * There are already integrations (either built-in or third-party)
          for many common editors used by kernel developers (e.g. vim,
          emacs, Sublime, Atom...) that allow you to format an entire file
          or, more usefully, just your selection.
      
        * Able to parse unified diffs -- you can, for instance, reformat
          only the lines changed by a git commit.
      
        * Able to reflow text comments as well.
      
        * Widely supported and used by hundreds of developers in highly
          complex projects and organizations (e.g. the LLVM project itself,
          Chromium, WebKit, Google, Mozilla...). Therefore, it will be
          supported for a long time.
      
      See more information about the tool at:
      
          https://clang.llvm.org/docs/ClangFormat.html
          https://clang.llvm.org/docs/ClangFormatStyleOptions.html
      
      Link: http://lkml.kernel.org/r/20180318171632.qfkemw3mwbcukth6@gmail.com
      
      
      Signed-off-by: default avatarMiguel Ojeda <miguel.ojeda.sandonis@gmail.com>
      Cc: Randy Dunlap <rdunlap@infradead.org>
      Cc: Andy Whitcroft <apw@canonical.com>
      Cc: Joe Perches <joe@perches.com>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      d4ef8d3f
Loading