16 Mar, 2019

1 commit


15 Mar, 2019

1 commit


11 Mar, 2019

1 commit

  • Pull IOMMU updates from Joerg Roedel:

    - A big cleanup and optimization patch-set for the Tegra GART driver

    - Documentation updates and fixes for the IOMMU-API

    - Support for page request in Intel VT-d scalable mode

    - Intel VT-d dma_[un]map_resource() support

    - Updates to the ATS enabling code for PCI (acked by Bjorn) and Intel
    VT-d to align with the latest version of the ATS spec

    - Relaxed IRQ source checking in the Intel VT-d driver for some aliased
    devices, needed for future devices which send IRQ messages from more
    than on request-ID

    - IRQ remapping driver for Hyper-V

    - Patches to make generic IOVA and IO-Page-Table code usable outside of
    the IOMMU code

    - Various other small fixes and cleanups

    * tag 'iommu-updates-v5.1' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu: (60 commits)
    iommu/vt-d: Get domain ID before clear pasid entry
    iommu/vt-d: Fix NULL pointer reference in intel_svm_bind_mm()
    iommu/vt-d: Set context field after value initialized
    iommu/vt-d: Disable ATS support on untrusted devices
    iommu/mediatek: Fix semicolon code style issue
    MAINTAINERS: Add Hyper-V IOMMU driver into Hyper-V CORE AND DRIVERS scope
    iommu/hyper-v: Add Hyper-V stub IOMMU driver
    x86/Hyper-V: Set x2apic destination mode to physical when x2apic is available
    PCI/ATS: Add inline to pci_prg_resp_pasid_required()
    iommu/vt-d: Check identity map for hot-added devices
    iommu: Fix IOMMU debugfs fallout
    iommu: Document iommu_ops.is_attach_deferred()
    iommu: Document iommu_ops.iotlb_sync_map()
    iommu/vt-d: Enable ATS only if the device uses page aligned address.
    PCI/ATS: Add pci_ats_page_aligned() interface
    iommu/vt-d: Fix PRI/PASID dependency issue.
    PCI/ATS: Add pci_prg_resp_pasid_required() interface.
    iommu/vt-d: Allow interrupts from the entire bus for aliased devices
    iommu/vt-d: Add helper to set an IRTE to verify only the bus number
    iommu: Fix flush_tlb_all typo
    ...

    Linus Torvalds
     

07 Mar, 2019

1 commit

  • Pull driver core updates from Greg KH:
    "Here is the big driver core patchset for 5.1-rc1

    More patches than "normal" here this merge window, due to some work in
    the driver core by Alexander Duyck to rework the async probe
    functionality to work better for a number of devices, and independant
    work from Rafael for the device link functionality to make it work
    "correctly".

    Also in here is:

    - lots of BUS_ATTR() removals, the macro is about to go away

    - firmware test fixups

    - ihex fixups and simplification

    - component additions (also includes i915 patches)

    - lots of minor coding style fixups and cleanups.

    All of these have been in linux-next for a while with no reported
    issues"

    * tag 'driver-core-5.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: (65 commits)
    driver core: platform: remove misleading err_alloc label
    platform: set of_node in platform_device_register_full()
    firmware: hardcode the debug message for -ENOENT
    driver core: Add missing description of new struct device_link field
    driver core: Fix PM-runtime for links added during consumer probe
    drivers/component: kerneldoc polish
    async: Add cmdline option to specify drivers to be async probed
    driver core: Fix possible supplier PM-usage counter imbalance
    PM-runtime: Fix __pm_runtime_set_status() race with runtime resume
    driver: platform: Support parsing GpioInt 0 in platform_get_irq()
    selftests: firmware: fix verify_reqs() return value
    Revert "selftests: firmware: remove use of non-standard diff -Z option"
    Revert "selftests: firmware: add CONFIG_FW_LOADER_USER_HELPER_FALLBACK to config"
    device: Fix comment for driver_data in struct device
    kernfs: Allocating memory for kernfs_iattrs with kmem_cache.
    sysfs: remove unused include of kernfs-internal.h
    driver core: Postpone DMA tear-down until after devres release
    driver core: Document limitation related to DL_FLAG_RPM_ACTIVE
    PM-runtime: Take suppliers into account in __pm_runtime_set_status()
    device.h: Add __cold to dev_ logging functions
    ...

    Linus Torvalds
     

