12 Jan, 2017

4 commits

  • commit aec0e86172a79eb5e44aff1055bb953fe4d47c59 upstream.

    We met the DMAR fault both on hpsa P420i and P421 SmartArray controllers
    under kdump, it can be steadily reproduced on several different machines,
    the dmesg log is like:
    HP HPSA Driver (v 3.4.16-0)
    hpsa 0000:02:00.0: using doorbell to reset controller
    hpsa 0000:02:00.0: board ready after hard reset.
    hpsa 0000:02:00.0: Waiting for controller to respond to no-op
    DMAR: Setting identity map for device 0000:02:00.0 [0xe8000 - 0xe8fff]
    DMAR: Setting identity map for device 0000:02:00.0 [0xf4000 - 0xf4fff]
    DMAR: Setting identity map for device 0000:02:00.0 [0xbdf6e000 - 0xbdf6efff]
    DMAR: Setting identity map for device 0000:02:00.0 [0xbdf6f000 - 0xbdf7efff]
    DMAR: Setting identity map for device 0000:02:00.0 [0xbdf7f000 - 0xbdf82fff]
    DMAR: Setting identity map for device 0000:02:00.0 [0xbdf83000 - 0xbdf84fff]
    DMAR: DRHD: handling fault status reg 2
    DMAR: [DMA Read] Request device [02:00.0] fault addr fffff000 [fault reason 06] PTE Read access is not set
    hpsa 0000:02:00.0: controller message 03:00 timed out
    hpsa 0000:02:00.0: no-op failed; re-trying

    After some debugging, we found that the fault addr is from DMA initiated at
    the driver probe stage after reset(not in-flight DMA), and the corresponding
    pte entry value is correct, the fault is likely due to the old iommu caches
    of the in-flight DMA before it.

    Thus we need to flush the old cache after context mapping is setup for the
    device, where the device is supposed to finish reset at its driver probe
    stage and no in-flight DMA exists hereafter.

    I'm not sure if the hardware is responsible for invalidating all the related
    caches allocated in the iommu hardware before, but seems not the case for hpsa,
    actually many device drivers have problems in properly resetting the hardware.
    Anyway flushing (again) by software in kdump kernel when the device gets context
    mapped which is a quite infrequent operation does little harm.

    With this patch, the problematic machine can survive the kdump tests.

    CC: Myron Stowe
    CC: Joseph Szczypek
    CC: Don Brace
    CC: Baoquan He
    CC: Dave Young
    Fixes: 091d42e43d21 ("iommu/vt-d: Copy translation tables from old kernel")
    Fixes: dbcd861f252d ("iommu/vt-d: Do not re-use domain-ids from the old kernel")
    Fixes: cf484d0e6939 ("iommu/vt-d: Mark copied context entries")
    Signed-off-by: Xunlei Pang
    Tested-by: Don Brace
    Signed-off-by: Joerg Roedel
    Signed-off-by: Greg Kroah-Hartman

    Xunlei Pang
     
  • commit 65ca7f5f7d1cdde6c25172fe6107cd16902f826f upstream.

    Different encodings are used to represent supported PASID bits
    and number of PASID table entries.
    The current code assigns ecap_pss directly to extended context
    table entry PTS which is wrong and could result in writing
    non-zero bits to the reserved fields. IOMMU fault reason
    11 will be reported when reserved bits are nonzero.
    This patch converts ecap_pss to extend context entry pts encoding
    based on VT-d spec. Chapter 9.4 as follows:
    - number of PASID bits = ecap_pss + 1
    - number of PASID table entries = 2^(pts + 5)
    Software assigned limit of pasid_max value is also respected to
    match the allocation limitation of PASID table.

    cc: Mika Kuoppala
    cc: Ashok Raj
    Signed-off-by: Jacob Pan
    Tested-by: Mika Kuoppala
    Fixes: 2f26e0a9c9860 ('iommu/vt-d: Add basic SVM PASID support')
    Signed-off-by: Joerg Roedel
    Signed-off-by: Greg Kroah-Hartman

    Jacob Pan
     
  • commit 432abf68a79332282329286d190e21fe3ac02a31 upstream.

    The generic command buffer entry is 128 bits (16 bytes), so the offset
    of tail and head pointer should be 16 bytes aligned and increased with
    0x10 per command.

    When cmd buf is full, head = (tail + 0x10) % CMD_BUFFER_SIZE.

    So when left space of cmd buf should be able to store only two
    command, we should be issued one COMPLETE_WAIT additionally to wait
    all older commands completed. Then the left space should be increased
    after IOMMU fetching from cmd buf.

    So left check value should be left
    Fixes: ac0ea6e92b222 ('x86/amd-iommu: Improve handling of full command buffer')
    Signed-off-by: Joerg Roedel
    Signed-off-by: Greg Kroah-Hartman

    Huang Rui
     
  • commit 24c790fbf5d8f54c8c82979db11edea8855b74bf upstream.

    We should set "ret" to -EINVAL if iommu_group_get() fails.

    Fixes: 55c99a4dc50f ("iommu/amd: Use iommu_attach_group()")
    Signed-off-by: Dan Carpenter
    Signed-off-by: Joerg Roedel
    Signed-off-by: Greg Kroah-Hartman

    Dan Carpenter
     

