1. 22 8月, 2018 1 次提交
    • P
      MIPS: Workaround GCC __builtin_unreachable reordering bug · 906d441f
      Paul Burton 提交于
      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
          <AdEL exception here>
      
      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 173a3efd
      ("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: NPaul Burton <paul.burton@mips.com>
      Fixes: 173a3efd ("bug.h: work around GCC PR82365 in BUG()")
      Patchwork: https://patchwork.linux-mips.org/patch/20270/
      Cc: James Hogan <jhogan@kernel.org>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: linux-mips@linux-mips.org
      906d441f
  2. 02 8月, 2018 3 次提交
  3. 31 7月, 2018 3 次提交
    • MIPS: Loongson: Set Loongson32 to MIPS32R1 · 968dc5a0
      谢致邦 (XIE Zhibang) 提交于
      LS232 (Loonson 2-issue 32-bit, also called GS232 (Godson 2-issue 32-bit))
      is the CPU core (microarchitecture) of Loongson 1A/1B/1C.
      
      According to "LS232 用户手册 (LS232 User Manual)", LS232 implements the
      MIPS32 Release 1 instruction set, and part of the MIPS32 Release 2
      instruction set.
      
      In the manual, LS232 implements all of the MIPS32R2 instruction set
      except the FPU instructions, and LS232 also implements 5 FPU
      instructions of the MIPS32R2 instruction set: CEIL.L.fmt, CVT.L.fmt,
      FLOOR.L.fmt, TRUNC.L.fmt, and ROUND.L.fmt.
      
      But a bug of the DI instruction has been found during tests, the DI
      instruction can not disable interrupts in arch_local_irq_disable() with
      CONFIG_PREEMPT_NONE=y and CFLAGS='-mno-branch-likely' in some cases.
      
      [paul.burton@mips.com:
        - Remove the _MIPS_ISA redefinition to match the change made for the
          generic MIPSr1 CPUs by commit 344ebf09 ("MIPS: Always use
          -march=<arch>, not -<arch> shortcuts").]
      Signed-off-by: N谢致邦 (XIE Zhibang) <Yeking@Red54.com>
      Signed-off-by: NPaul Burton <paul.burton@mips.com>
      Patchwork: https://patchwork.linux-mips.org/patch/16155/
      Cc: linux-mips@linux-mips.org
      Cc: ralf@linux-mips.org
      968dc5a0
    • P
      MIPS: generic: Select MIPS_AUTO_PFN_OFFSET · 0211d49e
      Paul Burton 提交于
      Enable CONFIG_MIPS_AUTO_PFN_OFFSET for the generic platform, allowing
      it to avoid wasted book-keeping for pages with addresses lower than the
      physical base address of memory.
      
      This has a minimal impact on kernel text size, with 64r6el_defconfig
      gaining 0.1% in size as reported by bloat-o-meter:
      
        add/remove: 4/1 grow/shrink: 345/13 up/down: 9017/-392 (8625)
        Function                                     old     new   delta
        pcpu_setup_first_chunk                      1444    1780    +336
        pcpu_alloc_first_chunk                       864    1136    +272
        start_kernel                                1064    1288    +224
        initcall_blacklist                           224     372    +148
        try_fill_recv                               2088    2184     +96
        ...
        Total: Before=8457273, After=8465898, chg +0.10%
      
      The gain for systems with large offsets to physical memory & the ability
      to continue using generic kernels on such systems seems well worth this
      small cost.
      Signed-off-by: NPaul Burton <paul.burton@mips.com>
      Suggested-by: NVladimir Kondratiev <vladimir.kondratiev@intel.com>
      Patchwork: https://patchwork.linux-mips.org/patch/20049/
      Cc: James Hogan <jhogan@kernel.org>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: linux-mips@linux-mips.org
      0211d49e
    • P
      MIPS: Allow auto-dection of ARCH_PFN_OFFSET & PHYS_OFFSET · 6c359eb1
      Paul Burton 提交于
      On systems where physical memory begins at a non-zero address, defining
      PHYS_OFFSET (which influences ARCH_PFN_OFFSET) can save us time & memory
      by avoiding book-keeping for pages from address zero to the start of
      memory.
      
      Some MIPS platforms already make use of this, but with the definition of
      PHYS_OFFSET being compile-time constant it hasn't been possible to
      enable this optimization for a kernel which may run on systems with
      varying physical memory base addresses.
      
      Introduce a new Kconfig option CONFIG_MIPS_AUTO_PFN_OFFSET which, when
      enabled, makes ARCH_PFN_OFFSET a variable & detects it from the boot
      memory map (which for example may have been populated from DT). The
      relationship with PHYS_OFFSET is reversed, with PHYS_OFFSET now being
      based on ARCH_PFN_OFFSET. This is because ARCH_PFN_OFFSET is used far
      more often, so avoiding the need for runtime calculation gives us a
      smaller impact on kernel text size (0.1% rather than 0.15% for
      64r6el_defconfig).
      Signed-off-by: NPaul Burton <paul.burton@mips.com>
      Suggested-by: NVladimir Kondratiev <vladimir.kondratiev@intel.com>
      Patchwork: https://patchwork.linux-mips.org/patch/20048/
      Cc: James Hogan <jhogan@kernel.org>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: linux-mips@linux-mips.org
      6c359eb1
  4. 25 7月, 2018 3 次提交
  5. 25 6月, 2018 12 次提交
  6. 20 6月, 2018 1 次提交
    • P
      MIPS: Add support for restartable sequences · 9ea141ad
      Paul Burton 提交于
      Implement support for restartable sequences on MIPS, which requires 3
      simple things:
      
        - Call rseq_handle_notify_resume() on return to userspace if
          TIF_NOTIFY_RESUME is set.
      
        - Call rseq_signal_deliver() to fixup the pre-signal stack frame when
          a signal is delivered whilst executing a restartable sequence
          critical section.
      
        - Select CONFIG_HAVE_RSEQ.
      Signed-off-by: NPaul Burton <paul.burton@mips.com>
      Reviewed-by: NJames Hogan <jhogan@kernel.org>
      Patchwork: https://patchwork.linux-mips.org/patch/19523/
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
      Cc: Boqun Feng <boqun.feng@gmail.com>
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      9ea141ad
  7. 15 6月, 2018 1 次提交
  8. 09 5月, 2018 4 次提交
  9. 08 5月, 2018 1 次提交
  10. 23 4月, 2018 1 次提交
  11. 17 4月, 2018 1 次提交
  12. 28 3月, 2018 1 次提交
  13. 26 3月, 2018 1 次提交
  14. 20 2月, 2018 1 次提交
  15. 06 2月, 2018 2 次提交
  16. 02 2月, 2018 1 次提交
  17. 24 1月, 2018 1 次提交
  18. 19 1月, 2018 2 次提交
    • C
      MIPS: Fix typo BIG_ENDIAN to CPU_BIG_ENDIAN · 2e6522c5
      Corentin Labbe 提交于
      MIPS_GENERIC selects some options conditional on BIG_ENDIAN which does
      not exist.
      
      Replace BIG_ENDIAN with CPU_BIG_ENDIAN which is the correct kconfig
      name. Note that BMIPS_GENERIC does the same which confirms that this
      patch is needed.
      
      Fixes: eed0eabd ("MIPS: generic: Introduce generic DT-based board support")
      Signed-off-by: NCorentin Labbe <clabbe.montjoie@gmail.com>
      Reviewed-by: NJames Hogan <jhogan@kernel.org>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: linux-mips@linux-mips.org
      Cc: <stable@vger.kernel.org> # 4.9+
      Patchwork: https://patchwork.linux-mips.org/patch/18495/
      [jhogan@kernel.org: Clean up commit message]
      Signed-off-by: NJames Hogan <jhogan@kernel.org>
      2e6522c5
    • J
      MIPS: Fix undefined reference to physical_memsize · f35764e7
      James Hogan 提交于
      Since commit d41e6858 ("MIPS: Kconfig: Set default MIPS system type
      as generic") switched the default platform to the "generic" platform,
      allmodconfig has been failing with the following linker error (among
      other errors):
      
      arch/mips/kernel/vpe-mt.o In function `vpe_run':
      (.text+0x59c): undefined reference to `physical_memsize'
      
      The Lantiq platform already worked around the same issue in commit
      9050d50e ("MIPS: lantiq: Set physical_memsize") by declaring
      physical_memsize with the initial value of 0 (on the assumption that the
      actual memory size will be hard-coded in the loaded VPE firmware), and
      the Malta platform already provided physical_memsize.
      
      Since all other platforms will fail to link with the VPE loader enabled,
      only allow Lantiq and Malta platforms to enable it, by way of a
      SYS_SUPPORTS_VPE_LOADER which is selected by those two platforms and
      which MIPS_VPE_LOADER depends on. SYS_SUPPORTS_MULTITHREADING is now a
      dependency of SYS_SUPPORTS_VPE_LOADER so that Kconfig emits a warning if
      SYS_SUPPORTS_VPE_LOADER is selected without SYS_SUPPORTS_MULTITHREADING.
      
      Fixes: d41e6858 ("MIPS: Kconfig: Set default MIPS system type as generic")
      Signed-off-by: NJames Hogan <jhogan@kernel.org>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: John Crispin <john@phrozen.org>
      Cc: Hauke Mehrtens <hauke@hauke-m.de>
      Cc: Paul Burton <paul.burton@mips.com>
      Cc: Matt Redfearn <matt.redfearn@imgtec.com>
      Cc: Guenter Roeck <linux@roeck-us.net>
      Cc: linux-mips@linux-mips.org
      Tested-by: NGuenter Roeck <linux@roeck-us.net>
      Patchwork: https://patchwork.linux-mips.org/patch/18453/
      f35764e7