1. 04 10月, 2016 9 次提交
  2. 02 10月, 2016 1 次提交
    • P
      MIPS: CM: Fix mips_cm_max_vp_width for non-MT kernels on MT systems · 6605d156
      Paul Burton 提交于
      When discovering the number of VPEs per core, smp_num_siblings will be
      incorrect for kernels built without support for the MIPS MultiThreading
      (MT) ASE running on systems which implement said ASE. This leads to
      accesses to VPEs in secondary cores being performed incorrectly since
      mips_cm_vp_id calculates the wrong ID to write to the local "other"
      registers. Fix this by examining the number of VPEs in the core as
      reported by the CM.
      
      This patch presumes that the number of VPEs will be the same in each
      core of the system. As this path only applies to systems with CM version
      2.5 or lower, and this property is true of all such known systems, this
      is likely to be fine but is described in a comment for good measure.
      Signed-off-by: NPaul Burton <paul.burton@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/14338/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      6605d156
  3. 30 9月, 2016 12 次提交
    • P
      MIPS: Fix detection of unsupported highmem with cache aliases · 058effe7
      Paul Burton 提交于
      The paging_init() function contains code which detects that highmem is
      in use but unsupported due to dcache aliasing. However this code was
      ineffective because it was being run before the caches are probed,
      meaning that cpu_has_dc_aliases would always evaluate to false (unless a
      platform overrides it to a compile-time constant) and the detection of
      the unsupported case is never triggered. The kernel would then go on to
      attempt to use highmem & either hit coherency issues or trigger the
      BUG_ON in flush_kernel_dcache_page().
      
      Fix this by running paging_init() later than cpu_cache_init(), such that
      the cpu_has_dc_aliases macro will evaluate correctly & the unsupported
      highmem case will be detected successfully.
      
      This then leads to a formerly hidden issue in that
      mem_init_free_highmem() will attempt to free all highmem pages, even
      though we're avoiding use of them & don't have valid page structs for
      them. This leads to an invalid pointer dereference & a TLB exception.
      Avoid this by skipping the loop in mem_init_free_highmem() if
      cpu_has_dc_aliases evaluates true.
      Signed-off-by: NPaul Burton <paul.burton@imgtec.com>
      Cc: Rabin Vincent <rabinv@axis.com>
      Cc: Matt Redfearn <matt.redfearn@imgtec.com>
      Cc: Jerome Marchand <jmarchan@redhat.com>
      Cc: Alexander Sverdlin <alexander.sverdlin@gmail.com>
      Cc: Aurelien Jarno <aurelien@aurel32.net>
      Cc: Jaedon Shin <jaedon.shin@gmail.com>
      Cc: Toshi Kani <toshi.kani@hpe.com>
      Cc: James Hogan <james.hogan@imgtec.com>
      Cc: Sergey Ryazanov <ryazanov.s.a@gmail.com>
      Cc: Jonas Gorski <jogo@openwrt.org>
      Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/14184/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      058effe7
    • P
      MIPS: Malta: Fix IOCU disable switch read for MIPS64 · 305723ab
      Paul Burton 提交于
      Malta boards used with CPU emulators feature a switch to disable use of
      an IOCU. Software has to check this switch & ignore any present IOCU if
      the switch is closed. The read used to do this was unsafe for 64 bit
      kernels, as it simply casted the address 0xbf403000 to a pointer &
      dereferenced it. Whilst in a 32 bit kernel this would access kseg1, in a
      64 bit kernel this attempts to access xuseg & results in an address
      error exception.
      
      Fix by accessing a correctly formed ckseg1 address generated using the
      CKSEG1ADDR macro.
      
      Whilst modifying this code, define the name of the register and the bit
      we care about within it, which indicates whether PCI DMA is routed to
      the IOCU or straight to DRAM. The code previously checked that bit 0 was
      also set, but the least significant 7 bits of the CONFIG_GEN0 register
      contain the value of the MReqInfo signal provided to the IOCU OCP bus,
      so singling out bit 0 makes little sense & that part of the check is
      dropped.
      Signed-off-by: NPaul Burton <paul.burton@imgtec.com>
      Fixes: b6d92b4a ("MIPS: Add option to disable software I/O coherency.")
      Cc: Matt Redfearn <matt.redfearn@imgtec.com>
      Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/14187/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      305723ab
    • P
      MIPS: Fix BUILD_ROLLBACK_PROLOGUE for microMIPS · 1eefcbc8
      Paul Burton 提交于
      When the kernel is built for microMIPS, branches targets need to be
      known to be microMIPS code in order to result in bit 0 of the PC being
      set. The branch target in the BUILD_ROLLBACK_PROLOGUE macro was simply
      the end of the macro, which may be pointing at padding rather than at
      code. This results in recent enough GNU linkers complaining like so:
      
          mips-img-linux-gnu-ld: arch/mips/built-in.o: .text+0x3e3c: Unsupported branch between ISA modes.
          mips-img-linux-gnu-ld: final link failed: Bad value
          Makefile:936: recipe for target 'vmlinux' failed
          make: *** [vmlinux] Error 1
      
      Fix this by changing the branch target to be the start of the
      appropriate handler, skipping over any padding.
      Signed-off-by: NPaul Burton <paul.burton@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/14019/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      1eefcbc8
    • P
      MIPS: clear execution hazard after changing FTLB enable · 67acd8d5
      Paul Burton 提交于
      On current P-series cores from Imagination the FTLB can be enabled or
      disabled via a bit in the Config6 register, and an execution hazard is
      created by changing the value of bit. The ftlb_disable function already
      cleared that hazard but that does no good for other callers. Clear the
      hazard in the set_ftlb_enable function that creates it, and only for the
      cores where it applies.
      
      This has the effect of reverting c982c6d6 ("MIPS: cpu-probe: Remove
      cp0 hazard barrier when enabling the FTLB") which was incorrect.
      Signed-off-by: NPaul Burton <paul.burton@imgtec.com>
      Fixes: c982c6d6 ("MIPS: cpu-probe: Remove cp0 hazard barrier when enabling the FTLB")
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/14023/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      67acd8d5
    • P
      MIPS: Configure FTLB after probing TLB sizes from config4 · ebd0e0f5
      Paul Burton 提交于
      On some cores (proAptiv, P5600) we make use of the sizes of the TLBs
      to determine the desired FTLB:VTLB write ratio. However set_ftlb_enable
      & thus calculate_ftlb_probability is called before decode_config4. This
      results in us calculating a probability based on zero sizes, and we end
      up setting FTLBP=3 for a 3:1 FTLB:VTLB write ratio in all cases. This
      will make abysmal use of the available FTLB resources in the affected
      cores.
      
      Fix this by configuring the FTLB probability after having decoded
      config4. However we do need to have enabled the FTLB before that point
      such that fields in config4 actually reflect that an FTLB is present. So
      set_ftlb_enable is now called twice, with flags indicating that it
      should configure the write probability only the second time.
      Signed-off-by: NPaul Burton <paul.burton@imgtec.com>
      Fixes: cf0a8aa0 ("MIPS: cpu-probe: Set the FTLB probability bit on supported cores")
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/14022/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      ebd0e0f5
    • P
      MIPS: Stop setting I6400 FTLBP · 72c70f01
      Paul Burton 提交于
      The FTLBP field in Config7 for the I6400 is intended as chicken bits for
      debugging rather than as a field that software actually makes use of.
      For best performance, FTLBP should be left at its default value of 0
      with all TLB writes hitting the FTLB by default.
      
      Additionally, since set_ftlb_enable is called from decode_configs before
      decode_config4 which determines the size of the TLBs, this was
      previously always setting FTLBP=3 for a 3:1 FTLB:VTLB write ratio which
      makes abysmal use of the available FTLB resources.
      
      This effectively reverts b0c4e1b79d8a ("MIPS: Set up FTLB probability
      for I6400").
      Signed-off-by: NPaul Burton <paul.burton@imgtec.com>
      Fixes: b0c4e1b79d8a ("MIPS: Set up FTLB probability for I6400")
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/14021/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      72c70f01
    • R
      MIPS: DEC: Avoid la pseudo-instruction in delay slots · 3021773c
      Ralf Baechle 提交于
      When expanding the la or dla pseudo-instruction in a delay slot the GNU
      assembler will complain should the pseudo-instruction expand to multiple
      actual instructions, since only the first of them will be in the delay
      slot leading to the pseudo-instruction being only partially executed if
      the branch is taken. Use of PTR_LA in the dec int-handler.S leads to
      such warnings:
      
        arch/mips/dec/int-handler.S: Assembler messages:
        arch/mips/dec/int-handler.S:149: Warning: macro instruction expanded into multiple instructions in a branch delay slot
        arch/mips/dec/int-handler.S:198: Warning: macro instruction expanded into multiple instructions in a branch delay slot
      
      Avoid this by open coding the PTR_LA macros.
      Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      3021773c
    • S
      MIPS: Octeon: mark GPIO controller node not populated after IRQ init. · 0a900553
      Steven J. Hill 提交于
      We clear the OF_POPULATED flag for the GPIO controller node on Octeon
      processors. Otherwise, none of the devices hanging on the GPIO lines
      are probed. The 'gpio-leds' driver on OCTEON failed to probe in addition
      to other devices on Cavium 71xx and 78xx development boards.
      
      Fixes: 15cc2ed6 ("of/irq: Mark initialised interrupt controllers as populated")
      Signed-off-by: NSteven J. Hill <steven.hill@cavium.com>
      Tested-by: NAaro Koskinen <aaro.koskinen@iki.fi>
      Cc: David Daney <david.daney@cavium.com>
      Cc: Rob Herring <robh@kernel.org>
      Cc: linux-mips@linux-mips.org
      Cc: devicetree@vger.kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/14091/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      0a900553
    • M
      MIPS: uprobes: fix use of uninitialised variable · ca86c9ef
      Marcin Nowakowski 提交于
      arch_uprobe_pre_xol needs to emulate a branch if a branch instruction
      has been replaced with a breakpoint, but in fact an uninitialised local
      variable was passed to the emulator routine instead of the original
      instruction
      Signed-off-by: NMarcin Nowakowski <marcin.nowakowski@imgtec.com>
      Fixes: 40e084a5 ('MIPS: Add uprobes support.')
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/14300/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      ca86c9ef
    • M
      MIPS: uprobes: remove incorrect set_orig_insn · ddabfa5c
      Marcin Nowakowski 提交于
      Generic kernel code implements a weak version of set_orig_insn that
      moves cached 'insn' from arch_uprobe to the original code location when
      the trap is removed.
      MIPS variant used arch_uprobe->orig_inst which was never initialised
      properly, so this code only inserted a nop instead of the original
      instruction. With that change orig_inst can also be safely removed.
      Signed-off-by: NMarcin Nowakowski <marcin.nowakowski@imgtec.com>
      Fixes: 40e084a5 ('MIPS: Add uprobes support.')
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/14299/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      ddabfa5c
    • M
      MIPS: fix uretprobe implementation · db06068a
      Marcin Nowakowski 提交于
      arch_uretprobe_hijack_return_addr should replace the return address for
      a call with a trampoline address.
      Signed-off-by: NMarcin Nowakowski <marcin.nowakowski@imgtec.com>
      Fixes: 40e084a5 ('MIPS: Add uprobes support.')
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/14298/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      db06068a
    • M
      MIPS: smp-cps: Avoid BUG() when offlining pre-r6 CPUs · 6ca8ac77
      Matt Redfearn 提交于
      Commit 0d2808f3 ("MIPS: smp-cps: Add support for CPU hotplug of
      MIPSr6 processors") added a call to mips_cm_lock_other in order to lock
      the CPC in CPUs containing a version 3 or higher Coherence Manager,
      which use the general CM core other register, where previous CMs had a
      dedicated core other register for the CPC.
      
      A kernel BUG() is triggered, however, if mips_cm_lock_other is called
      with a VP other than 0 on a CPU with CM < 3, a condition introduced by
      0d2808f3.
      
      Avoid the BUG() by always locking VP0 when locking the CPC, since the
      required register, cpc_stat_conf, is shared by all vps in a core.
      
      Fixes: 0d2808f3 ("MIPS: smp-cps: Add support for CPU hotplug...)
      Signed-off-by: NMatt Redfearn <matt.redfearn@imgtec.com>
      Cc: Qais Yousef <qsyousef@gmail.com>
      Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
      Cc: James Hogan <james.hogan@imgtec.com>
      Cc: Paul Burton <paul.burton@imgtec.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/14297/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      6ca8ac77
  4. 25 9月, 2016 2 次提交
  5. 24 9月, 2016 1 次提交
    • P
      MIPS: Fix pre-r6 emulation FPU initialisation · 7e956304
      Paul Burton 提交于
      In the mipsr2_decoder() function, used to emulate pre-MIPSr6
      instructions that were removed in MIPSr6, the init_fpu() function is
      called if a removed pre-MIPSr6 floating point instruction is the first
      floating point instruction used by the task. However, init_fpu()
      performs varous actions that rely upon not being migrated. For example
      in the most basic case it sets the coprocessor 0 Status.CU1 bit to
      enable the FPU & then loads FP register context into the FPU registers.
      If the task were to migrate during this time, it may end up attempting
      to load FP register context on a different CPU where it hasn't set the
      CU1 bit, leading to errors such as:
      
          do_cpu invoked from kernel context![#2]:
          CPU: 2 PID: 7338 Comm: fp-prctl Tainted: G      D         4.7.0-00424-g49b0c82 #2
          task: 838e4000 ti: 88d38000 task.ti: 88d38000
          $ 0   : 00000000 00000001 ffffffff 88d3fef8
          $ 4   : 838e4000 88d38004 00000000 00000001
          $ 8   : 3400fc01 801f8020 808e9100 24000000
          $12   : dbffffff 807b69d8 807b0000 00000000
          $16   : 00000000 80786150 00400fc4 809c0398
          $20   : 809c0338 0040273c 88d3ff28 808e9d30
          $24   : 808e9d30 00400fb4
          $28   : 88d38000 88d3fe88 00000000 8011a2ac
          Hi    : 0040273c
          Lo    : 88d3ff28
          epc   : 80114178 _restore_fp+0x10/0xa0
          ra    : 8011a2ac mipsr2_decoder+0xd5c/0x1660
          Status: 1400fc03	KERNEL EXL IE
          Cause : 1080002c (ExcCode 0b)
          PrId  : 0001a920 (MIPS I6400)
          Modules linked in:
          Process fp-prctl (pid: 7338, threadinfo=88d38000, task=838e4000, tls=766527d0)
          Stack : 00000000 00000000 00000000 88d3fe98 00000000 00000000 809c0398 809c0338
          	  808e9100 00000000 88d3ff28 00400fc4 00400fc4 0040273c 7fb69e18 004a0000
          	  004a0000 004a0000 7664add0 8010de18 00000000 00000000 88d3fef8 88d3ff28
          	  808e9100 00000000 766527d0 8010e534 000c0000 85755000 8181d580 00000000
          	  00000000 00000000 004a0000 00000000 766527d0 7fb69e18 004a0000 80105c20
          	  ...
          Call Trace:
          [<80114178>] _restore_fp+0x10/0xa0
          [<8011a2ac>] mipsr2_decoder+0xd5c/0x1660
          [<8010de18>] do_ri+0x90/0x6b8
          [<80105c20>] ret_from_exception+0x0/0x10
      
      Fix this by disabling preemption around the call to init_fpu(), ensuring
      that it starts & completes on one CPU.
      Signed-off-by: NPaul Burton <paul.burton@imgtec.com>
      Fixes: b0a668fb ("MIPS: kernel: mips-r2-to-r6-emul: Add R2 emulator for MIPS R6")
      Cc: linux-mips@linux-mips.org
      Cc: stable@vger.kernel.org # v4.0+
      Patchwork: https://patchwork.linux-mips.org/patch/14305/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      7e956304
  6. 21 9月, 2016 1 次提交
    • J
      MIPS: vDSO: Fix Malta EVA mapping to vDSO page structs · 554af0c3
      James Hogan 提交于
      The page structures associated with the vDSO pages in the kernel image
      are calculated using virt_to_page(), which uses __pa() under the hood to
      find the pfn associated with the virtual address. The vDSO data pointers
      however point to kernel symbols, so __pa_symbol() should really be used
      instead.
      
      Since there is no equivalent to virt_to_page() which uses __pa_symbol(),
      fix init_vdso_image() to work directly with pfns, calculated with
      __phys_to_pfn(__pa_symbol(...)).
      
      This issue broke the Malta Enhanced Virtual Addressing (EVA)
      configuration which has a non-default implementation of __pa_symbol().
      This is because it uses a physical alias so that the kernel executes
      from KSeg0 (VA 0x80000000 -> PA 0x00000000), while RAM is provided to
      the kernel in the KUSeg range (VA 0x00000000 -> PA 0x80000000) which
      uses the same underlying RAM.
      
      Since there are no page structures associated with the low physical
      address region, some arbitrary kernel memory would be interpreted as a
      page structure for the vDSO pages and badness ensues.
      
      Fixes: ebb5e78c ("MIPS: Initial implementation of a VDSO")
      Signed-off-by: NJames Hogan <james.hogan@imgtec.com>
      Cc: Leonid Yegoshin <leonid.yegoshin@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Cc: <stable@vger.kernel.org> # 4.4.x-
      Patchwork: https://patchwork.linux-mips.org/patch/14229/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      554af0c3
  7. 20 9月, 2016 1 次提交
  8. 19 9月, 2016 3 次提交
    • A
      MIPS: Octeon: Fix platform bus probing · 8074d782
      Aaro Koskinen 提交于
      Commit 44a7185c ("of/platform: Add common method to populate
      default bus") added new arch_initcall of_platform_default_populate_init()
      that will override device_initcall octeon_publish_devices(). This broke
      many OCTEON boards as important devices are not getting probed anymore
      (e.g. on EdgeRouter Lite the USB mass storage/rootfs is missing).
      
      Fix by changing octeon_publish_devices() to arch_initcall.
      
      Fixes: 44a7185c ("of/platform: Add common method to populate default bus")
      Signed-off-by: NAaro Koskinen <aaro.koskinen@iki.fi>
      Acked-by: NRob Herring <robh@kernel.org>
      Cc: David Daney <ddaney@caviumnetworks.com>
      Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
      Cc: linux-mips@linux-mips.org
      Cc: devicetree@vger.kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/14041/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      8074d782
    • A
      MIPS: Octeon: mangle-port: fix build failure with VDSO code · 3312eca5
      Aaro Koskinen 提交于
      Commit 1685ddbe ("MIPS: Octeon: Changes to support readq()/writeq()
      usage.") added bitwise shift operations that assume that unsigned long
      is always 64-bits. This broke the build of VDSO code, as it gets compiled
      also in "faked" 32-bit mode. Althought the failing inline functions are
      never executed in 32-bit mode, they still need to pass the compilation.
      Fix by using 64-bit types explicitly.
      
      The patch fixes the following build failure:
      
        CC      arch/mips/vdso/gettimeofday-o32.o
      In file included from los/git/devel/linux/arch/mips/include/asm/io.h:32:0,
                       from los/git/devel/linux/arch/mips/include/asm/page.h:194,
                       from los/git/devel/linux/arch/mips/vdso/vdso.h:26,
                       from los/git/devel/linux/arch/mips/vdso/gettimeofday.c:11:
      los/git/devel/linux/arch/mips/include/asm/mach-cavium-octeon/mangle-port.h: In function '__should_swizzle_bits':
      los/git/devel/linux/arch/mips/include/asm/mach-cavium-octeon/mangle-port.h:19:40: error: right shift count >= width of type [-Werror=shift-count-overflow]
        unsigned long did = ((unsigned long)a >> 40) & 0xff;
                                              ^~
      
      Fixes: 1685ddbe ("MIPS: Octeon: Changes to support readq()/writeq() usage.")
      Signed-off-by: NAaro Koskinen <aaro.koskinen@iki.fi>
      Acked-by: NDavid Daney <ddaney@caviumnetworks.com>
      Cc: David Daney <david.daney@cavium.com>
      Cc: Steven J. Hill <steven.hill@cavium.com>
      Cc: Alex Smith <alex.smith@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/14039/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      3312eca5
    • M
      MIPS: Avoid a BUG warning during prctl(PR_SET_FP_MODE, ...) · b244614a
      Marcin Nowakowski 提交于
      cpu_has_fpu macro uses smp_processor_id() and is currently executed
      with preemption enabled, that triggers the warning at runtime.
      
      It is assumed throughout the kernel that if any CPU has an FPU, then all
      CPUs would have an FPU as well, so it is safe to perform the check with
      preemption enabled - change the code to use raw_ variant of the check to
      avoid the warning.
      Signed-off-by: NMarcin Nowakowski <marcin.nowakowski@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Cc: stable@vger.kernel.org  # 4.0+
      Patchwork: https://patchwork.linux-mips.org/patch/14125/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      b244614a
  9. 14 9月, 2016 1 次提交
  10. 13 9月, 2016 8 次提交
  11. 27 8月, 2016 1 次提交