10 Jan, 2019

4 commits

  • commit 66a4059ba72c23ae74a7c702894ff76c4b7eac1f upstream.

    MIPS' asm/mmzone.h includes the machine/platform mmzone.h
    unconditionally, but since commit bb53fdf395ee ("MIPS: c-r4k: Add
    r4k_blast_scache_node for Loongson-3") is included by asm/rk4cache.h for
    all r4k-style configs regardless of CONFIG_NEED_MULTIPLE_NODES.

    This is problematic when CONFIG_NEED_MULTIPLE_NODES=n because both the
    loongson3 & ip27 mmzone.h headers unconditionally define the NODE_DATA
    preprocessor macro which is aready defined by linux/mmzone.h, resulting
    in the following build error:

    In file included from ./arch/mips/include/asm/mmzone.h:10,
    from ./arch/mips/include/asm/r4kcache.h:23,
    from arch/mips/mm/c-r4k.c:33:
    ./arch/mips/include/asm/mach-loongson64/mmzone.h:48: error: "NODE_DATA" redefined [-Werror]
    #define NODE_DATA(n) (&__node_data[(n)]->pglist)

    In file included from ./include/linux/topology.h:32,
    from ./include/linux/irq.h:19,
    from ./include/asm-generic/hardirq.h:13,
    from ./arch/mips/include/asm/hardirq.h:16,
    from ./include/linux/hardirq.h:9,
    from arch/mips/mm/c-r4k.c:11:
    ./include/linux/mmzone.h:907: note: this is the location of the previous definition
    #define NODE_DATA(nid) (&contig_page_data)

    Resolve this by only including the machine mmzone.h when
    CONFIG_NEED_MULTIPLE_NODES=y, which also removes the need for the empty
    mach-generic version of the header which we delete.

    Signed-off-by: Paul Burton
    Fixes: bb53fdf395ee ("MIPS: c-r4k: Add r4k_blast_scache_node for Loongson-3")
    Signed-off-by: Greg Kroah-Hartman

    Paul Burton
     
  • commit ff4dd232ec45a0e45ea69f28f069f2ab22b4908a upstream.

    ASIDs have always been stored as unsigned longs, ie. 32 bits on MIPS32
    kernels. This is problematic because it is feasible for the ASID version
    to overflow & wrap around to zero.

    We currently attempt to handle this overflow by simply setting the ASID
    version to 1, using asid_first_version(), but we make no attempt to
    account for the fact that there may be mm_structs with stale ASIDs that
    have versions which we now reuse due to the overflow & wrap around.

    Encountering this requires that:

    1) A struct mm_struct X is active on CPU A using ASID (V,n).

    2) That mm is not used on CPU A for the length of time that it takes
    for CPU A's asid_cache to overflow & wrap around to the same
    version V that the mm had in step 1. During this time tasks using
    the mm could either be sleeping or only scheduled on other CPUs.

    3) Some other mm Y becomes active on CPU A and is allocated the same
    ASID (V,n).

    4) mm X now becomes active on CPU A again, and now incorrectly has the
    same ASID as mm Y.

    Where struct mm_struct ASIDs are represented above in the format
    (version, EntryHi.ASID), and on a typical MIPS32 system version will be
    24 bits wide & EntryHi.ASID will be 8 bits wide.

    The length of time required in step 2 is highly dependent upon the CPU &
    workload, but for a hypothetical 2GHz CPU running a workload which
    generates a new ASID every 10000 cycles this period is around 248 days.
    Due to this long period of time & the fact that tasks need to be
    scheduled in just the right (or wrong, depending upon your inclination)
    way, this is obviously a difficult bug to encounter but it's entirely
    possible as evidenced by reports.

    In order to fix this, simply extend ASIDs to 64 bits even on MIPS32
    builds. This will extend the period of time required for the
    hypothetical system above to encounter the problem from 28 days to
    around 3 trillion years, which feels safely outside of the realms of
    possibility.

    The cost of this is slightly more generated code in some commonly
    executed paths, but this is pretty minimal:

    | Code Size Gain | Percentage
    -----------------------|----------------|-------------
    decstation_defconfig | +270 | +0.00%
    32r2el_defconfig | +652 | +0.01%
    32r6el_defconfig | +1000 | +0.01%

    I have been unable to measure any change in performance of the LMbench
    lat_ctx or lat_proc tests resulting from the 64b ASIDs on either
    32r2el_defconfig+interAptiv or 32r6el_defconfig+I6500 systems.

    Signed-off-by: Paul Burton
    Suggested-by: James Hogan
    References: https://lore.kernel.org/linux-mips/80B78A8B8FEE6145A87579E8435D78C30205D5F3@fzex.ruijie.com.cn/
    References: https://lore.kernel.org/linux-mips/1488684260-18867-1-git-send-email-jiwei.sun@windriver.com/
    Cc: Jiwei Sun
    Cc: Yu Huabing
    Cc: stable@vger.kernel.org # 2.6.12+
    Cc: linux-mips@vger.kernel.org
    Signed-off-by: Greg Kroah-Hartman

    Paul Burton
     
  • commit 92aa0718c9fa5160ad2f0e7b5bffb52f1ea1e51a upstream.

    This patch is borrowed from ARM64 to ensure pmd_present() returns false
    after pmd_mknotpresent(). This is needed for THP.

    References: 5bb1cc0ff9a6 ("arm64: Ensure pmd_present() returns false after pmd_mknotpresent()")
    Reviewed-by: James Hogan
    Signed-off-by: Huacai Chen
    Signed-off-by: Paul Burton
    Patchwork: https://patchwork.linux-mips.org/patch/21135/
    Cc: Ralf Baechle
    Cc: James Hogan
    Cc: Steven J . Hill
    Cc: linux-mips@linux-mips.org
    Cc: Fuxin Zhang
    Cc: Zhangjin Wu
    Cc: # 3.8+
    Signed-off-by: Greg Kroah-Hartman

    Huacai Chen
     
  • commit bb53fdf395eed103f85061bfff3b116cee123895 upstream.

    For multi-node Loongson-3 (NUMA configuration), r4k_blast_scache() can
    only flush Node-0's scache. So we add r4k_blast_scache_node() by using
    (CAC_BASE | (node_id << NODE_ADDRSPACE_SHIFT)) instead of CKSEG0 as the
    start address.

    Signed-off-by: Huacai Chen
    [paul.burton@mips.com: Include asm/mmzone.h from asm/r4kcache.h for
    nid_to_addrbase(). Add asm/mach-generic/mmzone.h
    to allow inclusion for all platforms.]
    Signed-off-by: Paul Burton
    Patchwork: https://patchwork.linux-mips.org/patch/21129/
    Cc: Ralf Baechle
    Cc: James Hogan
    Cc: Steven J . Hill
    Cc: linux-mips@linux-mips.org
    Cc: Fuxin Zhang
    Cc: Zhangjin Wu
    Cc: # 3.15+
    Signed-off-by: Greg Kroah-Hartman

    Huacai Chen
     

08 Dec, 2018

1 commit

  • commit c50cbd85cd7027d32ac5945bb60217936b4f7eaf upstream.

    When checking for TIF_32BIT_REGS flag, mips_get_syscall_arg() should
    use the task specified as its argument instead of the current task.

    This potentially affects all syscall_get_arguments() users
    who specify tasks different from the current.

    Fixes: c0ff3c53d4f99 ("MIPS: Enable HAVE_ARCH_TRACEHOOK.")
    Signed-off-by: Dmitry V. Levin
    Signed-off-by: Paul Burton
    Patchwork: https://patchwork.linux-mips.org/patch/21185/
    Cc: Elvira Khabirova
    Cc: Ralf Baechle
    Cc: James Hogan
    Cc: linux-mips@linux-mips.org
    Cc: linux-kernel@vger.kernel.org
    Cc: stable@vger.kernel.org # v3.13+
    Signed-off-by: Greg Kroah-Hartman

    Dmitry V. Levin
     

21 Nov, 2018

