29 Oct, 2018

1 commit

  • Normally the iommu pagetable could be in 64bit address space,
    but we have one patch to address PCIE driver, 'commit 9e03e5076269
    ("MLK-15064-2 ARM64: DMA: limit the dma mask to be 32bit")'

    The patch restrict swiotlb and iommu dma to be in 32bit address.

    So if we allocate pages in highmem, then dma_map_single will return
    a 32bit address. Then, we will get "Cannot accommodate DMA
    translation for IOMMU page tables", because `dma != virt_to_phys(pages)`.

    So we strict the lpae iommu pgtable in DMA area to fix this issue.

    Signed-off-by: Peng Fan

    Peng Fan
     

20 Oct, 2018

1 commit

  • [ Upstream commit 5ebb1bc2d63d90dd204169e21fd7a0b4bb8c776e ]

    ACPI HID devices do not actually have an alias for
    them in the IVRS. But dev_data->alias is still used
    for indexing into the IOMMU device table for devices
    being handled by the IOMMU. So for ACPI HID devices,
    we simply return the corresponding devid as an alias,
    as parsed from IVRS table.

    Signed-off-by: Arindam Nath
    Fixes: 2bf9a0a12749 ('iommu/amd: Add iommu support for ACPI HID devices')
    Signed-off-by: Joerg Roedel
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Arindam Nath
     

10 Oct, 2018

1 commit

  • commit b3e9b515b08e407ab3a026dc2e4d935c48d05f69 upstream.

    Boris Ostrovsky reported a memory leak with device passthrough when SME
    is active.

    The VFIO driver uses iommu_iova_to_phys() to get the physical address for
    an iova. This physical address is later passed into vfio_unmap_unpin() to
    unpin the memory. The vfio_unmap_unpin() uses pfn_valid() before unpinning
    the memory. The pfn_valid() check was failing because encryption mask was
    part of the physical address returned. This resulted in the memory not
    being unpinned and therefore leaked after the guest terminates.

    The memory encryption mask must be cleared from the physical address in
    iommu_iova_to_phys().

    Fixes: 2543a786aa25 ("iommu/amd: Allow the AMD IOMMU to work with memory encryption")
    Reported-by: Boris Ostrovsky
    Cc: Tom Lendacky
    Cc: Joerg Roedel
    Cc:
    Cc: Borislav Petkov
    Cc: Paolo Bonzini
    Cc: Radim Krčmář
    Cc: kvm@vger.kernel.org
    Cc: Boris Ostrovsky
    Cc: # 4.14+
    Signed-off-by: Brijesh Singh
    Signed-off-by: Joerg Roedel
    Signed-off-by: Greg Kroah-Hartman

    Singh, Brijesh
     

04 Oct, 2018

2 commits

  • [ Upstream commit 379521462e4add27f3514da8e4ab1fd7a54fe1c7 ]

    Fixes the following splat during boot:

    BUG: sleeping function called from invalid context at kernel/locking/mutex.c:747
    in_atomic(): 1, irqs_disabled(): 128, pid: 77, name: kworker/2:1
    4 locks held by kworker/2:1/77:
    #0: (ptrval) ((wq_completion)"events"){+.+.}, at: process_one_work+0x1fc/0x8fc
    #1: (ptrval) (deferred_probe_work){+.+.}, at: process_one_work+0x1fc/0x8fc
    #2: (ptrval) (&dev->mutex){....}, at: __device_attach+0x40/0x178
    #3: (ptrval) (msm_iommu_lock){....}, at: msm_iommu_add_device+0x28/0xcc
    irq event stamp: 348
    hardirqs last enabled at (347): [] kfree+0xe0/0x3c0
    hardirqs last disabled at (348): [] _raw_spin_lock_irqsave+0x2c/0x68
    softirqs last enabled at (0): [] copy_process.part.5+0x280/0x1a68
    softirqs last disabled at (0): [] (null)
    Preemption disabled at:
    [] (null)
    CPU: 2 PID: 77 Comm: kworker/2:1 Not tainted 4.17.0-rc5-wt-ath-01075-gaca0516bb4cf #239
    Hardware name: Generic DT based system
    Workqueue: events deferred_probe_work_func
    [] (unwind_backtrace) from [] (show_stack+0x20/0x24)
    [] (show_stack) from [] (dump_stack+0xa0/0xcc)
    [] (dump_stack) from [] (___might_sleep+0x1f8/0x2d4)
    ath10k_sdio mmc2:0001:1: Direct firmware load for ath10k/QCA9377/hw1.0/board-2.bin failed with error -2
    [] (___might_sleep) from [] (__might_sleep+0x70/0xa8)
    [] (__might_sleep) from [] (__mutex_lock+0x50/0xb28)
    [] (__mutex_lock) from [] (mutex_lock_nested+0x2c/0x34)
    ath10k_sdio mmc2:0001:1: board_file api 1 bmi_id N/A crc32 544289f7
    [] (mutex_lock_nested) from [] (kernfs_find_and_get_ns+0x30/0x5c)
    [] (kernfs_find_and_get_ns) from [] (sysfs_add_link_to_group+0x28/0x58)
    [] (sysfs_add_link_to_group) from [] (iommu_device_link+0x50/0xb4)
    [] (iommu_device_link) from [] (msm_iommu_add_device+0xa0/0xcc)
    [] (msm_iommu_add_device) from [] (add_iommu_group+0x3c/0x64)
    [] (add_iommu_group) from [] (bus_for_each_dev+0x84/0xc4)
    [] (bus_for_each_dev) from [] (bus_set_iommu+0xd0/0x10c)
    [] (bus_set_iommu) from [] (msm_iommu_probe+0x5b8/0x66c)
    [] (msm_iommu_probe) from [] (platform_drv_probe+0x60/0xbc)
    [] (platform_drv_probe) from [] (driver_probe_device+0x30c/0x4cc)
    [] (driver_probe_device) from [] (__device_attach_driver+0xac/0x14c)
    [] (__device_attach_driver) from [] (bus_for_each_drv+0x68/0xc8)
    [] (bus_for_each_drv) from [] (__device_attach+0xe4/0x178)
    [] (__device_attach) from [] (device_initial_probe+0x1c/0x20)
    [] (device_initial_probe) from [] (bus_probe_device+0x98/0xa0)
    [] (bus_probe_device) from [] (deferred_probe_work_func+0x74/0x198)
    [] (deferred_probe_work_func) from [] (process_one_work+0x2c4/0x8fc)
    [] (process_one_work) from [] (worker_thread+0x2c4/0x5cc)
    [] (worker_thread) from [] (kthread+0x180/0x188)
    [] (kthread) from [] (ret_from_fork+0x14/0x20)

    Fixes: 42df43b36163 ("iommu/msm: Make use of iommu_device_register interface")
    Signed-off-by: Niklas Cassel
    Reviewed-by: Vivek Gautam
    Signed-off-by: Joerg Roedel
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Niklas Cassel
     
  • [ Upstream commit 3c120143f584360a13614787e23ae2cdcb5e5ccd ]

    Although the mapping has already been removed in the page table, it maybe
    still exist in TLB. Suppose the freed IOVAs is reused by others before the
    flush operation completed, the new user can not correctly access to its
    meomory.

    Signed-off-by: Zhen Lei
    Fixes: b1516a14657a ('iommu/amd: Implement flush queue')
    Signed-off-by: Joerg Roedel
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Zhen Lei
     

26 Sep, 2018

