1. 03 9月, 2015 18 次提交
    • P
      MIPS: Use common FP sigcontext code for O32 compat · d02a40af
      Paul Burton 提交于
      Make use of the common FP sigcontext code for O32 binaries running on
      MIPS64 kernels now that it is taking appropriate offsets into struct
      sigcontext(32) from struct mips_abi.
      
      [ralf@linux-mips.org: Fixed reject.]
      Signed-off-by: NPaul Burton <paul.burton@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Cc: Guenter Roeck <linux@roeck-us.net>
      Cc: Matthew Fortune <matthew.fortune@imgtec.com>
      Cc: Leonid Yegoshin <Leonid.Yegoshin@imgtec.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: linux-kernel@vger.kernel.org
      Cc: Richard Weinberger <richard@nod.at>
      Cc: James Hogan <james.hogan@imgtec.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Markos Chandras <markos.chandras@imgtec.com>
      Cc: Manuel Lauss <manuel.lauss@gmail.com>
      Cc: Maciej W. Rozycki <macro@codesourcery.com>
      Patchwork: https://patchwork.linux-mips.org/patch/10792/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      d02a40af
    • P
      MIPS: Skip odd double FP registers when copying FP32 sigcontext · 6f0aba63
      Paul Burton 提交于
      When a task uses 32 bit floating point, the odd indexed 32b register
      values are stored in bits 63:32 of the preceding even indexed 64b
      FP register field in saved context. Thus there is no point in
      preserving the odd indexed 64b register fields since they hold no
      valid context. This patch will cause them to be skipped, as is
      already done in arch/mips/kernel/signal32.c.
      
      [ralf@linux-mips.org: Fixed reject.]
      Signed-off-by: NPaul Burton <paul.burton@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Cc: Guenter Roeck <linux@roeck-us.net>
      Cc: Matthew Fortune <matthew.fortune@imgtec.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: linux-kernel@vger.kernel.org
      Cc: Richard Weinberger <richard@nod.at>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Maciej W. Rozycki <macro@codesourcery.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Patchwork: https://patchwork.linux-mips.org/patch/10791/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      6f0aba63
    • P
      MIPS: Move FP usage checks into protected_{save, restore}_fp_context · 64243c2a
      Paul Burton 提交于
      In preparation for sharing protected_{save,restore}_fp_context with
      compat ABIs, move the FP usage checks into said functions. This will
      both enable that code to be shared, and allow for extensions of it in
      further patches to also be shared.
      Signed-off-by: NPaul Burton <paul.burton@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Cc: Guenter Roeck <linux@roeck-us.net>
      Cc: Matthew Fortune <matthew.fortune@imgtec.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: linux-kernel@vger.kernel.org
      Cc: Richard Weinberger <richard@nod.at>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Maciej W. Rozycki <macro@codesourcery.com>
      Patchwork: https://patchwork.linux-mips.org/patch/10790/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      64243c2a
    • P
      MIPS: Use struct mips_abi offsets to save FP context · 2db9ca0a
      Paul Burton 提交于
      When saving FP state to struct sigcontext, make use of the offsets
      provided by struct mips_abi to obtain appropriate addresses for the
      sc_fpregs & sc_fpc_csr fields of the sigcontext. This is done only for
      the native struct sigcontext in this patch (ie. for O32 in CONFIG_32BIT
      kernels or for N64 in CONFIG_64BIT kernels) but is done in preparation
      for sharing this code with compat ABIs in further patches.
      Signed-off-by: NPaul Burton <paul.burton@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Cc: Guenter Roeck <linux@roeck-us.net>
      Cc: Matthew Fortune <matthew.fortune@imgtec.com>
      Cc: Leonid Yegoshin <Leonid.Yegoshin@imgtec.com>
      Cc: linux-kernel@vger.kernel.org
      Cc: Richard Weinberger <richard@nod.at>
      Cc: James Hogan <james.hogan@imgtec.com>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Markos Chandras <markos.chandras@imgtec.com>
      Cc: Manuel Lauss <manuel.lauss@gmail.com>
      Cc: Maciej W. Rozycki <macro@codesourcery.com>
      Patchwork: https://patchwork.linux-mips.org/patch/10789/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      2db9ca0a
    • P
      MIPS: Add offsets to sigcontext FP fields to struct mips_abi · 77856100
      Paul Burton 提交于
      Add fields to struct mips_abi, which holds information regarding the
      kernel-userland ABI regarding signals, to specify the offsets to the FP
      related fields within the appropriate variant of struct sigcontext.
      Signed-off-by: NPaul Burton <paul.burton@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Cc: Guenter Roeck <linux@roeck-us.net>
      Cc: Matthew Fortune <matthew.fortune@imgtec.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: linux-kernel@vger.kernel.org
      Cc: Richard Weinberger <richard@nod.at>
      Cc: James Hogan <james.hogan@imgtec.com>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Maciej W. Rozycki <macro@codesourcery.com>
      Patchwork: https://patchwork.linux-mips.org/patch/10788/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      77856100
    • P
      MIPS: Simplify EVA FP context handling code · 689ee856
      Paul Burton 提交于
      The protected_{save,restore}_fp_context functions had effectively
      different implementations for EVA. Simplify & unify the code somewhat
      such that EVA configurations simply guarantee the FPU-not-owned path
      through the standard code path.
      Signed-off-by: NPaul Burton <paul.burton@imgtec.com>
      Cc: Markos Chandras <markos.chandras@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Cc: Guenter Roeck <linux@roeck-us.net>
      Cc: Matthew Fortune <matthew.fortune@imgtec.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: linux-kernel@vger.kernel.org
      Cc: Richard Weinberger <richard@nod.at>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Maciej W. Rozycki <macro@codesourcery.com>
      Patchwork: https://patchwork.linux-mips.org/patch/10787/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      689ee856
    • V
      MIPS: cevt-txx9: Migrate to new 'set-state' interface · d199da55
      Viresh Kumar 提交于
      Migrate cevt-txx9 driver to the new 'set-state' interface provided by
      clockevents core, the earlier 'set-mode' interface is marked obsolete
      now.
      
      This also enables us to implement callbacks for new states of clockevent
      devices, for example: ONESHOT_STOPPED.
      Signed-off-by: NViresh Kumar <viresh.kumar@linaro.org>
      Cc: Deng-Cheng Zhu <dengcheng.zhu@imgtec.com>
      Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
      Cc: linux-mips@linux-mips.org
      Cc: linaro-kernel@lists.linaro.org
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Viresh Kumar <viresh.kumar@linaro.org>
      Patchwork: https://patchwork.linux-mips.org/patch/10607/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      d199da55
    • V
      MIPS: cevt-sb1250: Migrate to new 'set-state' interface · 57e148ca
      Viresh Kumar 提交于
      Migrate cevt-rsb1250 driver to the new 'set-state' interface provided by
      clockevents core, the earlier 'set-mode' interface is marked obsolete
      now.
      
      This also enables us to implement callbacks for new states of clockevent
      devices, for example: ONESHOT_STOPPED.
      Signed-off-by: NViresh Kumar <viresh.kumar@linaro.org>
      Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
      Cc: linux-mips@linux-mips.org
      Cc: linaro-kernel@lists.linaro.org
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Patchwork: https://patchwork.linux-mips.org/patch/10606/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      57e148ca
    • V
      MIPS: cevt-r4k: Migrate to new 'set-state' interface · 877c61dc
      Viresh Kumar 提交于
      Migrate cevt-4k driver to the new 'set-state' interface provided by
      clockevents core, the earlier 'set-mode' interface is marked obsolete
      now.
      
      This also enables us to implement callbacks for new states of clockevent
      devices, for example: ONESHOT_STOPPED.
      
      We weren't doing anything in the ->set_mode() callback. So, this patch
      doesn't provide any set-state callbacks.
      Signed-off-by: NViresh Kumar <viresh.kumar@linaro.org>
      Cc: James Hogan <james.hogan@imgtec.com>
      Cc: Andrew Bresticker <abrestic@chromium.org>
      Cc: Qais Yousef <qais.yousef@imgtec.com>
      Cc: Jason Cooper <jason@lakedaemon.net>
      Cc: Leonid Yegoshin <Leonid.Yegoshin@imgtec.com>
      Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
      Cc: linux-mips@linux-mips.org
      Cc: linaro-kernel@lists.linaro.org
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Patchwork: https://patchwork.linux-mips.org/patch/10605/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      877c61dc
    • V
      MIPS: cevt-gt641xx: Migrate to new 'set-state' interface · c88f2fb4
      Viresh Kumar 提交于
      Migrate cevt-gt641xx driver to the new 'set-state' interface provided by
      clockevents core, the earlier 'set-mode' interface is marked obsolete
      now.
      
      This also enables us to implement callbacks for new states of clockevent
      devices, for example: ONESHOT_STOPPED.
      Signed-off-by: NViresh Kumar <viresh.kumar@linaro.org>
      Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
      Cc: linux-mips@linux-mips.org
      Cc: linaro-kernel@lists.linaro.org
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Patchwork: https://patchwork.linux-mips.org/patch/10604/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      c88f2fb4
    • V
      MIPS: cevt-ds1287: Migrate to new 'set-state' interface · 9f95618f
      Viresh Kumar 提交于
      Migrate cevt-ds1287 driver to the new 'set-state' interface provided by
      clockevents core, the earlier 'set-mode' interface is marked obsolete
      now.
      
      This also enables us to implement callbacks for new states of clockevent
      devices, for example: ONESHOT_STOPPED.
      Signed-off-by: NViresh Kumar <viresh.kumar@linaro.org>
      Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
      Cc: linux-mips@linux-mips.org
      Cc: linaro-kernel@lists.linaro.org
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Patchwork: https://patchwork.linux-mips.org/patch/10603/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      9f95618f
    • V
      MIPS: cevt-bcm1480: Migrate to new 'set-state' interface · 1edf907a
      Viresh Kumar 提交于
      Migrate cevt-bcm1480 driver to the new 'set-state' interface provided by
      clockevents core, the earlier 'set-mode' interface is marked obsolete
      now.
      
      This also enables us to implement callbacks for new states of clockevent
      devices, for example: ONESHOT_STOPPED.
      
      Read operation on R_SCD_TIMER_CFG and R_SCD_TIMER_INIT registers isn't
      performed now for many modes as there returned values aren't used.
      Signed-off-by: NViresh Kumar <viresh.kumar@linaro.org>
      Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
      Cc: linux-mips@linux-mips.org
      Cc: linaro-kernel@lists.linaro.org
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Patchwork: https://patchwork.linux-mips.org/patch/10602/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      1edf907a
    • R
    • J
      MIPS: Probe for small (1KiB) page support · aaa7be48
      James Hogan 提交于
      Probe Config3 for small page support. This will be useful to give clues
      as to whether the PageGrain register exists.
      Signed-off-by: NJames Hogan <james.hogan@imgtec.com>
      Cc: Maciej W. Rozycki <macro@linux-mips.org>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/10722/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      aaa7be48
    • J
      MIPS: Refactor dumping of TLB registers for r3k/r4k · 3c865dd9
      James Hogan 提交于
      The TLB registers are dumped in a couble of places:
       - sysrq_tlbdump_single() - when dumping TLB state.
       - do_mcheck() - in response to a machine check error.
      
      The main TLB registers also differ between r3k and r4k, but r4k appears
      to be assumed.
      
      Refactor this code into a dump_tlb_regs() function, implemented for both
      r3k and r4k, and used by both of the above functions.
      
      Fixes: d1e9a4f5 ("MIPS: Add SysRq operation to dump TLBs on all CPUs")
      Suggested-by: NMaciej W. Rozycki <macro@linux-mips.org>
      Signed-off-by: NJames Hogan <james.hogan@imgtec.com>
      Cc: Maciej W. Rozycki <macro@linux-mips.org>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/10721/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      3c865dd9
    • L
      MIPS: MSA unaligned memory access support · e4aa1f15
      Leonid Yegoshin 提交于
      The MSA architecture specification allows for hardware to not implement
      unaligned vector memory accesses in some or all cases. A typical example
      of this is the I6400 core which does not implement unaligned vector
      memory access when the memory crosses a page boundary. The architecture
      also requires that such memory accesses complete successfully as far as
      userland is concerned, so the kernel is required to emulate them.
      
      This patch implements support for emulating unaligned MSA ld & st
      instructions by copying between the user memory & the tasks FP context
      in struct thread_struct, updating hardware registers from there as
      appropriate in order to avoid saving & restoring the entire vector
      context for each unaligned memory access.
      
      Tested both using an I6400 CPU and with a QEMU build hacked to produce
      AdEL exceptions for unaligned vector memory accesses.
      
      [paul.burton@imgtec.com:
        - Remove #ifdef's
        - Move msa_op into enum major_op rather than #define
        - Replace msa_{to,from}_wd with {read,write}_msa_wr_{b,h,w,l} and the
          format-agnostic wrappers, removing the custom endian mangling for
          big endian systems.
        - Restructure the msa_op case in emulate_load_store_insn to share
          more code between the load & store cases.
        - Avoid the need for a temporary union fpureg on the stack by simply
          reusing the already suitably aligned context in struct
          thread_struct.
        - Use sizeof(*fpr) rather than hardcoding 16 as the size for user
          memory checks & copies.
        - Stop recalculating the address of the unaligned vector memory access
          and rely upon the value read from BadVAddr as we do for other
          unaligned memory access instructions.
        - Drop the now unused val8 & val16 fields in union fpureg.
        - Rewrite commit message.
        - General formatting cleanups.]
      Signed-off-by: NPaul Burton <paul.burton@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Cc: Leonid Yegoshin <Leonid.Yegoshin@imgtec.com>
      Cc: Huacai Chen <chenhc@lemote.com>
      Cc: Maciej W. Rozycki <macro@linux-mips.org>
      Cc: linux-kernel@vger.kernel.org
      Cc: Jie Chen <chenj@lemote.com>
      Cc: Markos Chandras <markos.chandras@imgtec.com>
      Patchwork: https://patchwork.linux-mips.org/patch/10573/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      e4aa1f15
    • P
      MIPS: Introduce accessors for MSA vector registers · 6b35e114
      Paul Burton 提交于
      Introduce accessor functions allowing the kernel to access arbitrary
      vector registers using an arbitrary data format. The accessors are
      implemented in assembly, using macros to avoid massive duplication, in
      order to make use of the existing support for MSA with & without
      toolchain support. The accessors will be used in a later patch.
      Signed-off-by: NPaul Burton <paul.burton@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Cc: Leonid Yegoshin <Leonid.Yegoshin@imgtec.com>
      Cc: linux-kernel@vger.kernel.org
      Cc: James Hogan <james.hogan@imgtec.com>
      Cc: Markos Chandras <markos.chandras@imgtec.com>
      Cc: Manuel Lauss <manuel.lauss@gmail.com>
      Patchwork: https://patchwork.linux-mips.org/patch/10572/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      6b35e114
    • B
      MIPS: Remove "weak" from get_c0_compare_int() declaration · ec0b9d35
      Bjorn Helgaas 提交于
      Weak header file declarations are error-prone because they make every
      definition weak, and the linker chooses one based on link order (see
      10629d71 ("PCI: Remove __weak annotation from pcibios_get_phb_of_node
      decl")).
      
      get_c0_compare_int() is defined in several files.  Each definition is weak,
      so I assume Kconfig prevents two or more from being included.  The caller
      contains default code used when get_c0_compare_int() isn't defined at all.
      
      Add a weak get_c0_compare_int() definition with the default code and remove
      the weak annotation from the declaration.
      
      Then the platform implementations will be strong and will override the weak
      default.  If multiple platforms are ever configured in, we'll get a link
      error instead of calling a random platform's implementation.
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      Reviewed-by: NJames Hogan <james.hogan@imgtec.com>
      Cc: Andrew Bresticker <abrestic@chromium.org>
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/10686/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      ec0b9d35
  2. 26 8月, 2015 14 次提交
  3. 18 8月, 2015 1 次提交
    • R
      MIPS: Fix LLVM build issue. · 158d3b2a
      Ralf Baechle 提交于
      Matthew Fortune <Matthew.Fortune@imgtec.com> reports:
      
      The genex.S file appears to mix the case of a macro between its definition and
      use. A cut down example of this is below. The macro __build_clear_none has
      lower case 'build' but ends up being instantiated with upper case BUILD. Can
      this be fixed on master. It has been picked up by the LLVM integrated assembler
      which is currently case sensitive. We are likely to fix the assembler as well
      but the code is currently inconsistent in the kernel.
      
       .macro __build_clear_none
       .endm
      
       .macro __BUILD_HANDLER exception handler clear verbose ext
       .align 5
       .globl handle_\exception; .align 2; .type handle_\exception, @function; .ent
      handle_\exception, 0; handle_\exception: .frame $29, 184, $29
       .set noat
       .globl handle_\exception\ext; .type handle_\exception\ext, @function;
      handle_\exception\ext:
       __BUILD_clear_\clear
       .endm
      
       .macro BUILD_HANDLER exception handler clear verbose
       __BUILD_HANDLER \exception \handler \clear \verbose _int
       .endm
      
      BUILD_HANDLER ftlb ftlb none silent
      Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      Reported-by: NMatthew Fortune <Matthew.Fortune@imgtec.com>
      158d3b2a
  4. 16 8月, 2015 1 次提交
  5. 07 8月, 2015 1 次提交
    • A
      signal: fix information leak in copy_siginfo_from_user32 · 3c00cb5e
      Amanieu d'Antras 提交于
      This function can leak kernel stack data when the user siginfo_t has a
      positive si_code value.  The top 16 bits of si_code descibe which fields
      in the siginfo_t union are active, but they are treated inconsistently
      between copy_siginfo_from_user32, copy_siginfo_to_user32 and
      copy_siginfo_to_user.
      
      copy_siginfo_from_user32 is called from rt_sigqueueinfo and
      rt_tgsigqueueinfo in which the user has full control overthe top 16 bits
      of si_code.
      
      This fixes the following information leaks:
      x86:   8 bytes leaked when sending a signal from a 32-bit process to
             itself. This leak grows to 16 bytes if the process uses x32.
             (si_code = __SI_CHLD)
      x86:   100 bytes leaked when sending a signal from a 32-bit process to
             a 64-bit process. (si_code = -1)
      sparc: 4 bytes leaked when sending a signal from a 32-bit process to a
             64-bit process. (si_code = any)
      
      parsic and s390 have similar bugs, but they are not vulnerable because
      rt_[tg]sigqueueinfo have checks that prevent sending a positive si_code
      to a different process.  These bugs are also fixed for consistency.
      Signed-off-by: NAmanieu d'Antras <amanieu@gmail.com>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Russell King <rmk@arm.linux.org.uk>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Chris Metcalf <cmetcalf@ezchip.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      3c00cb5e
  6. 03 8月, 2015 5 次提交
    • J
      MIPS: Replace add and sub instructions in relocate_kernel.S with addiu · a4504755
      James Cowgill 提交于
      Fixes the assembler errors generated when compiling a MIPS R6 kernel with
      CONFIG_KEXEC on, by replacing the offending add and sub instructions with
      addiu instructions.
      
      Build errors:
      arch/mips/kernel/relocate_kernel.S: Assembler messages:
      arch/mips/kernel/relocate_kernel.S:27: Error: invalid operands `dadd $16,$16,8'
      arch/mips/kernel/relocate_kernel.S:64: Error: invalid operands `dadd $20,$20,8'
      arch/mips/kernel/relocate_kernel.S:65: Error: invalid operands `dadd $18,$18,8'
      arch/mips/kernel/relocate_kernel.S:66: Error: invalid operands `dsub $22,$22,1'
      scripts/Makefile.build:294: recipe for target 'arch/mips/kernel/relocate_kernel.o' failed
      Signed-off-by: NJames Cowgill <James.Cowgill@imgtec.com>
      Cc: <stable@vger.kernel.org> # 4.0+
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/10558/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      a4504755
    • J
      MIPS: show_stack: Fix stack trace with EVA · 1e77863a
      James Hogan 提交于
      The show_stack() function deals exclusively with kernel contexts, but if
      it gets called in user context with EVA enabled, show_stacktrace() will
      attempt to access the stack using EVA accesses, which will either read
      other user mapped data, or more likely cause an exception which will be
      handled by __get_user().
      
      This is easily reproduced using SysRq t to show all task states, which
      results in the following stack dump output:
      
       Stack : (Bad stack address)
      
      Fix by setting the current user access mode to kernel around the call to
      show_stacktrace(). This causes __get_user() to use normal loads to read
      the kernel stack.
      
      Now we get the correct output, like this:
      
       Stack : 00000000 80168960 00000000 004a0000 00000000 00000000 8060016c 1f3abd0c
                 1f172cd8 8056f09c 7ff1e450 8014fc3c 00000001 806dd0b0 0000001d 00000002
                 1f17c6a0 1f17c804 1f17c6a0 8066f6e0 00000000 0000000a 00000000 00000000
                 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
                 00000000 00000000 00000000 00000000 00000000 0110e800 1f3abd6c 1f17c6a0
                 ...
      Signed-off-by: NJames Hogan <james.hogan@imgtec.com>
      Cc: Markos Chandras <markos.chandras@imgtec.com>
      Cc: Leonid Yegoshin <leonid.yegoshin@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Cc: <stable@vger.kernel.org> # 3.15+
      Patchwork: https://patchwork.linux-mips.org/patch/10778/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      1e77863a
    • J
      MIPS: do_mcheck: Fix kernel code dump with EVA · 55c723e1
      James Hogan 提交于
      If a machine check exception is raised in kernel mode, user context,
      with EVA enabled, then the do_mcheck handler will attempt to read the
      code around the EPC using EVA load instructions, i.e. as if the reads
      were from user mode. This will either read random user data if the
      process has anything mapped at the same address, or it will cause an
      exception which is handled by __get_user, resulting in this output:
      
       Code: (Bad address in epc)
      
      Fix by setting the current user access mode to kernel if the saved
      register context indicates the exception was taken in kernel mode. This
      causes __get_user to use normal loads to read the kernel code.
      Signed-off-by: NJames Hogan <james.hogan@imgtec.com>
      Cc: Markos Chandras <markos.chandras@imgtec.com>
      Cc: Leonid Yegoshin <leonid.yegoshin@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Cc: <stable@vger.kernel.org> # 3.15+
      Patchwork: https://patchwork.linux-mips.org/patch/10777/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      55c723e1
    • A
      MIPS: SMP: Don't increment irq_count multiple times for call function IPIs · 4ace6139
      Alex Smith 提交于
      The majority of SMP platforms handle their IPIs through do_IRQ()
      which calls irq_{enter/exit}(). When a call function IPI is received,
      smp_call_function_interrupt() is called which also calls
      irq_{enter,exit}(), meaning irq_count is raised twice.
      
      When tick broadcasting is used (which is implemented via a call
      function IPI), this incorrectly causes all CPU idle time on the core
      receiving broadcast ticks to be accounted as time spent servicing
      IRQs, as account_process_tick() will account as such if irq_count is
      greater than 1. This results in 100% CPU usage being reported on a
      core which receives its ticks via broadcast.
      
      This patch removes the SMP smp_call_function_interrupt() wrapper which
      calls irq_{enter,exit}(). Platforms which handle their IPIs through
      do_IRQ() now call generic_smp_call_function_interrupt() directly to
      avoid incrementing irq_count a second time. Platforms which don't
      (loongson, sgi-ip27, sibyte) call generic_smp_call_function_interrupt()
      wrapped in irq_{enter,exit}().
      Signed-off-by: NAlex Smith <alex.smith@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/10770/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      4ace6139
    • J
      MIPS: unaligned: Fix build error on big endian R6 kernels · 531a6d59
      James Cowgill 提交于
      Commit eeb53895 ("MIPS: unaligned: Prevent EVA instructions on kernel
      unaligned accesses") renamed the Load* and Store* defines in unaligned.c
      to _Load* and _Store* as part of its fix. One define was missed out which
      causes big endian R6 kernels to fail to build.
      
      arch/mips/kernel/unaligned.c:880:35:
      error: implicit declaration of function '_StoreDW'
       #define StoreDW(addr, value, res) _StoreDW(addr, value, res)
                                         ^
      Signed-off-by: NJames Cowgill <James.Cowgill@imgtec.com>
      Fixes: eeb53895 ("MIPS: unaligned: Prevent EVA instructions on kernel unaligned accesses")
      Cc: Markos Chandras <markos.chandras@imgtec.com>
      Cc: <stable@vger.kernel.org> # 4.0+
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/10575/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      531a6d59