1. 03 9月, 2015 3 次提交
  2. 26 8月, 2015 1 次提交
  3. 03 8月, 2015 2 次提交
    • 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
  4. 09 7月, 2015 1 次提交
  5. 22 6月, 2015 2 次提交
  6. 13 5月, 2015 1 次提交
  7. 08 4月, 2015 10 次提交
  8. 31 3月, 2015 2 次提交
    • J
      MIPS: Read CPU IRQ line that FDC to routed to · 8f7ff027
      James Hogan 提交于
      Read the CPU IRQ line reportedly used for the Fast Debug Channel (FDC)
      interrupt from the IntCtl register and store it in cp0_fdc_irq where
      platform implementations of the new weak platform function
      get_c0_fdc_int() can refer to it.
      
      [ralf@linux-mips.org: Fixed conflict.]
      Signed-off-by: NJames Hogan <james.hogan@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Cc: James Hogan <james.hogan@imgtec.com>
      Patchwork: https://patchwork.linux-mips.org/patch/9140/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      8f7ff027
    • J
      MIPS: Allow shared IRQ for timer & perf counter · 4a91d8fb
      James Hogan 提交于
      Before release 2 of the architecture there weren't separate interrupt
      pending bits for the local CPU interrupts (timer & perf counter
      overflow), so when they were connected to the same interrupt line the
      timer handler had to call the performance counter handler before knowing
      whether a timer interrupt was actually pending.
      
      Now another CPU local interrupt, for the Fast Debug Channel (FDC), can
      also be routed to an arbitrary interrupt line. It isn't scalable to keep
      adding cross-calls between handlers for these cases of shared interrupt
      lines, especially since the FDC could in theory share its interrupt line
      with the performance counter, timer, or both.
      
      Fortunately since release 2 of the architecture separate interrupt
      pending bits do exist in the Cause register. This allows local
      interrupts which share an interrupt line to have separate handlers using
      IRQF_SHARED. Unfortunately they can't easily have their own irqchip as
      there is no generic way to individually mask them.
      
      Enable this sharing to happen by removing the special case for when the
      perf count shares an IRQ with the timer. cp0_perfcount_irq and
      cp0_compare_irq can then be set to the same value with shared interrupt
      handlers registered for both of them.
      
      Pre-R2 code should be unaffected. cp0_perfcount_irq will always be -1
      and the timer handler will contnue to call into the perf counter
      handler.
      Signed-off-by: NJames Hogan <james.hogan@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/9131/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      4a91d8fb
  9. 28 3月, 2015 2 次提交
    • J
      MIPS: Clear [MSA]FPE CSR.Cause after notify_die() · 64bedffe
      James Hogan 提交于
      When handling floating point exceptions (FPEs) and MSA FPEs the Cause
      bits of the appropriate control and status register (FCSR for FPEs and
      MSACSR for MSA FPEs) are read and cleared before enabling interrupts,
      presumably so that it doesn't have to go through the pain of restoring
      those bits if the process is pre-empted, since writing those bits would
      cause another immediate exception while still in the kernel.
      
      The bits aren't normally ever restored again, since userland never
      expects to see them set.
      
      However for virtualisation it is necessary for the kernel to be able to
      restore these Cause bits, as the guest may have been interrupted in an
      FP exception handler but before it could read the Cause bits. This can
      be done by registering a die notifier, to get notified of the exception
      when such a value is restored, and if the PC was at the instruction
      which is used to restore the guest state, the handler can step over it
      and continue execution. The Cause bits can then remain set without
      causing further exceptions.
      
      For this to work safely a few changes are made:
      - __build_clear_fpe and __build_clear_msa_fpe no longer clear the Cause
        bits, and now return from exception level with interrupts disabled
        instead of enabled.
      - do_fpe() now clears the Cause bits and enables interrupts after
        notify_die() is called, so that the notifier can chose to return from
        exception without this happening.
      - do_msa_fpe() acts similarly, but now actually makes use of the second
        argument (msacsr) and calls notify_die() with the new DIE_MSAFP,
        allowing die notifiers to be informed of MSA FPEs too.
      Signed-off-by: NJames Hogan <james.hogan@imgtec.com>
      Acked-by: NRalf Baechle <ralf@linux-mips.org>
      Cc: Paul Burton <paul.burton@imgtec.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Gleb Natapov <gleb@kernel.org>
      Cc: linux-mips@linux-mips.org
      Cc: kvm@vger.kernel.org
      64bedffe
    • P
      MIPS: Ensure FCSR cause bits are clear after invoking FPU emulator · ad70c13a
      Paul Burton 提交于
      When running the emulator to handle an instruction that raised an FP
      unimplemented operation exception, the FCSR cause bits were being
      cleared. This is done to ensure that the kernel does not take an FP
      exception when later restoring FP context to registers. However, this
      was not being done when the emulator is invoked in response to a
      coprocessor unusable exception. This happens in 2 cases:
      
        - There is no FPU present in the system. In this case things were
          OK, since the FP context is never restored to hardware registers
          and thus no FP exception may be raised when restoring FCSR.
      
        - The FPU could not be configured to the mode required by the task.
          In this case it would be possible for the emulator to set cause
          bits which are later restored to hardware if the task migrates
          to a CPU whose associated FPU does support its mode requirements,
          or if the tasks FP mode requirements change.
      
      Consistently clear the cause bits after invoking the emulator, by moving
      the clearing to process_fpemu_return and ensuring this is always called
      before the tasks FP context is restored. This will make it easier to
      catch further paths invoking the emulator in future, as will be
      introduced in further patches.
      Signed-off-by: NPaul Burton <paul.burton@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/9165/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      ad70c13a
  10. 05 3月, 2015 1 次提交
  11. 17 2月, 2015 3 次提交
  12. 16 2月, 2015 1 次提交
  13. 12 2月, 2015 1 次提交
    • P
      MIPS,prctl: add PR_[GS]ET_FP_MODE prctl options for MIPS · 9791554b
      Paul Burton 提交于
      Userland code may be built using an ABI which permits linking to objects
      that have more restrictive floating point requirements. For example,
      userland code may be built to target the O32 FPXX ABI. Such code may be
      linked with other FPXX code, or code built for either one of the more
      restrictive FP32 or FP64. When linking with more restrictive code, the
      overall requirement of the process becomes that of the more restrictive
      code. The kernel has no way to know in advance which mode the process
      will need to be executed in, and indeed it may need to change during
      execution. The dynamic loader is the only code which will know the
      overall required mode, and so it needs to have a means to instruct the
      kernel to switch the FP mode of the process.
      
      This patch introduces 2 new options to the prctl syscall which provide
      such a capability. The FP mode of the process is represented as a
      simple bitmask combining a number of mode bits mirroring those present
      in the hardware. Userland can either retrieve the current FP mode of
      the process:
      
        mode = prctl(PR_GET_FP_MODE);
      
      or modify the current FP mode of the process:
      
        err = prctl(PR_SET_FP_MODE, new_mode);
      Signed-off-by: NPaul Burton <paul.burton@imgtec.com>
      Cc: Matthew Fortune <matthew.fortune@imgtec.com>
      Cc: Markos Chandras <markos.chandras@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/8899/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      9791554b
  14. 31 1月, 2015 1 次提交
    • J
      MIPS: traps: Fix inline asm ctc1 missing .set hardfloat · d76e9b9f
      James Hogan 提交于
      Commit 842dfc11 ("MIPS: Fix build with binutils 2.24.51+") in v3.18
      enabled -msoft-float and sprinkled ".set hardfloat" where necessary to
      use FP instructions. However it missed enable_restore_fp_context() which
      since v3.17 does a ctc1 with inline assembly, causing the following
      assembler errors on Mentor's 2014.05 toolchain:
      
      {standard input}: Assembler messages:
      {standard input}:2913: Error: opcode not supported on this processor: mips32r2 (mips32r2) `ctc1 $2,$31'
      scripts/Makefile.build:257: recipe for target 'arch/mips/kernel/traps.o' failed
      
      Fix that to use the new write_32bit_cp1_register() macro so that ".set
      hardfloat" is automatically added when -msoft-float is in use.
      
      Fixes 842dfc11 ("MIPS: Fix build with binutils 2.24.51+")
      Signed-off-by: NJames Hogan <james.hogan@imgtec.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Paul Burton <paul.burton@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Cc: <stable@vger.kernel.org> # 3.18+, depends on "MIPS: mipsregs.h: Add write_32bit_cp1_register()"
      Patchwork: https://patchwork.linux-mips.org/patch/9173/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      d76e9b9f
  15. 24 11月, 2014 4 次提交
  16. 02 8月, 2014 5 次提交