1. 07 4月, 2016 3 次提交
  2. 02 3月, 2016 2 次提交
    • D
      iommu/mediatek: Check for NULL instead of IS_ERR() · 3189e490
      Dan Carpenter 提交于
      of_platform_device_create() returns NULL on error, it never returns
      error pointers.
      
      Fixes: 0df4fabe ('iommu/mediatek: Add mt8173 IOMMU driver')
      Signed-off-by: NDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      3189e490
    • R
      iommu/io-pgtable-armv7s: Fix kmem_cache_alloc() flags · 048b31ca
      Robin Murphy 提交于
      Whilst the default SLUB allocator happily just merges the original
      allocation flags from kmem_cache_create() with those passed through
      kmem_cache_alloc(), there is a code path in the SLAB allocator which
      will aggressively BUG_ON() if the cache was created with SLAB_CACHE_DMA
      but GFP_DMA is not specified for an allocation:
      
        kernel BUG at mm/slab.c:2536!
        Internal error: Oops - BUG: 0 [#1] SMP ARM
        Modules linked in:[    1.299311] Modules linked in:
      
        CPU: 1 PID: 1 Comm: swapper/0 Not tainted
        4.5.0-rc6-koelsch-05892-ge7e45ad53ab6795e #2270
        Hardware name: Generic R8A7791 (Flattened Device Tree)
        task: ef422040 ti: ef442000 task.ti: ef442000
        PC is at cache_alloc_refill+0x2a0/0x530
        LR is at _raw_spin_unlock+0x8/0xc
      ...
        [<c02c6928>] (cache_alloc_refill) from [<c02c6630>] (kmem_cache_alloc+0x7c/0xd4)
        [<c02c6630>] (kmem_cache_alloc) from [<c04444bc>]
        (__arm_v7s_alloc_table+0x5c/0x278)
        [<c04444bc>] (__arm_v7s_alloc_table) from [<c0444e1c>]
        (__arm_v7s_map.constprop.6+0x68/0x25c)
        [<c0444e1c>] (__arm_v7s_map.constprop.6) from [<c0445044>]
        (arm_v7s_map+0x34/0xa4)
        [<c0445044>] (arm_v7s_map) from [<c0c18ee4>] (arm_v7s_do_selftests+0x140/0x418)
        [<c0c18ee4>] (arm_v7s_do_selftests) from [<c0201760>]
        (do_one_initcall+0x100/0x1b4)
        [<c0201760>] (do_one_initcall) from [<c0c00d4c>]
        (kernel_init_freeable+0x120/0x1e8)
        [<c0c00d4c>] (kernel_init_freeable) from [<c067a364>] (kernel_init+0x8/0xec)
        [<c067a364>] (kernel_init) from [<c0206b68>] (ret_from_fork+0x14/0x2c)
        Code: 1a000003 e7f001f2 e3130001 0a000000 (e7f001f2)
        ---[ end trace 190f6f6b84352efd ]---
      
      Keep the peace by adding GFP_DMA when allocating a table.
      Reported-by: NGeert Uytterhoeven <geert@linux-m68k.org>
      Acked-by: NWill Deacon <will.deacon@arm.com>
      Signed-off-by: NRobin Murphy <robin.murphy@arm.com>
      Tested-by: NGeert Uytterhoeven <geert+renesas@glider.be>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      048b31ca
  3. 01 3月, 2016 4 次提交
  4. 29 2月, 2016 4 次提交
    • A
      iommu/mediatek: Mark PM functions as __maybe_unused · fd99f796
      Arnd Bergmann 提交于
      When CONFIG_PM is unset, we get a harmless warning for this driver:
      
      drivers/iommu/mtk_iommu.c:665:12: error: 'mtk_iommu_suspend' defined but not used [-Werror=unused-function]
      drivers/iommu/mtk_iommu.c:680:12: error: 'mtk_iommu_resume' defined but not used [-Werror=unused-function]
      
      Marking the functions as __maybe_unused gits rid of the two functions
      and lets the compiler silently drop the object code, while still
      doing syntax checking on them for build-time verification.
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Fixes: 0df4fabe ("iommu/mediatek: Add mt8173 IOMMU driver")
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      fd99f796
    • A
      iommu/mediatek: Select ARM_DMA_USE_IOMMU · 1928832f
      Arnd Bergmann 提交于
      The newly added Mediatek IOMMU driver uses the IOMMU_DMA infrastructure,
      but unlike other such drivers, it does not select 'ARM_DMA_USE_IOMMU',
      which is a prerequisite, leading to a link error:
      
      warning: (MTK_IOMMU) selects IOMMU_DMA which has unmet direct dependencies (IOMMU_SUPPORT && NEED_SG_DMA_LENGTH)
      drivers/iommu/built-in.o: In function `iommu_put_dma_cookie':
      mtk_iommu.c:(.text+0x11fe): undefined reference to `put_iova_domain'
      drivers/iommu/built-in.o: In function `iommu_dma_init_domain':
      mtk_iommu.c:(.text+0x1316): undefined reference to `init_iova_domain'
      drivers/iommu/built-in.o: In function `__iommu_dma_unmap':
      mtk_iommu.c:(.text+0x1380): undefined reference to `find_iova'
      
      This adds the same select that the other drivers have. On a related
      note, I wonder if we should just always select ARM_DMA_USE_IOMMU
      whenever any IOMMU driver is enabled. Are there any cases where
      we would enable an IOMMU but not use it?
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Fixes: 0df4fabe ("iommu/mediatek: Add mt8173 IOMMU driver")
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      1928832f
    • M
      iommu/exynos: Use proper readl/writel register interface · 84bd0428
      Marek Szyprowski 提交于
      Drivers should use generic readl/writel calls to access HW registers, so
      replace all __raw_readl/writel with generic version.
      Suggested-by: NArnd Bergmann <arnd@arndb.de>
      Signed-off-by: NMarek Szyprowski <m.szyprowski@samsung.com>
      Acked-by: NArnd Bergmann <arnd@arndb.de>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      84bd0428
    • A
      iommu/exynos: Pointers are nto physical addresses · dbf6c6ef
      Arnd Bergmann 提交于
      The exynos iommu driver changed an incorrect cast from pointer
      to 'unsigned int' to an equally incorrect cast to a 'phys_addr_t',
      which results in an obvious compile-time error when phys_addr_t
      is wider than pointers are:
      
      drivers/iommu/exynos-iommu.c: In function 'alloc_lv2entry':
      drivers/iommu/exynos-iommu.c:918:32: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
      
      The code does not actually want the physical address (which would
      involve using virt_to_phys()), but just checks the alignment,
      so we can change it to use a cast to uintptr_t instead.
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Fixes: 740a01ee ("iommu/exynos: Add support for v5 SYSMMU")
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      dbf6c6ef
  5. 25 2月, 2016 16 次提交
  6. 19 2月, 2016 1 次提交
    • D
      mm/core: Do not enforce PKEY permissions on remote mm access · 1b2ee126
      Dave Hansen 提交于
      We try to enforce protection keys in software the same way that we
      do in hardware.  (See long example below).
      
      But, we only want to do this when accessing our *own* process's
      memory.  If GDB set PKRU[6].AD=1 (disable access to PKEY 6), then
      tried to PTRACE_POKE a target process which just happened to have
      some mprotect_pkey(pkey=6) memory, we do *not* want to deny the
      debugger access to that memory.  PKRU is fundamentally a
      thread-local structure and we do not want to enforce it on access
      to _another_ thread's data.
      
      This gets especially tricky when we have workqueues or other
      delayed-work mechanisms that might run in a random process's context.
      We can check that we only enforce pkeys when operating on our *own* mm,
      but delayed work gets performed when a random user context is active.
      We might end up with a situation where a delayed-work gup fails when
      running randomly under its "own" task but succeeds when running under
      another process.  We want to avoid that.
      
      To avoid that, we use the new GUP flag: FOLL_REMOTE and add a
      fault flag: FAULT_FLAG_REMOTE.  They indicate that we are
      walking an mm which is not guranteed to be the same as
      current->mm and should not be subject to protection key
      enforcement.
      
      Thanks to Jerome Glisse for pointing out this scenario.
      Signed-off-by: NDave Hansen <dave.hansen@linux.intel.com>
      Reviewed-by: NThomas Gleixner <tglx@linutronix.de>
      Cc: Alexey Kardashevskiy <aik@ozlabs.ru>
      Cc: Andrea Arcangeli <aarcange@redhat.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Boaz Harrosh <boaz@plexistor.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Dan Williams <dan.j.williams@intel.com>
      Cc: Dave Chinner <dchinner@redhat.com>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: David Gibson <david@gibson.dropbear.id.au>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: Dominik Dingel <dingel@linux.vnet.ibm.com>
      Cc: Dominik Vogt <vogt@linux.vnet.ibm.com>
      Cc: Eric B Munson <emunson@akamai.com>
      Cc: Geliang Tang <geliangtang@163.com>
      Cc: Guan Xuetao <gxt@mprc.pku.edu.cn>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Hugh Dickins <hughd@google.com>
      Cc: Jan Kara <jack@suse.cz>
      Cc: Jason Low <jason.low2@hp.com>
      Cc: Jerome Marchand <jmarchan@redhat.com>
      Cc: Joerg Roedel <joro@8bytes.org>
      Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
      Cc: Konstantin Khlebnikov <koct9i@gmail.com>
      Cc: Laurent Dufour <ldufour@linux.vnet.ibm.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Cc: Matthew Wilcox <willy@linux.intel.com>
      Cc: Mel Gorman <mgorman@suse.de>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Michal Hocko <mhocko@suse.com>
      Cc: Mikulas Patocka <mpatocka@redhat.com>
      Cc: Minchan Kim <minchan@kernel.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Rik van Riel <riel@redhat.com>
      Cc: Sasha Levin <sasha.levin@oracle.com>
      Cc: Shachar Raindel <raindel@mellanox.com>
      Cc: Vlastimil Babka <vbabka@suse.cz>
      Cc: Xie XiuQi <xiexiuqi@huawei.com>
      Cc: iommu@lists.linux-foundation.org
      Cc: linux-arch@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      Cc: linux-mm@kvack.org
      Cc: linux-s390@vger.kernel.org
      Cc: linuxppc-dev@lists.ozlabs.org
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      1b2ee126
  7. 18 2月, 2016 6 次提交
    • W
      iommu/arm-smmu: Treat IOMMU_DOMAIN_DMA as bypass for now · cbf8277e
      Will Deacon 提交于
      Until all upstream devices have their DMA ops swizzled to point at the
      SMMU, we need to treat the IOMMU_DOMAIN_DMA domain as bypass to avoid
      putting devices into an empty address space when detaching from VFIO.
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      cbf8277e
    • W
      iommu/arm-smmu: Don't fail device attach if already attached to a domain · bc7f2ce0
      Will Deacon 提交于
      The ARM SMMU attach_dev implementations returns -EEXIST if the device
      being attached is already attached to a domain. This doesn't play nicely
      with the default domain, resulting in splats such as:
      
        WARNING: at drivers/iommu/iommu.c:1257
        Modules linked in:
      
        CPU: 3 PID: 1939 Comm: virtio-net-tx Tainted: G S              4.5.0-rc4+ #1
        Hardware name: FVP Base (DT)
        task: ffffffc87a9d0000 ti: ffffffc07a278000 task.ti: ffffffc07a278000
        PC is at __iommu_detach_group+0x68/0xe8
        LR is at __iommu_detach_group+0x48/0xe8
      
      This patch fixes the problem by forcefully detaching the device from
      its old domain, if present, when attaching to a new one. The unused
      ->detach_dev callback is also removed the iommu_ops structures.
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      bc7f2ce0
    • R
      iommu/arm-smmu: Allow disabling unmatched stream bypass · 25a1c96c
      Robin Murphy 提交于
      Borrow the disable_bypass parameter from the SMMUv3 driver as a handy
      debugging/security feature so that unmatched stream IDs (i.e. devices
      not attached to an IOMMU domain) may be configured to fault.
      
      Rather than introduce unsightly inconsistency, or repeat the existing
      unnecessary use of module_param_named(), fix that as well in passing.
      Signed-off-by: NRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      25a1c96c
    • A
      of: iommu: Increment DT node refcount in of_iommu_set_ops() · 45bb966d
      Anup Patel 提交于
      We are saving pointer to iommu DT node in of_iommu_set_ops()
      hence we should increment DT node ref count.
      Reviewed-by: NRay Jui <rjui@broadcom.com>
      Reviewed-by: NScott Branden <sbranden@broadcom.com>
      Reviewed-by: NRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: NAnup Patel <anup.patel@broadcom.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      45bb966d
    • R
      iommu/arm-smmu: Support DMA-API domains · 9adb9594
      Robin Murphy 提交于
      With DMA mapping ops provided by the iommu-dma code, only a minimal
      contribution from the IOMMU driver is needed to create a suitable
      DMA-API domain for them to use. Implement this for the ARM SMMUs.
      Signed-off-by: NRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      9adb9594
    • R
      iommu/arm-smmu: Treat all device transactions as unprivileged · d346180e
      Robin Murphy 提交于
      The IOMMU API has no concept of privilege so assumes all devices and
      mappings are equal, and indeed most non-CPU master devices on an AMBA
      interconnect make little use of the attribute bits on the bus thus by
      default perform unprivileged data accesses.
      
      Some devices, however, believe themselves more equal than others, such
      as programmable DMA controllers whose 'master' thread issues bus
      transactions marked as privileged instruction fetches, while the data
      accesses of its channel threads (under the control of Linux, at least)
      are marked as unprivileged. This poses a problem for implementing the
      DMA API on an IOMMU conforming to ARM VMSAv8, under which a page that is
      unprivileged-writeable is also implicitly privileged-execute-never.
      Given that, there is no one set of attributes with which iommu_map() can
      implement, say, dma_alloc_coherent() that will allow every possible type
      of access without something running into unexecepted permission faults.
      
      Fortunately the SMMU architecture provides a means to mitigate such
      issues by overriding the incoming attributes of a transaction; make use
      of that to strip the privileged/unprivileged status off incoming
      transactions, leaving just the instruction/data dichotomy which the
      IOMMU API does at least understand; Four states good, two states better.
      Signed-off-by: NRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      d346180e
  8. 17 2月, 2016 4 次提交