22 Aug, 2016

1 commit


19 Aug, 2016

4 commits

  • The disable_bypass cmdline option changes the SMMUv3 driver to put down
    faulting stream table entries by default, as opposed to bypassing
    transactions from unconfigured devices.

    In this mode of operation, it is entirely expected to see aborting
    entries in the stream table if and when we come to installing a valid
    translation, so don't trigger a BUG() as a result of misdiagnosing these
    entries as stream table corruption.

    Cc:
    Fixes: 48ec83bcbcf5 ("iommu/arm-smmu: Add initial driver support for ARM SMMUv3 devices")
    Tested-by: Robin Murphy
    Reported-by: Robin Murphy
    Reviewed-by: Robin Murphy
    Signed-off-by: Will Deacon

    Will Deacon
     
  • Enabling stalling faults can result in hardware deadlock on poorly
    designed systems, particularly those with a PCI root complex upstream of
    the SMMU.

    Although it's not really Linux's job to save hardware integrators from
    their own misfortune, it *is* our job to stop userspace (e.g. VFIO
    clients) from hosing the system for everybody else, even if they might
    already be required to have elevated privileges.

    Given that the fault handling code currently executes entirely in IRQ
    context, there is nothing that can sensibly be done to recover from
    things like page faults anyway, so let's rip this code out for now and
    avoid the potential for deadlock.

    Cc:
    Fixes: 48ec83bcbcf5 ("iommu/arm-smmu: Add initial driver support for ARM SMMUv3 devices")
    Reported-by: Matt Evans
    Signed-off-by: Will Deacon

    Will Deacon
     
  • In the unlikely event of a global command queue error, the ARM SMMUv3
    driver attempts to convert the problematic command into a CMD_SYNC and
    resume the command queue. Unfortunately, this code is pretty badly
    broken:

    1. It uses the index into the error string table as the CMDQ index,
    so we probably read the wrong entry out of the queue

    2. The arguments to queue_write are the wrong way round, so we end up
    writing from the queue onto the stack.

    These happily cancel out, so the kernel is likely to stay alive, but
    the command queue will probably fault again when we resume.

    This patch fixes the error handling code to use the correct queue index
    and write back the CMD_SYNC to the faulting entry.

    Cc:
    Fixes: 48ec83bcbcf5 ("iommu/arm-smmu: Add initial driver support for ARM SMMUv3 devices")
    Reported-by: Diwakar Subraveti
    Signed-off-by: Will Deacon

    Will Deacon
     
  • Due to the attribute bits being all over the place in the different
    types of short-descriptor PTEs, when remapping an existing entry, e.g.
    splitting a section into pages, we take the approach of decomposing
    the PTE attributes back to the IOMMU API flags to start from scratch.

    On inspection, though, the existing code seems to have got the read-only
    bit backwards and ignored the XN bit. How embarrassing...

    Fortunately the primary user so far, the Mediatek IOMMU, both never
    splits blocks (because it only serves non-overlapping DMA API calls) and
    also ignores permissions anyway, but let's put things right before any
    future users trip up.

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

    Robin Murphy
     

10 Aug, 2016

1 commit

  • Where a device driver has set a 64-bit DMA mask to indicate the absence
    of addressing limitations, we still need to ensure that we don't
    allocate IOVAs beyond the actual input size of the IOMMU. The reported
    aperture is the most reliable way we have of inferring that input
    address size, so use that to enforce a hard upper limit where available.

    Fixes: 0db2e5d18f76 ("iommu: Implement common IOMMU ops for DMA mapping")
    Signed-off-by: Robin Murphy
    Signed-off-by: Joerg Roedel

    Robin Murphy
     

09 Aug, 2016