1 commit

  • [ Upstream commit 360fe725f8849aaddc53475fef5d4a0c439b05ae ]

    After commit e509bd7da149dc349160 ("genirq: Allow migration of chained
    interrupts by installing default action") Loongson-3 fails at here:

    setup_irq(LOONGSON_HT1_IRQ, &cascade_irqaction);

    This is because both chained_action and cascade_irqaction don't have
    IRQF_SHARED flag. This will cause Loongson-3 resume fails because HPET
    timer interrupt can't be delivered during S3. So we set the irqchip of
    the chained irq to loongson_irq_chip which doesn't disable the chained
    irq in CP0.Status.

    Cc: stable@vger.kernel.org
    Signed-off-by: Huacai Chen
    Signed-off-by: Paul Burton
    Patchwork: https://patchwork.linux-mips.org/patch/20434/
    Cc: Ralf Baechle
    Cc: James Hogan
    Cc: linux-mips@linux-mips.org
    Cc: Fuxin Zhang
    Cc: Zhangjin Wu
    Cc: Huacai Chen
    Signed-off-by: Sasha Levin

    Huacai Chen
     

04 Nov, 2018

1 commit

  • [ Upstream commit 906d441febc0de974b2a6ef848a8f058f3bfada3 ]

    Some versions of GCC for the MIPS architecture suffer from a bug which
    can lead to instructions from beyond an unreachable statement being
    incorrectly reordered into earlier branch delay slots if the unreachable
    statement is the only content of a case in a switch statement. This can
    lead to seemingly random behaviour, such as invalid memory accesses from
    incorrectly reordered loads or stores, and link failures on microMIPS
    builds.

    See this potential GCC fix for details:

    https://gcc.gnu.org/ml/gcc-patches/2015-09/msg00360.html

    Runtime problems resulting from this bug were initially observed using a
    maltasmvp_defconfig v4.4 kernel built using GCC 4.9.2 (from a Codescape
    SDK 2015.06-05 toolchain), with the result being an address exception
    taken after log messages about the L1 caches (during probe of the L2
    cache):

    Initmem setup node 0 [mem 0x0000000080000000-0x000000009fffffff]
    VPE topology {2,2} total 4
    Primary instruction cache 64kB, VIPT, 4-way, linesize 32 bytes.
    Primary data cache 64kB, 4-way, PIPT, no aliases, linesize 32 bytes

    This is early enough that the kernel exception vectors are not in use,
    so any further output depends upon the bootloader. This is reproducible
    in QEMU where no further output occurs - ie. the system hangs here.
    Given the nature of the bug it may potentially be hit with differing
    symptoms. The bug is known to affect GCC versions as recent as 7.3, and
    it is unclear whether GCC 8 fixed it or just happens not to encounter
    the bug in the testcase found at the link above due to differing
    optimizations.

    This bug can be worked around by placing a volatile asm statement, which
    GCC is prevented from reordering past, prior to the
    __builtin_unreachable call.

    That was actually done already for other reasons by commit 173a3efd3edb
    ("bug.h: work around GCC PR82365 in BUG()"), but creates problems for
    microMIPS builds due to the lack of a .insn directive. The microMIPS ISA
    allows for interlinking with regular MIPS32 code by repurposing bit 0 of
    the program counter as an ISA mode bit. To switch modes one changes the
    value of this bit in the PC. However typical branch instructions encode
    their offsets as multiples of 2-byte instruction halfwords, which means
    they cannot change ISA mode - this must be done using either an indirect
    branch (a jump-register in MIPS terminology) or a dedicated jalx
    instruction. In order to ensure that regular branches don't attempt to
    target code in a different ISA which they can't actually switch to, the
    linker will check that branch targets are code in the same ISA as the
    branch.

    Unfortunately our empty asm volatile statements don't qualify as code,
    and the link for microMIPS builds fails with errors such as:

    arch/mips/mm/dma-default.s:3265: Error: branch to a symbol in another ISA mode
    arch/mips/mm/dma-default.s:5027: Error: branch to a symbol in another ISA mode

    Resolve this by adding a .insn directive within the asm statement which
    declares that what comes next is code. This may or may not be true,
    since we don't really know what comes next, but as this code is in an
    unreachable path anyway that doesn't matter since we won't execute it.

    We do this in asm/compiler.h & select CONFIG_HAVE_ARCH_COMPILER_H in
    order to have this included by linux/compiler_types.h after
    linux/compiler-gcc.h. This will result in asm/compiler.h being included
    in all C compilations via the -include linux/compiler_types.h argument
    in c_flags, which should be harmless.

    Signed-off-by: Paul Burton
    Fixes: 173a3efd3edb ("bug.h: work around GCC PR82365 in BUG()")
    Patchwork: https://patchwork.linux-mips.org/patch/20270/
    Cc: James Hogan
    Cc: Ralf Baechle
    Cc: Arnd Bergmann
    Cc: linux-mips@linux-mips.org
    Signed-off-by: Sasha Levin

    Paul Burton
     

18 Oct, 2018

1 commit

  • commit ea7e0480a4b695d0aa6b3fa99bd658a003122113 upstream.

    When using the legacy mmap layout, for example triggered using ulimit -s
    unlimited, get_unmapped_area() fills memory from bottom to top starting
    from a fairly low address near TASK_UNMAPPED_BASE.

    This placement is suboptimal if the user application wishes to allocate
    large amounts of heap memory using the brk syscall. With the VDSO being
    located low in the user's virtual address space, the amount of space
    available for access using brk is limited much more than it was prior to
    the introduction of the VDSO.

    For example:

    # ulimit -s unlimited; cat /proc/self/maps
    00400000-004ec000 r-xp 00000000 08:00 71436 /usr/bin/coreutils
    004fc000-004fd000 rwxp 000ec000 08:00 71436 /usr/bin/coreutils
    004fd000-0050f000 rwxp 00000000 00:00 0
    00cc3000-00ce4000 rwxp 00000000 00:00 0 [heap]
    2ab96000-2ab98000 r--p 00000000 00:00 0 [vvar]
    2ab98000-2ab99000 r-xp 00000000 00:00 0 [vdso]
    2ab99000-2ab9d000 rwxp 00000000 00:00 0
    ...

    Resolve this by adjusting STACK_TOP to reserve space for the VDSO &
    providing an address hint to get_unmapped_area() causing it to use this
    space even when using the legacy mmap layout.

    We reserve enough space for the VDSO, plus 1MB or 256MB for 32 bit & 64
    bit systems respectively within which we randomize the VDSO base
    address. Previously this randomization was taken care of by the mmap
    base address randomization performed by arch_mmap_rnd(). The 1MB & 256MB
    sizes are somewhat arbitrary but chosen such that we have some
    randomization without taking up too much of the user's virtual address
    space, which is often in short supply for 32 bit systems.

    With this the VDSO is always mapped at a high address, leaving lots of
    space for statically linked programs to make use of brk:

    # ulimit -s unlimited; cat /proc/self/maps
    00400000-004ec000 r-xp 00000000 08:00 71436 /usr/bin/coreutils
    004fc000-004fd000 rwxp 000ec000 08:00 71436 /usr/bin/coreutils
    004fd000-0050f000 rwxp 00000000 00:00 0
    00c28000-00c49000 rwxp 00000000 00:00 0 [heap]
    ...
    7f67c000-7f69d000 rwxp 00000000 00:00 0 [stack]
    7f7fc000-7f7fd000 rwxp 00000000 00:00 0
    7fcf1000-7fcf3000 r--p 00000000 00:00 0 [vvar]
    7fcf3000-7fcf4000 r-xp 00000000 00:00 0 [vdso]

    Signed-off-by: Paul Burton
    Reported-by: Huacai Chen
    Fixes: ebb5e78cc634 ("MIPS: Initial implementation of a VDSO")
    Cc: Huacai Chen
    Cc: linux-mips@linux-mips.org
    Cc: stable@vger.kernel.org # v4.4+
    Signed-off-by: Greg Kroah-Hartman

    Paul Burton
     

26 Sep, 2018

1 commit

  • [ Upstream commit f8a7bfe1cb2c1ebfa07775c9c8ac0ad3ba8e5ff5 ]

    This patch disables irq on reboot to fix hang issues that were observed
    due to pending interrupts.

    Signed-off-by: Felix Fietkau
    Signed-off-by: John Crispin
    Signed-off-by: Paul Burton
    Patchwork: https://patchwork.linux-mips.org/patch/19913/
    Cc: James Hogan
    Cc: Ralf Baechle
    Cc: linux-mips@linux-mips.org
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Felix Fietkau
     

20 Sep, 2018

1 commit

  • [ Upstream commit 0494d7ffdcebc6935410ea0719b24ab626675351 ]

    isa_virt_to_bus() & isa_bus_to_virt() claim to treat ISA bus addresses
    as being identical to physical addresses, but they fail to do so in the
    presence of a non-zero PHYS_OFFSET.

    Correct this by having them use virt_to_phys() & phys_to_virt(), which
    consolidates the calculations to one place & ensures that ISA bus
    addresses do indeed match physical addresses.

    Signed-off-by: Paul Burton
    Patchwork: https://patchwork.linux-mips.org/patch/20047/
    Cc: James Hogan
    Cc: Ralf Baechle
    Cc: linux-mips@linux-mips.org
    Cc: Vladimir Kondratiev
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Paul Burton
     

05 Sep, 2018

3 commits

  • commit a30718868915fbb991a9ae9e45594b059f28e9ae upstream.

    Linux expects that if a CPU modifies a memory location, then that
    modification will eventually become visible to other CPUs in the system.

    Loongson 3 CPUs include a Store Fill Buffer (SFB) which sits between a
    core & its L1 data cache, queueing memory accesses & allowing for faster
    forwarding of data from pending stores to younger loads from the core.
    Unfortunately the SFB prioritizes loads such that a continuous stream of
    loads may cause a pending write to be buffered indefinitely. This is
    problematic if we end up with 2 CPUs which each perform a store that the
    other polls for - one or both CPUs may end up with their stores buffered
    in the SFB, never reaching cache due to the continuous reads from the
    poll loop. Such a deadlock condition has been observed whilst running
    qspinlock code.

    This patch changes the definition of cpu_relax() to smp_mb() for
    Loongson-3, forcing a flush of the SFB on SMP systems which will cause
    any pending writes to make it as far as the L1 caches where they will
    become visible to other CPUs. If the kernel is not compiled for SMP
    support, this will expand to a barrier() as before.

    This workaround matches that currently implemented for ARM when
    CONFIG_ARM_ERRATA_754327=y, which was introduced by commit 534be1d5a2da
    ("ARM: 6194/1: change definition of cpu_relax() for ARM11MPCore").

    Although the workaround is only required when the Loongson 3 SFB
    functionality is enabled, and we only began explicitly enabling that
    functionality in v4.7 with commit 1e820da3c9af ("MIPS: Loongson-3:
    Introduce CONFIG_LOONGSON3_ENHANCEMENT"), existing or future firmware
    may enable the SFB which means we may need the workaround backported to
    earlier kernels too.

    [paul.burton@mips.com:
    - Reword commit message & comment.
    - Limit stable backport to v3.15+ where we support Loongson 3 CPUs.]

    Signed-off-by: Huacai Chen
    Signed-off-by: Paul Burton
    References: 534be1d5a2da ("ARM: 6194/1: change definition of cpu_relax() for ARM11MPCore")
    References: 1e820da3c9af ("MIPS: Loongson-3: Introduce CONFIG_LOONGSON3_ENHANCEMENT")
    Patchwork: https://patchwork.linux-mips.org/patch/19830/
    Cc: Ralf Baechle
    Cc: James Hogan
    Cc: linux-mips@linux-mips.org
    Cc: Fuxin Zhang
    Cc: Zhangjin Wu
    Cc: Huacai Chen
    Cc: stable@vger.kernel.org # v3.15+
    Signed-off-by: Greg Kroah-Hartman

    Huacai Chen
     
  • commit f5958b4cf4fc38ed4583ab83fb7c4cd1ab05f47b upstream.

    Use the `unsigned long' rather than `__u32' type for DSP accumulator
    registers, like with the regular MIPS multiply/divide accumulator and
    general-purpose registers, as all are 64-bit in 64-bit implementations
    and using a 32-bit data type leads to contents truncation on context
    saving.

    Update `arch_ptrace' and `compat_arch_ptrace' accordingly, removing
    casts that are similarly not used with multiply/divide accumulator or
    general-purpose register accesses.

    Signed-off-by: Maciej W. Rozycki
    Signed-off-by: Paul Burton
    Fixes: e50c0a8fa60d ("Support the MIPS32 / MIPS64 DSP ASE.")
    Patchwork: https://patchwork.linux-mips.org/patch/19329/
    Cc: Alexander Viro
    Cc: James Hogan
    Cc: Ralf Baechle
    Cc: linux-fsdevel@vger.kernel.org
    Cc: linux-mips@linux-mips.org
    Cc: linux-kernel@vger.kernel.org
    Cc: stable@vger.kernel.org # 2.6.15+
    Signed-off-by: Greg Kroah-Hartman

    Maciej W. Rozycki
     
  • [ Upstream commit d5ea019f8a381f88545bb26993b62ec24a2796b7 ]

    This reverts commit 2a027b47dba6 ("MIPS: BCM47XX: Enable 74K Core
    ExternalSync for PCIe erratum").

    Enabling ExternalSync caused a regression for BCM4718A1 (used e.g. in
    Netgear E3000 and ASUS RT-N16): it simply hangs during PCIe
    initialization. It's likely that BCM4717A1 is also affected.

    I didn't notice that earlier as the only BCM47XX devices with PCIe I
    own are:
    1) BCM4706 with 2 x 14e4:4331
    2) BCM4706 with 14e4:4360 and 14e4:4331
    it appears that BCM4706 is unaffected.

    While BCM5300X-ES300-RDS.pdf seems to document that erratum and its
    workarounds (according to quotes provided by Tokunori) it seems not even
    Broadcom follows them.

    According to the provided info Broadcom should define CONF7_ES in their
    SDK's mipsinc.h and implement workaround in the si_mips_init(). Checking
    both didn't reveal such code. It *could* mean Broadcom also had some
    problems with the given workaround.

    Signed-off-by: Rafał Miłecki
    Signed-off-by: Paul Burton
    Reported-by: Michael Marley
    Patchwork: https://patchwork.linux-mips.org/patch/20032/
    URL: https://bugs.openwrt.org/index.php?do=details&task_id=1688
    Cc: Tokunori Ikegami
    Cc: Hauke Mehrtens
    Cc: Chris Packham
    Cc: James Hogan
    Cc: Ralf Baechle
    Cc: linux-mips@linux-mips.org
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Rafał Miłecki
     

03 Jul, 2018

2 commits

  • commit 18f3e95b90b28318ef35910d21c39908de672331 upstream.

    While a barrier is present in the outX() functions before the register
    write, a similar barrier is missing in the inX() functions after the
    register read. This could allow memory accesses following inX() to
    observe stale data.

    This patch is very similar to commit a1cc7034e33d12dc1 ("MIPS: io: Add
    barrier after register read in readX()"). Because war_io_reorder_wmb()
    is both used by writeX() and outX(), if readX() need a barrier then so
    does inX().

    Cc: stable@vger.kernel.org
    Signed-off-by: Huacai Chen
    Patchwork: https://patchwork.linux-mips.org/patch/19516/
    Signed-off-by: Paul Burton
    Cc: James Hogan
    Cc: linux-mips@linux-mips.org
    Cc: Fuxin Zhang
    Cc: Zhangjin Wu
    Cc: Huacai Chen
    Signed-off-by: Greg Kroah-Hartman

    Huacai Chen
     
  • commit 2a027b47dba6b77ab8c8e47b589ae9bbc5ac6175 upstream.

    The erratum and workaround are described by BCM5300X-ES300-RDS.pdf as
    below.

    R10: PCIe Transactions Periodically Fail

    Description: The BCM5300X PCIe does not maintain transaction ordering.
    This may cause PCIe transaction failure.
    Fix Comment: Add a dummy PCIe configuration read after a PCIe
    configuration write to ensure PCIe configuration access
    ordering. Set ES bit of CP0 configu7 register to enable
    sync function so that the sync instruction is functional.
    Resolution: hndpci.c: extpci_write_config()
    hndmips.c: si_mips_init()
    mipsinc.h CONF7_ES

    This is fixed by the CFE MIPS bcmsi chipset driver also for BCM47XX.
    Also the dummy PCIe configuration read is already implemented in the
    Linux BCMA driver.

    Enable ExternalSync in Config7 when CONFIG_BCMA_DRIVER_PCI_HOSTMODE=y
    too so that the sync instruction is externalised.

    Signed-off-by: Tokunori Ikegami
    Reviewed-by: Paul Burton
    Acked-by: Hauke Mehrtens
    Cc: Chris Packham
    Cc: Rafał Miłecki
    Cc: linux-mips@linux-mips.org
    Cc: stable@vger.kernel.org
    Patchwork: https://patchwork.linux-mips.org/patch/19461/
    Signed-off-by: James Hogan
    Signed-off-by: Greg Kroah-Hartman

    Tokunori Ikegami
     

21 Jun, 2018

2 commits

  • [ Upstream commit a1cc7034e33d12dc17d13fbcd7d597d552889097 ]

    While a barrier is present in the writeX() functions before the register
    write, a similar barrier is missing in the readX() functions after the
    register read. This could allow memory accesses following readX() to
    observe stale data.

    Signed-off-by: Sinan Kaya
    Reported-by: Arnd Bergmann
    Cc: Ralf Baechle
    Cc: Paul Burton
    Cc: linux-mips@linux-mips.org
    Patchwork: https://patchwork.linux-mips.org/patch/19069/
    [jhogan@kernel.org: Tidy commit message]
    Signed-off-by: James Hogan
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Sinan Kaya
     
  • [ Upstream commit f6b7aeee8f167409195fbf1364d02988fecad1d0 ]

    writeX() has strong ordering semantics with respect to memory updates.
    In the absence of a write barrier or a compiler barrier, the compiler
    can reorder register and memory update instructions. This breaks the
    writeX() API.

    Signed-off-by: Sinan Kaya
    Cc: Arnd Bergmann
    Cc: Ralf Baechle
    Cc: Paul Burton
    Cc: linux-mips@linux-mips.org
    Patchwork: https://patchwork.linux-mips.org/patch/18997/
    [jhogan@kernel.org: Tidy commit message]
    Signed-off-by: James Hogan
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Sinan Kaya
     

30 May, 2018

2 commits

  • [ Upstream commit 05454c1bde91fb013c0431801001da82947e6b5a ]

    According to the QCA u-boot source the "PCIE Phase Lock Loop
    Configuration (PCIE_PLL_CONFIG)" register is for all SoCs except the
    QCA955X and QCA956X at offset 0x10.

    Since the PCIE PLL config register is only defined for the AR724x fix
    only this value. The value is wrong since the day it was added and isn't
    used by any driver yet.

    Signed-off-by: Mathias Kresin
    Cc: Ralf Baechle
    Cc: linux-mips@linux-mips.org
    Patchwork: https://patchwork.linux-mips.org/patch/16048/
    Signed-off-by: James Hogan
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Mathias Kresin
     
  • [ Upstream commit 9a9ab3078e2744a1a55163cfaec73a5798aae33e ]

    We now have a platform (Ranchu) in the "generic" platform which matches
    based on the FDT compatible string using mips_machine_is_compatible(),
    however that function doesn't stop at a blank struct
    of_device_id::compatible as that is an array in the struct, not a
    pointer to a string.

    Fix the loop completion to check the first byte of the compatible array
    rather than the address of the compatible array in the struct.

    Fixes: eed0eabd12ef ("MIPS: generic: Introduce generic DT-based board support")
    Signed-off-by: James Hogan
    Reviewed-by: Paul Burton
    Reviewed-by: Matt Redfearn
    Cc: Ralf Baechle
    Cc: linux-mips@linux-mips.org
    Patchwork: https://patchwork.linux-mips.org/patch/18580/
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    James Hogan
     

24 Apr, 2018

1 commit

  • commit b3d7e55c3f886493235bfee08e1e5a4a27cbcce8 upstream.

    The micromips implementation of bzero additionally clobbers registers t7
    & t8. Specify this in the clobbers list when invoking bzero.

    Fixes: 26c5e07d1478 ("MIPS: microMIPS: Optimise 'memset' core library function.")
    Reported-by: James Hogan
    Signed-off-by: Matt Redfearn
    Cc: Ralf Baechle
    Cc: linux-mips@linux-mips.org
    Cc: # 3.10+
    Patchwork: https://patchwork.linux-mips.org/patch/19110/
    Signed-off-by: James Hogan
    Signed-off-by: Greg Kroah-Hartman

    Matt Redfearn
     

28 Feb, 2018

1 commit

  • commit 6ae1756faddefd7494353380ee546dd38c2f97eb upstream.

    MIPS' struct compat_flock doesn't match the 32-bit struct flock, as it
    has an extra short __unused before pad[4], which combined with alignment
    increases the size to 40 bytes compared with struct flock's 36 bytes.

    Since commit 8c6657cb50cb ("Switch flock copyin/copyout primitives to
    copy_{from,to}_user()"), put_compat_flock() writes the full compat_flock
    struct to userland, which results in corruption of the userland word
    after the struct flock when running 32-bit userlands on 64-bit kernels.

    This was observed to cause a bus error exception when starting Firefox
    on Debian 8 (Jessie).

    Reported-by: Peter Mamonov
    Signed-off-by: James Hogan
    Tested-by: Peter Mamonov
    Cc: Ralf Baechle
    Cc: Al Viro
    Cc: linux-mips@linux-mips.org
    Cc: # 4.13+
    Patchwork: https://patchwork.linux-mips.org/patch/18646/
    Signed-off-by: Greg Kroah-Hartman

    James Hogan
     

17 Dec, 2017

1 commit

  • commit 4d2dc2cc766c3b51929658cacbc6e34fc8e242fb upstream.

    Currently, we're capping the values too low in the F_GETLK64 case. The
    fields in that structure are 64-bit values, so we shouldn't need to do
    any sort of fixup there.

    Make sure we check that assumption at build time in the future however
    by ensuring that the sizes we're copying will fit.

    With this, we no longer need COMPAT_LOFF_T_MAX either, so remove it.

    Fixes: 94073ad77fff2 (fs/locks: don't mess with the address limit in compat_fcntl64)
    Reported-by: Vitaly Lipatov
    Signed-off-by: Jeff Layton
    Reviewed-by: David Howells
    Signed-off-by: Greg Kroah-Hartman

    Jeff Layton
     

10 Dec, 2017

1 commit

  • commit c8ec2041f549e7f2dee0c34d25381be6f7805f99 upstream.

    Add a custom serial.h header for MIPS, allowing platforms to override
    the asm-generic version if required.

    The generic platform uses this header to set BASE_BAUD to 0. The
    generic platform supports multiple boards, which may have different
    UART clocks. Also one of the boards supported is the Boston FPGA board,
    where the UART clock depends on the loaded FPGA bitfile. As such there
    is no way that the generic kernel can set a compile time default
    BASE_BAUD.

    Commit 31cb9a8575ca ("earlycon: initialise baud field of earlycon device
    structure") changed the behavior of of_setup_earlycon such that any baud
    rate set in the device tree is now set in the earlycon structure. The
    UART driver will then calculate a divisor based on BASE_BAUD and set it.
    With MIPS generic kernels this resulted in garbage output due to the
    incorrect uart clock rate being used to calculate a divisor. This
    commit, combined with "serial: 8250_early: Only set divisor if valid clk
    & baud" prevents the earlycon code setting a bad divisor and restores
    earlycon output.

    Fixes: 31cb9a8575ca ("earlycon: initialise baud field of earlycon device structure")
    Signed-off-by: Matt Redfearn
    Signed-off-by: Greg Kroah-Hartman

    Matt Redfearn
     

30 Nov, 2017

3 commits

  • commit 22b8ba765a726d90e9830ff6134c32b04f12c10f upstream.

    32-bit kernels can be configured to support MIPS64, in which case
    neither CONFIG_64BIT or CONFIG_CPU_MIPS32_R* will be set. This causes
    the CP0_Status.FR checks at the point of floating point register save
    and restore to be compiled out, which results in odd FP registers not
    being saved or restored to the task or signal context even when
    CP0_Status.FR is set.

    Fix the ifdefs to use CONFIG_CPU_MIPSR2 and CONFIG_CPU_MIPSR6, which are
    enabled for the relevant revisions of either MIPS32 or MIPS64, along
    with some other CPUs such as Octeon (r2), Loongson1 (r2), XLP (r2),
    Loongson 3A R2.

    The suspect code originates from commit 597ce1723e0f ("MIPS: Support for
    64-bit FP with O32 binaries") in v3.14, however the code in
    __enable_fpu() was consistent and refused to set FR=1, falling back to
    software FPU emulation. This was suboptimal but should be functionally
    correct.

    Commit fcc53b5f6c38 ("MIPS: fpu.h: Allow 64-bit FPU on a 64-bit MIPS R6
    CPU") in v4.2 (and stable tagged back to 4.0) later introduced the bug
    by updating __enable_fpu() to set FR=1 but failing to update the other
    similar ifdefs to enable FR=1 state handling.

    Fixes: fcc53b5f6c38 ("MIPS: fpu.h: Allow 64-bit FPU on a 64-bit MIPS R6 CPU")
    Signed-off-by: James Hogan
    Cc: Ralf Baechle
    Cc: Paul Burton
    Cc: linux-mips@linux-mips.org
    Patchwork: https://patchwork.linux-mips.org/patch/16739/
    Signed-off-by: Greg Kroah-Hartman

    James Hogan
     
  • commit c7fd89a6407ea3a44a2a2fa12d290162c42499c4 upstream.

    Building 32-bit MIPS64r2 kernels produces warnings like the following
    on certain toolchains (such as GNU assembler 2.24.90, but not GNU
    assembler 2.28.51) since commit 22b8ba765a72 ("MIPS: Fix MIPS64 FP
    save/restore on 32-bit kernels"), due to the exposure of fpu_save_16odd
    from fpu_save_double and fpu_restore_16odd from fpu_restore_double:

    arch/mips/kernel/r4k_fpu.S:47: Warning: float register should be even, was 1
    ...
    arch/mips/kernel/r4k_fpu.S:59: Warning: float register should be even, was 1
    ...

    This appears to be because .set mips64r2 does not change the FPU ABI to
    64-bit when -march=mips64r2 (or e.g. -march=xlp) is provided on the
    command line on that toolchain, from the default FPU ABI of 32-bit due
    to the -mabi=32. This makes access to the odd FPU registers invalid.

    Fix by explicitly changing the FPU ABI with .set fp=64 directives in
    fpu_save_16odd and fpu_restore_16odd, and moving the undefine of fp up
    in asmmacro.h so fp doesn't turn into $30.

    Fixes: 22b8ba765a72 ("MIPS: Fix MIPS64 FP save/restore on 32-bit kernels")
    Signed-off-by: James Hogan
    Cc: Ralf Baechle
    Cc: Paul Burton
    Cc: linux-mips@linux-mips.org
    Patchwork: https://patchwork.linux-mips.org/patch/17656/
    Signed-off-by: Greg Kroah-Hartman

    James Hogan
     
  • commit a3f143106596d739e7fbc4b84c96b1475247d876 upstream.

    __cmpxchg64_local_generic() is atomic only w.r.t tasks and interrupts
    on the same CPU (that's what the 'local' means). We can't use it to
    implement cmpxchg64() in SMP configurations.

    So, for 32-bit SMP configurations:

    - Don't define cmpxchg64()
    - Don't enable HAVE_VIRT_CPU_ACCOUNTING_GEN, which requires it

    Fixes: e2093c7b03c1 ("MIPS: Fall back to generic implementation of ...")
    Fixes: bb877e96bea1 ("MIPS: Add support for full dynticks CPU time accounting")
    Signed-off-by: Ben Hutchings
    Cc: Ralf Baechle
    Cc: Deng-Cheng Zhu
    Cc: linux-mips@linux-mips.org
    Patchwork: https://patchwork.linux-mips.org/patch/17413/
    Signed-off-by: James Hogan
    Signed-off-by: Greg Kroah-Hartman

    Ben Hutchings
     

05 Nov, 2017

1 commit

  • Pull MIPS fixes from James Hogan:
    "A selection of important MIPS fixes for 4.14, and some MAINTAINERS /
    email address updates:

    Maintainership updates:
    - imgtec.com -> mips.com email addresses (this trivially updates
    comments in quite a few files, as well as MAINTAINERS)
    - Pistachio SoC maintainership update

    Fixes:
    - NI 169445 build (new platform in 4.14)
    - EVA regression (4.14)
    - SMP-CPS build & preemption regressions (4.14)
    - SMP/hotplug deadlock & race (deadlock reintroduced 4.13)
    - ebpf_jit error return (4.13)
    - SMP-CMP build regressions (4.11 and 4.14)
    - bad UASM microMIPS encoding (3.16)
    - CM definitions (3.15)"

    [ I had taken the email address updates separately, because I didn't
    expect James to send a pull request, so those got applied twice. - Linus]

    * tag 'mips_fixes_4.14' of git://git.kernel.org/pub/scm/linux/kernel/git/jhogan/mips:
    MIPS: Update email address for Marcin Nowakowski
    MIPS: smp-cmp: Fix vpe_id build error
    MAINTAINERS: Update Pistachio platform maintainers
    MIPS: smp-cmp: Use right include for task_struct
    MIPS: Update Goldfish RTC driver maintainer email address
    MIPS: Update RINT emulation maintainer email address
    MIPS: CPS: Fix use of current_cpu_data in preemptible code
    MIPS: SMP: Fix deadlock & online race
    MIPS: bpf: Fix a typo in build_one_insn()
    MIPS: microMIPS: Fix incorrect mask in insn_table_MM
    MIPS: Fix CM region target definitions
    MIPS: generic: Fix compilation error from include asm/mips-cpc.h
    MIPS: Fix exception entry when CONFIG_EVA enabled
    MIPS: generic: Fix NI 169445 its build
    Update MIPS email addresses

    Linus Torvalds
     

04 Nov, 2017

1 commit

  • MIPS will soon not be a part of Imagination Technologies, and as such
    many @imgtec.com email addresses will no longer be valid. This patch
    updates the addresses for those who:

    - Have 10 or more patches in mainline authored using an @imgtec.com
    email address, or any patches dated within the past year.

    - Are still with Imagination but leaving as part of the MIPS business
    unit, as determined from an internal email address list.

    - Haven't already updated their email address (ie. JamesH) or expressed
    a desire to be excluded (ie. Maciej).

    - Acked v2 or earlier of this patch, which leaves Deng-Cheng, Matt &
    myself.

    New addresses are of the form firstname.lastname@mips.com, and all
    verified against an internal email address list. An entry is added to
    .mailmap for each person such that get_maintainer.pl will report the new
    addresses rather than @imgtec.com addresses which will soon be dead.

    Instances of the affected addresses throughout the tree are then
    mechanically replaced with the new @mips.com address.

    Signed-off-by: Paul Burton
    Cc: Deng-Cheng Zhu
    Cc: Deng-Cheng Zhu
    Acked-by: Dengcheng Zhu
    Cc: Matt Redfearn
    Cc: Matt Redfearn
    Acked-by: Matt Redfearn
    Cc: Andrew Morton
    Cc: linux-kernel@vger.kernel.org
    Cc: linux-mips@linux-mips.org
    Cc: trivial@kernel.org
    Signed-off-by: Linus Torvalds

    Paul Burton
     

02 Nov, 2017

3 commits

  • Many user space API headers have licensing information, which is either
    incomplete, badly formatted or just a shorthand for referring to the
    license under which the file is supposed to be. This makes it hard for
    compliance tools to determine the correct license.

    Update these files with an SPDX license identifier. The identifier was
    chosen based on the license information in the file.

    GPL/LGPL licensed headers get the matching GPL/LGPL SPDX license
    identifier with the added 'WITH Linux-syscall-note' exception, which is
    the officially assigned exception identifier for the kernel syscall
    exception:

    NOTE! This copyright does *not* cover user programs that use kernel
    services by normal system calls - this is merely considered normal use
    of the kernel, and does *not* fall under the heading of "derived work".

    This exception makes it possible to include GPL headers into non GPL
    code, without confusing license compliance tools.

    Headers which have either explicit dual licensing or are just licensed
    under a non GPL license are updated with the corresponding SPDX
    identifier and the GPLv2 with syscall exception identifier. The format
    is:
    ((GPL-2.0 WITH Linux-syscall-note) OR SPDX-ID-OF-OTHER-LICENSE)

    SPDX license identifiers are a legally binding shorthand, which can be
    used instead of the full boiler plate text. The update does not remove
    existing license information as this has to be done on a case by case
    basis and the copyright holders might have to be consulted. This will
    happen in a separate step.

    This patch is based on work done by Thomas Gleixner and Kate Stewart and
    Philippe Ombredanne. See the previous patch in this series for the
    methodology of how this patch was researched.

    Reviewed-by: Kate Stewart
    Reviewed-by: Philippe Ombredanne
    Reviewed-by: Thomas Gleixner
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     
  • Many user space API headers are missing licensing information, which
    makes it hard for compliance tools to determine the correct license.

    By default are files without license information under the default
    license of the kernel, which is GPLV2. Marking them GPLV2 would exclude
    them from being included in non GPLV2 code, which is obviously not
    intended. The user space API headers fall under the syscall exception
    which is in the kernels COPYING file:

    NOTE! This copyright does *not* cover user programs that use kernel
    services by normal system calls - this is merely considered normal use
    of the kernel, and does *not* fall under the heading of "derived work".

    otherwise syscall usage would not be possible.

    Update the files which contain no license information with an SPDX
    license identifier. The chosen identifier is 'GPL-2.0 WITH
    Linux-syscall-note' which is the officially assigned identifier for the
    Linux syscall exception. SPDX license identifiers are a legally binding
    shorthand, which can be used instead of the full boiler plate text.

    This patch is based on work done by Thomas Gleixner and Kate Stewart and
    Philippe Ombredanne. See the previous patch in this series for the
    methodology of how this patch was researched.

    Reviewed-by: Kate Stewart
    Reviewed-by: Philippe Ombredanne
    Reviewed-by: Thomas Gleixner
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     
  • Many source files in the tree are missing licensing information, which
    makes it harder for compliance tools to determine the correct license.

    By default all files without license information are under the default
    license of the kernel, which is GPL version 2.

    Update the files which contain no license information with the 'GPL-2.0'
    SPDX license identifier. The SPDX identifier is a legally binding
    shorthand, which can be used instead of the full boiler plate text.

    This patch is based on work done by Thomas Gleixner and Kate Stewart and
    Philippe Ombredanne.

    How this work was done:

    Patches were generated and checked against linux-4.14-rc6 for a subset of
    the use cases:
    - file had no licensing information it it.
    - file was a */uapi/* one with no licensing information in it,
    - file was a */uapi/* one with existing licensing information,

    Further patches will be generated in subsequent months to fix up cases
    where non-standard license headers were used, and references to license
    had to be inferred by heuristics based on keywords.

    The analysis to determine which SPDX License Identifier to be applied to
    a file was done in a spreadsheet of side by side results from of the
    output of two independent scanners (ScanCode & Windriver) producing SPDX
    tag:value files created by Philippe Ombredanne. Philippe prepared the
    base worksheet, and did an initial spot review of a few 1000 files.

    The 4.13 kernel was the starting point of the analysis with 60,537 files
    assessed. Kate Stewart did a file by file comparison of the scanner
    results in the spreadsheet to determine which SPDX license identifier(s)
    to be applied to the file. She confirmed any determination that was not
    immediately clear with lawyers working with the Linux Foundation.

    Criteria used to select files for SPDX license identifier tagging was:
    - Files considered eligible had to be source code files.
    - Make and config files were included as candidates if they contained >5
    lines of source
    - File already had some variant of a license header in it (even if
    Reviewed-by: Philippe Ombredanne
    Reviewed-by: Thomas Gleixner
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

01 Nov, 2017

3 commits

  • The default CM target field in the GCR_BASE register is encoded with 0
    meaning memory & 1 being reserved. However the definitions we use for
    those bits effectively get these two values backwards - likely because
    they were copied from the definitions for the CM regions where the
    target is encoded differently. This results in use setting up GCR_BASE
    with the reserved target value by default, rather than targeting memory
    as intended. Although we currently seem to get away with this it's not a
    great idea to rely upon.

    Fix this by changing our macros to match the documentated target values.

    The incorrect encoding became used as of commit 9f98f3dd0c51 ("MIPS: Add
    generic CM probe & access code") in the Linux v3.15 cycle, and was
    likely carried forwards from older but unused code introduced by
    commit 39b8d5254246 ("[MIPS] Add support for MIPS CMP platform.") in the
    v2.6.26 cycle.

    Fixes: 9f98f3dd0c51 ("MIPS: Add generic CM probe & access code")
    Signed-off-by: Paul Burton
    Reported-by: Matt Redfearn
    Reviewed-by: James Hogan
    Cc: Matt Redfearn
    Cc: Ralf Baechle
    Cc: linux-mips@linux-mips.org
    Cc: # v3.15+
    Patchwork: https://patchwork.linux-mips.org/patch/17562/
    Signed-off-by: James Hogan

    Paul Burton
     
  • Commit 9fef68686317b ("MIPS: Make SAVE_SOME more standard") made several
    changes to the order in which registers are saved in the SAVE_SOME
    macro, used by exception handlers to save the processor state. In
    particular, it removed the
    move k1, sp
    in the delay slot of the branch testing if the processor is already in
    kernel mode. This is replaced later in the macro by a
    move k0, sp
    When CONFIG_EVA is disabled, this instruction actually appears in the
    delay slot of the branch. However, when CONFIG_EVA is enabled, instead
    the RPS workaround of
    MFC0 k0, CP0_ENTRYHI
    appears in the delay slot. This results in k0 not containing the stack
    pointer, but some unrelated value, which is then saved to the kernel
    stack. On exit from the exception, this bogus value is restored to the
    stack pointer, resulting in an OOPS.

    Fix this by moving the save of SP in k0 explicitly in the delay slot of
    the branch, outside of the CONFIG_EVA section, restoring the expected
    instruction ordering when CONFIG_EVA is active.

    Fixes: 9fef68686317b ("MIPS: Make SAVE_SOME more standard")
    Signed-off-by: Matt Redfearn
    Reported-by: Vladimir Kondratiev
    Reviewed-by: Corey Minyard
    Reviewed-by: James Hogan
    Patchwork: https://patchwork.linux-mips.org/patch/17471/
    Signed-off-by: James Hogan

    Matt Redfearn
     
  • MIPS will soon not be a part of Imagination Technologies, and as such
    many @imgtec.com email addresses will no longer be valid. This patch
    updates the addresses for those who:

    - Have 10 or more patches in mainline authored using an @imgtec.com
    email address, or any patches dated within the past year.

    - Are still with Imagination but leaving as part of the MIPS business
    unit, as determined from an internal email address list.

    - Haven't already updated their email address (ie. JamesH) or expressed
    a desire to be excluded (ie. Maciej).

    - Acked v2 or earlier of this patch, which leaves Deng-Cheng, Matt &
    myself.

    New addresses are of the form firstname.lastname@mips.com, and all
    verified against an internal email address list. An entry is added to
    .mailmap for each person such that get_maintainer.pl will report the new
    addresses rather than @imgtec.com addresses which will soon be dead.

    Instances of the affected addresses throughout the tree are then
    mechanically replaced with the new @mips.com address.

    Signed-off-by: Paul Burton
    Cc: Deng-Cheng Zhu
    Cc: Deng-Cheng Zhu
    Acked-by: Dengcheng Zhu
    Cc: Matt Redfearn
    Cc: Matt Redfearn
    Acked-by: Matt Redfearn
    Cc: Andrew Morton
    Cc: linux-kernel@vger.kernel.org
    Cc: linux-mips@linux-mips.org
    Cc: trivial@kernel.org
    Patchwork: https://patchwork.linux-mips.org/patch/17540/
    Signed-off-by: James Hogan

    Paul Burton
     

09 Oct, 2017

1 commit

  • Commit 8263db4d7768 ("MIPS: cmpxchg: Implement __cmpxchg() as a
    function") refactored our implementation of __cmpxchg() to be a function
    rather than a macro, with the aim of making it easier to read & modify.
    Unfortunately the commit breaks use of cmpxchg() for signed 32 bit
    values when we have a 64 bit kernel with kernel_uses_llsc == false,
    because:

    - In cmpxchg_local() we cast the old value to the type the pointer
    points to, and then to an unsigned long. If the pointer points to a
    signed type smaller than 64 bits then the old value will be sign
    extended to 64 bits. That is, bits beyond the size of the pointed to
    type will be set to 1 if the old value is negative. In the case of a
    signed 32 bit integer with a negative value, bits 63:32 will all be
    set.

    - In __cmpxchg_asm() we load the value from memory, ie. dereference the
    pointer, and store the value as an unsigned integer (__ret) whose
    size matches the pointer. For a 32 bit cmpxchg() this means we store
    the value in a u32, because the pointer provided to __cmpxchg_asm()
    by __cmpxchg() is of type volatile u32 *.

    - __cmpxchg_asm() then checks whether the value in memory (__ret)
    matches the provided old value, by comparing the two values. This
    results in the u32 being promoted to a 64 bit unsigned long to match
    the old argument - however because both types are unsigned the value
    is zero extended, which does not match the sign extension performed
    on the old value in cmpxchg_local() earlier.

    This mismatch means that unfortunate cmpxchg() calls can incorrectly
    fail for 64 bit kernels with kernel_uses_llsc == false. This is the case
    on at least non-SMP Cavium Octeon kernels, which hardcode
    kernel_uses_llsc in their cpu-feature-overrides.h header. Using a
    v4.13-rc7 kernel configured using cavium_octeon_defconfig with SMP
    manually disabled, this presents itself as oddity when we reach
    userland - for example:

    can't run '/bin/mount': Text file busy
    can't run '/bin/mkdir': Text file busy
    can't run '/bin/mkdir': Text file busy
    can't run '/bin/mount': Text file busy
    can't run '/bin/hostname': Text file busy
    can't run '/etc/init.d/rcS': Text file busy
    can't run '/sbin/getty': Text file busy
    can't run '/sbin/getty': Text file busy

    It appears that some part of the init process, which is in this case
    buildroot's busybox init, is running successfully. It never manages to
    reach the login prompt though, and complains about /sbin/getty being
    busy repeatedly and indefinitely.

    Fix this by casting the old value provided to __cmpxchg_asm() to an
    appropriately sized unsigned integer, such that we consistently
    zero-extend avoiding the mismatch. The __cmpxchg_small() case for 8 & 16
    bit values is unaffected because __cmpxchg_small() already masks
    provided values appropriately.

    Signed-off-by: Paul Burton
    Fixes: 8263db4d7768 ("MIPS: cmpxchg: Implement __cmpxchg() as a function")
    Cc: linux-mips@linux-mips.org
    Patchwork: https://patchwork.linux-mips.org/patch/17226/
    Cc: linux-mips@linux-mips.org
    Signed-off-by: Ralf Baechle

    Paul Burton
     

21 Sep, 2017

1 commit

  • The inline asm in __write_64bit_c0_split() modifies the 64-bit input
    operand by shifting the high register left by 32, and constructing the
    full 64-bit value in the low register (even on a 32-bit kernel), so if
    that value is used again it could cause breakage as GCC would assume the
    registers haven't changed when they have.

    To quote the GCC extended asm documentation:
    > Warning: Do not modify the contents of input-only operands (except for
    > inputs tied to outputs). The compiler assumes that on exit from the
    > asm statement these operands contain the same values as they had
    > before executing the statement.

    Avoid modifying the input by using a temporary variable as an output
    which is modified instead of the input and not otherwise used. The asm
    is always __volatile__ so GCC shouldn't optimise it out. The low
    register of the temporary output is written before the high register of
    the input is read, so we have two constraint alternatives, one where
    both use the same registers (for when the input value isn't subsequently
    used), and one with an early clobber on the output in case the low
    output uses the same register as the high input. This allows the
    resulting assembly to remain mostly unchanged.

    A diff of a MIPS32r6 kernel reveals only three differences, two in
    relation to write_c0_r10k_diag() in cpu_probe() (register allocation
    rearranged slightly but otherwise identical), and one in relation to
    write_c0_cvmmemctl2() in kvm_vz_local_flush_guesttlb_all(), but the
    octeon CPU is only supported on 64-bit kernels where
    __write_64bit_c0_split() isn't used so that shouldn't matter in
    practice. So there currently doesn't appear to be anything broken by
    this bug.

    Signed-off-by: James Hogan
    Cc: linux-mips@linux-mips.org
    Patchwork: https://patchwork.linux-mips.org/patch/17315/
    Signed-off-by: Ralf Baechle

    James Hogan
     

16 Sep, 2017

1 commit

  • Pull MIPS updates from Ralf Baechle:
    "This is the main pull request for 4.14 for MIPS; below a summary of
    the non-merge commits:

    CM:
    - Rename mips_cm_base to mips_gcr_base
    - Specify register size when generating accessors
    - Use BIT/GENMASK for register fields, order & drop shifts
    - Add cluster & block args to mips_cm_lock_other()

    CPC:
    - Use common CPS accessor generation macros
    - Use BIT/GENMASK for register fields, order & drop shifts
    - Introduce register modify (set/clear/change) accessors
    - Use change_*, set_* & clear_* where appropriate
    - Add CM/CPC 3.5 register definitions
    - Use GlobalNumber macros rather than magic numbers
    - Have asm/mips-cps.h include CM & CPC headers
    - Cluster support for topology functions
    - Detect CPUs in secondary clusters

    CPS:
    - Read GIC_VL_IDENT directly, not via irqchip driver

    DMA:
    - Consolidate coherent and non-coherent dma_alloc code
    - Don't use dma_cache_sync to implement fd_cacheflush

    FPU emulation / FP assist code:
    - Another series of 14 commits fixing corner cases such as NaN
    propgagation and other special input values.
    - Zero bits 32-63 of the result for a CLASS.D instruction.
    - Enhanced statics via debugfs
    - Do not use bools for arithmetic. GCC 7.1 moans about this.
    - Correct user fault_addr type

    Generic MIPS:
    - Enhancement of stack backtraces
    - Cleanup from non-existing options
    - Handle non word sized instructions when examining frame
    - Fix detection and decoding of ADDIUSP instruction
    - Fix decoding of SWSP16 instruction
    - Refactor handling of stack pointer in get_frame_info
    - Remove unreachable code from force_fcr31_sig()
    - Convert to using %pOF instead of full_name
    - Remove the R6000 support.
    - Move FP code from *_switch.S to *_fpu.S
    - Remove unused ST_OFF from r2300_switch.S
    - Allow platform to specify multiple its.S files
    - Add #includes to various files to ensure code builds reliable and
    without warning..
    - Remove __invalidate_kernel_vmap_range
    - Remove plat_timer_setup
    - Declare various variables & functions static
    - Abstract CPU core & VP(E) ID access through accessor functions
    - Store core & VP IDs in GlobalNumber-style variable
    - Unify checks for sibling CPUs
    - Add CPU cluster number accessors
    - Prevent direct use of generic_defconfig
    - Make CONFIG_MIPS_MT_SMP default y
    - Add __ioread64_copy
    - Remove unnecessary inclusions of linux/irqchip/mips-gic.h

    GIC:
    - Introduce asm/mips-gic.h with accessor functions
    - Use new GIC accessor functions in mips-gic-timer
    - Remove counter access functions from irq-mips-gic.c
    - Remove gic_read_local_vp_id() from irq-mips-gic.c
    - Simplify shared interrupt pending/mask reads in irq-mips-gic.c
    - Simplify gic_local_irq_domain_map() in irq-mips-gic.c
    - Drop gic_(re)set_mask() functions in irq-mips-gic.c
    - Remove gic_set_polarity(), gic_set_trigger(), gic_set_dual_edge(),
    gic_map_to_pin() and gic_map_to_vpe() from irq-mips-gic.c.
    - Convert remaining shared reg access, local int mask access and
    remaining local reg access to new accessors
    - Move GIC_LOCAL_INT_* to asm/mips-gic.h
    - Remove GIC_CPU_INT* macros from irq-mips-gic.c
    - Move various definitions to the driver
    - Remove gic_get_usm_range()
    - Remove __gic_irq_dispatch() forward declaration
    - Remove gic_init()
    - Use mips_gic_present() in place of gic_present and remove
    gic_present
    - Move gic_get_c0_*_int() to asm/mips-gic.h
    - Remove linux/irqchip/mips-gic.h
    - Inline __gic_init()
    - Inline gic_basic_init()
    - Make pcpu_masks a per-cpu variable
    - Use pcpu_masks to avoid reading GIC_SH_MASK*
    - Clean up mti, reserved-cpu-vectors handling
    - Use cpumask_first_and() in gic_set_affinity()
    - Let the core set struct irq_common_data affinity

    microMIPS:
    - Fix microMIPS stack unwinding on big endian systems

    MIPS-GIC:
    - SYNC after enabling GIC region

    NUMA:
    - Remove the unused parent_node() macro

    R6:
    - Constify r2_decoder_tables
    - Add accessor & bit definitions for GlobalNumber

    SMP:
    - Constify smp ops
    - Allow boot_secondary SMP op to return errors

    VDSO:
    - Drop gic_get_usm_range() usage
    - Avoid use of linux/irqchip/mips-gic.h

    Platform changes:

    Alchemy:
    - Add devboard machine type to cpuinfo
    - update cpu feature overrides
    - Threaded carddetect irqs for devboards

    AR7:
    - allow NULL clock for clk_get_rate

    BCM63xx:
    - Fix ENETDMA_6345_MAXBURST_REG offset
    - Allow NULL clock for clk_get_rate

    CI20:
    - Enable GPIO and RTC drivers in defconfig
    - Add ethernet and fixed-regulator nodes to DTS

    Generic platform:
    - Move Boston and NI 169445 FIT image source to their own files
    - Include asm/bootinfo.h for plat_fdt_relocated()
    - Include asm/time.h for get_c0_*_int()
    - Include asm/bootinfo.h for plat_fdt_relocated()
    - Include asm/time.h for get_c0_*_int()
    - Allow filtering enabled boards by requirements
    - Don't explicitly disable CONFIG_USB_SUPPORT
    - Bump default NR_CPUS to 16

    JZ4700:
    - Probe the jz4740-rtc driver from devicetree

    Lantiq:
    - Drop check of boot select from the spi-falcon driver.
    - Drop check of boot select from the lantiq-flash MTD driver.
    - Access boot cause register in the watchdog driver through regmap
    - Add device tree binding documentation for the watchdog driver
    - Add docs for the RCU DT bindings.
    - Convert the fpi bus driver to a platform_driver
    - Remove ltq_reset_cause() and ltq_boot_select(
    - Switch to a proper reset driver
    - Switch to a new drivers/soc GPHY driver
    - Add an USB PHY driver for the Lantiq SoCs using the RCU module
    - Use of_platform_default_populate instead of __dt_register_buses
    - Enable MFD_SYSCON to be able to use it for the RCU MFD
    - Replace ltq_boot_select() with dummy implementation.

    Loongson 2F:
    - Allow NULL clock for clk_get_rate

    Malta:
    - Use new GIC accessor functions

    NI 169445:
    - Add support for NI 169445 board.
    - Only include in 32r2el kernels

    Octeon:
    - Add support for watchdog of 78XX SOCs.
    - Add support for watchdog of CN68XX SOCs.
    - Expose support for mips32r1, mips32r2 and mips64r1
    - Enable more drivers in config file
    - Add support for accessing the boot vector.
    - Remove old boot vector code from watchdog driver
    - Define watchdog registers for 70xx, 73xx, 78xx, F75xx.
    - Make CSR functions node aware.
    - Allow access to CIU3 IRQ domains.
    - Misc cleanups in the watchdog driver

    Omega2+:
    - New board, add support and defconfig

    Pistachio:
    - Enable Root FS on NFS in defconfig

    Ralink:
    - Add Mediatek MT7628A SoC
    - Allow NULL clock for clk_get_rate
    - Explicitly request exclusive reset control in the pci-mt7620 PCI driver.

    SEAD3:
    - Only include in 32 bit kernels by default

    VoCore:
    - Add VoCore as a vendor t0 dt-bindings
    - Add defconfig file"

    * '4.14-features' of git://git.linux-mips.org/pub/scm/ralf/upstream-linus: (167 commits)
    MIPS: Refactor handling of stack pointer in get_frame_info
    MIPS: Stacktrace: Fix microMIPS stack unwinding on big endian systems
    MIPS: microMIPS: Fix decoding of swsp16 instruction
    MIPS: microMIPS: Fix decoding of addiusp instruction
    MIPS: microMIPS: Fix detection of addiusp instruction
    MIPS: Handle non word sized instructions when examining frame
    MIPS: ralink: allow NULL clock for clk_get_rate
    MIPS: Loongson 2F: allow NULL clock for clk_get_rate
    MIPS: BCM63XX: allow NULL clock for clk_get_rate
    MIPS: AR7: allow NULL clock for clk_get_rate
    MIPS: BCM63XX: fix ENETDMA_6345_MAXBURST_REG offset
    mips: Save all registers when saving the frame
    MIPS: Add DWARF unwinding to assembly
    MIPS: Make SAVE_SOME more standard
    MIPS: Fix issues in backtraces
    MIPS: jz4780: DTS: Probe the jz4740-rtc driver from devicetree
    MIPS: Ci20: Enable RTC driver
    watchdog: octeon-wdt: Add support for 78XX SOCs.
    watchdog: octeon-wdt: Add support for cn68XX SOCs.
    watchdog: octeon-wdt: File cleaning.
    ...

    Linus Torvalds
     

12 Sep, 2017

1 commit

  • Pull namespace updates from Eric Biederman:
    "Life has been busy and I have not gotten half as much done this round
    as I would have liked. I delayed it so that a minor conflict
    resolution with the mips tree could spend a little time in linux-next
    before I sent this pull request.

    This includes two long delayed user namespace changes from Kirill
    Tkhai. It also includes a very useful change from Serge Hallyn that
    allows the security capability attribute to be used inside of user
    namespaces. The practical effect of this is people can now untar
    tarballs and install rpms in user namespaces. It had been suggested to
    generalize this and encode some of the namespace information
    information in the xattr name. Upon close inspection that makes the
    things that should be hard easy and the things that should be easy
    more expensive.

    Then there is my bugfix/cleanup for signal injection that removes the
    magic encoding of the siginfo union member from the kernel internal
    si_code. The mips folks reported the case where I had used FPE_FIXME
    me is impossible so I have remove FPE_FIXME from mips, while at the
    same time including a return statement in that case to keep gcc from
    complaining about unitialized variables.

    I almost finished the work to get make copy_siginfo_to_user a trivial
    copy to user. The code is available at:

    git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace.git neuter-copy_siginfo_to_user-v3

    But I did not have time/energy to get the code posted and reviewed
    before the merge window opened.

    I was able to see that the security excuse for just copying fields
    that we know are initialized doesn't work in practice there are buggy
    initializations that don't initialize the proper fields in siginfo. So
    we still sometimes copy unitialized data to userspace"

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace:
    Introduce v3 namespaced file capabilities
    mips/signal: In force_fcr31_sig return in the impossible case
    signal: Remove kernel interal si_code magic
    fcntl: Don't use ambiguous SIG_POLL si_codes
    prctl: Allow local CAP_SYS_ADMIN changing exe_file
    security: Use user_namespace::level to avoid redundant iterations in cap_capable()
    userns,pidns: Verify the userns for new pid namespaces
    signal/testing: Don't look for __SI_FAULT in userspace
    signal/mips: Document a conflict with SI_USER with SIGFPE
    signal/sparc: Document a conflict with SI_USER with SIGFPE
    signal/ia64: Document a conflict with SI_USER with SIGFPE
    signal/alpha: Document a conflict with SI_USER for SIGTRAP

    Linus Torvalds
     

10 Sep, 2017

1 commit

  • Pull MTD updates from Boris Brezillon:
    "General updates:
    - Constify pci_device_id in various drivers
    - Constify device_type
    - Remove pad control code from the Gemini driver
    - Use %pOF to print OF node full_name
    - Various fixes in the physmap_of driver
    - Remove unused vars in mtdswap
    - Check devm_kzalloc() return value in the spear_smi driver
    - Check clk_prepare_enable() return code in the st_spi_fsm driver
    - Create per MTD device debugfs enties

    NAND updates, from Boris Brezillon:
    - Fix memory leaks in the core
    - Remove unused NAND locking support
    - Rename nand.h into rawnand.h (preparing support for spi NANDs)
    - Use NAND_MAX_ID_LEN where appropriate
    - Fix support for 20nm Hynix chips
    - Fix support for Samsung and Hynix SLC NANDs
    - Various cleanup, improvements and fixes in the qcom driver
    - Fixes for bugs detected by various static code analysis tools
    - Fix mxc ooblayout definition
    - Add a new part_parsers to tmio and sharpsl platform data in order
    to define a custom list of partition parsers
    - Request the reset line in exclusive mode in the sunxi driver
    - Fix a build error in the orion-nand driver when compiled for ARMv4
    - Allow 64-bit mvebu platforms to select the PXA3XX driver

    SPI NOR updates, from Cyrille Pitchen and Marek Vasut:
    - add support to the JEDEC JESD216B specification (SFDP tables).
    - add support to the Intel Denverton SPI flash controller.
    - fix error recovery for Spansion/Cypress SPI NOR memories.
    - fix 4-byte address management for the Aspeed SPI controller.
    - add support to some Microchip SST26 memory parts
    - remove unneeded pinctrl header Write a message for tag:"

    * tag 'for-linus-20170904' of git://git.infradead.org/linux-mtd: (74 commits)
    mtd: nand: complain loudly when chip->bits_per_cell is not correctly initialized
    mtd: nand: make Samsung SLC NAND usable again
    mtd: nand: tmio: Register partitions using the parsers
    mfd: tmio: Add partition parsers platform data
    mtd: nand: sharpsl: Register partitions using the parsers
    mtd: nand: sharpsl: Add partition parsers platform data
    mtd: nand: qcom: Support for IPQ8074 QPIC NAND controller
    mtd: nand: qcom: support for IPQ4019 QPIC NAND controller
    dt-bindings: qcom_nandc: IPQ8074 QPIC NAND documentation
    dt-bindings: qcom_nandc: IPQ4019 QPIC NAND documentation
    dt-bindings: qcom_nandc: fix the ipq806x device tree example
    mtd: nand: qcom: support for different DEV_CMD register offsets
    mtd: nand: qcom: QPIC data descriptors handling
    mtd: nand: qcom: enable BAM or ADM mode
    mtd: nand: qcom: erased codeword detection configuration
    mtd: nand: qcom: support for read location registers
    mtd: nand: qcom: support for passing flags in DMA helper functions
    mtd: nand: qcom: add BAM DMA descriptor handling
    mtd: nand: qcom: allocate BAM transaction
    mtd: nand: qcom: DMA mapping support for register read buffer
    ...

    Linus Torvalds
     

09 Sep, 2017

1 commit

  • Where possible, call memset16(), memmove() or memcpy() instead of using
    open-coded loops. I don't like the calling convention that uses a byte
    count instead of a count of u16s, but it's a little late to change that.
    Reduces code size of fbcon.o by almost 400 bytes on my laptop build.

    [akpm@linux-foundation.org: fix build]
    Link: http://lkml.kernel.org/r/20170720184539.31609-9-willy@infradead.org
    Signed-off-by: Matthew Wilcox
    Cc: Ralf Baechle
    Cc: David Miller
    Cc: Sam Ravnborg
    Cc: "H. Peter Anvin"
    Cc: "James E.J. Bottomley"
    Cc: "Martin K. Petersen"
    Cc: Ingo Molnar
    Cc: Ivan Kokshaysky
    Cc: Matt Turner
    Cc: Michael Ellerman
    Cc: Minchan Kim
    Cc: Richard Henderson
    Cc: Russell King
    Cc: Sergey Senozhatsky
    Cc: Thomas Gleixner
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Matthew Wilcox