28 Nov, 2016

1 commit

  • Pull IOMMU fixes from David Woodhouse:
    "Two minor fixes.

    The first fixes the assignment of SR-IOV virtual functions to the
    correct IOMMU unit, and the second fixes the excessively large (and
    physically contiguous) PASID tables used with SVM"

    * git://git.infradead.org/intel-iommu:
    iommu/vt-d: Fix PASID table allocation
    iommu/vt-d: Fix IOMMU lookup for SR-IOV Virtual Functions

    Linus Torvalds
     

20 Nov, 2016

1 commit

  • Somehow I ended up with an off-by-three error in calculating the size of
    the PASID and PASID State tables, which triggers allocations failures as
    those tables unfortunately have to be physically contiguous.

    In fact, even the *correct* maximum size of 8MiB is problematic and is
    wont to lead to allocation failures. Since I have extracted a promise
    that this *will* be fixed in hardware, I'm happy to limit it on the
    current hardware to a maximum of 0x20000 PASIDs, which gives us 1MiB
    tables — still not ideal, but better than before.

    Reported by Mika Kuoppala and also by
    Xunlei Pang who submitted a simpler patch to fix
    only the allocation (and not the free) to the "correct" limit... which
    was still problematic.

    Signed-off-by: David Woodhouse
    Cc: stable@vger.kernel.org

    David Woodhouse
     

08 Nov, 2016

5 commits

  • It turns out that the disable_dmar_iommu() code-path tried
    to get the device_domain_lock recursivly, which will
    dead-lock when this code runs on dmar removal. Fix both
    code-paths that could lead to the dead-lock.

    Fixes: 55d940430ab9 ('iommu/vt-d: Get rid of domain->iommu_lock')
    Signed-off-by: Joerg Roedel

    Joerg Roedel
     
  • When we iterate a master's config entries, what we generally care
    about is the entry's stream map index, rather than the entry index
    itself, so it's nice to have the iterator automatically assign the
    former from the latter. Unfortunately, booting with KASAN reveals
    the oversight that using a simple comma operator results in the
    entry index being dereferenced before being checked for validity,
    so we always access one element past the end of the fwspec array.

    Flip things around so that the check always happens before the index
    may be dereferenced.

    Fixes: adfec2e709d2 ("iommu/arm-smmu: Convert to iommu_fwspec")
    Reported-by: Mark Rutland
    Signed-off-by: Robin Murphy
    Acked-by: Will Deacon
    Signed-off-by: Joerg Roedel

    Robin Murphy
     
  • We seem to have forgotten to check that iommu_fwspecs actually belong to
    us before we go ahead and dereference their private data. Oops.

    Fixes: 021bb8420d44 ("iommu/arm-smmu: Wire up generic configuration support")
    Signed-off-by: Robin Murphy
    Signed-off-by: Joerg Roedel

    Robin Murphy
     
  • We now delay installing our per-bus iommu_ops until we know an SMMU has
    successfully probed, as they don't serve much purpose beforehand, and
    doing so also avoids fights between multiple IOMMU drivers in a single
    kernel. However, the upshot of passing the return value of bus_set_iommu()
    back from our probe function is that if there happens to be more than
    one SMMUv3 device in a system, the second and subsequent probes will
    wind up returning -EBUSY to the driver core and getting torn down again.

    Avoid re-setting ops if ours are already installed, so that any genuine
    failures stand out.

    Fixes: 08d4ca2a672b ("iommu/arm-smmu: Support non-PCI devices with SMMUv3")
    CC: Lorenzo Pieralisi
    CC: Hanjun Guo
    Signed-off-by: Robin Murphy
    Signed-off-by: Joerg Roedel

    Robin Murphy
     
  • The 32-bit ARM DMA configuration code predates the IOMMU core's default
    domain functionality, and instead relies on allocating its own domains
    and attaching any devices using the generic IOMMU binding to them.
    Unfortunately, it does this relatively early on in the creation of the
    device, before we've seen our add_device callback, which leads us to
    attempt to operate on a half-configured master.

    To avoid a crash, check for this situation on attach, but refuse to
    play, as there's nothing we can do. This at least allows VFIO to keep
    working for people who update their 32-bit DTs to the generic binding,
    albeit with a few (innocuous) warnings from the DMA layer on boot.

    Signed-off-by: Robin Murphy
    Signed-off-by: Will Deacon
    Signed-off-by: Joerg Roedel

    Robin Murphy
     

