13 Jan, 2019

1 commit

  • commit c92a54cfa0257e8ffd66b2a17d49e9c0bd4b769f upstream.

    The dma_direct_supported() function intends to check the DMA mask against
    specific values. However, the phys_to_dma() function includes the SME
    encryption mask, which defeats the intended purpose of the check. This
    results in drivers that support less than 48-bit DMA (SME encryption mask
    is bit 47) from being able to set the DMA mask successfully when SME is
    active, which results in the driver failing to initialize.

    Change the function used to check the mask from phys_to_dma() to
    __phys_to_dma() so that the SME encryption mask is not part of the check.

    Fixes: c1d0af1a1d5d ("kernel/dma/direct: take DMA offset into account in dma_direct_supported")
    Signed-off-by: Tom Lendacky
    Signed-off-by: Christoph Hellwig
    Signed-off-by: Greg Kroah-Hartman

    Lendacky, Thomas
     

14 Nov, 2018

1 commit

  • commit a3ceed87b07769fb80ce9dc6b604e515dba14c4b upstream.

    early_cma does not check input argument before passing it to
    simple_strtoull. The argument would be a NULL pointer if "cma", without
    its value, is set in command line and thus causes the following panic.

    PANIC: early exception 0xe3 IP 10:ffffffffa3e9db8d error 0 cr2 0x0
    [ 0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 4.19.0-rc3-yocto-standard+ #7
    [ 0.000000] RIP: 0010:_parse_integer_fixup_radix+0xd/0x70
    ...
    [ 0.000000] Call Trace:
    [ 0.000000] simple_strtoull+0x29/0x70
    [ 0.000000] memparse+0x26/0x90
    [ 0.000000] early_cma+0x17/0x6a
    [ 0.000000] do_early_param+0x57/0x8e
    [ 0.000000] parse_args+0x208/0x320
    [ 0.000000] ? rdinit_setup+0x30/0x30
    [ 0.000000] parse_early_options+0x29/0x2d
    [ 0.000000] ? rdinit_setup+0x30/0x30
    [ 0.000000] parse_early_param+0x36/0x4d
    [ 0.000000] setup_arch+0x336/0x99e
    [ 0.000000] start_kernel+0x6f/0x4e6
    [ 0.000000] x86_64_start_reservations+0x24/0x26
    [ 0.000000] x86_64_start_kernel+0x6f/0x72
    [ 0.000000] secondary_startup_64+0xa4/0xb0

    This patch adds a check to prevent the panic.

    Signed-off-by: He Zhe
    Reviewed-by: Marek Szyprowski
    Cc: stable@vger.kernel.org
    Signed-off-by: Christoph Hellwig
    Signed-off-by: Greg Kroah-Hartman

    He Zhe
     

26 Sep, 2018

1 commit


01 Sep, 2018

1 commit


18 Aug, 2018

2 commits

  • The CMA memory allocator doesn't support standard gfp flags for memory
    allocation, so there is no point having it as a parameter for
    dma_alloc_from_contiguous() function. Replace it by a boolean no_warn
    argument, which covers all the underlaying cma_alloc() function
    supports.

    This will help to avoid giving false feeling that this function supports
    standard gfp flags and callers can pass __GFP_ZERO to get zeroed buffer,
    what has already been an issue: see commit dd65a941f6ba ("arm64:
    dma-mapping: clear buffers allocated with FORCE_CONTIGUOUS flag").

    Link: http://lkml.kernel.org/r/20180709122020eucas1p21a71b092975cb4a3b9954ffc63f699d1~-sqUFoa-h2939329393eucas1p2Y@eucas1p2.samsung.com
    Signed-off-by: Marek Szyprowski
    Acked-by: Michał Nazarewicz
    Acked-by: Vlastimil Babka
    Reviewed-by: Christoph Hellwig
    Cc: Laura Abbott
    Cc: Michal Hocko
    Cc: Joonsoo Kim
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Marek Szyprowski
     
  • cma_alloc() doesn't really support gfp flags other than __GFP_NOWARN, so
    convert gfp_mask parameter to boolean no_warn parameter.

    This will help to avoid giving false feeling that this function supports
    standard gfp flags and callers can pass __GFP_ZERO to get zeroed buffer,
    what has already been an issue: see commit dd65a941f6ba ("arm64:
    dma-mapping: clear buffers allocated with FORCE_CONTIGUOUS flag").

    Link: http://lkml.kernel.org/r/20180709122019eucas1p2340da484acfcc932537e6014f4fd2c29~-sqTPJKij2939229392eucas1p2j@eucas1p2.samsung.com
    Signed-off-by: Marek Szyprowski
    Acked-by: Michal Hocko
    Acked-by: Michał Nazarewicz
    Acked-by: Laura Abbott
    Acked-by: Vlastimil Babka
    Reviewed-by: Christoph Hellwig
    Cc: Joonsoo Kim
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Marek Szyprowski
     

15 Aug, 2018

1 commit

  • Pull dma-mapping updates from Christoph Hellwig:

    - a series from Robin to fix bus imposed dma limits by adding a
    separate mask for them to struct device instead of trying to squeeze
    a second meaning out of the existing dma mask as we did before.

    This has ACKs from the various other subsystems touched

    - a small swiotlb cleanup from Kees (acked by Konrad)

    - conversion of nios2 and sh to the new generic dma-noncoherent code.

    Various other architecture conversions will come through the
    architectures maintainers trees.

    * tag 'dma-mapping-4.19' of git://git.infradead.org/users/hch/dma-mapping:
    sh: use generic dma_noncoherent_ops
    sh: split arch/sh/mm/consistent.c
    sh: use dma_direct_ops for the CONFIG_DMA_COHERENT case
    sh: introduce a sh_cacheop_vaddr helper
    sh: simplify get_arch_dma_ops
    OF: Don't set default coherent DMA mask
    ACPI/IORT: Don't set default coherent DMA mask
    iommu/dma: Respect bus DMA limit for IOVAs
    of/device: Set bus DMA mask as appropriate
    ACPI/IORT: Set bus DMA mask as appropriate
    dma-mapping: Generalise dma_32bit_limit flag
    ACPI/IORT: Support address size limit for root complexes
    of/platform: Initialise default DMA masks
    nios2: use generic dma_noncoherent_ops
    swiotlb: clean up reporting
    dma-mapping: relax warning for per-device areas

    Linus Torvalds
     

14 Aug, 2018

1 commit

  • Pull MIPS updates from Paul Burton:
    "Here are the main MIPS changes for 4.19.

    An overview of the general architecture changes:

    - Massive DMA ops refactoring from Christoph Hellwig (huzzah for
    deleting crufty code!).

    - We introduce NT_MIPS_DSP & NT_MIPS_FP_MODE ELF notes &
    corresponding regsets to expose DSP ASE & floating point mode state
    respectively, both for live debugging & core dumps.

    - We better optimize our code by hard-coding cpu_has_* macros at
    compile time where their values are known due to the ISA revision
    that the kernel build is targeting.

    - The EJTAG exception handler now better handles SMP systems, where
    it was previously possible for CPUs to clobber a register value
    saved by another CPU.

    - Our implementation of memset() gained a couple of fixes for MIPSr6
    systems to return correct values in some cases where stores fault.

    - We now implement ioremap_wc() using the uncached-accelerated cache
    coherency attribute where supported, which is detected during boot,
    and fall back to plain uncached access where necessary. The
    MIPS-specific (and unused in tree) ioremap_uncached_accelerated() &
    ioremap_cacheable_cow() are removed.

    - The prctl(PR_SET_FP_MODE, ...) syscall is better supported for SMP
    systems by reworking the way we ensure remote CPUs that may be
    running threads within the affected process switch mode.

    - Systems using the MIPS Coherence Manager will now set the
    MIPS_IC_SNOOPS_REMOTE flag to avoid some unnecessary cache
    maintenance overhead when flushing the icache.

    - A few fixes were made for building with clang/LLVM, which now
    sucessfully builds kernels for many of our platforms.

    - Miscellaneous cleanups all over.

    And some platform-specific changes:

    - ar7 gained stubs for a few clock API functions to fix build
    failures for some drivers.

    - ath79 gained support for a few new SoCs, a few fixes & better
    gpio-keys support.

    - Ci20 now exposes its SPI bus using the spi-gpio driver.

    - The generic platform can now auto-detect a suitable value for
    PHYS_OFFSET based upon the memory map described by the device tree,
    allowing us to avoid wasting memory on page book-keeping for
    systems where RAM starts at a non-zero physical address.

    - Ingenic systems using the jz4740 platform code now link their
    vmlinuz higher to allow for kernels of a realistic size.

    - Loongson32 now builds the kernel targeting MIPSr1 rather than
    MIPSr2 to avoid CPU errata.

    - Loongson64 gains a couple of fixes, a workaround for a write
    buffering issue & support for the Loongson 3A R3.1 CPU.

    - Malta now uses the piix4-poweroff driver to handle powering down.

    - Microsemi Ocelot gained support for its SPI bus & NOR flash, its
    second MDIO bus and can now be supported by a FIT/.itb image.

    - Octeon saw a bunch of header cleanups which remove a lot of
    duplicate or unused code"

    * tag 'mips_4.19' of git://git.kernel.org/pub/scm/linux/kernel/git/mips/linux: (123 commits)
    MIPS: Remove remnants of UASM_ISA
    MIPS: netlogic: xlr: Remove erroneous check in nlm_fmn_send()
    MIPS: VDSO: Force link endianness
    MIPS: Always specify -EB or -EL when using clang
    MIPS: Use dins to simplify __write_64bit_c0_split()
    MIPS: Use read-write output operand in __write_64bit_c0_split()
    MIPS: Avoid using array as parameter to write_c0_kpgd()
    MIPS: vdso: Allow clang's --target flag in VDSO cflags
    MIPS: genvdso: Remove GOT checks
    MIPS: Remove obsolete MIPS checks for DST node "chosen@0"
    MIPS: generic: Remove input symbols from defconfig
    MIPS: Delete unused code in linux32.c
    MIPS: Remove unused sys_32_mmap2
    MIPS: Remove nabi_no_regargs
    mips: dts: mscc: enable spi and NOR flash support on ocelot PCB123
    mips: dts: mscc: Add spi on Ocelot
    MIPS: Loongson: Merge load addresses
    MIPS: Loongson: Set Loongson32 to MIPS32R1
    MIPS: mscc: ocelot: add interrupt controller properties to GPIO controller
    MIPS: generic: Select MIPS_AUTO_PFN_OFFSET
    ...

    Linus Torvalds
     

28 Jul, 2018

1 commit

  • Whilst the notion of an upstream DMA restriction is most commonly seen
    in PCI host bridges saddled with a 32-bit native interface, a more
    general version of the same issue can exist on complex SoCs where a bus
    or point-to-point interconnect link from a device's DMA master interface
    to another component along the path to memory (often an IOMMU) may carry
    fewer address bits than the interfaces at both ends nominally support.
    In order to properly deal with this, the first step is to expand the
    dma_32bit_limit flag into an arbitrary mask.

    To minimise the impact on existing code, we'll make sure to only
    consider this new mask valid if set. That makes sense anyway, since a
    mask of zero would represent DMA not being wired up at all, and that
    would be better handled by not providing valid ops in the first place.

    Signed-off-by: Robin Murphy
    Acked-by: Ard Biesheuvel
    Signed-off-by: Christoph Hellwig

    Robin Murphy
     

25 Jul, 2018

1 commit

  • This removes needless use of '%p', and refactors the printk calls to
    use pr_*() helpers instead.

    Signed-off-by: Kees Cook
    Reviewed-by: Konrad Rzeszutek Wilk
    Signed-off-by: Christoph Hellwig

    Kees Cook
     

28 Jun, 2018

1 commit

  • For architectures that do not use per-device dma ops we need to export
    the dma_map_ops structure returned from get_arch_dma_ops().

    Fixes: 10314e09 ("riscv: add swiotlb support")
    Signed-off-by: Christoph Hellwig
    Reported-by: Andreas Schwab

    Christoph Hellwig
     

25 Jun, 2018

1 commit

  • The MIPS bmips platform needs a global flush when transferring ownership
    back to the CPU. Add a hook for that to the dma-noncoherent
    implementation.

    Signed-off-by: Christoph Hellwig
    Patchwork: https://patchwork.linux-mips.org/patch/19549/
    Signed-off-by: Paul Burton
    Cc: Florian Fainelli
    Cc: David Daney
    Cc: Kevin Cernekee
    Cc: Jiaxun Yang
    Cc: Tom Bogendoerfer
    Cc: Huacai Chen
    Cc: iommu@lists.linux-foundation.org
    Cc: linux-mips@linux-mips.org

    Christoph Hellwig
     

14 Jun, 2018

1 commit

  • Currently the code is split over various files with dma- prefixes in the
    lib/ and drives/base directories, and the number of files keeps growing.
    Move them into a single directory to keep the code together and remove
    the file name prefixes. To match the irq infrastructure this directory
    is placed under the kernel/ directory.

    Signed-off-by: Christoph Hellwig

    Christoph Hellwig