2 commits

  • Due to the limitations of having to wait until we see a device's DMA
    restrictions before we know how we want an IOVA domain initialised,
    there is a window for error if a DMA ops domain is allocated but later
    freed without ever being used. In that case, init_iova_domain() was
    never called, so calling put_iova_domain() from iommu_put_dma_cookie()
    ends up trying to take an uninitialised lock and crashing.

    Make things robust by skipping the call unless the IOVA domain actually
    has been initialised, as we probably should have done from the start.

    Fixes: 0db2e5d18f76 ("iommu: Implement common IOMMU ops for DMA mapping")
    Cc: stable@vger.kernel.org
    Reported-by: Nate Watterson
    Reviewed-by: Nate Watterson
    Tested-by: Nate Watterson
    Reviewed-by: Eric Auger
    Tested-by: Eric Auger
    Signed-off-by: Robin Murphy
    Signed-off-by: Joerg Roedel

    Robin Murphy
     
  • This was an oversight while merging these functions. Fix it.

    Cc: Honghui Zhang
    Fixes: 9ca340c98c0d ('iommu/mediatek: move the common struct into header file')
    Signed-off-by: Joerg Roedel

    Joerg Roedel
     

04 Aug, 2016

1 commit

  • The dma-mapping core and the implementations do not change the DMA
    attributes passed by pointer. Thus the pointer can point to const data.
    However the attributes do not have to be a bitfield. Instead unsigned
    long will do fine:

    1. This is just simpler. Both in terms of reading the code and setting
    attributes. Instead of initializing local attributes on the stack
    and passing pointer to it to dma_set_attr(), just set the bits.

    2. It brings safeness and checking for const correctness because the
    attributes are passed by value.

    Semantic patches for this change (at least most of them):

    virtual patch
    virtual context

    @r@
    identifier f, attrs;

    @@
    f(...,
    - struct dma_attrs *attrs
    + unsigned long attrs
    , ...)
    {
    ...
    }

    @@
    identifier r.f;
    @@
    f(...,
    - NULL
    + 0
    )

    and

    // Options: --all-includes
    virtual patch
    virtual context

    @r@
    identifier f, attrs;
    type t;

    @@
    t f(..., struct dma_attrs *attrs);

    @@
    identifier r.f;
    @@
    f(...,
    - NULL
    + 0
    )

    Link: http://lkml.kernel.org/r/1468399300-5399-2-git-send-email-k.kozlowski@samsung.com
    Signed-off-by: Krzysztof Kozlowski
    Acked-by: Vineet Gupta
    Acked-by: Robin Murphy
    Acked-by: Hans-Christian Noren Egtvedt
    Acked-by: Mark Salter [c6x]
    Acked-by: Jesper Nilsson [cris]
    Acked-by: Daniel Vetter [drm]
    Reviewed-by: Bart Van Assche
    Acked-by: Joerg Roedel [iommu]
    Acked-by: Fabien Dessenne [bdisp]
    Reviewed-by: Marek Szyprowski [vb2-core]
    Acked-by: David Vrabel [xen]
    Acked-by: Konrad Rzeszutek Wilk [xen swiotlb]
    Acked-by: Joerg Roedel [iommu]
    Acked-by: Richard Kuo [hexagon]
    Acked-by: Geert Uytterhoeven [m68k]
    Acked-by: Gerald Schaefer [s390]
    Acked-by: Bjorn Andersson
    Acked-by: Hans-Christian Noren Egtvedt [avr32]
    Acked-by: Vineet Gupta [arc]
    Acked-by: Robin Murphy [arm64 and dma-iommu]
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Krzysztof Kozlowski
     

01 Aug, 2016

1 commit

  • Pull IOMMU updates from Joerg Roedel:

    - big-endian support and preparation for defered probing for the Exynos
    IOMMU driver

    - simplifications in iommu-group id handling

    - support for Mediatek generation one IOMMU hardware

    - conversion of the AMD IOMMU driver to use the generic IOVA allocator.
    This driver now also benefits from the recent scalability
    improvements in the IOVA code.

    - preparations to use generic DMA mapping code in the Rockchip IOMMU
    driver

    - device tree adaption and conversion to use generic page-table code
    for the MSM IOMMU driver

    - an iova_to_phys optimization in the ARM-SMMU driver to greatly
    improve page-table teardown performance with VFIO

    - various other small fixes and conversions

    * tag 'iommu-updates-v4.8' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu: (59 commits)
    iommu/amd: Initialize dma-ops domains with 3-level page-table
    iommu/amd: Update Alias-DTE in update_device_table()
    iommu/vt-d: Return error code in domain_context_mapping_one()
    iommu/amd: Use container_of to get dma_ops_domain
    iommu/amd: Flush iova queue before releasing dma_ops_domain
    iommu/amd: Handle IOMMU_DOMAIN_DMA in ops->domain_free call-back
    iommu/amd: Use dev_data->domain in get_domain()
    iommu/amd: Optimize map_sg and unmap_sg
    iommu/amd: Introduce dir2prot() helper
    iommu/amd: Implement timeout to flush unmap queues
    iommu/amd: Implement flush queue
    iommu/amd: Allow NULL pointer parameter for domain_flush_complete()
    iommu/amd: Set up data structures for flush queue
    iommu/amd: Remove align-parameter from __map_single()
    iommu/amd: Remove other remains of old address allocator
    iommu/amd: Make use of the generic IOVA allocator
    iommu/amd: Remove special mapping code for dma_ops path
    iommu/amd: Pass gfp-flags to iommu_map_page()
    iommu/amd: Implement apply_dm_region call-back
    iommu/amd: Create a list of reserved iova addresses
    ...

    Linus Torvalds
     