30 Oct, 2016

1 commit

  • The VT-d specification (§8.3.3) says:
    ‘Virtual Functions’ of a ‘Physical Function’ are under the scope
    of the same remapping unit as the ‘Physical Function’.

    The BIOS is not required to list all the possible VFs in the scope
    tables, and arguably *shouldn't* make any attempt to do so, since there
    could be a huge number of them.

    This has been broken basically for ever — the VF is never going to match
    against a specific unit's scope, so it ends up being assigned to the
    INCLUDE_ALL IOMMU. Which was always actually correct by coincidence, but
    now we're looking at Root-Complex integrated devices with SR-IOV support
    it's going to start being wrong.

    Fix it to simply use pci_physfn() before doing the lookup for PCI devices.

    Cc: stable@vger.kernel.org
    Signed-off-by: Sainath Grandhi
    Signed-off-by: Ashok Raj
    Signed-off-by: David Woodhouse

    Ashok Raj
     

12 Oct, 2016

1 commit

  • Pull IOMMU updates from Joerg Roedel:

    - support for interrupt virtualization in the AMD IOMMU driver. These
    patches were shared with the KVM tree and are already merged through
    that tree.

    - generic DT-binding support for the ARM-SMMU driver. With this the
    driver now makes use of the generic DMA-API code. This also required
    some changes outside of the IOMMU code, but these are acked by the
    respective maintainers.

    - more cleanups and fixes all over the place.

    * tag 'iommu-updates-v4.9' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu: (40 commits)
    iommu/amd: No need to wait iommu completion if no dte irq entry change
    iommu/amd: Free domain id when free a domain of struct dma_ops_domain
    iommu/amd: Use standard bitmap operation to set bitmap
    iommu/amd: Clean up the cmpxchg64 invocation
    iommu/io-pgtable-arm: Check for v7s-incapable systems
    iommu/dma: Avoid PCI host bridge windows
    iommu/dma: Add support for mapping MSIs
    iommu/arm-smmu: Set domain geometry
    iommu/arm-smmu: Wire up generic configuration support
    Docs: dt: document ARM SMMU generic binding usage
    iommu/arm-smmu: Convert to iommu_fwspec
    iommu/arm-smmu: Intelligent SMR allocation
    iommu/arm-smmu: Add a stream map entry iterator
    iommu/arm-smmu: Streamline SMMU data lookups
    iommu/arm-smmu: Refactor mmu-masters handling
    iommu/arm-smmu: Keep track of S2CR state
    iommu/arm-smmu: Consolidate stream map entry state
    iommu/arm-smmu: Handle stream IDs more dynamically
    iommu/arm-smmu: Set PRIVCFG in stage 1 STEs
    iommu/arm-smmu: Support non-PCI devices with SMMUv3
    ...

    Linus Torvalds
     

07 Oct, 2016

