1. 03 6月, 2019 1 次提交
  2. 28 5月, 2019 13 次提交
  3. 27 5月, 2019 7 次提交
    • J
      iommu/vt-d: Implement apply_resv_region iommu ops entry · 73bcbdc9
      James Sewart 提交于
      Used by iommu.c before creating identity mappings for reserved
      ranges to ensure dma-ops won't ever remap these ranges.
      Signed-off-by: NJames Sewart <jamessewart@arista.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      73bcbdc9
    • L
      iommu: Add API to request DMA domain for device · 7423e017
      Lu Baolu 提交于
      Normally during iommu probing a device, a default doamin will
      be allocated and attached to the device. The domain type of
      the default domain is statically defined, which results in a
      situation where the allocated default domain isn't suitable
      for the device due to some limitations. We already have API
      iommu_request_dm_for_dev() to replace a DMA domain with an
      identity one. This adds iommu_request_dma_domain_for_dev()
      to request a dma domain if an allocated identity domain isn't
      suitable for the device in question.
      Signed-off-by: NLu Baolu <baolu.lu@linux.intel.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      7423e017
    • S
      iommu/vt-d: Add debugfs support to show scalable mode DMAR table internals · dd5142ca
      Sai Praneeth Prakhya 提交于
      A DMAR table walk would typically follow the below process.
      1. Bus number is used to index into root table which points to a context
         table.
      2. Device number and Function number are used together to index into
         context table which then points to a pasid directory.
      3. PASID[19:6] is used to index into PASID directory which points to a
         PASID table.
      4. PASID[5:0] is used to index into PASID table which points to all levels
         of page tables.
      
      Whenever a user opens the file
      "/sys/kernel/debug/iommu/intel/dmar_translation_struct", the above
      described DMAR table walk is performed and the contents of the table are
      dumped into the file. The dump could be handy while dealing with devices
      that use PASID.
      
      Example of such dump:
      cat /sys/kernel/debug/iommu/intel/dmar_translation_struct
      
      (Please note that because of 80 char limit, entries that should have been
      in the same line are broken into different lines)
      
      IOMMU dmar0: Root Table Address: 0x436f7c000
      B.D.F	Root_entry				Context_entry
      PASID	PASID_table_entry
      00:0a.0	0x0000000000000000:0x000000044dd3f001	0x0000000000100000:0x0000000435460e1d
      0	0x000000044d6e1089:0x0000000000000003:0x0000000000000001
      00:0a.0	0x0000000000000000:0x000000044dd3f001	0x0000000000100000:0x0000000435460e1d
      1	0x0000000000000049:0x0000000000000001:0x0000000003c0e001
      
      Note that the above format is followed even for legacy DMAR table dump
      which doesn't support PASID and hence in such cases PASID is defaulted to
      -1 indicating that PASID and it's related fields are invalid.
      
      Cc: Joerg Roedel <joro@8bytes.org>
      Cc: Ashok Raj <ashok.raj@intel.com>
      Cc: Lu Baolu <baolu.lu@linux.intel.com>
      Cc: Sohil Mehta <sohil.mehta@intel.com>
      Cc: David Woodhouse <dwmw2@infradead.org>
      Cc: Jacob Pan <jacob.jun.pan@linux.intel.com>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Reviewed-by: NLu Baolu <baolu.lu@linux.intel.com>
      Reviewed-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Signed-off-by: NSai Praneeth Prakhya <sai.praneeth.prakhya@intel.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      dd5142ca
    • S
      iommu/vt-d: Introduce macros useful for dumping DMAR table · cdd3a249
      Sai Praneeth Prakhya 提交于
      A scalable mode DMAR table walk would involve looking at bits in each stage
      of walk, like,
      1. Is PASID enabled in the context entry?
      2. What's the size of PASID directory?
      3. Is the PASID directory entry present?
      4. Is the PASID table entry present?
      5. Number of PASID table entries?
      
      Hence, add these macros that will later be used during this walk.
      Apart from adding new macros, move existing macros (like
      pasid_pde_is_present(), get_pasid_table_from_pde() and pasid_supported())
      to appropriate header files so that they could be reused.
      
      Cc: Joerg Roedel <joro@8bytes.org>
      Cc: Ashok Raj <ashok.raj@intel.com>
      Cc: Lu Baolu <baolu.lu@linux.intel.com>
      Cc: Sohil Mehta <sohil.mehta@intel.com>
      Cc: David Woodhouse <dwmw2@infradead.org>
      Cc: Jacob Pan <jacob.jun.pan@linux.intel.com>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Reviewed-by: NLu Baolu <baolu.lu@linux.intel.com>
      Reviewed-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Signed-off-by: NSai Praneeth Prakhya <sai.praneeth.prakhya@intel.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      cdd3a249
    • S
      iommu/vt-d: Modify the format of intel DMAR tables dump · ea09506c
      Sai Praneeth Prakhya 提交于
      Presently, "/sys/kernel/debug/iommu/intel/dmar_translation_struct" file
      dumps DMAR tables in the below format
      
      IOMMU dmar2: Root Table Address:4362cc000
      Root Table Entries:
       Bus: 0 H: 0 L: 4362f0001
       Context Table Entries for Bus: 0
        Entry	B:D.F	High	Low
        160   00:14.0	102     4362ef001
        184   00:17.0	302     435ec4001
        248   00:1f.0	202     436300001
      
      This format has few short comings like
      1. When extended for dumping scalable mode DMAR table it will quickly be
         very clumsy, making it unreadable.
      2. It has information like the Bus number and Entry which are basically
         part of B:D.F, hence are a repetition and are not so useful.
      
      So, change it to a new format which could be easily extended to dump
      scalable mode DMAR table. The new format looks as below:
      
      IOMMU dmar2: Root Table Address: 0x436f7d000
      B.D.F	Root_entry				Context_entry
      00:14.0	0x0000000000000000:0x0000000436fbd001	0x0000000000000102:0x0000000436fbc001
      00:17.0	0x0000000000000000:0x0000000436fbd001	0x0000000000000302:0x0000000436af4001
      00:1f.0	0x0000000000000000:0x0000000436fbd001	0x0000000000000202:0x0000000436fcd001
      
      Cc: Joerg Roedel <joro@8bytes.org>
      Cc: Ashok Raj <ashok.raj@intel.com>
      Cc: Lu Baolu <baolu.lu@linux.intel.com>
      Cc: Sohil Mehta <sohil.mehta@intel.com>
      Cc: David Woodhouse <dwmw2@infradead.org>
      Cc: Jacob Pan <jacob.jun.pan@linux.intel.com>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Reviewed-by: NLu Baolu <baolu.lu@linux.intel.com>
      Reviewed-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Signed-off-by: NSai Praneeth Prakhya <sai.praneeth.prakhya@intel.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      ea09506c
    • L
      iommu/vt-d: Remove unnecessary rcu_read_locks · f780a8dc
      Lukasz Odzioba 提交于
      We use RCU's for rarely updated lists like iommus, rmrr, atsr units.
      
      I'm not sure why domain_remove_dev_info() in domain_exit() was surrounded
      by rcu_read_lock. Lock was present before refactoring in d160aca5,
      but it was related to rcu list, not domain_remove_dev_info function.
      
      dmar_remove_one_dev_info() doesn't touch any of those lists, so it doesn't
      require a lock. In fact it is called 6 times without it anyway.
      
      Fixes: d160aca5 ("iommu/vt-d: Unify domain->iommu attach/detachment")
      Signed-off-by: NLukasz Odzioba <lukasz.odzioba@intel.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      f780a8dc
    • J
      iommu/vt-d: Fix bind svm with multiple devices · d7af4d98
      Jacob Pan 提交于
      If multiple devices try to bind to the same mm/PASID, we need to
      set up first level PASID entries for all the devices. The current
      code does not consider this case which results in failed DMA for
      devices after the first bind.
      Signed-off-by: NJacob Pan <jacob.jun.pan@linux.intel.com>
      Reported-by: NMike Campin <mike.campin@intel.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      d7af4d98
  4. 21 5月, 2019 2 次提交
  5. 15 5月, 2019 2 次提交
  6. 07 5月, 2019 2 次提交
  7. 06 5月, 2019 1 次提交
  8. 03 5月, 2019 7 次提交
  9. 30 4月, 2019 2 次提交
  10. 26 4月, 2019 3 次提交
    • L
      iommu/vt-d: Don't request page request irq under dmar_global_lock · a7755c3c
      Lu Baolu 提交于
      Requesting page reqest irq under dmar_global_lock could cause
      potential lock race condition (caught by lockdep).
      
      [    4.100055] ======================================================
      [    4.100063] WARNING: possible circular locking dependency detected
      [    4.100072] 5.1.0-rc4+ #2169 Not tainted
      [    4.100078] ------------------------------------------------------
      [    4.100086] swapper/0/1 is trying to acquire lock:
      [    4.100094] 000000007dcbe3c3 (dmar_lock){+.+.}, at: dmar_alloc_hwirq+0x35/0x140
      [    4.100112] but task is already holding lock:
      [    4.100120] 0000000060bbe946 (dmar_global_lock){++++}, at: intel_iommu_init+0x191/0x1438
      [    4.100136] which lock already depends on the new lock.
      [    4.100146] the existing dependency chain (in reverse order) is:
      [    4.100155]
                     -> #2 (dmar_global_lock){++++}:
      [    4.100169]        down_read+0x44/0xa0
      [    4.100178]        intel_irq_remapping_alloc+0xb2/0x7b0
      [    4.100186]        mp_irqdomain_alloc+0x9e/0x2e0
      [    4.100195]        __irq_domain_alloc_irqs+0x131/0x330
      [    4.100203]        alloc_isa_irq_from_domain.isra.4+0x9a/0xd0
      [    4.100212]        mp_map_pin_to_irq+0x244/0x310
      [    4.100221]        setup_IO_APIC+0x757/0x7ed
      [    4.100229]        x86_late_time_init+0x17/0x1c
      [    4.100238]        start_kernel+0x425/0x4e3
      [    4.100247]        secondary_startup_64+0xa4/0xb0
      [    4.100254]
                     -> #1 (irq_domain_mutex){+.+.}:
      [    4.100265]        __mutex_lock+0x7f/0x9d0
      [    4.100273]        __irq_domain_add+0x195/0x2b0
      [    4.100280]        irq_domain_create_hierarchy+0x3d/0x40
      [    4.100289]        msi_create_irq_domain+0x32/0x110
      [    4.100297]        dmar_alloc_hwirq+0x111/0x140
      [    4.100305]        dmar_set_interrupt.part.14+0x1a/0x70
      [    4.100314]        enable_drhd_fault_handling+0x2c/0x6c
      [    4.100323]        apic_bsp_setup+0x75/0x7a
      [    4.100330]        x86_late_time_init+0x17/0x1c
      [    4.100338]        start_kernel+0x425/0x4e3
      [    4.100346]        secondary_startup_64+0xa4/0xb0
      [    4.100352]
                     -> #0 (dmar_lock){+.+.}:
      [    4.100364]        lock_acquire+0xb4/0x1c0
      [    4.100372]        __mutex_lock+0x7f/0x9d0
      [    4.100379]        dmar_alloc_hwirq+0x35/0x140
      [    4.100389]        intel_svm_enable_prq+0x61/0x180
      [    4.100397]        intel_iommu_init+0x1128/0x1438
      [    4.100406]        pci_iommu_init+0x16/0x3f
      [    4.100414]        do_one_initcall+0x5d/0x2be
      [    4.100422]        kernel_init_freeable+0x1f0/0x27c
      [    4.100431]        kernel_init+0xa/0x110
      [    4.100438]        ret_from_fork+0x3a/0x50
      [    4.100444]
                     other info that might help us debug this:
      
      [    4.100454] Chain exists of:
                       dmar_lock --> irq_domain_mutex --> dmar_global_lock
      [    4.100469]  Possible unsafe locking scenario:
      
      [    4.100476]        CPU0                    CPU1
      [    4.100483]        ----                    ----
      [    4.100488]   lock(dmar_global_lock);
      [    4.100495]                                lock(irq_domain_mutex);
      [    4.100503]                                lock(dmar_global_lock);
      [    4.100512]   lock(dmar_lock);
      [    4.100518]
                      *** DEADLOCK ***
      
      Cc: Ashok Raj <ashok.raj@intel.com>
      Cc: Jacob Pan <jacob.jun.pan@linux.intel.com>
      Cc: Kevin Tian <kevin.tian@intel.com>
      Reported-by: NDave Jiang <dave.jiang@intel.com>
      Fixes: a222a7f0 ("iommu/vt-d: Implement page request handling")
      Signed-off-by: NLu Baolu <baolu.lu@linux.intel.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      a7755c3c
    • G
      iommu/vt-d: Use struct_size() helper · 553d66cb
      Gustavo A. R. Silva 提交于
      Make use of the struct_size() helper instead of an open-coded version
      in order to avoid any potential type mistakes, in particular in the
      context in which this code is being used.
      
      So, replace code of the following form:
      
      size = sizeof(*info) + level * sizeof(info->path[0]);
      
      with:
      
      size = struct_size(info, path, level);
      Signed-off-by: NGustavo A. R. Silva <gustavo@embeddedor.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      553d66cb
    • W
      iommu/mediatek: Fix leaked of_node references · 1eb8e4e2
      Wen Yang 提交于
      The call to of_parse_phandle returns a node pointer with refcount
      incremented thus it must be explicitly decremented after the last
      usage.
      
      581 static int mtk_iommu_probe(struct platform_device *pdev)
      582 {
          ...
      626         for (i = 0; i < larb_nr; i++) {
      627                 struct device_node *larbnode;
          ...
      631                 larbnode = of_parse_phandle(...);
      632                 if (!larbnode)
      633                         return -EINVAL;
      634
      635                 if (!of_device_is_available(larbnode))
      636                         continue;             ---> leaked here
      637
          ...
      643                 if (!plarbdev)
      644                         return -EPROBE_DEFER; ---> leaked here
          ...
      647                 component_match_add_release(dev, &match, release_of,
      648                                             compare_of, larbnode);
                                         ---> release_of will call of_node_put
      649         }
          ...
      650
      
      Detected by coccinelle with the following warnings:
      ./drivers/iommu/mtk_iommu.c:644:3-9: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 631, but without a corresponding object release within this function.
      Signed-off-by: NWen Yang <wen.yang99@zte.com.cn>
      Cc: Joerg Roedel <joro@8bytes.org>
      Cc: Matthias Brugger <matthias.bgg@gmail.com>
      Cc: iommu@lists.linux-foundation.org
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: linux-mediatek@lists.infradead.org
      Cc: linux-kernel@vger.kernel.org
      Reviewed-by: NMatthias Brugger <mbrugger@suse.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      1eb8e4e2