31 Jul, 2016

1 commit

  • Pull DeviceTree updates from Rob Herring:

    - remove most of_platform_populate() calls in arch code. Now the DT
    core code calls it in the default case and platforms only need to
    call it if they have special needs

    - use pr_fmt on all the DT core print statements

    - CoreSight binding doc improvements to block name descriptions

    - add dt_to_config script which can parse dts files and list
    corresponding kernel config options

    - fix memory leak hit with a PowerMac DT

    - correct a bunch of STMicro compatible strings to use the correct
    vendor prefix

    - fix DA9052 PMIC binding doc to match what is actually used in dts
    files

    * tag 'devicetree-for-4.8' of git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux: (35 commits)
    documentation: da9052: Update regulator bindings names to match DA9052/53 DTS expectations
    xtensa: Partially Revert "xtensa: Remove unnecessary of_platform_populate with default match table"
    xtensa: Fix build error due to missing include file
    MIPS: ath79: Add missing include file
    Fix spelling errors in Documentation/devicetree
    ARM: dts: fix STMicroelectronics compatible strings
    powerpc/dts: fix STMicroelectronics compatible strings
    Documentation: dt: i2c: use correct STMicroelectronics vendor prefix
    scripts/dtc: dt_to_config - kernel config options for a devicetree
    of: fdt: mark unflattened tree as detached
    of: overlay: add resolver error prints
    coresight: document binding acronyms
    Documentation/devicetree: document cavium-pip rx-delay/tx-delay properties
    of: use pr_fmt prefix for all console printing
    of/irq: Mark initialised interrupt controllers as populated
    of: fix memory leak related to safe_name()
    Revert "of/platform: export of_default_bus_match_table"
    of: unittest: use of_platform_default_populate() to populate default bus
    memory: omap-gpmc: use of_platform_default_populate() to populate default bus
    bus: uniphier-system-bus: use of_platform_default_populate() to populate default bus
    ...

    Linus Torvalds
     

28 Jul, 2016

1 commit

  • Some of our "for_each_xyz()" macro constructs make gcc unhappy about
    lack of braces around if-statements inside or outside the loop, because
    the loop construct itself has a "if-then-else" statement inside of it.

    The resulting warnings look something like this:

    drivers/gpu/drm/i915/i915_debugfs.c: In function ‘i915_dump_lrc’:
    drivers/gpu/drm/i915/i915_debugfs.c:2103:6: warning: suggest explicit braces to avoid ambiguous ‘else’ [-Wparentheses]
    if (ctx != dev_priv->kernel_context)
    ^

    even if the code itself is fine.

    Since the warning is fairly easy to avoid by adding a braces around the
    if-statement near the for_each_xyz() construct, do so, rather than
    disabling the otherwise potentially useful warning.

    (The if-then-else statements used in the "for_each_xyz()" constructs are
    designed to be inherently safe even with no braces, but in this case
    it's quite understandable that gcc isn't really able to tell that).

    This finally leaves the standard "allmodconfig" build with just a
    handful of remaining warnings, so new and valid warnings hopefully will
    stand out.

    Signed-off-by: Linus Torvalds

    Linus Torvalds
     

27 Jul, 2016

1 commit


26 Jul, 2016

3 commits


14 Jul, 2016

6 commits


13 Jul, 2016

18 commits