06 Mar, 2019

1 commit

  • Patch series "Replace all open encodings for NUMA_NO_NODE", v3.

    All these places for replacement were found by running the following
    grep patterns on the entire kernel code. Please let me know if this
    might have missed some instances. This might also have replaced some
    false positives. I will appreciate suggestions, inputs and review.

    1. git grep "nid == -1"
    2. git grep "node == -1"
    3. git grep "nid = -1"
    4. git grep "node = -1"

    This patch (of 2):

    At present there are multiple places where invalid node number is
    encoded as -1. Even though implicitly understood it is always better to
    have macros in there. Replace these open encodings for an invalid node
    number with the global macro NUMA_NO_NODE. This helps remove NUMA
    related assumptions like 'invalid node' from various places redirecting
    them to a common definition.

    Link: http://lkml.kernel.org/r/1545127933-10711-2-git-send-email-anshuman.khandual@arm.com
    Signed-off-by: Anshuman Khandual
    Reviewed-by: David Hildenbrand
    Acked-by: Jeff Kirsher [ixgbe]
    Acked-by: Jens Axboe [mtip32xx]
    Acked-by: Vinod Koul [dmaengine.c]
    Acked-by: Michael Ellerman [powerpc]
    Acked-by: Doug Ledford [drivers/infiniband]
    Cc: Joseph Qi
    Cc: Hans Verkuil
    Cc: Stephen Rothwell
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Anshuman Khandual
     

02 Mar, 2019

1 commit


01 Mar, 2019