1 commit

  • Pull KVM updates from Radim Krčmář:
    "All architectures:
    - move `make kvmconfig` stubs from x86
    - use 64 bits for debugfs stats

    ARM:
    - Important fixes for not using an in-kernel irqchip
    - handle SError exceptions and present them to guests if appropriate
    - proxying of GICV access at EL2 if guest mappings are unsafe
    - GICv3 on AArch32 on ARMv8
    - preparations for GICv3 save/restore, including ABI docs
    - cleanups and a bit of optimizations

    MIPS:
    - A couple of fixes in preparation for supporting MIPS EVA host
    kernels
    - MIPS SMP host & TLB invalidation fixes

    PPC:
    - Fix the bug which caused guests to falsely report lockups
    - other minor fixes
    - a small optimization

    s390:
    - Lazy enablement of runtime instrumentation
    - up to 255 CPUs for nested guests
    - rework of machine check deliver
    - cleanups and fixes

    x86:
    - IOMMU part of AMD's AVIC for vmexit-less interrupt delivery
    - Hyper-V TSC page
    - per-vcpu tsc_offset in debugfs
    - accelerated INS/OUTS in nVMX
    - cleanups and fixes"

    * tag 'kvm-4.9-1' of git://git.kernel.org/pub/scm/virt/kvm/kvm: (140 commits)
    KVM: MIPS: Drop dubious EntryHi optimisation
    KVM: MIPS: Invalidate TLB by regenerating ASIDs
    KVM: MIPS: Split kernel/user ASID regeneration
    KVM: MIPS: Drop other CPU ASIDs on guest MMU changes
    KVM: arm/arm64: vgic: Don't flush/sync without a working vgic
    KVM: arm64: Require in-kernel irqchip for PMU support
    KVM: PPC: Book3s PR: Allow access to unprivileged MMCR2 register
    KVM: PPC: Book3S PR: Support 64kB page size on POWER8E and POWER8NVL
    KVM: PPC: Book3S: Remove duplicate setting of the B field in tlbie
    KVM: PPC: BookE: Fix a sanity check
    KVM: PPC: Book3S HV: Take out virtual core piggybacking code
    KVM: PPC: Book3S: Treat VTB as a per-subcore register, not per-thread
    ARM: gic-v3: Work around definition of gic_write_bpr1
    KVM: nVMX: Fix the NMI IDT-vectoring handling
    KVM: VMX: Enable MSR-BASED TPR shadow even if APICv is inactive
    KVM: nVMX: Fix reload apic access page warning
    kvmconfig: add virtio-gpu to config fragment
    config: move x86 kvm_guest.config to a common location
    arm64: KVM: Remove duplicating init code for setting VMID
    ARM: KVM: Support vgic-v3
    ...

    Linus Torvalds
     

05 Oct, 2016

1 commit

  • Pull s390 updates from Martin Schwidefsky:
    "The new features and main improvements in this merge for v4.9

    - Support for the UBSAN sanitizer

    - Set HAVE_EFFICIENT_UNALIGNED_ACCESS, it improves the code in some
    places

    - Improvements for the in-kernel fpu code, in particular the overhead
    for multiple consecutive in kernel fpu users is recuded

    - Add a SIMD implementation for the RAID6 gen and xor operations

    - Add RAID6 recovery based on the XC instruction

    - The PCI DMA flush logic has been improved to increase the speed of
    the map / unmap operations

    - The time synchronization code has seen some updates

    And bug fixes all over the place"

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux: (48 commits)
    s390/con3270: fix insufficient space padding
    s390/con3270: fix use of uninitialised data
    MAINTAINERS: update DASD maintainer
    s390/cio: fix accidental interrupt enabling during resume
    s390/dasd: add missing \n to end of dev_err messages
    s390/config: Enable config options for Docker
    s390/dasd: make query host access interruptible
    s390/dasd: fix panic during offline processing
    s390/dasd: fix hanging offline processing
    s390/pci_dma: improve lazy flush for unmap
    s390/pci_dma: split dma_update_trans
    s390/pci_dma: improve map_sg
    s390/pci_dma: simplify dma address calculation
    s390/pci_dma: remove dma address range check
    iommu/s390: simplify registration of I/O address translation parameters
    s390: migrate exception table users off module.h and onto extable.h
    s390: export header for CLP ioctl
    s390/vmur: fix irq pointer dereference in int handler
    s390/dasd: add missing KOBJ_CHANGE event for unformatted devices
    s390: enable UBSAN
    ...

    Linus Torvalds
     

