1. 03 9月, 2015 3 次提交
    • 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
  2. 13 2月, 2015 1 次提交
    • A
      all arches, signal: move restart_block to struct task_struct · f56141e3
      Andy Lutomirski 提交于
      If an attacker can cause a controlled kernel stack overflow, overwriting
      the restart block is a very juicy exploit target.  This is because the
      restart_block is held in the same memory allocation as the kernel stack.
      
      Moving the restart block to struct task_struct prevents this exploit by
      making the restart_block harder to locate.
      
      Note that there are other fields in thread_info that are also easy
      targets, at least on some architectures.
      
      It's also a decent simplification, since the restart code is more or less
      identical on all architectures.
      
      [james.hogan@imgtec.com: metag: align thread_info::supervisor_stack]
      Signed-off-by: NAndy Lutomirski <luto@amacapital.net>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: David Miller <davem@davemloft.net>
      Acked-by: NRichard Weinberger <richard@nod.at>
      Cc: Richard Henderson <rth@twiddle.net>
      Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
      Cc: Matt Turner <mattst88@gmail.com>
      Cc: Vineet Gupta <vgupta@synopsys.com>
      Cc: Russell King <rmk@arm.linux.org.uk>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: Haavard Skinnemoen <hskinnemoen@gmail.com>
      Cc: Hans-Christian Egtvedt <egtvedt@samfundet.no>
      Cc: Steven Miao <realmz6@gmail.com>
      Cc: Mark Salter <msalter@redhat.com>
      Cc: Aurelien Jacquiot <a-jacquiot@ti.com>
      Cc: Mikael Starvik <starvik@axis.com>
      Cc: Jesper Nilsson <jesper.nilsson@axis.com>
      Cc: David Howells <dhowells@redhat.com>
      Cc: Richard Kuo <rkuo@codeaurora.org>
      Cc: "Luck, Tony" <tony.luck@intel.com>
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Cc: Michal Simek <monstr@monstr.eu>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Jonas Bonn <jonas@southpole.se>
      Cc: "James E.J. Bottomley" <jejb@parisc-linux.org>
      Cc: Helge Deller <deller@gmx.de>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Acked-by: Michael Ellerman <mpe@ellerman.id.au> (powerpc)
      Tested-by: Michael Ellerman <mpe@ellerman.id.au> (powerpc)
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Chen Liqin <liqin.linux@gmail.com>
      Cc: Lennox Wu <lennox.wu@gmail.com>
      Cc: Chris Metcalf <cmetcalf@ezchip.com>
      Cc: Guan Xuetao <gxt@mprc.pku.edu.cn>
      Cc: Chris Zankel <chris@zankel.net>
      Cc: Max Filippov <jcmvbkbc@gmail.com>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Guenter Roeck <linux@roeck-us.net>
      Signed-off-by: NJames Hogan <james.hogan@imgtec.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      f56141e3
  3. 24 11月, 2014 2 次提交
    • M
      MIPS: signal.c: Fix an invalid cast in ISA mode bit handling · 2fabc7d2
      Maciej W. Rozycki 提交于
      Fix:
      
      arch/mips/kernel/signal.c: In function 'handle_signal':
      arch/mips/kernel/signal.c:533:21: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
        unsigned int tmp = (unsigned int)current->mm->context.vdso;
                           ^
      arch/mips/kernel/signal.c:536:9: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
        vdso = (void *)tmp;
               ^
      cc1: all warnings being treated as errors
      
      when building a 64-bit kernel.
      
      This is not really a supported configuration, but the cast is wrong
      either way, Linux makes the assumption that sizeof(void *) equals
      sizeof(unsigned long) and therefore the latter type is expected to be
      used where integer operations have to be applied to pointers for some
      reason.
      Signed-off-by: NMaciej W. Rozycki <macro@codesourcery.com>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/8480/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      2fabc7d2
    • P
      MIPS: fix EVA & non-SMP non-FPU FP context signal handling · 14fa12df
      Paul Burton 提交于
      The save_fp_context & restore_fp_context pointers were being assigned
      to the wrong variables if either:
      
        - The kernel is configured for UP & runs on a system without an FPU,
          since b2ead528 "MIPS: Move & rename
          fpu_emulator_{save,restore}_context".
      
        - The kernel is configured for EVA, since ca750649 "MIPS: kernel:
          signal: Prevent save/restore FPU context in user memory".
      
      This would lead to FP context being clobbered incorrectly when setting
      up a sigcontext, then the garbage values being saved uselessly when
      returning from the signal.
      
      Fix by swapping the pointer assignments appropriately.
      Signed-off-by: NPaul Burton <paul.burton@imgtec.com>
      Cc: stable@vger.kernel.org # v3.15+
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/8230/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      14fa12df
  4. 06 8月, 2014 2 次提交
  5. 26 6月, 2014 1 次提交
    • P
      Revert "MIPS: Save/restore MSA context around signals" · 16f77de8
      Paul Burton 提交于
      This reverts commit eec43a22 "MIPS: Save/restore MSA context around
      signals" and the MSA parts of ca750649 "MIPS: kernel: signal:
      Prevent save/restore FPU context in user memory" (the restore path of
      which appears incorrect anyway...).
      
      The reverted patch took care not to break compatibility with userland
      users of struct sigcontext, but inadvertantly changed the offset of the
      uc_sigmask field of struct ucontext. Thus Linux v3.15 breaks the
      userland ABI. The MSA context will need to be saved via some other
      opt-in mechanism, but for now revert the change to reduce the fallout.
      
      This will have minimal impact upon use of MSA since the only supported
      CPU which includes it (the P5600) is 32-bit and therefore requires that
      the experimental CONFIG_MIPS_O32_FP64_SUPPORT Kconfig option be selected
      before the kernel will set FR=1 for a task, a requirement for MSA use.
      Thus the users of MSA are limited to known small groups of people & this
      patch won't be breaking any previously working MSA-using userland
      outside of experimental settings.
      
      [ralf@linux-mips.org: Fixed rejects.]
      
      Cc: stable@vger.kernel.org
      Reported-by: NJoseph S. Myers <joseph@codesourcery.com>
      Signed-off-by: NPaul Burton <paul.burton@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Cc: stable@vger.kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/7107/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      16f77de8
  6. 27 3月, 2014 5 次提交
  7. 14 1月, 2014 1 次提交
    • P
      MIPS: Support for 64-bit FP with O32 binaries · 597ce172
      Paul Burton 提交于
      CPUs implementing MIPS32 R2 may include a 64-bit FPU, just as MIPS64 CPUs
      do. In order to preserve backwards compatibility a 64-bit FPU will act
      like a 32-bit FPU (by accessing doubles from the least significant 32
      bits of an even-odd pair of FP registers) when the Status.FR bit is
      zero, again just like a mips64 CPU. The standard O32 ABI is defined
      expecting a 32-bit FPU, however recent toolchains support use of a
      64-bit FPU from an O32 MIPS32 executable. When an ELF executable is
      built to use a 64-bit FPU a new flag (EF_MIPS_FP64) is set in the ELF
      header.
      
      With this patch the kernel will check the EF_MIPS_FP64 flag when
      executing an O32 binary, and set Status.FR accordingly. The addition
      of O32 64-bit FP support lessens the opportunity for optimisation in
      the FPU emulator, so a CONFIG_MIPS_O32_FP64_SUPPORT Kconfig option is
      introduced to allow this support to be disabled for those that don't
      require it.
      
      Inspired by an earlier patch by Leonid Yegoshin, but implemented more
      cleanly & correctly.
      Signed-off-by: NPaul Burton <paul.burton@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Cc: Paul Burton <paul.burton@imgtec.com>
      Patchwork: https://patchwork.linux-mips.org/patch/6154/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      597ce172
  8. 11 6月, 2013 1 次提交
  9. 09 5月, 2013 1 次提交
  10. 04 2月, 2013 4 次提交
  11. 01 2月, 2013 1 次提交
  12. 12 12月, 2012 1 次提交
    • R
      MIPS: Fix harmlessly missing else statement. · 9ec9b5ac
      Ralf Baechle 提交于
      The actual bug is a missing else statement - but really this should be
      expressed using a switch() statement.
      
      Found by Al Viro who writes "the funny thing is, it *does* work only
      because r2 is syscall number and syscall number around 512 => return
      value being ENOSYS and not one of ERESTART...  so we really can't hit
      the first if and emerge from it with ERESTART_RESTARTBLOCK.  still
      wrong to write it that way..."
      Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      9ec9b5ac
  13. 01 10月, 2012 1 次提交
  14. 22 9月, 2012 1 次提交
  15. 02 6月, 2012 6 次提交
  16. 24 5月, 2012 1 次提交
  17. 22 5月, 2012 1 次提交
  18. 27 4月, 2012 1 次提交
    • M
      MIPS: Use set_current_blocked() and block_sigmask() · 8598f3cd
      Matt Fleming 提交于
      As described in e6fa16ab ("signal: sigprocmask() should do
      retarget_shared_pending()") the modification of current->blocked is
      incorrect as we need to check whether the signal we're about to block
      is pending in the shared queue.
      
      Also, use the new helper function introduced in commit 5e6292c0
      ("signal: add block_sigmask() for adding sigmask to current->blocked")
      which centralises the code for updating current->blocked after
      successfully delivering a signal and reduces the amount of duplicate
      code across architectures. In the past some architectures got this
      code wrong, so using this helper function should stop that from
      happening again.
      
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: linux-kernel@vger.kernel.org
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: David Daney <ddaney@caviumnetworks.com>
      Cc: linux-mips@linux-mips.org
      Signed-off-by: NMatt Fleming <matt.fleming@intel.com>
      Patchwork: https://patchwork.linux-mips.org/patch/3363/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      8598f3cd
  19. 29 3月, 2012 1 次提交
  20. 21 9月, 2011 1 次提交
    • R
      MIPS: Handle __put_user() sleeping. · 1f717929
      Ralf Baechle 提交于
      do_signal() does __put_user() which can fault, resulting in a might_sleep()
      warning in down_read(&mm->mmap_sem) and a "scheduling while atomic" warning
      when mmap_sem is contented. On Swarm this also results in:
      
      WARNING: at kernel/smp.c:459 smp_call_function_many+0x148/0x398()
      Modules linked in:
      Call Trace:
      
      [<ffffffff804b48a4>] dump_stack+0x1c/0x50
      [<ffffffff8013dc94>] warn_slowpath_common+0x8c/0xc8
      [<ffffffff8013dcfc>] warn_slowpath_null+0x2c/0x40
      [<ffffffff801864a0>] smp_call_function_many+0x148/0x398
      [<ffffffff80186748>] smp_call_function+0x58/0xa8
      [<ffffffff80119b5c>] r4k_flush_data_cache_page+0x54/0xd8
      [<ffffffff801f39bc>] handle_pte_fault+0xa9c/0xad0
      [<ffffffff801f40d0>] handle_mm_fault+0x158/0x200
      [<ffffffff80115548>] do_page_fault+0x218/0x3b0
      [<ffffffff80102744>] ret_from_exception+0x0/0x10
      [<ffffffff8010eb18>] copy_siginfo_to_user32+0x50/0x298
      [<ffffffff8010edf0>] setup_rt_frame_32+0x90/0x250
      [<ffffffff80106414>] do_notify_resume+0x154/0x358
      [<ffffffff80102930>] work_notifysig+0xc/0x14
      
      Fixed by enabling interrupts in do_notify_resume before delivering signals.
      
      [ralf@linux-mips.org: Reported and original fix by tglx but I wanted to
      minimize the amount of code being run with interrupts disabled so I moved
      the local_irq_disable() call right into do_notify_resume.  Which is saner
      than doing it in entry.S.]
      Reported-by: NThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      1f717929
  21. 15 3月, 2011 1 次提交
  22. 18 10月, 2010 3 次提交