6 commits

  • …, 'x86/amd', 'hyper-v' and 'core' into next

    Joerg Roedel
     
  • After tearing down a pasid entry, the domain id is used to
    invalidate the translation caches. Retrieve the domain id
    from the pasid entry value before clearing the pasid entry.
    Otherwise, we will always use domain id 0.

    Cc: Ashok Raj
    Cc: Jacob Pan
    Signed-off-by: Liu Yi L
    Fixes: 6f7db75e1c469 ("iommu/vt-d: Add second level page table interface")
    Signed-off-by: Lu Baolu
    Signed-off-by: Joerg Roedel

    Lu Baolu
     
  • Intel IOMMU could be turned off with intel_iommu=off. If Intel
    IOMMU is off, the intel_iommu struct will not be initialized.
    When device drivers call intel_svm_bind_mm(), the NULL pointer
    reference will happen there.

    Add dmar_disabled check to avoid NULL pointer reference.

    Cc: Ashok Raj
    Cc: Jacob Pan
    Reported-by: Dave Jiang
    Fixes: 2f26e0a9c9860 ("iommu/vt-d: Add basic SVM PASID support")
    Signed-off-by: Lu Baolu
    Signed-off-by: Joerg Roedel

    Lu Baolu
     
  • Otherwise, the translation type field of a context entry for
    a PCI device will always be 0. All translated DMA requests
    will be blocked by IOMMU. As the result, the PCI devices with
    PCI ATS (device IOTBL) support won't work as expected.

    Cc: Ashok Raj
    Cc: Jacob Pan
    Suggested-by: Kevin Tian
    Fixes: 7373a8cc38197 ("iommu/vt-d: Setup context and enable RID2PASID support")
    Signed-off-by: Lu Baolu
    Signed-off-by: Joerg Roedel

    Lu Baolu
     
  • Commit fb58fdcd295b9 ("iommu/vt-d: Do not enable ATS for untrusted
    devices") disables ATS support on the devices which have been marked
    as untrusted. Unfortunately this is not enough to fix the DMA attack
    vulnerabiltiies because IOMMU driver allows translated requests as
    long as a device advertises the ATS capability. Hence a malicious
    peripheral device could use this to bypass IOMMU.

    This disables the ATS support on untrusted devices by clearing the
    internal per-device ATS mark. As the result, IOMMU driver will block
    any translated requests from any device marked as untrusted.

    Cc: Jacob Pan
    Cc: Mika Westerberg
    Suggested-by: Kevin Tian
    Suggested-by: Ashok Raj
    Fixes: fb58fdcd295b9 ("iommu/vt-d: Do not enable ATS for untrusted devices")
    Signed-off-by: Lu Baolu
    Signed-off-by: Joerg Roedel

    Lu Baolu
     
  • Delete a superfluous semicolon in mtk_iommu_add_device().

    Signed-off-by: Yang Wei
    Signed-off-by: Joerg Roedel

    Yang Wei
     

28 Feb, 2019

1 commit

  • On the bare metal, enabling X2APIC mode requires interrupt remapping
    function which helps to deliver irq to cpu with 32-bit APIC ID.
    Hyper-V doesn't provide interrupt remapping function so far and Hyper-V
    MSI protocol already supports to deliver interrupt to the CPU whose
    virtual processor index is more than 255. IO-APIC interrupt still has
    8-bit APIC ID limitation.

    This patch is to add Hyper-V stub IOMMU driver in order to enable
    X2APIC mode successfully in Hyper-V Linux guest. The driver returns X2APIC
    interrupt remapping capability when X2APIC mode is available. Otherwise,
    it creates a Hyper-V irq domain to limit IO-APIC interrupts' affinity
    and make sure cpus assigned with IO-APIC interrupt have 8-bit APIC ID.

    Define 24 IO-APIC remapping entries because Hyper-V only expose one
    single IO-APIC and one IO-APIC has 24 pins according IO-APIC spec(
    https://pdos.csail.mit.edu/6.828/2016/readings/ia32/ioapic.pdf).

    Reviewed-by: Michael Kelley
    Signed-off-by: Lan Tianyu
    Signed-off-by: Joerg Roedel

    Lan Tianyu
     

26 Feb, 2019

8 commits

  • The Intel IOMMU driver will put devices into a static identity
    mapped domain during boot if the kernel parameter "iommu=pt" is
    used. That means the IOMMU hardware will translate a DMA address
    into the same memory address.

    Unfortunately, hot-added devices are not subject to this. That
    results in some devices not working properly after hot added. A
    quick way to reproduce this issue is to boot a system with

    iommu=pt

    and, remove then readd the pci device with

    echo 1 > /sys/bus/pci/devices/[pci_source_id]/remove
    echo 1 > /sys/bus/pci/rescan

    You will find the identity mapped domain was replaced with a
    normal domain.

    Cc: Ashok Raj
    Cc: Jacob Pan
    Cc: Fenghua Yu
    Cc: stable@vger.kernel.org
    Reported-by: Jis Ben
    Signed-off-by: Lu Baolu
    Tested-by: James Dong
    Fixes: 99dcadede42f ('intel-iommu: Support PCIe hot-plug')
    Signed-off-by: Joerg Roedel

    Lu Baolu
     
  • Commit 57384592c433 ("iommu/vt-d: Store bus information in RMRR PCI
    device path") changed the type of the path data, however, the change in
    path type was not reflected in size calculations. Update to use the
    correct type and prevent a buffer overflow.

    This bug manifests in systems with deep PCI hierarchies, and can lead to
    an overflow of the static allocated buffer (dmar_pci_notify_info_buf),
    or can lead to overflow of slab-allocated data.

    BUG: KASAN: global-out-of-bounds in dmar_alloc_pci_notify_info+0x1d5/0x2e0
    Write of size 1 at addr ffffffff90445d80 by task swapper/0/1
    CPU: 0 PID: 1 Comm: swapper/0 Tainted: G W 4.14.87-rt49-02406-gd0a0e96 #1
    Call Trace:
    ? dump_stack+0x46/0x59
    ? print_address_description+0x1df/0x290
    ? dmar_alloc_pci_notify_info+0x1d5/0x2e0
    ? kasan_report+0x256/0x340
    ? dmar_alloc_pci_notify_info+0x1d5/0x2e0
    ? e820__memblock_setup+0xb0/0xb0
    ? dmar_dev_scope_init+0x424/0x48f
    ? __down_write_common+0x1ec/0x230
    ? dmar_dev_scope_init+0x48f/0x48f
    ? dmar_free_unused_resources+0x109/0x109
    ? cpumask_next+0x16/0x20
    ? __kmem_cache_create+0x392/0x430
    ? kmem_cache_create+0x135/0x2f0
    ? e820__memblock_setup+0xb0/0xb0
    ? intel_iommu_init+0x170/0x1848
    ? _raw_spin_unlock_irqrestore+0x32/0x60
    ? migrate_enable+0x27a/0x5b0
    ? sched_setattr+0x20/0x20
    ? migrate_disable+0x1fc/0x380
    ? task_rq_lock+0x170/0x170
    ? try_to_run_init_process+0x40/0x40
    ? locks_remove_file+0x85/0x2f0
    ? dev_prepare_static_identity_mapping+0x78/0x78
    ? rt_spin_unlock+0x39/0x50
    ? lockref_put_or_lock+0x2a/0x40
    ? dput+0x128/0x2f0
    ? __rcu_read_unlock+0x66/0x80
    ? __fput+0x250/0x300
    ? __rcu_read_lock+0x1b/0x30
    ? mntput_no_expire+0x38/0x290
    ? e820__memblock_setup+0xb0/0xb0
    ? pci_iommu_init+0x25/0x63
    ? pci_iommu_init+0x25/0x63
    ? do_one_initcall+0x7e/0x1c0
    ? initcall_blacklisted+0x120/0x120
    ? kernel_init_freeable+0x27b/0x307
    ? rest_init+0xd0/0xd0
    ? kernel_init+0xf/0x120
    ? rest_init+0xd0/0xd0
    ? ret_from_fork+0x1f/0x40
    The buggy address belongs to the variable:
    dmar_pci_notify_info_buf+0x40/0x60

    Fixes: 57384592c433 ("iommu/vt-d: Store bus information in RMRR PCI device path")
    Signed-off-by: Julia Cartwright
    Signed-off-by: Joerg Roedel

    Julia Cartwright
     
  • A change made in the final version of IOMMU debugfs support replaced the
    public function iommu_debugfs_new_driver_dir() by the public dentry
    iommu_debugfs_dir in , but forgot to update both the
    implementation in iommu-debugfs.c, and the patch description.

    Fix this by exporting iommu_debugfs_dir, and removing the reference to
    and implementation of iommu_debugfs_new_driver_dir().

    Fixes: bad614b24293ae46 ("iommu: Enable debugfs exposure of IOMMU driver internals")
    Signed-off-by: Geert Uytterhoeven
    Acked-by: Gary R Hook
    Signed-off-by: Joerg Roedel

    Geert Uytterhoeven
     
  • As per Intel vt-d specification, Rev 3.0 (section 7.5.1.1, title "Page
    Request Descriptor"), Intel IOMMU page request descriptor only uses
    bits[63:12] of the page address. Hence Intel IOMMU driver would only
    permit devices that advertise they would only send Page Aligned Requests
    to participate in ATS service.

    Cc: Ashok Raj
    Cc: Jacob Pan
    Cc: Keith Busch
    Suggested-by: Ashok Raj
    Signed-off-by: Kuppuswamy Sathyanarayanan
    Signed-off-by: Joerg Roedel

    Kuppuswamy Sathyanarayanan
     
  • In Intel IOMMU, if the Page Request Queue (PRQ) is full, it will
    automatically respond to the device with a success message as a keep
    alive. And when sending the success message, IOMMU will include PASID in
    the Response Message when the Page Request has a PASID in Request
    Message and it does not check against the PRG Response PASID requirement
    of the device before sending the response. Also, if the device receives
    the PRG response with PASID when its not expecting it the device behavior
    is undefined. So if PASID is enabled in the device, enable PRI only if
    device expects PASID in PRG Response Message.

    Cc: Ashok Raj
    Cc: Jacob Pan
    Cc: Keith Busch
    Suggested-by: Ashok Raj
    Signed-off-by: Kuppuswamy Sathyanarayanan
    Signed-off-by: Joerg Roedel

    Kuppuswamy Sathyanarayanan
     
  • When a device has multiple aliases that all are from the same bus,
    we program the IRTE to accept requests from any matching device on the
    bus.

    This is so NTB devices which can have requests from multiple bus-devfns
    can pass MSI interrupts through across the bridge.

    Signed-off-by: Logan Gunthorpe
    Cc: David Woodhouse
    Cc: Joerg Roedel
    Cc: Jacob Pan
    Signed-off-by: Joerg Roedel

    Logan Gunthorpe
     
  • The current code uses set_irte_sid() with SVT_VERIFY_BUS and PCI_DEVID
    to set the SID value. However, this is very confusing because, with
    SVT_VERIFY_BUS, the SID value is not a PCI devfn address, but the start
    and end bus numbers to match against.

    According to the Intel Virtualization Technology for Directed I/O
    Architecture Specification, Rev. 3.0, page 9-36:

    The most significant 8-bits of the SID field contains the Startbus#,
    and the least significant 8-bits of the SID field contains the Endbus#.
    Interrupt requests that reference this IRTE must have a requester-id
    whose bus# (most significant 8-bits of requester-id) has a value equal
    to or within the Startbus# to Endbus# range.

    So to make this more clear, introduce a new set_irte_verify_bus() that
    explicitly takes a start bus and end bus so that we can stop abusing
    the PCI_DEVID macro.

    This helper function will be called a second time in an subsequent patch.

    Signed-off-by: Logan Gunthorpe
    Cc: David Woodhouse
    Cc: Joerg Roedel
    Cc: Jacob Pan
    Signed-off-by: Joerg Roedel

    Logan Gunthorpe
     
  • L1 tables are allocated with __get_dma_pages, and therefore already
    ignored by kmemleak.

    Without this, the kernel would print this error message on boot,
    when the first L1 table is allocated:

    [ 2.810533] kmemleak: Trying to color unknown object at 0xffffffd652388000 as Black
    [ 2.818190] CPU: 5 PID: 39 Comm: kworker/5:0 Tainted: G S 4.19.16 #8
    [ 2.831227] Workqueue: events deferred_probe_work_func
    [ 2.836353] Call trace:
    ...
    [ 2.852532] paint_ptr+0xa0/0xa8
    [ 2.855750] kmemleak_ignore+0x38/0x6c
    [ 2.859490] __arm_v7s_alloc_table+0x168/0x1f4
    [ 2.863922] arm_v7s_alloc_pgtable+0x114/0x17c
    [ 2.868354] alloc_io_pgtable_ops+0x3c/0x78
    ...

    Fixes: e5fc9753b1a8314 ("iommu/io-pgtable: Add ARMv7 short descriptor support")
    Signed-off-by: Nicolas Boichat
    Acked-by: Will Deacon
    Signed-off-by: Joerg Roedel

    Nicolas Boichat
     

11 Feb, 2019

8 commits

  • The "Domain 0 is reserved, so dont process it" comment suggests that a NULL
    pointer corresponds to domain 0. I don't think that's true, and in any
    case, every caller supplies a non-NULL domain pointer that has already been
    dereferenced, so the test is unnecessary.

    Remove the test for a null "domain" pointer. No functional change
    intended.

    This null pointer check was added by 5e98c4b1d6e8 ("Allocation and free
    functions of virtual machine domain").

    Signed-off-by: Bjorn Helgaas
    Signed-off-by: Joerg Roedel

    Bjorn Helgaas
     
  • domain_remove_dev_info() takes a struct dmar_domain * argument, but doesn't
    use it. Remove it. No functional change intended.

    The last use of this argument was removed by 127c761598f7 ("iommu/vt-d:
    Pass device_domain_info to __dmar_remove_one_dev_info").

    Signed-off-by: Bjorn Helgaas
    Signed-off-by: Joerg Roedel

    Bjorn Helgaas
     
  • A local variable initialization is a hint that the variable will be used in
    an unusual way. If the initialization is unnecessary, that hint becomes a
    distraction.

    Remove unnecessary initializations. No functional change intended.

    Signed-off-by: Bjorn Helgaas
    Signed-off-by: Joerg Roedel

    Bjorn Helgaas
     
  • Use dev_printk() when possible so the IOMMU messages are more consistent
    with other messages related to the device.

    Signed-off-by: Bjorn Helgaas
    Signed-off-by: Joerg Roedel

    Bjorn Helgaas
     
  • Use dev_printk() when possible so the IOMMU messages are more consistent
    with other messages related to the device.

    Signed-off-by: Bjorn Helgaas
    Signed-off-by: Joerg Roedel

    Bjorn Helgaas
     
  • Use dev_printk() when possible so the IOMMU messages are more consistent
    with other messages related to the device.

    E.g., I think these messages related to surprise hotplug:

    pciehp 0000:80:10.0:pcie004: Slot(36): Link Down
    iommu: Removing device 0000:87:00.0 from group 12
    pciehp 0000:80:10.0:pcie004: Slot(36): Card present
    pcieport 0000:80:10.0: Data Link Layer Link Active not set in 1000 msec

    would be easier to read as these (also requires some PCI changes not
    included here):

    pci 0000:80:10.0: Slot(36): Link Down
    pci 0000:87:00.0: Removing from iommu group 12
    pci 0000:80:10.0: Slot(36): Card present
    pci 0000:80:10.0: Data Link Layer Link Active not set in 1000 msec

    Signed-off-by: Bjorn Helgaas
    Signed-off-by: Joerg Roedel

    Bjorn Helgaas
     
  • Move io-pgtable.h to include/linux/ and export alloc_io_pgtable_ops
    and free_io_pgtable_ops. This enables drivers outside drivers/iommu/ to
    use the page table library. Specifically, some ARM Mali GPUs use the
    ARM page table formats.

    Cc: Will Deacon
    Cc: Robin Murphy
    Cc: Joerg Roedel
    Cc: Matthias Brugger
    Cc: Rob Clark
    Cc: linux-arm-kernel@lists.infradead.org
    Cc: iommu@lists.linux-foundation.org
    Cc: linux-mediatek@lists.infradead.org
    Cc: linux-arm-msm@vger.kernel.org
    Signed-off-by: Rob Herring
    Signed-off-by: Joerg Roedel

    Rob Herring
     
  • We need the debugfs fixes in here as well.

    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

09 Feb, 2019

1 commit


01 Feb, 2019

1 commit

  • The device links used by rockchip-iommu and exynos-iommu are
    completely managed by these drivers within the IOMMU framework,
    so there is no reason to involve the driver core in the management
    of these links.

    For this reason, make rockchip-iommu and exynos-iommu pass
    DL_FLAG_STATELESS in flags to device_link_add(), so that the device
    links used by them are stateless.

    [Note that this change is requisite for a subsequent one that will
    rework the management of stateful device links in the driver core
    and it will not be compatible with the two drivers in question any
    more.]

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Marek Szyprowski
    Acked-by: Joerg Roedel
    Signed-off-by: Greg Kroah-Hartman

    Rafael J. Wysocki
     

31 Jan, 2019

6 commits

  • Pull IOMMU fixes from Joerg Roedel:
    "A few more fixes this time:

    - Two patches to fix the error path of the map_sg implementation of
    the AMD IOMMU driver.

    - Also a missing IOTLB flush is fixed in the AMD IOMMU driver.

    - Memory leak fix for the Intel IOMMU driver.

    - Fix a regression in the Mediatek IOMMU driver which caused device
    initialization to fail (seen as broken HDMI output)"

    * tag 'iommu-fixes-v5.0-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu:
    iommu/amd: Fix IOMMU page flush when detach device from a domain
    iommu/mediatek: Use correct fwspec in mtk_iommu_add_device()
    iommu/vt-d: Fix memory leak in intel_iommu_put_resv_regions()
    iommu/amd: Unmap all mapped pages in error path of map_sg
    iommu/amd: Call free_iova_fast with pfn in map_sg

    Linus Torvalds
     
  • The change_pte() interface is tailored for PFN updates, while the
    other notifier invalidate_range() should be enough for Intel IOMMU
    cache flushing. Actually we've done similar thing for AMD IOMMU
    already in 8301da53fbc1 ("iommu/amd: Remove change_pte mmu_notifier
    call-back", 2014-07-30) but the Intel IOMMU driver still have it.

    Signed-off-by: Peter Xu
    Signed-off-by: Joerg Roedel

    Peter Xu
     
  • AMD IOMMU driver is using the clear_flush_young() to do cache flushing
    but that's actually already covered by invalidate_range(). Remove the
    extra notifier and the chunks.

    Signed-off-by: Peter Xu
    Signed-off-by: Joerg Roedel

    Peter Xu
     
  • Since there are multiple possible failures in iommu_map_page
    it would be useful to know which case is being hit when the
    error message is printed in map_sg. While here, fix up checkpatch
    complaint about using function name in a string instead of
    __func__.

    Cc: Joerg Roedel
    Signed-off-by: Jerry Snitselaar
    Signed-off-by: Joerg Roedel

    Jerry Snitselaar
     
  • Commit 765b6a98c1de3 ("iommu/vt-d: Enumerate the scalable
    mode capability") enables VT-d scalable mode if hardware
    advertises the capability. As we will bring up different
    features and use cases to upstream in different patch
    series, it will leave some intermediate kernel versions
    which support partial features. Hence, end user might run
    into problems when they use such kernels on bare metals
    or virtualization environments.

    This leaves scalable mode default off and end users could
    turn it on with "intel-iommu=sm_on" only when they have
    clear ideas about which scalable features are supported
    in the kernel.

    Cc: Liu Yi L
    Cc: Jacob Pan
    Suggested-by: Ashok Raj
    Suggested-by: Kevin Tian
    Signed-off-by: Lu Baolu
    Signed-off-by: Joerg Roedel

    Lu Baolu
     
  • Currently the Intel IOMMU uses the default dma_[un]map_resource()
    implementations does nothing and simply returns the physical address
    unmodified.

    However, this doesn't create the IOVA entries necessary for addresses
    mapped this way to work when the IOMMU is enabled. Thus, when the
    IOMMU is enabled, drivers relying on dma_map_resource() will trigger
    DMAR errors. We see this when running ntb_transport with the IOMMU
    enabled, DMA, and switchtec hardware.

    The implementation for intel_map_resource() is nearly identical to
    intel_map_page(), we just have to re-create __intel_map_single().
    dma_unmap_resource() uses intel_unmap_page() directly as the
    functions are identical.

    Signed-off-by: Logan Gunthorpe
    Cc: David Woodhouse
    Cc: Joerg Roedel
    Reviewed-by: Christoph Hellwig
    Signed-off-by: Joerg Roedel

    Logan Gunthorpe
     

24 Jan, 2019

2 commits

  • When a VM is terminated, the VFIO driver detaches all pass-through
    devices from VFIO domain by clearing domain id and page table root
    pointer from each device table entry (DTE), and then invalidates
    the DTE. Then, the VFIO driver unmap pages and invalidate IOMMU pages.

    Currently, the IOMMU driver keeps track of which IOMMU and how many
    devices are attached to the domain. When invalidate IOMMU pages,
    the driver checks if the IOMMU is still attached to the domain before
    issuing the invalidate page command.

    However, since VFIO has already detached all devices from the domain,
    the subsequent INVALIDATE_IOMMU_PAGES commands are being skipped as
    there is no IOMMU attached to the domain. This results in data
    corruption and could cause the PCI device to end up in indeterministic
    state.

    Fix this by invalidate IOMMU pages when detach a device, and
    before decrementing the per-domain device reference counts.

    Cc: Boris Ostrovsky
    Suggested-by: Joerg Roedel
    Co-developed-by: Brijesh Singh
    Signed-off-by: Brijesh Singh
    Signed-off-by: Suravee Suthikulpanit
    Fixes: 6de8ad9b9ee0 ('x86/amd-iommu: Make iommu_flush_pages aware of multiple IOMMUs')
    Signed-off-by: Joerg Roedel

    Suravee Suthikulpanit
     
  • end_pfn is never used after commit ('iommu/iova: Make dma
    32bit pfn implicit'), cleanup it.

    Cc: Joerg Roedel
    Cc: Robin Murphy
    Cc: Zhen Lei
    Signed-off-by: Shaokun Zhang
    Signed-off-by: Joerg Roedel

    Shaokun Zhang
     

23 Jan, 2019

1 commit

  • The mtk_iommu_add_device() function keeps the fwspec in an
    on-stack pointer and calls mtk_iommu_create_mapping(), which
    might change its source, dev->iommu_fwspec. This causes the
    on-stack pointer to be obsoleted and the device
    initialization to fail. Update the on-stack fwspec pointer
    after mtk_iommu_create_mapping() has been called.

    Reported-by: Frank Wunderlich
    Fixes: a9bf2eec5a6f ('iommu/mediatek: Use helper functions to access dev->iommu_fwspec')
    Tested-by: Frank Wunderlich
    Signed-off-by: Joerg Roedel

    Joerg Roedel