1. 18 8月, 2021 7 次提交
  2. 11 8月, 2021 1 次提交
  3. 09 8月, 2021 1 次提交
  4. 02 8月, 2021 1 次提交
    • F
      iommu: Check if group is NULL before remove device · 5aa95d88
      Frank Wunderlich 提交于
      If probe_device is failing, iommu_group is not initialized because
      iommu_group_add_device is not reached, so freeing it will result
      in NULL pointer access.
      
      iommu_bus_init
        ->bus_iommu_probe
            ->probe_iommu_group in for each:/* return -22 in fail case */
                ->iommu_probe_device
                    ->__iommu_probe_device       /* return -22 here.*/
                        -> ops->probe_device          /* return -22 here.*/
                        -> iommu_group_get_for_dev
                              -> ops->device_group
                              -> iommu_group_add_device //good case
        ->remove_iommu_group  //in fail case, it will remove group
           ->iommu_release_device
               ->iommu_group_remove_device // here we don't have group
      
      In my case ops->probe_device (mtk_iommu_probe_device from
      mtk_iommu_v1.c) is due to failing fwspec->ops mismatch.
      
      Fixes: d72e31c9 ("iommu: IOMMU Groups")
      Signed-off-by: NFrank Wunderlich <frank-w@public-files.de>
      Link: https://lore.kernel.org/r/20210731074737.4573-1-linux@fw-web.deSigned-off-by: NJoerg Roedel <jroedel@suse.de>
      5aa95d88
  5. 26 7月, 2021 8 次提交
  6. 09 6月, 2021 1 次提交
  7. 16 4月, 2021 1 次提交
  8. 07 4月, 2021 8 次提交
  9. 18 3月, 2021 1 次提交
  10. 02 2月, 2021 1 次提交
  11. 28 1月, 2021 1 次提交
    • L
      iommu: use the __iommu_attach_device() directly for deferred attach · 3ab65729
      Lianbo Jiang 提交于
      Currently, because domain attach allows to be deferred from iommu
      driver to device driver, and when iommu initializes, the devices
      on the bus will be scanned and the default groups will be allocated.
      
      Due to the above changes, some devices could be added to the same
      group as below:
      
      [    3.859417] pci 0000:01:00.0: Adding to iommu group 16
      [    3.864572] pci 0000:01:00.1: Adding to iommu group 16
      [    3.869738] pci 0000:02:00.0: Adding to iommu group 17
      [    3.874892] pci 0000:02:00.1: Adding to iommu group 17
      
      But when attaching these devices, it doesn't allow that a group has
      more than one device, otherwise it will return an error. This conflicts
      with the deferred attaching. Unfortunately, it has two devices in the
      same group for my side, for example:
      
      [    9.627014] iommu_group_device_count(): device name[0]:0000:01:00.0
      [    9.633545] iommu_group_device_count(): device name[1]:0000:01:00.1
      ...
      [   10.255609] iommu_group_device_count(): device name[0]:0000:02:00.0
      [   10.262144] iommu_group_device_count(): device name[1]:0000:02:00.1
      
      Finally, which caused the failure of tg3 driver when tg3 driver calls
      the dma_alloc_coherent() to allocate coherent memory in the tg3_test_dma().
      
      [    9.660310] tg3 0000:01:00.0: DMA engine test failed, aborting
      [    9.754085] tg3: probe of 0000:01:00.0 failed with error -12
      [    9.997512] tg3 0000:01:00.1: DMA engine test failed, aborting
      [   10.043053] tg3: probe of 0000:01:00.1 failed with error -12
      [   10.288905] tg3 0000:02:00.0: DMA engine test failed, aborting
      [   10.334070] tg3: probe of 0000:02:00.0 failed with error -12
      [   10.578303] tg3 0000:02:00.1: DMA engine test failed, aborting
      [   10.622629] tg3: probe of 0000:02:00.1 failed with error -12
      
      In addition, the similar situations also occur in other drivers such
      as the bnxt_en driver. That can be reproduced easily in kdump kernel
      when SME is active.
      
      Let's move the handling currently in iommu_dma_deferred_attach() into
      the iommu core code so that it can call the __iommu_attach_device()
      directly instead of the iommu_attach_device(). The external interface
      iommu_attach_device() is not suitable for handling this situation.
      Signed-off-by: NLianbo Jiang <lijiang@redhat.com>
      Reviewed-by: NRobin Murphy <robin.murphy@arm.com>
      Link: https://lore.kernel.org/r/20210126115337.20068-3-lijiang@redhat.comSigned-off-by: NJoerg Roedel <jroedel@suse.de>
      3ab65729
  12. 27 1月, 2021 5 次提交
  13. 07 12月, 2020 1 次提交
  14. 26 11月, 2020 1 次提交
  15. 25 11月, 2020 2 次提交
    • S
      iommu: Take lock before reading iommu group default domain type · 0b8a96a3
      Sai Praneeth Prakhya 提交于
      "/sys/kernel/iommu_groups/<grp_id>/type" file could be read to find out the
      default domain type of an iommu group. The default domain of an iommu group
      doesn't change after booting and hence could be read directly. But,
      after addding support to dynamically change iommu group default domain, the
      above assumption no longer stays valid.
      
      iommu group default domain type could be changed at any time by writing to
      "/sys/kernel/iommu_groups/<grp_id>/type". So, take group mutex before
      reading iommu group default domain type so that the user wouldn't see stale
      values or iommu_group_show_type() doesn't try to derefernce stale pointers.
      Signed-off-by: NSai Praneeth Prakhya <sai.praneeth.prakhya@intel.com>
      Signed-off-by: NLu Baolu <baolu.lu@linux.intel.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Joerg Roedel <joro@8bytes.org>
      Cc: Ashok Raj <ashok.raj@intel.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: Sohil Mehta <sohil.mehta@intel.com>
      Cc: Robin Murphy <robin.murphy@arm.com>
      Cc: Jacob Pan <jacob.jun.pan@linux.intel.com>
      Link: https://lore.kernel.org/r/20201124130604.2912899-4-baolu.lu@linux.intel.comSigned-off-by: NWill Deacon <will@kernel.org>
      0b8a96a3
    • S
      iommu: Add support to change default domain of an iommu group · 08a27c1c
      Sai Praneeth Prakhya 提交于
      Presently, the default domain of an iommu group is allocated during boot
      time and it cannot be changed later. So, the device would typically be
      either in identity (also known as pass_through) mode or the device would be
      in DMA mode as long as the machine is up and running. There is no way to
      change the default domain type dynamically i.e. after booting, a device
      cannot switch between identity mode and DMA mode.
      
      But, assume a use case wherein the user trusts the device and believes that
      the OS is secure enough and hence wants *only* this device to bypass IOMMU
      (so that it could be high performing) whereas all the other devices to go
      through IOMMU (so that the system is protected). Presently, this use case
      is not supported. It will be helpful if there is some way to change the
      default domain of an iommu group dynamically. Hence, add such support.
      
      A privileged user could request the kernel to change the default domain
      type of a iommu group by writing to
      "/sys/kernel/iommu_groups/<grp_id>/type" file. Presently, only three values
      are supported
      1. identity: all the DMA transactions from the device in this group are
                   *not* translated by the iommu
      2. DMA: all the DMA transactions from the device in this group are
              translated by the iommu
      3. auto: change to the type the device was booted with
      
      Note:
      1. Default domain of an iommu group with two or more devices cannot be
         changed.
      2. The device in the iommu group shouldn't be bound to any driver.
      3. The device shouldn't be assigned to user for direct access.
      4. The change request will fail if any device in the group has a mandatory
         default domain type and the requested one conflicts with that.
      
      Please see "Documentation/ABI/testing/sysfs-kernel-iommu_groups" for more
      information.
      Signed-off-by: NSai Praneeth Prakhya <sai.praneeth.prakhya@intel.com>
      Signed-off-by: NLu Baolu <baolu.lu@linux.intel.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Joerg Roedel <joro@8bytes.org>
      Cc: Ashok Raj <ashok.raj@intel.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: Sohil Mehta <sohil.mehta@intel.com>
      Cc: Robin Murphy <robin.murphy@arm.com>
      Cc: Jacob Pan <jacob.jun.pan@linux.intel.com>
      Link: https://lore.kernel.org/r/20201124130604.2912899-3-baolu.lu@linux.intel.comSigned-off-by: NWill Deacon <will@kernel.org>
      08a27c1c