1. 21 12月, 2017 1 次提交
  2. 02 11月, 2017 1 次提交
    • G
      License cleanup: add SPDX GPL-2.0 license identifier to files with no license · b2441318
      Greg Kroah-Hartman 提交于
      Many source files in the tree are missing licensing information, which
      makes it harder for compliance tools to determine the correct license.
      
      By default all files without license information are under the default
      license of the kernel, which is GPL version 2.
      
      Update the files which contain no license information with the 'GPL-2.0'
      SPDX license identifier.  The SPDX identifier is a legally binding
      shorthand, which can be used instead of the full boiler plate text.
      
      This patch is based on work done by Thomas Gleixner and Kate Stewart and
      Philippe Ombredanne.
      
      How this work was done:
      
      Patches were generated and checked against linux-4.14-rc6 for a subset of
      the use cases:
       - file had no licensing information it it.
       - file was a */uapi/* one with no licensing information in it,
       - file was a */uapi/* one with existing licensing information,
      
      Further patches will be generated in subsequent months to fix up cases
      where non-standard license headers were used, and references to license
      had to be inferred by heuristics based on keywords.
      
      The analysis to determine which SPDX License Identifier to be applied to
      a file was done in a spreadsheet of side by side results from of the
      output of two independent scanners (ScanCode & Windriver) producing SPDX
      tag:value files created by Philippe Ombredanne.  Philippe prepared the
      base worksheet, and did an initial spot review of a few 1000 files.
      
      The 4.13 kernel was the starting point of the analysis with 60,537 files
      assessed.  Kate Stewart did a file by file comparison of the scanner
      results in the spreadsheet to determine which SPDX license identifier(s)
      to be applied to the file. She confirmed any determination that was not
      immediately clear with lawyers working with the Linux Foundation.
      
      Criteria used to select files for SPDX license identifier tagging was:
       - Files considered eligible had to be source code files.
       - Make and config files were included as candidates if they contained >5
         lines of source
       - File already had some variant of a license header in it (even if <5
         lines).
      
      All documentation files were explicitly excluded.
      
      The following heuristics were used to determine which SPDX license
      identifiers to apply.
      
       - when both scanners couldn't find any license traces, file was
         considered to have no license information in it, and the top level
         COPYING file license applied.
      
         For non */uapi/* files that summary was:
      
         SPDX license identifier                            # files
         ---------------------------------------------------|-------
         GPL-2.0                                              11139
      
         and resulted in the first patch in this series.
      
         If that file was a */uapi/* path one, it was "GPL-2.0 WITH
         Linux-syscall-note" otherwise it was "GPL-2.0".  Results of that was:
      
         SPDX license identifier                            # files
         ---------------------------------------------------|-------
         GPL-2.0 WITH Linux-syscall-note                        930
      
         and resulted in the second patch in this series.
      
       - if a file had some form of licensing information in it, and was one
         of the */uapi/* ones, it was denoted with the Linux-syscall-note if
         any GPL family license was found in the file or had no licensing in
         it (per prior point).  Results summary:
      
         SPDX license identifier                            # files
         ---------------------------------------------------|------
         GPL-2.0 WITH Linux-syscall-note                       270
         GPL-2.0+ WITH Linux-syscall-note                      169
         ((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause)    21
         ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)    17
         LGPL-2.1+ WITH Linux-syscall-note                      15
         GPL-1.0+ WITH Linux-syscall-note                       14
         ((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause)    5
         LGPL-2.0+ WITH Linux-syscall-note                       4
         LGPL-2.1 WITH Linux-syscall-note                        3
         ((GPL-2.0 WITH Linux-syscall-note) OR MIT)              3
         ((GPL-2.0 WITH Linux-syscall-note) AND MIT)             1
      
         and that resulted in the third patch in this series.
      
       - when the two scanners agreed on the detected license(s), that became
         the concluded license(s).
      
       - when there was disagreement between the two scanners (one detected a
         license but the other didn't, or they both detected different
         licenses) a manual inspection of the file occurred.
      
       - In most cases a manual inspection of the information in the file
         resulted in a clear resolution of the license that should apply (and
         which scanner probably needed to revisit its heuristics).
      
       - When it was not immediately clear, the license identifier was
         confirmed with lawyers working with the Linux Foundation.
      
       - If there was any question as to the appropriate license identifier,
         the file was flagged for further research and to be revisited later
         in time.
      
      In total, over 70 hours of logged manual review was done on the
      spreadsheet to determine the SPDX license identifiers to apply to the
      source files by Kate, Philippe, Thomas and, in some cases, confirmation
      by lawyers working with the Linux Foundation.
      
      Kate also obtained a third independent scan of the 4.13 code base from
      FOSSology, and compared selected files where the other two scanners
      disagreed against that SPDX file, to see if there was new insights.  The
      Windriver scanner is based on an older version of FOSSology in part, so
      they are related.
      
      Thomas did random spot checks in about 500 files from the spreadsheets
      for the uapi headers and agreed with SPDX license identifier in the
      files he inspected. For the non-uapi files Thomas did random spot checks
      in about 15000 files.
      
      In initial set of patches against 4.14-rc6, 3 files were found to have
      copy/paste license identifier errors, and have been fixed to reflect the
      correct identifier.
      
      Additionally Philippe spent 10 hours this week doing a detailed manual
      inspection and review of the 12,461 patched files from the initial patch
      version early this week with:
       - a full scancode scan run, collecting the matched texts, detected
         license ids and scores
       - reviewing anything where there was a license detected (about 500+
         files) to ensure that the applied SPDX license was correct
       - reviewing anything where there was no detection but the patch license
         was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
         SPDX license was correct
      
      This produced a worksheet with 20 files needing minor correction.  This
      worksheet was then exported into 3 different .csv files for the
      different types of files to be modified.
      
      These .csv files were then reviewed by Greg.  Thomas wrote a script to
      parse the csv files and add the proper SPDX tag to the file, in the
      format that the file expected.  This script was further refined by Greg
      based on the output to detect more types of files automatically and to
      distinguish between header and source .c files (which need different
      comment types.)  Finally Greg ran the script using the .csv files to
      generate the patches.
      Reviewed-by: NKate Stewart <kstewart@linuxfoundation.org>
      Reviewed-by: NPhilippe Ombredanne <pombredanne@nexb.com>
      Reviewed-by: NThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b2441318
  3. 25 10月, 2017 1 次提交
    • M
      locking/atomics: COCCINELLE/treewide: Convert trivial ACCESS_ONCE() patterns... · 6aa7de05
      Mark Rutland 提交于
      locking/atomics: COCCINELLE/treewide: Convert trivial ACCESS_ONCE() patterns to READ_ONCE()/WRITE_ONCE()
      
      Please do not apply this to mainline directly, instead please re-run the
      coccinelle script shown below and apply its output.
      
      For several reasons, it is desirable to use {READ,WRITE}_ONCE() in
      preference to ACCESS_ONCE(), and new code is expected to use one of the
      former. So far, there's been no reason to change most existing uses of
      ACCESS_ONCE(), as these aren't harmful, and changing them results in
      churn.
      
      However, for some features, the read/write distinction is critical to
      correct operation. To distinguish these cases, separate read/write
      accessors must be used. This patch migrates (most) remaining
      ACCESS_ONCE() instances to {READ,WRITE}_ONCE(), using the following
      coccinelle script:
      
      ----
      // Convert trivial ACCESS_ONCE() uses to equivalent READ_ONCE() and
      // WRITE_ONCE()
      
      // $ make coccicheck COCCI=/home/mark/once.cocci SPFLAGS="--include-headers" MODE=patch
      
      virtual patch
      
      @ depends on patch @
      expression E1, E2;
      @@
      
      - ACCESS_ONCE(E1) = E2
      + WRITE_ONCE(E1, E2)
      
      @ depends on patch @
      expression E;
      @@
      
      - ACCESS_ONCE(E)
      + READ_ONCE(E)
      ----
      Signed-off-by: NMark Rutland <mark.rutland@arm.com>
      Signed-off-by: NPaul E. McKenney <paulmck@linux.vnet.ibm.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: davem@davemloft.net
      Cc: linux-arch@vger.kernel.org
      Cc: mpe@ellerman.id.au
      Cc: shuah@kernel.org
      Cc: snitzer@redhat.com
      Cc: thor.thayer@linux.intel.com
      Cc: tj@kernel.org
      Cc: viro@zeniv.linux.org.uk
      Cc: will.deacon@arm.com
      Link: http://lkml.kernel.org/r/1508792849-3115-19-git-send-email-paulmck@linux.vnet.ibm.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      6aa7de05
  4. 21 10月, 2017 2 次提交
  5. 03 10月, 2017 3 次提交
  6. 31 8月, 2017 3 次提交
  7. 11 8月, 2017 2 次提交
  8. 28 7月, 2017 1 次提交
  9. 27 7月, 2017 1 次提交
  10. 08 7月, 2017 1 次提交
    • A
      vfio: Remove unnecessary uses of vfio_container.group_lock · 7f56c30b
      Alex Williamson 提交于
      The original intent of vfio_container.group_lock is to protect
      vfio_container.group_list, however over time it's become a crutch to
      prevent changes in container composition any time we call into the
      iommu driver backend.  This introduces problems when we start to have
      more complex interactions, for example when a user's DMA unmap request
      triggers a notification to an mdev vendor driver, who responds by
      attempting to unpin mappings within that request, re-entering the
      iommu backend.  We incorrectly assume that the use of read-locks here
      allow for this nested locking behavior, but a poorly timed write-lock
      could in fact trigger a deadlock.
      
      The current use of group_lock seems to fall into the trap of locking
      code, not data.  Correct that by removing uses of group_lock that are
      not directly related to group_list.  Note that the vfio type1 iommu
      backend has its own mutex, vfio_iommu.lock, which it uses to protect
      itself for each of these interfaces anyway.  The group_lock appears to
      be a redundancy for these interfaces and type1 even goes so far as to
      release its mutex to allow for exactly the re-entrant code path above.
      Reported-by: NChuanxiao Dong <chuanxiao.dong@intel.com>
      Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
      Acked-by: NAlexey Kardashevskiy <aik@ozlabs.ru>
      Cc: stable@vger.kernel.org # v4.10+
      7f56c30b
  11. 29 6月, 2017 2 次提交
  12. 20 6月, 2017 1 次提交
    • I
      sched/wait: Rename wait_queue_t => wait_queue_entry_t · ac6424b9
      Ingo Molnar 提交于
      Rename:
      
      	wait_queue_t		=>	wait_queue_entry_t
      
      'wait_queue_t' was always a slight misnomer: its name implies that it's a "queue",
      but in reality it's a queue *entry*. The 'real' queue is the wait queue head,
      which had to carry the name.
      
      Start sorting this out by renaming it to 'wait_queue_entry_t'.
      
      This also allows the real structure name 'struct __wait_queue' to
      lose its double underscore and become 'struct wait_queue_entry',
      which is the more canonical nomenclature for such data types.
      
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: linux-kernel@vger.kernel.org
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      ac6424b9
  13. 13 6月, 2017 2 次提交
  14. 19 4月, 2017 2 次提交
  15. 14 4月, 2017 1 次提交
    • A
      vfio/type1: Remove locked page accounting workqueue · 0cfef2b7
      Alex Williamson 提交于
      If the mmap_sem is contented then the vfio type1 IOMMU backend will
      defer locked page accounting updates to a workqueue task.  This has a
      few problems and depending on which side the user tries to play, they
      might be over-penalized for unmaps that haven't yet been accounted or
      race the workqueue to enter more mappings than they're allowed.  The
      original intent of this workqueue mechanism seems to be focused on
      reducing latency through the ioctl, but we cannot do so at the cost
      of correctness.  Remove this workqueue mechanism and update the
      callers to allow for failure.  We can also now recheck the limit under
      write lock to make sure we don't exceed it.
      
      vfio_pin_pages_remote() also now necessarily includes an unwind path
      which we can jump to directly if the consecutive page pinning finds
      that we're exceeding the user's memory limits.  This avoids the
      current lazy approach which does accounting and mapping up to the
      fault, only to return an error on the next iteration to unwind the
      entire vfio_dma.
      
      Cc: stable@vger.kernel.org
      Reviewed-by: NPeter Xu <peterx@redhat.com>
      Reviewed-by: NKirti Wankhede <kwankhede@nvidia.com>
      Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
      0cfef2b7
  16. 12 4月, 2017 2 次提交
  17. 30 3月, 2017 2 次提交
  18. 22 3月, 2017 2 次提交
    • R
      iommu: Disambiguate MSI region types · 9d3a4de4
      Robin Murphy 提交于
      The introduction of reserved regions has left a couple of rough edges
      which we could do with sorting out sooner rather than later. Since we
      are not yet addressing the potential dynamic aspect of software-managed
      reservations and presenting them at arbitrary fixed addresses, it is
      incongruous that we end up displaying hardware vs. software-managed MSI
      regions to userspace differently, especially since ARM-based systems may
      actually require one or the other, or even potentially both at once,
      (which iommu-dma currently has no hope of dealing with at all). Let's
      resolve the former user-visible inconsistency ASAP before the ABI has
      been baked into a kernel release, in a way that also lays the groundwork
      for the latter shortcoming to be addressed by follow-up patches.
      
      For clarity, rename the software-managed type to IOMMU_RESV_SW_MSI, use
      IOMMU_RESV_MSI to describe the hardware type, and document everything a
      little bit. Since the x86 MSI remapping hardware falls squarely under
      this meaning of IOMMU_RESV_MSI, apply that type to their regions as well,
      so that we tell the same story to userspace across all platforms.
      
      Secondly, as the various region types require quite different handling,
      and it really makes little sense to ever try combining them, convert the
      bitfield-esque #defines to a plain enum in the process before anyone
      gets the wrong impression.
      
      Fixes: d30ddcaa ("iommu: Add a new type field in iommu_resv_region")
      Reviewed-by: NEric Auger <eric.auger@redhat.com>
      CC: Alex Williamson <alex.williamson@redhat.com>
      CC: David Woodhouse <dwmw2@infradead.org>
      CC: kvm@vger.kernel.org
      Signed-off-by: NRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      9d3a4de4
    • A
      vfio: Rework group release notifier warning · 65b1adeb
      Alex Williamson 提交于
      The intent of the original warning is make sure that the mdev vendor
      driver has removed any group notifiers at the point where the group
      is closed by the user.  Theoretically this would be through an
      orderly shutdown where any devices are release prior to the group
      release.  We can't always count on an orderly shutdown, the user can
      close the group before the notifier can be removed or the user task
      might be killed.  We'd like to add this sanity test when the group is
      idle and the only references are from the devices within the group
      themselves, but we don't have a good way to do that.  Instead check
      both when the group itself is removed and when the group is opened.
      A bit later than we'd prefer, but better than the current over
      aggressive approach.
      
      Fixes: ccd46dba ("vfio: support notifier chain in vfio_group")
      Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
      Cc: <stable@vger.kernel.org> # v4.10
      Cc: Jike Song <jike.song@intel.com>
      65b1adeb
  19. 02 3月, 2017 2 次提交
  20. 23 2月, 2017 1 次提交
  21. 10 2月, 2017 2 次提交
  22. 09 2月, 2017 2 次提交
    • A
      vfio/mdev: Use a module softdep for vfio_mdev · f790eb57
      Alex Williamson 提交于
      Use an explicit module softdep rather than a request module call such
      that the dependency is exposed to userspace.  This allows us to more
      easily support modules loaded at initrd time.
      
      Reviewed by: Kirti Wankhede <kwankhede@nvidia.com>
      Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
      f790eb57
    • M
      vfio: Fix build break when SPAPR_TCE_IOMMU=n · d88423f7
      Michael Ellerman 提交于
      Currently the kconfig logic for VFIO_IOMMU_SPAPR_TCE and VFIO_SPAPR_EEH
      is broken when SPAPR_TCE_IOMMU=n. Leading to:
      
          warning: (VFIO) selects VFIO_IOMMU_SPAPR_TCE which has unmet direct dependencies (VFIO && SPAPR_TCE_IOMMU)
          warning: (VFIO) selects VFIO_IOMMU_SPAPR_TCE which has unmet direct dependencies (VFIO && SPAPR_TCE_IOMMU)
          drivers/vfio/vfio_iommu_spapr_tce.c:113:8: error: implicit declaration of function 'mm_iommu_find'
      
      This stems from the fact that VFIO selects VFIO_IOMMU_SPAPR_TCE, and
      although it has an if clause, the condition is not correct.
      
      We could fix it by doing select VFIO_IOMMU_SPAPR_TCE if SPAPR_TCE_IOMMU,
      but the cleaner fix is to drop the selects and tie VFIO_IOMMU_SPAPR_TCE
      to the value of VFIO, and express the dependencies in only once place.
      
      Do the same for VFIO_SPAPR_EEH.
      
      The end result is that the values of VFIO_IOMMU_SPAPR_TCE and
      VFIO_SPAPR_EEH follow the value of VFIO, except when SPAPR_TCE_IOMMU=n
      and/or EEH=n. Which is exactly what we want to happen.
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
      d88423f7
  23. 08 2月, 2017 1 次提交
  24. 02 2月, 2017 1 次提交
  25. 25 1月, 2017 1 次提交
    • G
      vfio/spapr: fail tce_iommu_attach_group() when iommu_data is null · bd00fdf1
      Greg Kurz 提交于
      The recently added mediated VFIO driver doesn't know about powerpc iommu.
      It thus doesn't register a struct iommu_table_group in the iommu group
      upon device creation. The iommu_data pointer hence remains null.
      
      This causes a kernel oops when userspace tries to set the iommu type of a
      container associated with a mediated device to VFIO_SPAPR_TCE_v2_IOMMU.
      
      [   82.585440] mtty mtty: MDEV: Registered
      [   87.655522] iommu: Adding device 83b8f4f2-509f-382f-3c1e-e6bfe0fa1001 to group 10
      [   87.655527] vfio_mdev 83b8f4f2-509f-382f-3c1e-e6bfe0fa1001: MDEV: group_id = 10
      [  116.297184] Unable to handle kernel paging request for data at address 0x00000030
      [  116.297389] Faulting instruction address: 0xd000000007870524
      [  116.297465] Oops: Kernel access of bad area, sig: 11 [#1]
      [  116.297611] SMP NR_CPUS=2048
      [  116.297611] NUMA
      [  116.297627] PowerNV
      ...
      [  116.297954] CPU: 33 PID: 7067 Comm: qemu-system-ppc Not tainted 4.10.0-rc5-mdev-test #8
      [  116.297993] task: c000000e7718b680 task.stack: c000000e77214000
      [  116.298025] NIP: d000000007870524 LR: d000000007870518 CTR: 0000000000000000
      [  116.298064] REGS: c000000e77217990 TRAP: 0300   Not tainted  (4.10.0-rc5-mdev-test)
      [  116.298103] MSR: 9000000000009033 <SF,HV,EE,ME,IR,DR,RI,LE>
      [  116.298107]   CR: 84004444  XER: 00000000
      [  116.298154] CFAR: c00000000000888c DAR: 0000000000000030 DSISR: 40000000 SOFTE: 1
                     GPR00: d000000007870518 c000000e77217c10 d00000000787b0ed c000000eed2103c0
                     GPR04: 0000000000000000 0000000000000000 c000000eed2103e0 0000000f24320000
                     GPR08: 0000000000000104 0000000000000001 0000000000000000 d0000000078729b0
                     GPR12: c00000000025b7e0 c00000000fe08400 0000000000000001 000001002d31d100
                     GPR16: 000001002c22c850 00003ffff315c750 0000000043145680 0000000043141bc0
                     GPR20: ffffffffffffffed fffffffffffff000 0000000020003b65 d000000007706018
                     GPR24: c000000f16cf0d98 d000000007706000 c000000003f42980 c000000003f42980
                     GPR28: c000000f1575ac00 c000000003f429c8 0000000000000000 c000000eed2103c0
      [  116.298504] NIP [d000000007870524] tce_iommu_attach_group+0x10c/0x360 [vfio_iommu_spapr_tce]
      [  116.298555] LR [d000000007870518] tce_iommu_attach_group+0x100/0x360 [vfio_iommu_spapr_tce]
      [  116.298601] Call Trace:
      [  116.298610] [c000000e77217c10] [d000000007870518] tce_iommu_attach_group+0x100/0x360 [vfio_iommu_spapr_tce] (unreliable)
      [  116.298671] [c000000e77217cb0] [d0000000077033a0] vfio_fops_unl_ioctl+0x278/0x3e0 [vfio]
      [  116.298713] [c000000e77217d40] [c0000000002a3ebc] do_vfs_ioctl+0xcc/0x8b0
      [  116.298745] [c000000e77217de0] [c0000000002a4700] SyS_ioctl+0x60/0xc0
      [  116.298782] [c000000e77217e30] [c00000000000b220] system_call+0x38/0xfc
      [  116.298812] Instruction dump:
      [  116.298828] 7d3f4b78 409effc8 3d220000 e9298020 3c800140 38a00018 608480c0 e8690028
      [  116.298869] 4800249d e8410018 7c7f1b79 41820230 <e93e0030> 2fa90000 419e0114 e9090020
      [  116.298914] ---[ end trace 1e10b0ced08b9120 ]---
      
      This patch fixes the oops.
      Reported-by: NVaibhav Jain <vaibhav@linux.vnet.ibm.com>
      Signed-off-by: NGreg Kurz <groug@kaod.org>
      Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
      bd00fdf1