1. 11 8月, 2017 1 次提交
  2. 26 7月, 2017 1 次提交
    • J
      iommu/amd: Fix schedule-while-atomic BUG in initialization code · 74ddda71
      Joerg Roedel 提交于
      The register_syscore_ops() function takes a mutex and might
      sleep. In the IOMMU initialization code it is invoked during
      irq-remapping setup already, where irqs are disabled.
      
      This causes a schedule-while-atomic bug:
      
       BUG: sleeping function called from invalid context at kernel/locking/mutex.c:747
       in_atomic(): 0, irqs_disabled(): 1, pid: 1, name: swapper/0
       no locks held by swapper/0/1.
       irq event stamp: 304
       hardirqs last  enabled at (303): [<ffffffff818a87b6>] _raw_spin_unlock_irqrestore+0x36/0x60
       hardirqs last disabled at (304): [<ffffffff8235d440>] enable_IR_x2apic+0x79/0x196
       softirqs last  enabled at (36): [<ffffffff818ae75f>] __do_softirq+0x35f/0x4ec
       softirqs last disabled at (31): [<ffffffff810c1955>] irq_exit+0x105/0x120
       CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.13.0-rc2.1.el7a.test.x86_64.debug #1
       Hardware name:          PowerEdge C6145 /040N24, BIOS 3.5.0 10/28/2014
       Call Trace:
        dump_stack+0x85/0xca
        ___might_sleep+0x22a/0x260
        __might_sleep+0x4a/0x80
        __mutex_lock+0x58/0x960
        ? iommu_completion_wait.part.17+0xb5/0x160
        ? register_syscore_ops+0x1d/0x70
        ? iommu_flush_all_caches+0x120/0x150
        mutex_lock_nested+0x1b/0x20
        register_syscore_ops+0x1d/0x70
        state_next+0x119/0x910
        iommu_go_to_state+0x29/0x30
        amd_iommu_enable+0x13/0x23
      
      Fix it by moving the register_syscore_ops() call to the next
      initialization step, which runs with irqs enabled.
      Reported-by: NArtem Savkov <asavkov@redhat.com>
      Tested-by: NArtem Savkov <asavkov@redhat.com>
      Acked-by: NThomas Gleixner <tglx@linutronix.de>
      Fixes: 2c0ae172 ('iommu/amd: Convert iommu initialization to state machine')
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      74ddda71
  3. 25 7月, 2017 1 次提交
  4. 20 7月, 2017 5 次提交
    • R
      iommu/io-pgtable: Sanitise map/unmap addresses · 76557391
      Robin Murphy 提交于
      It may be an egregious error to attempt to use addresses outside the
      range of the pagetable format, but that still doesn't mean we should
      merrily wreak havoc by silently mapping/unmapping whatever truncated
      portions of them might happen to correspond to real addresses.
      
      Add some up-front checks to sanitise our inputs so that buggy callers
      don't invite potential memory corruption.
      Signed-off-by: NRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      76557391
    • V
      iommu/arm-smmu: Fix the error path in arm_smmu_add_device · c54451a5
      Vivek Gautam 提交于
      fwspec->iommu_priv is available only after arm_smmu_master_cfg
      instance has been allocated. We shouldn't free it before that.
      Also it's logical to free the master cfg itself without
      checking for fwspec.
      Signed-off-by: NVivek Gautam <vivek.gautam@codeaurora.org>
      [will: remove redundant assignment to fwspec]
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      c54451a5
    • R
      Revert "iommu/io-pgtable: Avoid redundant TLB syncs" · 2984f7f3
      Robin Murphy 提交于
      The tlb_sync_pending flag was necessary for correctness in the Mediatek
      M4U driver, but since it offered a small theoretical optimisation for
      all io-pgtable users it was implemented as a high-level thing. However,
      now that some users may not be using a synchronising lock, there are
      several ways this flag can go wrong for them, and at worst it could
      result in incorrect behaviour.
      
      Since we've addressed the correctness issue within the Mediatek driver
      itself, and fixing the optimisation aspect to be concurrency-safe would
      be quite a headache (and impose extra overhead on every operation for
      the sake of slightly helping one case which will virtually never happen
      in typical usage), let's just retire it.
      
      This reverts commit 88492a47.
      Signed-off-by: NRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      2984f7f3
    • R
      iommu/mtk: Avoid redundant TLB syncs locally · 98a8f63e
      Robin Murphy 提交于
      Under certain circumstances, the io-pgtable code may end up issuing two
      TLB sync operations without any intervening invalidations. This goes
      badly for the M4U hardware, since it means the second sync ends up
      polling for a non-existent operation to finish, and as a result times
      out and warns. The io_pgtable_tlb_* helpers implement a high-level
      optimisation to avoid issuing the second sync at all in such cases, but
      in order to work correctly that requires all pagetable operations to be
      serialised under a lock, thus is no longer applicable to all io-pgtable
      users.
      
      Since we're the only user actually relying on this flag for correctness,
      let's reimplement it locally to avoid the headache of trying to make the
      high-level version concurrency-safe for other users.
      
      CC: Yong Wu <yong.wu@mediatek.com>
      CC: Matthias Brugger <matthias.bgg@gmail.com>
      Tested-by: NYong Wu <yong.wu@mediatek.com>
      Signed-off-by: NRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      98a8f63e
    • W
      iommu/arm-smmu: Reintroduce locking around TLB sync operations · 8e517e76
      Will Deacon 提交于
      Commit 523d7423 ("iommu/arm-smmu: Remove io-pgtable spinlock")
      removed the locking used to serialise map/unmap calls into the io-pgtable
      code from the ARM SMMU driver. This is good for performance, but opens
      us up to a nasty race with TLB syncs because the TLB sync register is
      shared within a context bank (or even globally for stage-2 on SMMUv1).
      
      There are two cases to consider:
      
        1. A CPU can be spinning on the completion of a TLB sync, take an
           interrupt which issues a subsequent TLB sync, and then report a
           timeout on return from the interrupt.
      
        2. A CPU can be spinning on the completion of a TLB sync, but other
           CPUs can continuously issue additional TLB syncs in such a way that
           the backoff logic reports a timeout.
      
      Rather than fix this by spinning for completion of prior TLB syncs before
      issuing a new one (which may suffer from fairness issues on large systems),
      instead reintroduce locking around TLB sync operations in the ARM SMMU
      driver.
      
      Fixes: 523d7423 ("iommu/arm-smmu: Remove io-pgtable spinlock")
      Cc: Robin Murphy <robin.murphy@arm.com>
      Reported-by: NRay Jui <ray.jui@broadcom.com>
      Tested-by: NRay Jui <ray.jui@broadcom.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      8e517e76
  5. 28 6月, 2017 10 次提交
  6. 24 6月, 2017 19 次提交
  7. 23 6月, 2017 3 次提交