22 Sep, 2016

1 commit

  • When a new function is attached to an iommu domain we need to register
    I/O address translation parameters. Since commit
    69eea95c ("s390/pci_dma: fix DMA table corruption with > 4 TB main memory")
    start_dma and end_dma correctly describe the range of usable I/O addresses.

    Simplify the code by using these values directly.

    Signed-off-by: Sebastian Ott
    Reviewed-by: Gerald Schaefer
    Signed-off-by: Martin Schwidefsky

    Sebastian Ott
     

20 Sep, 2016

2 commits


19 Sep, 2016

3 commits


16 Sep, 2016

19 commits

  • On machines with no 32-bit addressable RAM whatsoever, we shouldn't
    even touch the v7s format as it's never going to work.

    Fixes: e5fc9753b1a8 ("iommu/io-pgtable: Add ARMv7 short descriptor support")
    Reported-by: Eric Auger
    Tested-by: Eric Auger
    Signed-off-by: Robin Murphy
    Signed-off-by: Will Deacon

    Robin Murphy
     
  • With our DMA ops enabled for PCI devices, we should avoid allocating
    IOVAs which a host bridge might misinterpret as peer-to-peer DMA and
    lead to faults, corruption or other badness. To be safe, punch out holes
    for all of the relevant host bridge's windows when initialising a DMA
    domain for a PCI device.

    CC: Marek Szyprowski
    CC: Inki Dae
    Reported-by: Lorenzo Pieralisi
    Signed-off-by: Robin Murphy
    Signed-off-by: Will Deacon

    Robin Murphy
     
  • When an MSI doorbell is located downstream of an IOMMU, attaching
    devices to a DMA ops domain and switching on translation leads to a rude
    shock when their attempt to write to the physical address returned by
    the irqchip driver faults (or worse, writes into some already-mapped
    buffer) and no interrupt is forthcoming.

    Address this by adding a hook for relevant irqchip drivers to call from
    their compose_msi_msg() callback, to swizzle the physical address with
    an appropriatly-mapped IOVA for any device attached to one of our DMA
    ops domains.

    Acked-by: Thomas Gleixner
    Acked-by: Marc Zyngier
    Signed-off-by: Robin Murphy
    Signed-off-by: Will Deacon

    Robin Murphy
     
  • For non-aperture-based IOMMUs, the domain geometry seems to have become
    the de-facto way of indicating the input address space size. That is
    quite a useful thing from the users' perspective, so let's do the same.

    Reviewed-by: Eric Auger
    Tested-by: Lorenzo Pieralisi
    Signed-off-by: Robin Murphy
    Signed-off-by: Will Deacon

    Robin Murphy
     
  • With everything else now in place, fill in an of_xlate callback and the
    appropriate registration to plumb into the generic configuration
    machinery, and watch everything just work.

    Signed-off-by: Robin Murphy
    Signed-off-by: Will Deacon

    Robin Murphy
     
  • In the final step of preparation for full generic configuration support,
    swap our fixed-size master_cfg for the generic iommu_fwspec. For the
    legacy DT bindings, the driver simply gets to act as its own 'firmware'.
    Farewell, arbitrary MAX_MASTER_STREAMIDS!

    Signed-off-by: Robin Murphy
    Signed-off-by: Will Deacon

    Robin Murphy
     
  • Stream Match Registers are one of the more awkward parts of the SMMUv2
    architecture; there are typically never enough to assign one to each
    stream ID in the system, and configuring them such that a single ID
    matches multiple entries is catastrophically bad - at best, every
    transaction raises a global fault; at worst, they go *somewhere*.

    To address the former issue, we can mask ID bits such that a single
    register may be used to match multiple IDs belonging to the same device
    or group, but doing so also heightens the risk of the latter problem
    (which can be nasty to debug).

    Tackle both problems at once by replacing the simple bitmap allocator
    with something much cleverer. Now that we have convenient in-memory
    representations of the stream mapping table, it becomes straightforward
    to properly validate new SMR entries against the current state, opening
    the door to arbitrary masking and SMR sharing.

    Another feature which falls out of this is that with IDs shared by
    separate devices being automatically accounted for, simply associating a
    group pointer with the S2CR offers appropriate group allocation almost
    for free, so hook that up in the process.

    Signed-off-by: Robin Murphy
    Signed-off-by: Will Deacon

    Robin Murphy
     
  • We iterate over the SMEs associated with a master config quite a lot in
    various places, and are about to do so even more. Let's wrap the idiom
    in a handy iterator macro before the repetition gets out of hand.

    Tested-by: Lorenzo Pieralisi
    Signed-off-by: Robin Murphy
    Signed-off-by: Will Deacon

    Robin Murphy
     
  • Simplify things somewhat by stashing our arm_smmu_device instance in
    drvdata, so that it's readily available to our driver model callbacks.
    Then we can excise the private list entirely, since the driver core
    already has a perfectly good list of SMMU devices we can use in the one
    instance we actually need to. Finally, make a further modest code saving
    with the relatively new of_device_get_match_data() helper.

    Tested-by: Lorenzo Pieralisi
    Signed-off-by: Robin Murphy
    Signed-off-by: Will Deacon

    Robin Murphy
     
  • To be able to support the generic bindings and handle of_xlate() calls,
    we need to be able to associate SMMUs and stream IDs directly with
    devices *before* allocating IOMMU groups. Furthermore, to support real
    default domains with multi-device groups we also have to handle domain
    attach on a per-device basis, as the "whole group at a time" assumption
    fails to properly handle subsequent devices added to a group after the
    first has already triggered default domain creation and attachment.

    To that end, use the now-vacant dev->archdata.iommu field for easy
    config and SMMU instance lookup, and unify config management by chopping
    down the platform-device-specific tree and probing the "mmu-masters"
    property on-demand instead. This may add a bit of one-off overhead to
    initially adding a new device, but we're about to deprecate that binding
    in favour of the inherently-more-efficient generic ones anyway.

    For the sake of simplicity, this patch does temporarily regress the case
    of aliasing PCI devices by losing the duplicate stream ID detection that
    the previous per-group config had. Stay tuned, because we'll be back to
    fix that in a better and more general way momentarily...

    Tested-by: Lorenzo Pieralisi
    Signed-off-by: Robin Murphy
    Signed-off-by: Will Deacon

    Robin Murphy
     
  • Making S2CRs first-class citizens within the driver with a high-level
    representation of their state offers a neat solution to a few problems:

    Firstly, the information about which context a device's stream IDs are
    associated with is already present by necessity in the S2CR. With that
    state easily accessible we can refer directly to it and obviate the need
    to track an IOMMU domain in each device's archdata (its earlier purpose
    of enforcing correct attachment of multi-device groups now being handled
    by the IOMMU core itself).

    Secondly, the core API now deprecates explicit domain detach and expects
    domain attach to move devices smoothly from one domain to another; for
    SMMUv2, this notion maps directly to simply rewriting the S2CRs assigned
    to the device. By giving the driver a suitable abstraction of those
    S2CRs to work with, we can massively reduce the overhead of the current
    heavy-handed "detach, free resources, reallocate resources, attach"
    approach.

    Thirdly, making the software state hardware-shaped and attached to the
    SMMU instance once again makes suspend/resume of this register group
    that much simpler to implement in future.

    Signed-off-by: Robin Murphy
    Signed-off-by: Will Deacon

    Robin Murphy
     
  • In order to consider SMR masking, we really want to be able to validate
    ID/mask pairs against existing SMR contents to prevent stream match
    conflicts, which at best would cause transactions to fault unexpectedly,
    and at worst lead to silent unpredictable behaviour. With our SMMU
    instance data holding only an allocator bitmap, and the SMR values
    themselves scattered across master configs hanging off devices which we
    may have no way of finding, there's essentially no way short of digging
    everything back out of the hardware. Similarly, the thought of power
    management ops to support suspend/resume faces the exact same problem.

    By massaging the software state into a closer shape to the underlying
    hardware, everything comes together quite nicely; the allocator and the
    high-level view of the data become a single centralised state which we
    can easily keep track of, and to which any updates can be validated in
    full before being synchronised to the hardware itself.

    Signed-off-by: Robin Murphy
    Signed-off-by: Will Deacon

    Robin Murphy
     
  • Rather than assuming fixed worst-case values for stream IDs and SMR
    masks, keep track of whatever implemented bits the hardware actually
    reports. This also obviates the slightly questionable validation of SMR
    fields in isolation - rather than aborting the whole SMMU probe for a
    hardware configuration which is still architecturally valid, we can
    simply refuse masters later if they try to claim an unrepresentable ID
    or mask (which almost certainly implies a DT error anyway).

    Acked-by: Will Deacon
    Tested-by: Lorenzo Pieralisi
    Signed-off-by: Robin Murphy
    Signed-off-by: Will Deacon

    Robin Murphy
     
  • Implement the SMMUv3 equivalent of d346180e70b9 ("iommu/arm-smmu: Treat
    all device transactions as unprivileged"), so that once again those
    pesky DMA controllers with their privileged instruction fetches don't
    unexpectedly fault in stage 1 domains due to VMSAv8 rules.

    Acked-by: Will Deacon
    Tested-by: Lorenzo Pieralisi
    Signed-off-by: Robin Murphy
    Signed-off-by: Will Deacon

    Robin Murphy
     
  • With the device stream ID relationship suitably abstracted and
    of_xlate() hooked up, the PCI dependency now looks, and is, entirely
    arbitrary. Any bus using the of_dma_configure() mechanism will work,
    so extend support to the platform and AMBA buses which do just that.

    Acked-by: Will Deacon
    Tested-by: Lorenzo Pieralisi
    Signed-off-by: Robin Murphy
    Signed-off-by: Will Deacon

    Robin Murphy
     
  • Now that we can properly describe the mapping between PCI RIDs and
    stream IDs via "iommu-map", and have it fed it to the driver
    automatically via of_xlate(), rework the SMMUv3 driver to benefit from
    that, and get rid of the current misuse of the "iommus" binding.

    Since having of_xlate wired up means that masters will now be given the
    appropriate DMA ops, we also need to make sure that default domains work
    properly. This necessitates dispensing with the "whole group at a time"
    notion for attaching to a domain, as devices which share a group get
    attached to the group's default domain one by one as they are initially
    probed.

    Signed-off-by: Robin Murphy
    Signed-off-by: Will Deacon

    Robin Murphy
     
  • Unlike SMMUv2, SMMUv3 has no easy way to bypass unknown stream IDs,
    other than allocating and filling in the entire stream table with bypass
    entries, which for some configurations would waste *gigabytes* of RAM.
    Otherwise, all transactions on unknown stream IDs will simply be aborted
    with a C_BAD_STREAMID event.

    Rather than render the system unusable in the case of an invalid DT,
    avoid enabling the SMMU altogether such that everything bypasses
    (though letting the explicit disable_bypass option take precedence).

    Signed-off-by: Robin Murphy
    Signed-off-by: Will Deacon

    Robin Murphy
     
  • Introduce a common structure to hold the per-device firmware data that
    most IOMMU drivers need to keep track of. This enables us to configure
    much of that data from common firmware code, and consolidate a lot of
    the equivalent implementations, device look-up tables, etc. which are
    currently strewn across IOMMU drivers.

    This will also be enable us to address the outstanding "multiple IOMMUs
    on the platform bus" problem by tweaking IOMMU API calls to prefer
    dev->fwspec->ops before falling back to dev->bus->iommu_ops, and thus
    gracefully handle those troublesome systems which we currently cannot.

    As the first user, hook up the OF IOMMU configuration mechanism. The
    driver-defined nature of DT cells means that we still need the drivers
    to translate and add the IDs themselves, but future users such as the
    much less free-form ACPI IORT will be much simpler and self-contained.

    CC: Greg Kroah-Hartman
    Suggested-by: Will Deacon
    Signed-off-by: Robin Murphy
    Signed-off-by: Will Deacon

    Robin Murphy
     
  • Now that we have a way to pick up the RID translation and target IOMMU,
    hook up of_iommu_configure() to bring PCI devices into the of_xlate
    mechanism and allow them IOMMU-backed DMA ops without the need for
    driver-specific handling.

    Reviewed-by: Will Deacon
    Signed-off-by: Robin Murphy
    Signed-off-by: Will Deacon

    Robin Murphy