2 commits

  • [ Upstream commit 29859aeb8a6ea17ba207933a81b6b77b4d4df81a ]

    When run on a 64-bit system in selftest, the v7s driver may obtain page
    table with physical addresses larger than 32-bit. Level-2 tables are 1KB
    and are are allocated with slab, which doesn't accept the GFP_DMA32
    flag. Currently map() truncates the address written in the PTE, causing
    iova_to_phys() or unmap() to access invalid memory. Kasan reports it as
    a use-after-free. To avoid any nasty surprise, test if the physical
    address fits in a PTE before returning a new table. 32-bit systems,
    which are the main users of this page table format, shouldn't see any
    difference.

    Signed-off-by: Jean-Philippe Brucker
    Signed-off-by: Will Deacon
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Jean-Philippe Brucker
     
  • [ Upstream commit 0d535967ac658966c6ade8f82b5799092f7d5441 ]

    When PRI queue occurs overflow, driver should update the OVACKFLG to
    the PRIQ consumer register, otherwise subsequent PRI requests will not
    be processed.

    Cc: Will Deacon
    Cc: Robin Murphy
    Signed-off-by: Miao Zhong
    Signed-off-by: Will Deacon
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Miao Zhong
     

20 Sep, 2018

1 commit

  • [ Upstream commit 46583e8c48c5a094ba28060615b3a7c8c576690f ]

    When attaching a device to an IOMMU group with
    CONFIG_DEBUG_ATOMIC_SLEEP=y:

    BUG: sleeping function called from invalid context at mm/slab.h:421
    in_atomic(): 1, irqs_disabled(): 128, pid: 61, name: kworker/1:1
    ...
    Call trace:
    ...
    arm_lpae_alloc_pgtable+0x114/0x184
    arm_64_lpae_alloc_pgtable_s1+0x2c/0x128
    arm_32_lpae_alloc_pgtable_s1+0x40/0x6c
    alloc_io_pgtable_ops+0x60/0x88
    ipmmu_attach_device+0x140/0x334

    ipmmu_attach_device() takes a spinlock, while arm_lpae_alloc_pgtable()
    allocates memory using GFP_KERNEL. Originally, the ipmmu-vmsa driver
    had its own custom page table allocation implementation using
    GFP_ATOMIC, hence the spinlock was fine.

    Fix this by replacing the spinlock by a mutex, like the arm-smmu driver
    does.

    Fixes: f20ed39f53145e45 ("iommu/ipmmu-vmsa: Use the ARM LPAE page table allocator")
    Signed-off-by: Geert Uytterhoeven
    Reviewed-by: Laurent Pinchart
    Signed-off-by: Joerg Roedel
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Geert Uytterhoeven
     

15 Sep, 2018

1 commit

  • [ Upstream commit 04c532a1cdc7e423656c07937aa4b5c1c2b064f9 ]

    The base address used for DMA operations on the second-level table
    did incorrectly include the offset for the table entry. The offset
    was then added again which lead to incorrect behavior.

    Operations on the L1 table are not affected.

    The calculation of the base address is changed to point to the
    beginning of the L2 table.

    Fixes: bfee0cf0ee1d ("iommu/omap: Use DMA-API for performing cache flushes")
    Acked-by: Suman Anna
    Signed-off-by: Ralf Goebel
    Signed-off-by: Joerg Roedel
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Ralf Goebel
     

10 Sep, 2018

2 commits

  • commit 1c48db44924298ad0cb5a6386b88017539be8822 upstream.

    PFSID should be used in the invalidation descriptor for flushing
    device IOTLBs on SRIOV VFs.

    Signed-off-by: Jacob Pan
    Cc: stable@vger.kernel.org
    Cc: "Ashok Raj"
    Cc: "Lu Baolu"
    Signed-off-by: Joerg Roedel
    Signed-off-by: Greg Kroah-Hartman

    Jacob Pan
     
  • commit 0f725561e168485eff7277d683405c05b192f537 upstream.

    When SRIOV VF device IOTLB is invalidated, we need to provide
    the PF source ID such that IOMMU hardware can gauge the depth
    of invalidation queue which is shared among VFs. This is needed
    when device invalidation throttle (DIT) capability is supported.

    This patch adds bit definitions for checking and tracking PFSID.

    Signed-off-by: Jacob Pan
    Cc: stable@vger.kernel.org
    Cc: "Ashok Raj"
    Cc: "Lu Baolu"
    Signed-off-by: Joerg Roedel
    Signed-off-by: Greg Kroah-Hartman

    Jacob Pan
     

05 Sep, 2018

1 commit

  • commit d1e20222d5372e951bbb2fd3f6489ec4a6ea9b11 upstream.

    Currently we check if the number of context banks is not equal to
    num_context_interrupts. However, there are booloaders such as, one
    on sdm845 that reserves few context banks and thus kernel views
    less than the total available context banks.
    So, although the hardware definition in device tree would mention
    the correct number of context interrupts, this number can be
    greater than the number of context banks visible to smmu in kernel.
    We should therefore error out only when the number of context banks
    is greater than the available number of context interrupts.

    Signed-off-by: Vivek Gautam
    Suggested-by: Tomasz Figa
    Cc: Robin Murphy
    Cc: Will Deacon
    [will: drop useless printk]
    Signed-off-by: Will Deacon
    Cc: Jitendra Bhivare
    Signed-off-by: Greg Kroah-Hartman

    Vivek Gautam
     

21 Jun, 2018

1 commit

  • [ Upstream commit 0dfc0c792d691f8056f38b5c30789f504be0e467 ]

    It allows to flush more than 4GB of device TLBs. So the mask should be
    64bit wide. UBSAN captured this fault as below.

    [ 3.760024] ================================================================================
    [ 3.768440] UBSAN: Undefined behaviour in drivers/iommu/dmar.c:1348:3
    [ 3.774864] shift exponent 64 is too large for 32-bit type 'int'
    [ 3.780853] CPU: 2 PID: 0 Comm: swapper/2 Tainted: G U 4.17.0-rc1+ #89
    [ 3.788661] Hardware name: Dell Inc. OptiPlex 7040/0Y7WYT, BIOS 1.2.8 01/26/2016
    [ 3.796034] Call Trace:
    [ 3.798472]
    [ 3.800479] dump_stack+0x90/0xfb
    [ 3.803787] ubsan_epilogue+0x9/0x40
    [ 3.807353] __ubsan_handle_shift_out_of_bounds+0x10e/0x170
    [ 3.812916] ? qi_flush_dev_iotlb+0x124/0x180
    [ 3.817261] qi_flush_dev_iotlb+0x124/0x180
    [ 3.821437] iommu_flush_dev_iotlb+0x94/0xf0
    [ 3.825698] iommu_flush_iova+0x10b/0x1c0
    [ 3.829699] ? fq_ring_free+0x1d0/0x1d0
    [ 3.833527] iova_domain_flush+0x25/0x40
    [ 3.837448] fq_flush_timeout+0x55/0x160
    [ 3.841368] ? fq_ring_free+0x1d0/0x1d0
    [ 3.845200] ? fq_ring_free+0x1d0/0x1d0
    [ 3.849034] call_timer_fn+0xbe/0x310
    [ 3.852696] ? fq_ring_free+0x1d0/0x1d0
    [ 3.856530] run_timer_softirq+0x223/0x6e0
    [ 3.860625] ? sched_clock+0x5/0x10
    [ 3.864108] ? sched_clock+0x5/0x10
    [ 3.867594] __do_softirq+0x1b5/0x6f5
    [ 3.871250] irq_exit+0xd4/0x130
    [ 3.874470] smp_apic_timer_interrupt+0xb8/0x2f0
    [ 3.879075] apic_timer_interrupt+0xf/0x20
    [ 3.883159]
    [ 3.885255] RIP: 0010:poll_idle+0x60/0xe7
    [ 3.889252] RSP: 0018:ffffb1b201943e30 EFLAGS: 00000246 ORIG_RAX: ffffffffffffff13
    [ 3.896802] RAX: 0000000080200000 RBX: 000000000000008e RCX: 000000000000001f
    [ 3.903918] RDX: 0000000000000000 RSI: 000000002819aa06 RDI: 0000000000000000
    [ 3.911031] RBP: ffff9e93c6b33280 R08: 00000010f717d567 R09: 000000000010d205
    [ 3.918146] R10: ffffb1b201943df8 R11: 0000000000000001 R12: 00000000e01b169d
    [ 3.925260] R13: 0000000000000000 R14: ffffffffb12aa400 R15: 0000000000000000
    [ 3.932382] cpuidle_enter_state+0xb4/0x470
    [ 3.936558] do_idle+0x222/0x310
    [ 3.939779] cpu_startup_entry+0x78/0x90
    [ 3.943693] start_secondary+0x205/0x2e0
    [ 3.947607] secondary_startup_64+0xa5/0xb0
    [ 3.951783] ================================================================================

    Signed-off-by: Changbin Du
    Signed-off-by: Joerg Roedel
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Changbin Du
     

