Skip to content
  1. Aug 13, 2015
  2. Aug 07, 2015
    • Vineet Gupta's avatar
      ARCv2: spinlock/rwlock/atomics: reduce 1 instruction in exponential backoff · 10971638
      Vineet Gupta authored
      
      
      The increment of delay counter was 2 instructions:
      Arithmatic Shfit Left (ASL) + set to 1 on overflow
      
      This can be done in 1 using ROtate Left (ROL)
      
      Suggested-by: default avatarNigel Topham <ntopham@synopsys.com>
      Cc: Peter Zijlstra (Intel) <peterz@infradead.org>
      Cc: linux-kernel@vger.kernel.org
      Signed-off-by: default avatarVineet Gupta <vgupta@synopsys.com>
      10971638
    • David S. Miller's avatar
      sparc64: Fix userspace FPU register corruptions. · 44922150
      David S. Miller authored
      
      
      If we have a series of events from userpsace, with %fprs=FPRS_FEF,
      like follows:
      
      ETRAP
      	ETRAP
      		VIS_ENTRY(fprs=0x4)
      		VIS_EXIT
      		RTRAP (kernel FPU restore with fpu_saved=0x4)
      	RTRAP
      
      We will not restore the user registers that were clobbered by the FPU
      using kernel code in the inner-most trap.
      
      Traps allocate FPU save slots in the thread struct, and FPU using
      sequences save the "dirty" FPU registers only.
      
      This works at the initial trap level because all of the registers
      get recorded into the top-level FPU save area, and we'll return
      to userspace with the FPU disabled so that any FPU use by the user
      will take an FPU disabled trap wherein we'll load the registers
      back up properly.
      
      But this is not how trap returns from kernel to kernel operate.
      
      The simplest fix for this bug is to always save all FPU register state
      for anything other than the top-most FPU save area.
      
      Getting rid of the optimized inner-slot FPU saving code ends up
      making VISEntryHalf degenerate into plain VISEntry.
      
      Longer term we need to do something smarter to reinstate the partial
      save optimizations.  Perhaps the fundament error is having trap entry
      and exit allocate FPU save slots and restore register state.  Instead,
      the VISEntry et al. calls should be doing that work.
      
      This bug is about two decades old.
      
      Reported-by: default avatarJames Y Knight <jyknight@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      44922150
    • Amanieu d'Antras's avatar
      signal: fix information leak in copy_siginfo_to_user · 26135022
      Amanieu d'Antras authored
      
      
      This function may copy the si_addr_lsb, si_lower and si_upper fields to
      user mode when they haven't been initialized, which can leak kernel
      stack data to user mode.
      
      Just checking the value of si_code is insufficient because the same
      si_code value is shared between multiple signals.  This is solved by
      checking the value of si_signo in addition to si_code.
      
      Signed-off-by: default avatarAmanieu 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>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      26135022
    • Amanieu d'Antras's avatar
      signal: fix information leak in copy_siginfo_from_user32 · 3c00cb5e
      Amanieu d'Antras authored
      
      
      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: default avatarAmanieu 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: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      3c00cb5e
  3. Aug 05, 2015
  4. Aug 04, 2015
  5. Aug 03, 2015
    • Vineet Gupta's avatar
      ARCv2: Fix the peripheral address space detection · e13c42ec
      Vineet Gupta authored
      
      
      With HS 2.1 release, the peripheral space register no longer contains
      the uncached space specifics, causing the kernel to panic early on.
      So read the newer NON VOLATILE AUX register to get that info.
      
      Signed-off-by: default avatarVineet Gupta <vgupta@synopsys.com>
      e13c42ec
    • James Cowgill's avatar
      MIPS: Replace add and sub instructions in relocate_kernel.S with addiu · a4504755
      James Cowgill authored
      
      
      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: default avatarJames 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: default avatarRalf Baechle <ralf@linux-mips.org>
      a4504755
    • James Hogan's avatar
      MIPS: Flush RPS on kernel entry with EVA · 3aff47c0
      James Hogan authored
      
      
      When EVA is enabled, flush the Return Prediction Stack (RPS) present on
      some MIPS cores on entry to the kernel from user mode.
      
      This is important specifically for interAptiv with EVA enabled,
      otherwise kernel mode RPS mispredicts may trigger speculative fetches of
      user return addresses, which may be sensitive in the kernel address
      space due to EVA's overlapping user/kernel address spaces.
      
      Signed-off-by: default avatarJames Hogan <james.hogan@imgtec.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      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.x-
      Patchwork: https://patchwork.linux-mips.org/patch/10812/
      
      
      Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
      3aff47c0
    • Florian Fainelli's avatar
      Revert "MIPS: BCM63xx: Provide a plat_post_dma_flush hook" · 247bfb65
      Florian Fainelli authored
      This reverts commit 3cf29543
      
       ("MIPS:
      BCM63xx: Provide a plat_post_dma_flush hook") since this commit was
      found to prevent BCM6358 (early BMIPS4350 cores) and some BCM6368
      (BMIPS4380 cores) from booting reliably.
      
      Alvaro was able to track this down to an issue specifically located to
      devices that use the second thread (TP1) when booting. Since BCM63xx did
      not have a need for plat_post_dma_flush() hook before, let's just keep
      things the way they were.
      
      Reported-by: default avatarÁlvaro Fernández Rojas <noltari@gmail.com>
      Reported-by: default avatarJonas Gorski <jogo@openwrt.org>
      Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Cc: stable@vger.kernel.org
      Cc: Kevin Cernekee <cernekee@gmail.com>
      Cc: Nicolas Schichan <nschichan@freebox.fr>
      Cc: linux-mips@linux-mips.org
      Cc: blogic@openwrt.org
      Cc: noltari@gmail.com
      Cc: jogo@openwrt.org
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: stable@vger.kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/10804/
      
      
      Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
      247bfb65
    • Kevin Cernekee's avatar
      MIPS: BMIPS: Delete unused Kconfig symbol · 3592bb08
      Kevin Cernekee authored
      
      
      This was left over from an earlier iteration of the BMIPS irqchip changes.
      It doesn't actually have an effect, so let's nuke it.
      
      Reported-by: default avatarValentin Rothberg <valentinrothberg@gmail.com>
      Signed-off-by: default avatarKevin Cernekee <cernekee@chromium.org>
      Acked-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Cc: stable@vger.kernel.org # v4.1+
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/9910/
      
      
      Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
      3592bb08
    • Felix Fietkau's avatar
      MIPS: Export get_c0_perfcount_int() · 0cb0985f
      Felix Fietkau authored
      get_c0_perfcount_int is tested from oprofile code. If oprofile is
      compiled as module, get_c0_perfcount_int needs to be exported, otherwise
      it cannot be resolved.
      
      Fixes: a669efc4
      
       ("MIPS: Add hook to get C0 performance counter interrupt")
      Cc: stable@vger.kernel.org # v3.19+
      Signed-off-by: default avatarFelix Fietkau <nbd@openwrt.org>
      Cc: linux-mips@linux-mips.org
      Cc: abrestic@chromium.org
      Patchwork: https://patchwork.linux-mips.org/patch/10763/
      
      
      Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
      0cb0985f
    • James Hogan's avatar
      MIPS: show_stack: Fix stack trace with EVA · 1e77863a
      James Hogan authored
      
      
      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: default avatarJames 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: default avatarRalf Baechle <ralf@linux-mips.org>
      1e77863a
    • James Hogan's avatar
      MIPS: do_mcheck: Fix kernel code dump with EVA · 55c723e1
      James Hogan authored
      
      
      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: default avatarJames 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: default avatarRalf Baechle <ralf@linux-mips.org>
      55c723e1
    • Alex Smith's avatar
      MIPS: SMP: Don't increment irq_count multiple times for call function IPIs · 4ace6139
      Alex Smith authored
      
      
      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: default avatarAlex Smith <alex.smith@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/10770/
      
      
      Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
      4ace6139
    • Ralf Baechle's avatar
      MIPS: Partially disable RIXI support. · 55fdcb2d
      Ralf Baechle authored
      
      
      Execution of break instruction, trap instructions, emulation of unaligned
      loads or floating point instructions - anything that tries to read the
      instruction's opcode from userspace - needs read access to a page.
      
      RIXI (Read Inhibit / Execute Inhibit) support however allows the creation of
      pags that are executable but not readable.  On such a mapping the attempted
      load of the opcode by the kernel is going to cause an endless loop of
      page faults.
      
      The quick workaround for this is to disable the combinations that the kernel
      currently isn't able to handle which are executable mappings.
      
      Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
      55fdcb2d
    • Ralf Baechle's avatar
      MIPS: Handle page faults of executable but unreadable pages correctly. · e070dab7
      Ralf Baechle authored
      
      
      Without this we end taking execeptions in an endless loop hanging the
      thread.
      
      Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
      e070dab7
    • James Hogan's avatar
      MIPS: Malta: Don't reinitialise RTC · 106eccb4
      James Hogan authored
      On Malta, since commit a87ea88d ("MIPS: Malta: initialise the RTC at
      boot"), the RTC is reinitialised and forced into binary coded decimal
      (BCD) mode during init, even if the bootloader has already initialised
      it, and may even have already put it into binary mode (as YAMON does).
      This corrupts the current time, can result in the RTC seconds being an
      invalid BCD (e.g. 0x1a..0x1f) for up to 6 seconds, as well as confusing
      YAMON for a while after reset, enough for it to report timeouts when
      attempting to load from TFTP (it actually uses the RTC in that code).
      
      Therefore only initialise the RTC to the extent that is necessary so
      that Linux avoids interfering with the bootloader setup, while also
      allowing it to estimate the CPU frequency without hanging, without a
      bootloader necessarily having done anything with the RTC (for example
      when the kernel is loaded via EJTAG).
      
      The divider control is configured for a 32KHZ reference clock if
      necessary, and the SET bit of the RTC_CONTROL register is cleared if
      necessary without changing any other bits (this bit will be set when
      coming out of reset if the battery has been disconnected).
      
      Fixes: a87ea88d
      
       ("MIPS: Malta: initialise the RTC at boot")
      Signed-off-by: default avatarJames Hogan <james.hogan@imgtec.com>
      Reviewed-by: default avatarPaul Burton <paul.burton@imgtec.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Maciej W. Rozycki <macro@linux-mips.org>
      Cc: linux-mips@linux-mips.org
      Cc: <stable@vger.kernel.org> # 3.14+
      Patchwork: https://patchwork.linux-mips.org/patch/10739/
      
      
      Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
      106eccb4
    • James Cowgill's avatar
      MIPS: unaligned: Fix build error on big endian R6 kernels · 531a6d59
      James Cowgill authored
      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: default avatarJames 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: default avatarRalf Baechle <ralf@linux-mips.org>
      531a6d59