1. 13 3月, 2020 1 次提交
    • H
      iommu/vt-d: dmar_parse_one_rmrr: replace WARN_TAINT with pr_warn + add_taint · 96788c7a
      Hans de Goede 提交于
      Quoting from the comment describing the WARN functions in
      include/asm-generic/bug.h:
      
       * WARN(), WARN_ON(), WARN_ON_ONCE, and so on can be used to report
       * significant kernel issues that need prompt attention if they should ever
       * appear at runtime.
       *
       * Do not use these macros when checking for invalid external inputs
      
      The (buggy) firmware tables which the dmar code was calling WARN_TAINT
      for really are invalid external inputs. They are not under the kernel's
      control and the issues in them cannot be fixed by a kernel update.
      So logging a backtrace, which invites bug reports to be filed about this,
      is not helpful.
      
      Some distros, e.g. Fedora, have tools watching for the kernel backtraces
      logged by the WARN macros and offer the user an option to file a bug for
      this when these are encountered. The WARN_TAINT in dmar_parse_one_rmrr
      + another iommu WARN_TAINT, addressed in another patch, have lead to over
      a 100 bugs being filed this way.
      
      This commit replaces the WARN_TAINT("...") call, with a
      pr_warn(FW_BUG "...") + add_taint(TAINT_FIRMWARE_WORKAROUND, ...) call
      avoiding the backtrace and thus also avoiding bug-reports being filed
      about this against the kernel.
      
      Fixes: f5a68bb0 ("iommu/vt-d: Mark firmware tainted if RMRR fails sanity check")
      Signed-off-by: NHans de Goede <hdegoede@redhat.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      Acked-by: NLu Baolu <baolu.lu@linux.intel.com>
      Cc: stable@vger.kernel.org
      Cc: Barret Rhoden <brho@google.com>
      Link: https://lore.kernel.org/r/20200309140138.3753-3-hdegoede@redhat.com
      BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1808874
      96788c7a
  2. 10 3月, 2020 1 次提交
    • Q
      iommu/vt-d: Fix RCU-list bugs in intel_iommu_init() · 2d48ea0e
      Qian Cai 提交于
      There are several places traverse RCU-list without holding any lock in
      intel_iommu_init(). Fix them by acquiring dmar_global_lock.
      
       WARNING: suspicious RCU usage
       -----------------------------
       drivers/iommu/intel-iommu.c:5216 RCU-list traversed in non-reader section!!
      
       other info that might help us debug this:
      
       rcu_scheduler_active = 2, debug_locks = 1
       no locks held by swapper/0/1.
      
       Call Trace:
        dump_stack+0xa0/0xea
        lockdep_rcu_suspicious+0x102/0x10b
        intel_iommu_init+0x947/0xb13
        pci_iommu_init+0x26/0x62
        do_one_initcall+0xfe/0x500
        kernel_init_freeable+0x45a/0x4f8
        kernel_init+0x11/0x139
        ret_from_fork+0x3a/0x50
       DMAR: Intel(R) Virtualization Technology for Directed I/O
      
      Fixes: d8190dc6 ("iommu/vt-d: Enable DMA remapping after rmrr mapped")
      Signed-off-by: NQian Cai <cai@lca.pw>
      Acked-by: NLu Baolu <baolu.lu@linux.intel.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      2d48ea0e
  3. 03 3月, 2020 1 次提交
  4. 19 2月, 2020 5 次提交
  5. 25 1月, 2020 2 次提交
  6. 24 1月, 2020 5 次提交
  7. 08 1月, 2020 2 次提交
    • J
      iommu/vt-d: Unlink device if failed to add to group · f78947c4
      Jon Derrick 提交于
      If the device fails to be added to the group, make sure to unlink the
      reference before returning.
      Signed-off-by: NJon Derrick <jonathan.derrick@intel.com>
      Fixes: 39ab9555 ("iommu: Add sysfs bindings for struct iommu_device")
      Acked-by: NLu Baolu <baolu.lu@linux.intel.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      f78947c4
    • P
      iommu/vt-d: Fix adding non-PCI devices to Intel IOMMU · 4a350a0e
      Patrick Steinhardt 提交于
      Starting with commit fa212a97 ("iommu/vt-d: Probe DMA-capable ACPI
      name space devices"), we now probe DMA-capable ACPI name
      space devices. On Dell XPS 13 9343, which has an Intel LPSS platform
      device INTL9C60 enumerated via ACPI, this change leads to the following
      warning:
      
          ------------[ cut here ]------------
          WARNING: CPU: 1 PID: 1 at pci_device_group+0x11a/0x130
          CPU: 1 PID: 1 Comm: swapper/0 Tainted: G                T 5.5.0-rc3+ #22
          Hardware name: Dell Inc. XPS 13 9343/0310JH, BIOS A20 06/06/2019
          RIP: 0010:pci_device_group+0x11a/0x130
          Code: f0 ff ff 48 85 c0 49 89 c4 75 c4 48 8d 74 24 10 48 89 ef e8 48 ef ff ff 48 85 c0 49 89 c4 75 af e8 db f7 ff ff 49 89 c4 eb a5 <0f> 0b 49 c7 c4 ea ff ff ff eb 9a e8 96 1e c7 ff 66 0f 1f 44 00 00
          RSP: 0000:ffffc0d6c0043cb0 EFLAGS: 00010202
          RAX: 0000000000000000 RBX: ffffa3d1d43dd810 RCX: 0000000000000000
          RDX: ffffa3d1d4fecf80 RSI: ffffa3d12943dcc0 RDI: ffffa3d1d43dd810
          RBP: ffffa3d1d43dd810 R08: 0000000000000000 R09: ffffa3d1d4c04a80
          R10: ffffa3d1d4c00880 R11: ffffa3d1d44ba000 R12: 0000000000000000
          R13: ffffa3d1d4383b80 R14: ffffa3d1d4c090d0 R15: ffffa3d1d4324530
          FS:  0000000000000000(0000) GS:ffffa3d1d6700000(0000) knlGS:0000000000000000
          CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
          CR2: 0000000000000000 CR3: 000000000460a001 CR4: 00000000003606e0
          Call Trace:
           ? iommu_group_get_for_dev+0x81/0x1f0
           ? intel_iommu_add_device+0x61/0x170
           ? iommu_probe_device+0x43/0xd0
           ? intel_iommu_init+0x1fa2/0x2235
           ? pci_iommu_init+0x52/0xe7
           ? e820__memblock_setup+0x15c/0x15c
           ? do_one_initcall+0xcc/0x27e
           ? kernel_init_freeable+0x169/0x259
           ? rest_init+0x95/0x95
           ? kernel_init+0x5/0xeb
           ? ret_from_fork+0x35/0x40
          ---[ end trace 28473e7abc25b92c ]---
          DMAR: ACPI name space devices didn't probe correctly
      
      The bug results from the fact that while we now enumerate ACPI devices,
      we aren't able to handle any non-PCI device when generating the device
      group. Fix the issue by implementing an Intel-specific callback that
      returns `pci_device_group` only if the device is a PCI device.
      Otherwise, it will return a generic device group.
      
      Fixes: fa212a97 ("iommu/vt-d: Probe DMA-capable ACPI name space devices")
      Signed-off-by: NPatrick Steinhardt <ps@pks.im>
      Cc: stable@vger.kernel.org # v5.3+
      Acked-by: NLu Baolu <baolu.lu@linux.intel.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      4a350a0e
  8. 07 1月, 2020 14 次提交
  9. 23 12月, 2019 2 次提交
    • T
      iommu: intel: Use generic_iommu_put_resv_regions() · 0ecdebb7
      Thierry Reding 提交于
      Use the new standard function instead of open-coding it.
      
      Cc: David Woodhouse <dwmw2@infradead.org>
      Signed-off-by: NThierry Reding <treding@nvidia.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      0ecdebb7
    • Q
      iommu/iova: Silence warnings under memory pressure · 944c9175
      Qian Cai 提交于
      When running heavy memory pressure workloads, this 5+ old system is
      throwing endless warnings below because disk IO is too slow to recover
      from swapping. Since the volume from alloc_iova_fast() could be large,
      once it calls printk(), it will trigger disk IO (writing to the log
      files) and pending softirqs which could cause an infinite loop and make
      no progress for days by the ongoimng memory reclaim. This is the counter
      part for Intel where the AMD part has already been merged. See the
      commit 3d708895 ("iommu/amd: Silence warnings under memory
      pressure"). Since the allocation failure will be reported in
      intel_alloc_iova(), so just call dev_err_once() there because even the
      "ratelimited" is too much, and silence the one in alloc_iova_mem() to
      avoid the expensive warn_alloc().
      
       hpsa 0000:03:00.0: DMAR: Allocating 1-page iova failed
       hpsa 0000:03:00.0: DMAR: Allocating 1-page iova failed
       hpsa 0000:03:00.0: DMAR: Allocating 1-page iova failed
       hpsa 0000:03:00.0: DMAR: Allocating 1-page iova failed
       hpsa 0000:03:00.0: DMAR: Allocating 1-page iova failed
       hpsa 0000:03:00.0: DMAR: Allocating 1-page iova failed
       hpsa 0000:03:00.0: DMAR: Allocating 1-page iova failed
       hpsa 0000:03:00.0: DMAR: Allocating 1-page iova failed
       slab_out_of_memory: 66 callbacks suppressed
       SLUB: Unable to allocate memory on node -1, gfp=0xa20(GFP_ATOMIC)
         cache: iommu_iova, object size: 40, buffer size: 448, default order:
      0, min order: 0
         node 0: slabs: 1822, objs: 16398, free: 0
         node 1: slabs: 2051, objs: 18459, free: 31
       SLUB: Unable to allocate memory on node -1, gfp=0xa20(GFP_ATOMIC)
         cache: iommu_iova, object size: 40, buffer size: 448, default order:
      0, min order: 0
         node 0: slabs: 1822, objs: 16398, free: 0
         node 1: slabs: 2051, objs: 18459, free: 31
       SLUB: Unable to allocate memory on node -1, gfp=0xa20(GFP_ATOMIC)
         cache: iommu_iova, object size: 40, buffer size: 448, default order:
      0, min order: 0
       SLUB: Unable to allocate memory on node -1, gfp=0xa20(GFP_ATOMIC)
       SLUB: Unable to allocate memory on node -1, gfp=0xa20(GFP_ATOMIC)
       SLUB: Unable to allocate memory on node -1, gfp=0xa20(GFP_ATOMIC)
       SLUB: Unable to allocate memory on node -1, gfp=0xa20(GFP_ATOMIC)
       SLUB: Unable to allocate memory on node -1, gfp=0xa20(GFP_ATOMIC)
         cache: skbuff_head_cache, object size: 208, buffer size: 640, default
      order: 0, min order: 0
         cache: skbuff_head_cache, object size: 208, buffer size: 640, default
      order: 0, min order: 0
         cache: skbuff_head_cache, object size: 208, buffer size: 640, default
      order: 0, min order: 0
         cache: skbuff_head_cache, object size: 208, buffer size: 640, default
      order: 0, min order: 0
         node 0: slabs: 697, objs: 4182, free: 0
         node 0: slabs: 697, objs: 4182, free: 0
         node 0: slabs: 697, objs: 4182, free: 0
         node 0: slabs: 697, objs: 4182, free: 0
         node 1: slabs: 381, objs: 2286, free: 27
         node 1: slabs: 381, objs: 2286, free: 27
         node 1: slabs: 381, objs: 2286, free: 27
         node 1: slabs: 381, objs: 2286, free: 27
         node 0: slabs: 1822, objs: 16398, free: 0
         cache: skbuff_head_cache, object size: 208, buffer size: 640, default
      order: 0, min order: 0
         node 1: slabs: 2051, objs: 18459, free: 31
         node 0: slabs: 697, objs: 4182, free: 0
       SLUB: Unable to allocate memory on node -1, gfp=0xa20(GFP_ATOMIC)
         node 1: slabs: 381, objs: 2286, free: 27
         cache: skbuff_head_cache, object size: 208, buffer size: 640, default
      order: 0, min order: 0
         node 0: slabs: 697, objs: 4182, free: 0
         node 1: slabs: 381, objs: 2286, free: 27
       hpsa 0000:03:00.0: DMAR: Allocating 1-page iova failed
       warn_alloc: 96 callbacks suppressed
       kworker/11:1H: page allocation failure: order:0,
      mode:0xa20(GFP_ATOMIC), nodemask=(null),cpuset=/,mems_allowed=0-1
       CPU: 11 PID: 1642 Comm: kworker/11:1H Tainted: G    B
       Hardware name: HP ProLiant XL420 Gen9/ProLiant XL420 Gen9, BIOS U19
      12/27/2015
       Workqueue: kblockd blk_mq_run_work_fn
       Call Trace:
        dump_stack+0xa0/0xea
        warn_alloc.cold.94+0x8a/0x12d
        __alloc_pages_slowpath+0x1750/0x1870
        __alloc_pages_nodemask+0x58a/0x710
        alloc_pages_current+0x9c/0x110
        alloc_slab_page+0xc9/0x760
        allocate_slab+0x48f/0x5d0
        new_slab+0x46/0x70
        ___slab_alloc+0x4ab/0x7b0
        __slab_alloc+0x43/0x70
        kmem_cache_alloc+0x2dd/0x450
       SLUB: Unable to allocate memory on node -1, gfp=0xa20(GFP_ATOMIC)
        alloc_iova+0x33/0x210
         cache: skbuff_head_cache, object size: 208, buffer size: 640, default
      order: 0, min order: 0
         node 0: slabs: 697, objs: 4182, free: 0
        alloc_iova_fast+0x62/0x3d1
         node 1: slabs: 381, objs: 2286, free: 27
        intel_alloc_iova+0xce/0xe0
        intel_map_sg+0xed/0x410
        scsi_dma_map+0xd7/0x160
        scsi_queue_rq+0xbf7/0x1310
        blk_mq_dispatch_rq_list+0x4d9/0xbc0
        blk_mq_sched_dispatch_requests+0x24a/0x300
        __blk_mq_run_hw_queue+0x156/0x230
        blk_mq_run_work_fn+0x3b/0x40
        process_one_work+0x579/0xb90
        worker_thread+0x63/0x5b0
        kthread+0x1e6/0x210
        ret_from_fork+0x3a/0x50
       Mem-Info:
       active_anon:2422723 inactive_anon:361971 isolated_anon:34403
        active_file:2285 inactive_file:1838 isolated_file:0
        unevictable:0 dirty:1 writeback:5 unstable:0
        slab_reclaimable:13972 slab_unreclaimable:453879
        mapped:2380 shmem:154 pagetables:6948 bounce:0
        free:19133 free_pcp:7363 free_cma:0
      Signed-off-by: NQian Cai <cai@lca.pw>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      944c9175
  10. 17 12月, 2019 3 次提交
  11. 11 11月, 2019 2 次提交
    • D
      iommu/vt-d: Turn off translations at shutdown · 6c3a44ed
      Deepa Dinamani 提交于
      The intel-iommu driver assumes that the iommu state is
      cleaned up at the start of the new kernel.
      But, when we try to kexec boot something other than the
      Linux kernel, the cleanup cannot be relied upon.
      Hence, cleanup before we go down for reboot.
      
      Keeping the cleanup at initialization also, in case BIOS
      leaves the IOMMU enabled.
      
      I considered turning off iommu only during kexec reboot, but a clean
      shutdown seems always a good idea. But if someone wants to make it
      conditional, such as VMM live update, we can do that.  There doesn't
      seem to be such a condition at this time.
      
      Tested that before, the info message
      'DMAR: Translation was enabled for <iommu> but we are not in kdump mode'
      would be reported for each iommu. The message will not appear when the
      DMA-remapping is not enabled on entry to the kernel.
      Signed-off-by: NDeepa Dinamani <deepa.kernel@gmail.com>
      Acked-by: NLu Baolu <baolu.lu@linux.intel.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      6c3a44ed
    • Y
      iommu/vt-d: Check VT-d RMRR region in BIOS is reported as reserved · f036c7fa
      Yian Chen 提交于
      VT-d RMRR (Reserved Memory Region Reporting) regions are reserved
      for device use only and should not be part of allocable memory pool of OS.
      
      BIOS e820_table reports complete memory map to OS, including OS usable
      memory ranges and BIOS reserved memory ranges etc.
      
      x86 BIOS may not be trusted to include RMRR regions as reserved type
      of memory in its e820 memory map, hence validate every RMRR entry
      with the e820 memory map to make sure the RMRR regions will not be
      used by OS for any other purposes.
      
      ia64 EFI is working fine so implement RMRR validation as a dummy function
      Reviewed-by: NLu Baolu <baolu.lu@linux.intel.com>
      Reviewed-by: NSohil Mehta <sohil.mehta@intel.com>
      Signed-off-by: NYian Chen <yian.chen@intel.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      f036c7fa
  12. 30 10月, 2019 1 次提交
    • J
      iommu/vt-d: Fix panic after kexec -p for kdump · 160c63f9
      John Donnelly 提交于
      This cures a panic on restart after a kexec operation on 5.3 and 5.4
      kernels.
      
      The underlying state of the iommu registers (iommu->flags &
      VTD_FLAG_TRANS_PRE_ENABLED) on a restart results in a domain being marked as
      "DEFER_DEVICE_DOMAIN_INFO" that produces an Oops in identity_mapping().
      
      [   43.654737] BUG: kernel NULL pointer dereference, address:
      0000000000000056
      [   43.655720] #PF: supervisor read access in kernel mode
      [   43.655720] #PF: error_code(0x0000) - not-present page
      [   43.655720] PGD 0 P4D 0
      [   43.655720] Oops: 0000 [#1] SMP PTI
      [   43.655720] CPU: 0 PID: 1 Comm: swapper/0 Not tainted
      5.3.2-1940.el8uek.x86_64 #1
      [   43.655720] Hardware name: Oracle Corporation ORACLE SERVER
      X5-2/ASM,MOTHERBOARD,1U, BIOS 30140300 09/20/2018
      [   43.655720] RIP: 0010:iommu_need_mapping+0x29/0xd0
      [   43.655720] Code: 00 0f 1f 44 00 00 48 8b 97 70 02 00 00 48 83 fa ff
      74 53 48 8d 4a ff b8 01 00 00 00 48 83 f9 fd 76 01 c3 48 8b 35 7f 58 e0
      01 <48> 39 72 58 75 f2 55 48 89 e5 41 54 53 48 8b 87 28 02 00 00 4c 8b
      [   43.655720] RSP: 0018:ffffc9000001b9b0 EFLAGS: 00010246
      [   43.655720] RAX: 0000000000000001 RBX: 0000000000001000 RCX:
      fffffffffffffffd
      [   43.655720] RDX: fffffffffffffffe RSI: ffff8880719b8000 RDI:
      ffff8880477460b0
      [   43.655720] RBP: ffffc9000001b9e8 R08: 0000000000000000 R09:
      ffff888047c01700
      [   43.655720] R10: 00002194036fc692 R11: 0000000000000000 R12:
      0000000000000000
      [   43.655720] R13: ffff8880477460b0 R14: 0000000000000cc0 R15:
      ffff888072d2b558
      [   43.655720] FS:  0000000000000000(0000) GS:ffff888071c00000(0000)
      knlGS:0000000000000000
      [   43.655720] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [   43.655720] CR2: 0000000000000056 CR3: 000000007440a002 CR4:
      00000000001606b0
      [   43.655720] Call Trace:
      [   43.655720]  ? intel_alloc_coherent+0x2a/0x180
      [   43.655720]  ? __schedule+0x2c2/0x650
      [   43.655720]  dma_alloc_attrs+0x8c/0xd0
      [   43.655720]  dma_pool_alloc+0xdf/0x200
      [   43.655720]  ehci_qh_alloc+0x58/0x130
      [   43.655720]  ehci_setup+0x287/0x7ba
      [   43.655720]  ? _dev_info+0x6c/0x83
      [   43.655720]  ehci_pci_setup+0x91/0x436
      [   43.655720]  usb_add_hcd.cold.48+0x1d4/0x754
      [   43.655720]  usb_hcd_pci_probe+0x2bc/0x3f0
      [   43.655720]  ehci_pci_probe+0x39/0x40
      [   43.655720]  local_pci_probe+0x47/0x80
      [   43.655720]  pci_device_probe+0xff/0x1b0
      [   43.655720]  really_probe+0xf5/0x3a0
      [   43.655720]  driver_probe_device+0xbb/0x100
      [   43.655720]  device_driver_attach+0x58/0x60
      [   43.655720]  __driver_attach+0x8f/0x150
      [   43.655720]  ? device_driver_attach+0x60/0x60
      [   43.655720]  bus_for_each_dev+0x74/0xb0
      [   43.655720]  driver_attach+0x1e/0x20
      [   43.655720]  bus_add_driver+0x151/0x1f0
      [   43.655720]  ? ehci_hcd_init+0xb2/0xb2
      [   43.655720]  ? do_early_param+0x95/0x95
      [   43.655720]  driver_register+0x70/0xc0
      [   43.655720]  ? ehci_hcd_init+0xb2/0xb2
      [   43.655720]  __pci_register_driver+0x57/0x60
      [   43.655720]  ehci_pci_init+0x6a/0x6c
      [   43.655720]  do_one_initcall+0x4a/0x1fa
      [   43.655720]  ? do_early_param+0x95/0x95
      [   43.655720]  kernel_init_freeable+0x1bd/0x262
      [   43.655720]  ? rest_init+0xb0/0xb0
      [   43.655720]  kernel_init+0xe/0x110
      [   43.655720]  ret_from_fork+0x24/0x50
      
      Fixes: 8af46c78 ("iommu/vt-d: Implement is_attach_deferred iommu ops entry")
      Cc: stable@vger.kernel.org # v5.3+
      Signed-off-by: NJohn Donnelly <john.p.donnelly@oracle.com>
      Reviewed-by: NLu Baolu <baolu.lu@linux.intel.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      160c63f9
  13. 18 10月, 2019 1 次提交