30 May, 2018

2 commits

  • [ Upstream commit 70ca608b2ec6dafa6bb1c2b0691852fc78f8f717 ]

    In MediaTek's IOMMU design, When a iommu translation fault occurs
    (HW can NOT translate the destination address to a valid physical
    address), the IOMMU HW output the dirty data into a special memory
    to avoid corrupting the main memory, this is called "protect memory".
    the register(0x114) for protect memory is a little different between
    mt8173 and mt2712.

    In the mt8173, bit[30:6] in the register represents [31:7] of the
    physical address. In the 4GB mode, the register bit[31] should be 1.
    While in the mt2712, the bits don't shift. bit[31:7] in the register
    represents [31:7] in the physical address, and bit[1:0] in the
    register represents bit[33:32] of the physical address if it has.

    Fixes: e6dec9230862 ("iommu/mediatek: Add mt2712 IOMMU support")
    Reported-by: Honghui Zhang
    Signed-off-by: Yong Wu
    Signed-off-by: Joerg Roedel
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Yong Wu
     
  • [ Upstream commit 39ffe39545cd5cb5b8cee9f0469165cf24dc62c2 ]

    find_dev_data() does not check whether the return value alloc_dev_data()
    is NULL. This was okay once because the pointer was returned once as-is.
    Since commit df3f7a6e8e85 ("iommu/amd: Use is_attach_deferred
    call-back") the pointer may be used within find_dev_data() so a NULL
    check is required.

    Cc: Baoquan He
    Fixes: df3f7a6e8e85 ("iommu/amd: Use is_attach_deferred call-back")
    Signed-off-by: Sebastian Andrzej Siewior
    Signed-off-by: Joerg Roedel
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Sebastian Andrzej Siewior
     

26 Apr, 2018

2 commits

  • [ Upstream commit 9d2e6505f6d6934e681aed502f566198cb25c74a ]

    after commit a1ddcbe93010 ("iommu/vt-d: Pass dmar_domain directly into
    iommu_flush_iotlb_psi", 2015-08-12), we have domain pointer as parameter
    to iommu_flush_iotlb_psi(), so no need to fetch it from cache again.

    More importantly, a NULL reference pointer bug is reported on RHEL7 (and
    it can be reproduced on some old upstream kernels too, e.g., v4.13) by
    unplugging an 40g nic from a VM (hard to test unplug on real host, but
    it should be the same):

    https://bugzilla.redhat.com/show_bug.cgi?id=1531367

    [ 24.391863] pciehp 0000:00:03.0:pcie004: Slot(0): Attention button pressed
    [ 24.393442] pciehp 0000:00:03.0:pcie004: Slot(0): Powering off due to button press
    [ 29.721068] i40evf 0000:01:00.0: Unable to send opcode 2 to PF, err I40E_ERR_QUEUE_EMPTY, aq_err OK
    [ 29.783557] iommu: Removing device 0000:01:00.0 from group 3
    [ 29.784662] BUG: unable to handle kernel NULL pointer dereference at 0000000000000304
    [ 29.785817] IP: iommu_flush_iotlb_psi+0xcf/0x120
    [ 29.786486] PGD 0
    [ 29.786487] P4D 0
    [ 29.786812]
    [ 29.787390] Oops: 0000 [#1] SMP
    [ 29.787876] Modules linked in: ip6t_rpfilter ip6t_REJECT nf_reject_ipv6 xt_conntrack ip_set nfnetlink ebtable_nat ebtable_broute bridge stp llc ip6table_ng
    [ 29.795371] CPU: 0 PID: 156 Comm: kworker/0:2 Not tainted 4.13.0 #14
    [ 29.796366] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.11.0-1.el7 04/01/2014
    [ 29.797593] Workqueue: pciehp-0 pciehp_power_thread
    [ 29.798328] task: ffff94f5745b4a00 task.stack: ffffb326805ac000
    [ 29.799178] RIP: 0010:iommu_flush_iotlb_psi+0xcf/0x120
    [ 29.799919] RSP: 0018:ffffb326805afbd0 EFLAGS: 00010086
    [ 29.800666] RAX: ffff94f5bc56e800 RBX: 0000000000000000 RCX: 0000000200000025
    [ 29.801667] RDX: ffff94f5bc56e000 RSI: 0000000000000082 RDI: 0000000000000000
    [ 29.802755] RBP: ffffb326805afbf8 R08: 0000000000000000 R09: ffff94f5bc86bbf0
    [ 29.803772] R10: ffffb326805afba8 R11: 00000000000ffdc4 R12: ffff94f5bc86a400
    [ 29.804789] R13: 0000000000000000 R14: 00000000ffdc4000 R15: 0000000000000000
    [ 29.805792] FS: 0000000000000000(0000) GS:ffff94f5bfc00000(0000) knlGS:0000000000000000
    [ 29.806923] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    [ 29.807736] CR2: 0000000000000304 CR3: 000000003499d000 CR4: 00000000000006f0
    [ 29.808747] Call Trace:
    [ 29.809156] flush_unmaps_timeout+0x126/0x1c0
    [ 29.809800] domain_exit+0xd6/0x100
    [ 29.810322] device_notifier+0x6b/0x70
    [ 29.810902] notifier_call_chain+0x4a/0x70
    [ 29.812822] __blocking_notifier_call_chain+0x47/0x60
    [ 29.814499] blocking_notifier_call_chain+0x16/0x20
    [ 29.816137] device_del+0x233/0x320
    [ 29.817588] pci_remove_bus_device+0x6f/0x110
    [ 29.819133] pci_stop_and_remove_bus_device+0x1a/0x20
    [ 29.820817] pciehp_unconfigure_device+0x7a/0x1d0
    [ 29.822434] pciehp_disable_slot+0x52/0xe0
    [ 29.823931] pciehp_power_thread+0x8a/0xa0
    [ 29.825411] process_one_work+0x18c/0x3a0
    [ 29.826875] worker_thread+0x4e/0x3b0
    [ 29.828263] kthread+0x109/0x140
    [ 29.829564] ? process_one_work+0x3a0/0x3a0
    [ 29.831081] ? kthread_park+0x60/0x60
    [ 29.832464] ret_from_fork+0x25/0x30
    [ 29.833794] Code: 85 ed 74 0b 5b 41 5c 41 5d 41 5e 41 5f 5d c3 49 8b 54 24 60 44 89 f8 0f b6 c4 48 8b 04 c2 48 85 c0 74 49 45 0f b6 ff 4a 8b 3c f8 bf
    [ 29.838514] RIP: iommu_flush_iotlb_psi+0xcf/0x120 RSP: ffffb326805afbd0
    [ 29.840362] CR2: 0000000000000304
    [ 29.841716] ---[ end trace b10ec0d6900868d3 ]---

    This patch fixes that problem if applied to v4.13 kernel.

    The bug does not exist on latest upstream kernel since it's fixed as a
    side effect of commit 13cf01744608 ("iommu/vt-d: Make use of iova
    deferred flushing", 2017-08-15). But IMHO it's still good to have this
    patch upstream.

    CC: Alex Williamson
    Signed-off-by: Peter Xu
    Fixes: a1ddcbe93010 ("iommu/vt-d: Pass dmar_domain directly into iommu_flush_iotlb_psi")
    Reviewed-by: Alex Williamson
    Signed-off-by: Joerg Roedel
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Peter Xu
     
  • [ Upstream commit dc98b8480d8a68c2ce9aa28b9f0d714fd258bc0b ]

    Removing the early device registration hook overlooked the fact that
    it only ran conditionally on a compatible device being present in the
    DT. With exynos_iommu_init() now running as an unconditional initcall,
    problems arise on non-Exynos systems when other IOMMU drivers find
    themselves unable to install their ops on the platform bus, or at worst
    the Exynos ops get called with someone else's domain and all hell breaks
    loose.

    The global ops/cache setup could probably all now be triggered from the
    first IOMMU probe, as with dma_dev assigment, but for the time being the
    simplest fix is to resurrect the logic from commit a7b67cd5d9af
    ("iommu/exynos: Play nice in multi-platform builds") to explicitly check
    the DT for the presence of an Exynos IOMMU before trying anything.

    Fixes: 928055a01b3f ("iommu/exynos: Remove custom platform device registration code")
    Signed-off-by: Robin Murphy
    Acked-by: Marek Szyprowski
    Signed-off-by: Joerg Roedel
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Robin Murphy
     

24 Apr, 2018

1 commit

  • commit bbe4b3af9d9e3172fb9aa1f8dcdfaedcb381fc64 upstream.

    A memory block was allocated in intel_svm_bind_mm() but never freed
    in a failure path. This patch fixes this by free it to avoid memory
    leakage.

    Cc: Ashok Raj
    Cc: Jacob Pan
    Cc: # v4.4+
    Signed-off-by: Lu Baolu
    Fixes: 2f26e0a9c9860 ('iommu/vt-d: Add basic SVM PASID support')
    Signed-off-by: Joerg Roedel
    Signed-off-by: Greg Kroah-Hartman

    Lu Baolu
     

24 Mar, 2018

1 commit

  • [ Upstream commit 72d548113881dd32bf7f0b221d031e6586468437 ]

    It is unlikely request_threaded_irq will fail, but if it does for some
    reason we should clear iommu->pr_irq in the error path. Also
    intel_svm_finish_prq shouldn't try to clean up the page request
    interrupt if pr_irq is 0. Without these, if request_threaded_irq were
    to fail the following occurs:

    fail with no fixes:

    [ 0.683147] ------------[ cut here ]------------
    [ 0.683148] NULL pointer, cannot free irq
    [ 0.683158] WARNING: CPU: 1 PID: 1 at kernel/irq/irqdomain.c:1632 irq_domain_free_irqs+0x126/0x140
    [ 0.683160] Modules linked in:
    [ 0.683163] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 4.15.0-rc2 #3
    [ 0.683165] Hardware name: /NUC7i3BNB, BIOS BNKBL357.86A.0036.2017.0105.1112 01/05/2017
    [ 0.683168] RIP: 0010:irq_domain_free_irqs+0x126/0x140
    [ 0.683169] RSP: 0000:ffffc90000037ce8 EFLAGS: 00010292
    [ 0.683171] RAX: 000000000000001d RBX: ffff880276283c00 RCX: ffffffff81c5e5e8
    [ 0.683172] RDX: 0000000000000001 RSI: 0000000000000096 RDI: 0000000000000246
    [ 0.683174] RBP: ffff880276283c00 R08: 0000000000000000 R09: 000000000000023c
    [ 0.683175] R10: 0000000000000007 R11: 0000000000000000 R12: 000000000000007a
    [ 0.683176] R13: 0000000000000001 R14: 0000000000000000 R15: 0000010010000000
    [ 0.683178] FS: 0000000000000000(0000) GS:ffff88027ec80000(0000) knlGS:0000000000000000
    [ 0.683180] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    [ 0.683181] CR2: 0000000000000000 CR3: 0000000001c09001 CR4: 00000000003606e0
    [ 0.683182] Call Trace:
    [ 0.683189] intel_svm_finish_prq+0x3c/0x60
    [ 0.683191] free_dmar_iommu+0x1ac/0x1b0
    [ 0.683195] init_dmars+0xaaa/0xaea
    [ 0.683200] ? klist_next+0x19/0xc0
    [ 0.683203] ? pci_do_find_bus+0x50/0x50
    [ 0.683205] ? pci_get_dev_by_id+0x52/0x70
    [ 0.683208] intel_iommu_init+0x498/0x5c7
    [ 0.683211] pci_iommu_init+0x13/0x3c
    [ 0.683214] ? e820__memblock_setup+0x61/0x61
    [ 0.683217] do_one_initcall+0x4d/0x1a0
    [ 0.683220] kernel_init_freeable+0x186/0x20e
    [ 0.683222] ? set_debug_rodata+0x11/0x11
    [ 0.683225] ? rest_init+0xb0/0xb0
    [ 0.683226] kernel_init+0xa/0xff
    [ 0.683229] ret_from_fork+0x1f/0x30
    [ 0.683259] Code: 89 ee 44 89 e7 e8 3b e8 ff ff 5b 5d 44 89 e7 44 89 ee 41 5c 41 5d 41 5e e9 a8 84 ff ff 48 c7 c7 a8 71 a7 81 31 c0 e8 6a d3 f9 ff ff 5b 5d 41 5c 41 5d 41 5
    e c3 0f 1f 44 00 00 66 2e 0f 1f 84
    [ 0.683285] ---[ end trace f7650e42792627ca ]---

    with iommu->pr_irq = 0, but no check in intel_svm_finish_prq:

    [ 0.669561] ------------[ cut here ]------------
    [ 0.669563] Trying to free already-free IRQ 0
    [ 0.669573] WARNING: CPU: 3 PID: 1 at kernel/irq/manage.c:1546 __free_irq+0xa4/0x2c0
    [ 0.669574] Modules linked in:
    [ 0.669577] CPU: 3 PID: 1 Comm: swapper/0 Not tainted 4.15.0-rc2 #4
    [ 0.669579] Hardware name: /NUC7i3BNB, BIOS BNKBL357.86A.0036.2017.0105.1112 01/05/2017
    [ 0.669581] RIP: 0010:__free_irq+0xa4/0x2c0
    [ 0.669582] RSP: 0000:ffffc90000037cc0 EFLAGS: 00010082
    [ 0.669584] RAX: 0000000000000021 RBX: 0000000000000000 RCX: ffffffff81c5e5e8
    [ 0.669585] RDX: 0000000000000001 RSI: 0000000000000086 RDI: 0000000000000046
    [ 0.669587] RBP: 0000000000000000 R08: 0000000000000000 R09: 000000000000023c
    [ 0.669588] R10: 0000000000000007 R11: 0000000000000000 R12: ffff880276253960
    [ 0.669589] R13: ffff8802762538a4 R14: ffff880276253800 R15: ffff880276283600
    [ 0.669593] FS: 0000000000000000(0000) GS:ffff88027ed80000(0000) knlGS:0000000000000000
    [ 0.669594] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    [ 0.669596] CR2: 0000000000000000 CR3: 0000000001c09001 CR4: 00000000003606e0
    [ 0.669602] Call Trace:
    [ 0.669616] free_irq+0x30/0x60
    [ 0.669620] intel_svm_finish_prq+0x34/0x60
    [ 0.669623] free_dmar_iommu+0x1ac/0x1b0
    [ 0.669627] init_dmars+0xaaa/0xaea
    [ 0.669631] ? klist_next+0x19/0xc0
    [ 0.669634] ? pci_do_find_bus+0x50/0x50
    [ 0.669637] ? pci_get_dev_by_id+0x52/0x70
    [ 0.669639] intel_iommu_init+0x498/0x5c7
    [ 0.669642] pci_iommu_init+0x13/0x3c
    [ 0.669645] ? e820__memblock_setup+0x61/0x61
    [ 0.669648] do_one_initcall+0x4d/0x1a0
    [ 0.669651] kernel_init_freeable+0x186/0x20e
    [ 0.669653] ? set_debug_rodata+0x11/0x11
    [ 0.669656] ? rest_init+0xb0/0xb0
    [ 0.669658] kernel_init+0xa/0xff
    [ 0.669661] ret_from_fork+0x1f/0x30
    [ 0.669662] Code: 7a 08 75 0e e9 c3 01 00 00 4c 39 7b 08 74 57 48 89 da 48 8b 5a 18 48 85 db 75 ee 89 ee 48 c7 c7 78 67 a7 81 31 c0 e8 4c 37 fa ff ff 48 8b 34 24 4c 89 ef e
    8 0e 4c 68 00 49 8b 46 40 48 8b 80
    [ 0.669688] ---[ end trace 58a470248700f2fc ]---

    Cc: Alex Williamson
    Cc: Joerg Roedel
    Cc: Ashok Raj
    Signed-off-by: Jerry Snitselaar
    Reviewed-by: Ashok Raj
    Signed-off-by: Alex Williamson
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Jerry Snitselaar
     

10 Jan, 2018

2 commits

  • commit 563b5cbe334e9503ab2b234e279d500fc4f76018 upstream.

    For PCI devices behind an aliasing PCIe-to-PCI/X bridge, the bridge
    alias to DevFn 0.0 on the subordinate bus may match the original RID of
    the device, resulting in the same SID being present in the device's
    fwspec twice. This causes trouble later in arm_smmu_write_strtab_ent()
    when we wind up visiting the STE a second time and find it already live.

    Avoid the issue by giving arm_smmu_install_ste_for_dev() the cleverness
    to skip over duplicates. It seems mildly counterintuitive compared to
    preventing the duplicates from existing in the first place, but since
    the DT and ACPI probe paths build their fwspecs differently, this is
    actually the cleanest and most self-contained way to deal with it.

    Fixes: 8f78515425da ("iommu/arm-smmu: Implement of_xlate() for SMMUv3")
    Reported-by: Tomasz Nowicki
    Tested-by: Tomasz Nowicki
    Tested-by: Jayachandran C.
    Signed-off-by: Robin Murphy
    Signed-off-by: Will Deacon
    Signed-off-by: Greg Kroah-Hartman

    Robin Murphy
     
  • commit 57d72e159b60456c8bb281736c02ddd3164037aa upstream.

    Kasan reports a double free when finalise_stage_fn fails: the io_pgtable
    ops are freed by arm_smmu_domain_finalise and then again by
    arm_smmu_domain_free. Prevent this by leaving pgtbl_ops empty on failure.

    Fixes: 48ec83bcbcf5 ("iommu/arm-smmu: Add initial driver support for ARM SMMUv3 devices")
    Reviewed-by: Robin Murphy
    Signed-off-by: Jean-Philippe Brucker
    Signed-off-by: Will Deacon
    Signed-off-by: Greg Kroah-Hartman

    Jean-Philippe Brucker
     

20 Dec, 2017

2 commits

  • [ Upstream commit b92b4fb5c14257c0e7eae291ecc1f7b1962e1699 ]

    The extent of pages specified when applying a reserved region should
    include up to the last page of the range, but not the page following
    the range.

    Signed-off-by: Gary R Hook
    Fixes: 8d54d6c8b8f3 ('iommu/amd: Implement apply_dm_region call-back')
    Signed-off-by: Alex Williamson
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Gary R Hook
     
  • [ Upstream commit 395df08d2e1de238a9c8c33fdcd0e2160efd63a9 ]

    There exist two Mediatek iommu drivers for the two different
    generations of the device. But both drivers have the same name
    "mtk-iommu". This breaks the registration of the second driver:

    Error: Driver 'mtk-iommu' is already registered, aborting...

    Fix this by changing the name for first generation to
    "mtk-iommu-v1".

    Fixes: b17336c55d89 ("iommu/mediatek: add support for mtk iommu generation one HW")
    Signed-off-by: Matthias Brugger
    Signed-off-by: Alex Williamson
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Matthias Brugger
     

14 Dec, 2017

1 commit

  • commit 29a90b70893817e2f2bb3cea40a29f5308e21b21 upstream.

    The intel-iommu DMA ops fail to correctly handle scatterlists where
    sg->offset is greater than PAGE_SIZE - the IOVA allocation is computed
    appropriately based on the page-aligned portion of the offset, but the
    mapping is set up relative to sg->page, which means it fails to actually
    cover the whole buffer (and in the worst case doesn't cover it at all):

    (sg->dma_address + sg->dma_len) ----+
    sg->dma_address ---------+ |
    iov_pfn------+ | |
    | | |
    v v v
    iova: a b c d e f
    |--------|--------|--------|--------|--------|

    [_____mapped______]
    pfn: 0 1 2 3 4 5
    |--------|--------|--------|--------|--------|
    ^ ^ ^
    | | |
    sg->page ----+ | |
    sg->offset --------------+ |
    (sg->offset + sg->length) ----------+

    As a result, the caller ends up overrunning the mapping into whatever
    lies beyond, which usually goes badly:

    [ 429.645492] DMAR: DRHD: handling fault status reg 2
    [ 429.650847] DMAR: [DMA Write] Request device [02:00.4] fault addr f2682000 ...

    Whilst this is a fairly rare occurrence, it can happen from the result
    of intermediate scatterlist processing such as scatterwalk_ffwd() in the
    crypto layer. Whilst that particular site could be fixed up, it still
    seems worthwhile to bring intel-iommu in line with other DMA API
    implementations in handling this robustly.

    To that end, fix the intel_map_sg() path to line up the mapping
    correctly (in units of MM pages rather than VT-d pages to match the
    aligned_nrpages() calculation) regardless of the offset, and use
    sg_phys() consistently for clarity.

    Reported-by: Harsh Jain
    Signed-off-by: Robin Murphy
    Reviewed by: Ashok Raj
    Tested by: Jacob Pan
    Signed-off-by: Alex Williamson
    Signed-off-by: Greg Kroah-Hartman

    Robin Murphy
     

02 Nov, 2017

1 commit

  • 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
    Reviewed-by: Philippe Ombredanne
    Reviewed-by: Thomas Gleixner
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

13 Oct, 2017

1 commit


12 Oct, 2017

1 commit

  • Exynos SYSMMU registers standard platform device with sysmmu_of_match
    table, what means that this table is accessed every time a new platform
    device is registered in a system. This might happen also after the boot,
    so the table must not be attributed as initconst to avoid potential kernel
    oops caused by access to freed memory.

    Fixes: 6b21a5db3642 ("iommu/exynos: Support for device tree")
    Signed-off-by: Marek Szyprowski
    Reviewed-by: Krzysztof Kozlowski
    Signed-off-by: Joerg Roedel

    Marek Szyprowski
     

11 Oct, 2017

1 commit

  • When SME memory encryption is active it will rely on SWIOTLB to handle
    DMA for devices that cannot support the addressing requirements of
    having the encryption mask set in the physical address. The IOMMU
    currently disables SWIOTLB if it is not running in passthrough mode.
    This is not desired as non-PCI devices attempting DMA may fail. Update
    the code to check if SME is active and not disable SWIOTLB.

    Fixes: 2543a786aa25 ("iommu/amd: Allow the AMD IOMMU to work with memory encryption")
    Signed-off-by: Tom Lendacky
    Signed-off-by: Joerg Roedel

    Tom Lendacky
     

27 Sep, 2017

3 commits

  • pr_err() messages should end with a new-line to avoid other messages
    being concatenated. So replace '/n' with '\n'.

    Signed-off-by: Arvind Yadav
    Fixes: 45a01c42933b ('iommu/amd: Add function copy_dev_tables()')
    Signed-off-by: Joerg Roedel

    Arvind Yadav
     
  • The ARM short descriptor has already limited the physical address
    to 32bit after the commit ("iommu/io-pgtable: Sanitise
    map/unmap addresses"). But in MediaTek 4GB mode, the physical address
    is from 0x1_0000_0000 to 0x1_ffff_ffff. this will cause:

    WARNING: CPU: 4 PID: 3900 at
    xxx/drivers/iommu/io-pgtable-arm-v7s.c:482 arm_v7s_map+0x40/0xf8
    Modules linked in:

    CPU: 4 PID: 3900 Comm: weston Tainted: G S W 4.9.44 #1
    Hardware name: MediaTek MT2712m1v1 board (DT)
    task: ffffffc0eaa5b280 task.stack: ffffffc0e9858000
    PC is at arm_v7s_map+0x40/0xf8
    LR is at mtk_iommu_map+0x64/0x90
    pc : [] lr : [] pstate: 000001c5
    sp : ffffffc0e985b920
    x29: ffffffc0e985b920 x28: 0000000127d00000
    x27: 0000000000100000 x26: ffffff8008f9e000
    x25: 0000000000000003 x24: 0000000000100000
    x23: 0000000127d00000 x22: 00000000ff800000
    x21: ffffffc0f7ec8ce0 x20: 0000000000000003
    x19: 0000000000000003 x18: 0000000000000002
    x17: 0000007f7e5d72c0 x16: ffffff80082b0f08
    x15: 0000000000000001 x14: 000000000000003f
    x13: 0000000000000000 x12: 0000000000000028
    x11: 0088000000000000 x10: 0000000000000000
    x9 : ffffff80092fa000 x8 : ffffffc0e9858000
    x7 : ffffff80085b29d8 x6 : 0000000000000000
    x5 : ffffff80085b09a8 x4 : 0000000000000003
    x3 : 0000000000100000 x2 : 0000000127d00000
    x1 : 00000000ff800000 x0 : 0000000000000001
    ...
    Call trace:
    [] arm_v7s_map+0x40/0xf8
    [] mtk_iommu_map+0x64/0x90
    [] iommu_map+0x100/0x3a0
    [] default_iommu_map_sg+0x104/0x168
    [] iommu_dma_alloc+0x238/0x3f8
    [] __iommu_alloc_attrs+0xa8/0x260
    [] mtk_drm_gem_create+0xac/0x180
    [] mtk_drm_gem_dumb_create+0x54/0xc8
    [] drm_mode_create_dumb_ioctl+0xa4/0xd8
    [] drm_ioctl+0x1c0/0x490

    In order to satify this, Limit the physical address to 32bit.

    Signed-off-by: Yong Wu
    Acked-by: Will Deacon
    Signed-off-by: Joerg Roedel

    Yong Wu
     
  • Fix the commit 81b3c2521844 ("iommu/io-pgtable: Introduce explicit
    coherency"). If there is no IO_PGTABLE_QUIRK_NO_DMA, we should call
    dma_sync_single_for_device for cache synchronization.

    Signed-off-by: Yong Wu
    Fixes: 81b3c2521844 ('iommu/io-pgtable: Introduce explicit coherency')
    Reviewed-by: Robin Murphy
    Signed-off-by: Joerg Roedel

    Yong Wu
     

22 Sep, 2017

1 commit

  • of_pci_iommu_init() tries to be clever and stop its alias walk at the
    device represented by master_np, in case of weird PCI topologies where
    the bridge to the IOMMU and the rest of the system is not at the root.
    It turns out this is a bit short-sighted, since there are plenty of
    other callers of pci_for_each_dma_alias() which would also need the same
    behaviour in that situation, and the only platform so far with such a
    topology (Cavium ThunderX2) already solves it more generally via a PCI
    quirk. As this check is effectively redundant, and returning a boolean
    value as an int is a bit broken anyway, let's just get rid of it.

    Reported-by: Jean-Philippe Brucker
    Fixes: d87beb749281 ("iommu/of: Handle PCI aliases properly")
    Signed-off-by: Robin Murphy
    Tested-by: Jean-Philippe Brucker
    Signed-off-by: Joerg Roedel

    Robin Murphy
     

19 Sep, 2017

3 commits

  • If NO_DMA=y:

    warning: (IPMMU_VMSA && ARM_SMMU && ARM_SMMU_V3 && QCOM_IOMMU) selects IOMMU_IO_PGTABLE_LPAE which has unmet direct dependencies (IOMMU_SUPPORT && HAS_DMA && (ARM || ARM64 || COMPILE_TEST && !GENERIC_ATOMIC64))

    and

    drivers/iommu/io-pgtable-arm.o: In function `__arm_lpae_sync_pte':
    io-pgtable-arm.c:(.text+0x206): undefined reference to `bad_dma_ops'
    drivers/iommu/io-pgtable-arm.o: In function `__arm_lpae_free_pages':
    io-pgtable-arm.c:(.text+0x6a6): undefined reference to `bad_dma_ops'
    drivers/iommu/io-pgtable-arm.o: In function `__arm_lpae_alloc_pages':
    io-pgtable-arm.c:(.text+0x812): undefined reference to `bad_dma_ops'
    io-pgtable-arm.c:(.text+0x81c): undefined reference to `bad_dma_ops'
    io-pgtable-arm.c:(.text+0x862): undefined reference to `bad_dma_ops'
    drivers/iommu/io-pgtable-arm.o: In function `arm_lpae_run_tests':
    io-pgtable-arm.c:(.init.text+0x86): undefined reference to `alloc_io_pgtable_ops'
    io-pgtable-arm.c:(.init.text+0x47c): undefined reference to `free_io_pgtable_ops'
    drivers/iommu/qcom_iommu.o: In function `qcom_iommu_init_domain':
    qcom_iommu.c:(.text+0x1ce): undefined reference to `alloc_io_pgtable_ops'
    drivers/iommu/qcom_iommu.o: In function `qcom_iommu_domain_free':
    qcom_iommu.c:(.text+0x754): undefined reference to `free_io_pgtable_ops'

    QCOM_IOMMU selects IOMMU_IO_PGTABLE_LPAE, which bypasses its dependency
    on HAS_DMA. Make QCOM_IOMMU depend on HAS_DMA to fix this.

    Fixes: 0ae349a0f33fb040 ("iommu/qcom: Add qcom_iommu")
    Signed-off-by: Geert Uytterhoeven
    Signed-off-by: Joerg Roedel

    Geert Uytterhoeven
     
  • Building with gcc-4.6 results in this warning due to
    dmar_table_print_dmar_entry being inlined as in newer compiler versions:

    WARNING: vmlinux.o(.text+0x5c8bee): Section mismatch in reference from the function dmar_walk_remapping_entries() to the function .init.text:dmar_table_print_dmar_entry()
    The function dmar_walk_remapping_entries() references
    the function __init dmar_table_print_dmar_entry().
    This is often because dmar_walk_remapping_entries lacks a __init
    annotation or the annotation of dmar_table_print_dmar_entry is wrong.

    This removes the __init annotation to avoid the warning. On compilers
    that don't show the warning today, this should have no impact since the
    function gets inlined anyway.

    Signed-off-by: Arnd Bergmann
    Signed-off-by: Joerg Roedel

    Arnd Bergmann
     
  • parisc:allmodconfig, xtensa:allmodconfig, and possibly others generate
    the following Kconfig warning.

    warning: (IPMMU_VMSA && ARM_SMMU && ARM_SMMU_V3 && QCOM_IOMMU) selects
    IOMMU_IO_PGTABLE_LPAE which has unmet direct dependencies (IOMMU_SUPPORT &&
    HAS_DMA && (ARM || ARM64 || COMPILE_TEST && !GENERIC_ATOMIC64))

    IOMMU_IO_PGTABLE_LPAE depends on (COMPILE_TEST && !GENERIC_ATOMIC64),
    so any configuration option selecting it needs to have the same dependencies.

    Signed-off-by: Guenter Roeck
    Signed-off-by: Joerg Roedel

    Guenter Roeck
     

10 Sep, 2017

1 commit

  • Pull IOMMU updates from Joerg Roedel:
    "Slightly more changes than usual this time:

    - KDump Kernel IOMMU take-over code for AMD IOMMU. The code now tries
    to preserve the mappings of the kernel so that master aborts for
    devices are avoided. Master aborts cause some devices to fail in
    the kdump kernel, so this code makes the dump more likely to
    succeed when AMD IOMMU is enabled.

    - common flush queue implementation for IOVA code users. The code is
    still optional, but AMD and Intel IOMMU drivers had their own
    implementation which is now unified.

    - finish support for iommu-groups. All drivers implement this feature
    now so that IOMMU core code can rely on it.

    - finish support for 'struct iommu_device' in iommu drivers. All
    drivers now use the interface.

    - new functions in the IOMMU-API for explicit IO/TLB flushing. This
    will help to reduce the number of IO/TLB flushes when IOMMU drivers
    support this interface.

    - support for mt2712 in the Mediatek IOMMU driver

    - new IOMMU driver for QCOM hardware

    - system PM support for ARM-SMMU

    - shutdown method for ARM-SMMU-v3

    - some constification patches

    - various other small improvements and fixes"

    * tag 'iommu-updates-v4.14' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu: (87 commits)
    iommu/vt-d: Don't be too aggressive when clearing one context entry
    iommu: Introduce Interface for IOMMU TLB Flushing
    iommu/s390: Constify iommu_ops
    iommu/vt-d: Avoid calling virt_to_phys() on null pointer
    iommu/vt-d: IOMMU Page Request needs to check if address is canonical.
    arm/tegra: Call bus_set_iommu() after iommu_device_register()
    iommu/exynos: Constify iommu_ops
    iommu/ipmmu-vmsa: Make ipmmu_gather_ops const
    iommu/ipmmu-vmsa: Rereserving a free context before setting up a pagetable
    iommu/amd: Rename a few flush functions
    iommu/amd: Check if domain is NULL in get_domain() and return -EBUSY
    iommu/mediatek: Fix a build warning of BIT(32) in ARM
    iommu/mediatek: Fix a build fail of m4u_type
    iommu: qcom: annotate PM functions as __maybe_unused
    iommu/pamu: Fix PAMU boot crash
    memory: mtk-smi: Degrade SMI init to module_init
    iommu/mediatek: Enlarge the validate PA range for 4GB mode
    iommu/mediatek: Disable iommu clock when system suspend
    iommu/mediatek: Move pgtable allocation into domain_alloc
    iommu/mediatek: Merge 2 M4U HWs into one iommu domain
    ...

    Linus Torvalds
     

09 Sep, 2017

1 commit

  • Pull PCI updates from Bjorn Helgaas:

    - add enhanced Downstream Port Containment support, which prints more
    details about Root Port Programmed I/O errors (Dongdong Liu)

    - add Layerscape ls1088a and ls2088a support (Hou Zhiqiang)

    - add MediaTek MT2712 and MT7622 support (Ryder Lee)

    - add MediaTek MT2712 and MT7622 MSI support (Honghui Zhang)

    - add Qualcom IPQ8074 support (Varadarajan Narayanan)

    - add R-Car r8a7743/5 device tree support (Biju Das)

    - add Rockchip per-lane PHY support for better power management (Shawn
    Lin)

    - fix IRQ mapping for hot-added devices by replacing the
    pci_fixup_irqs() boot-time design with a host bridge hook called at
    probe-time (Lorenzo Pieralisi, Matthew Minter)

    - fix race when enabling two devices that results in upstream bridge
    not being enabled correctly (Srinath Mannam)

    - fix pciehp power fault infinite loop (Keith Busch)

    - fix SHPC bridge MSI hotplug events by enabling bus mastering
    (Aleksandr Bezzubikov)

    - fix a VFIO issue by correcting PCIe capability sizes (Alex
    Williamson)

    - fix an INTD issue on Xilinx and possibly other drivers by unifying
    INTx IRQ domain support (Paul Burton)

    - avoid IOMMU stalls by marking AMD Stoney GPU ATS as broken (Joerg
    Roedel)

    - allow APM X-Gene device assignment to guests by adding an ACS quirk
    (Feng Kan)

    - fix driver crashes by disabling Extended Tags on Broadcom HT2100
    (Extended Tags support is required for PCIe Receivers but not
    Requesters, and we now enable them by default when Requesters support
    them) (Sinan Kaya)

    - fix MSIs for devices that use phantom RIDs for DMA by assuming MSIs
    use the real Requester ID (not a phantom RID) (Robin Murphy)

    - prevent assignment of Intel VMD children to guests (which may be
    supported eventually, but isn't yet) by not associating an IOMMU with
    them (Jon Derrick)

    - fix Intel VMD suspend/resume by releasing IRQs on suspend (Scott
    Bauer)

    - fix a Function-Level Reset issue with Intel 750 NVMe by waiting
    longer (up to 60sec instead of 1sec) for device to become ready
    (Sinan Kaya)

    - fix a Function-Level Reset issue on iProc Stingray by working around
    hardware defects in the CRS implementation (Oza Pawandeep)

    - fix an issue with Intel NVMe P3700 after an iProc reset by adding a
    delay during shutdown (Oza Pawandeep)

    - fix a Microsoft Hyper-V lockdep issue by polling instead of blocking
    in compose_msi_msg() (Stephen Hemminger)

    - fix a wireless LAN driver timeout by clearing DesignWare MSI
    interrupt status after it is handled, not before (Faiz Abbas)

    - fix DesignWare ATU enable checking (Jisheng Zhang)

    - reduce Layerscape dependencies on the bootloader by doing more
    initialization in the driver (Hou Zhiqiang)

    - improve Intel VMD performance allowing allocation of more IRQ vectors
    than present CPUs (Keith Busch)

    - improve endpoint framework support for initial DMA mask, different
    BAR sizes, configurable page sizes, MSI, test driver, etc (Kishon
    Vijay Abraham I, Stan Drozd)

    - rework CRS support to add periodic messages while we poll during
    enumeration and after Function-Level Reset and prepare for possible
    other uses of CRS (Sinan Kaya)

    - clean up Root Port AER handling by removing unnecessary code and
    moving error handler methods to struct pcie_port_service_driver
    (Christoph Hellwig)

    - clean up error handling paths in various drivers (Bjorn Andersson,
    Fabio Estevam, Gustavo A. R. Silva, Harunobu Kurokawa, Jeffy Chen,
    Lorenzo Pieralisi, Sergei Shtylyov)

    - clean up SR-IOV resource handling by disabling VF decoding before
    updating the corresponding resource structs (Gavin Shan)

    - clean up DesignWare-based drivers by unifying quirks to update Class
    Code and Interrupt Pin and related handling of write-protected
    registers (Hou Zhiqiang)

    - clean up by adding empty generic pcibios_align_resource() and
    pcibios_fixup_bus() and removing empty arch-specific implementations
    (Palmer Dabbelt)

    - request exclusive reset control for several drivers to allow cleanup
    elsewhere (Philipp Zabel)

    - constify various structures (Arvind Yadav, Bhumika Goyal)

    - convert from full_name() to %pOF (Rob Herring)

    - remove unused variables from iProc, HiSi, Altera, Keystone (Shawn
    Lin)

    * tag 'pci-v4.14-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci: (170 commits)
    PCI: xgene: Clean up whitespace
    PCI: xgene: Define XGENE_PCI_EXP_CAP and use generic PCI_EXP_RTCTL offset
    PCI: xgene: Fix platform_get_irq() error handling
    PCI: xilinx-nwl: Fix platform_get_irq() error handling
    PCI: rockchip: Fix platform_get_irq() error handling
    PCI: altera: Fix platform_get_irq() error handling
    PCI: spear13xx: Fix platform_get_irq() error handling
    PCI: artpec6: Fix platform_get_irq() error handling
    PCI: armada8k: Fix platform_get_irq() error handling
    PCI: dra7xx: Fix platform_get_irq() error handling
    PCI: exynos: Fix platform_get_irq() error handling
    PCI: iproc: Clean up whitespace
    PCI: iproc: Rename PCI_EXP_CAP to IPROC_PCI_EXP_CAP
    PCI: iproc: Add 500ms delay during device shutdown
    PCI: Fix typos and whitespace errors
    PCI: Remove unused "res" variable from pci_resource_io()
    PCI: Correct kernel-doc of pci_vpd_srdt_size(), pci_vpd_srdt_tag()
    PCI/AER: Reformat AER register definitions
    iommu/vt-d: Prevent VMD child devices from being remapping targets
    x86/PCI: Use is_vmd() rather than relying on the domain number
    ...

    Linus Torvalds
     

05 Sep, 2017

1 commit

  • Pull x86 mm changes from Ingo Molnar:
    "PCID support, 5-level paging support, Secure Memory Encryption support

    The main changes in this cycle are support for three new, complex
    hardware features of x86 CPUs:

    - Add 5-level paging support, which is a new hardware feature on
    upcoming Intel CPUs allowing up to 128 PB of virtual address space
    and 4 PB of physical RAM space - a 512-fold increase over the old
    limits. (Supercomputers of the future forecasting hurricanes on an
    ever warming planet can certainly make good use of more RAM.)

    Many of the necessary changes went upstream in previous cycles,
    v4.14 is the first kernel that can enable 5-level paging.

    This feature is activated via CONFIG_X86_5LEVEL=y - disabled by
    default.

    (By Kirill A. Shutemov)

    - Add 'encrypted memory' support, which is a new hardware feature on
    upcoming AMD CPUs ('Secure Memory Encryption', SME) allowing system
    RAM to be encrypted and decrypted (mostly) transparently by the
    CPU, with a little help from the kernel to transition to/from
    encrypted RAM. Such RAM should be more secure against various
    attacks like RAM access via the memory bus and should make the
    radio signature of memory bus traffic harder to intercept (and
    decrypt) as well.

    This feature is activated via CONFIG_AMD_MEM_ENCRYPT=y - disabled
    by default.

    (By Tom Lendacky)

    - Enable PCID optimized TLB flushing on newer Intel CPUs: PCID is a
    hardware feature that attaches an address space tag to TLB entries
    and thus allows to skip TLB flushing in many cases, even if we
    switch mm's.

    (By Andy Lutomirski)

    All three of these features were in the works for a long time, and
    it's coincidence of the three independent development paths that they
    are all enabled in v4.14 at once"

    * 'x86-mm-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (65 commits)
    x86/mm: Enable RCU based page table freeing (CONFIG_HAVE_RCU_TABLE_FREE=y)
    x86/mm: Use pr_cont() in dump_pagetable()
    x86/mm: Fix SME encryption stack ptr handling
    kvm/x86: Avoid clearing the C-bit in rsvd_bits()
    x86/CPU: Align CR3 defines
    x86/mm, mm/hwpoison: Clear PRESENT bit for kernel 1:1 mappings of poison pages
    acpi, x86/mm: Remove encryption mask from ACPI page protection type
    x86/mm, kexec: Fix memory corruption with SME on successive kexecs
    x86/mm/pkeys: Fix typo in Documentation/x86/protection-keys.txt
    x86/mm/dump_pagetables: Speed up page tables dump for CONFIG_KASAN=y
    x86/mm: Implement PCID based optimization: try to preserve old TLB entries using PCID
    x86: Enable 5-level paging support via CONFIG_X86_5LEVEL=y
    x86/mm: Allow userspace have mappings above 47-bit
    x86/mm: Prepare to expose larger address space to userspace
    x86/mpx: Do not allow MPX if we have mappings above 47-bit
    x86/mm: Rename tasksize_32bit/64bit to task_size_32bit/64bit()
    x86/xen: Redefine XEN_ELFNOTE_INIT_P2M using PUD_SIZE * PTRS_PER_PUD
    x86/mm/dump_pagetables: Fix printout of p4d level
    x86/mm/dump_pagetables: Generalize address normalization
    x86/boot: Fix memremap() related build failure
    ...

    Linus Torvalds
     

01 Sep, 2017

2 commits