1. 29 8月, 2017 3 次提交
    • P
      MIPS: Remove unused R6000 support · 3b2db173
      Paul Burton 提交于
      The kernel contains a small amount of incomplete code aimed at
      supporting old R6000 CPUs. This is:
      
        - Unused, as no machine selects CONFIG_SYS_HAS_CPU_R6000.
      
        - Broken, since there are glaring errors such as r6000_fpu.S moving
          the FCSR register to t1, then ignoring it & instead saving t0 into
          struct sigcontext...
      
        - A maintenance headache, since it's code that nobody can test which
          nevertheless imposes constraints on code which it shares with other
          machines.
      
      Remove this incomplete & broken R6000 CPU support in order to clean up
      and in preparation for changes which will no longer need to consider
      dragging the pretense of R6000 support along with them.
      Signed-off-by: NPaul Burton <paul.burton@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/16236/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      3b2db173
    • M
      MIPS: R6: Constify r2_decoder_tables · 114c3708
      Matt Redfearn 提交于
      The r2_decoder_tables are never modified. They are arrays of constant
      values and as such should be declared const.
      
      This change saves 256 bytes of kernel text, and 128 bytes of kernel data
      (384 bytes total) on a 32r6el_defconfig (with SMP disabled)
      Before:
         text	   data	    bss	    dec	    hex	filename
      5576221	1080804	 267040	6924065	 69a721	vmlinux
      After:
         text	   data	    bss	    dec	    hex	filename
      5575965	1080676	 267040	6923681	 69a5a1	vmlinux
      Signed-off-by: NMatt Redfearn <matt.redfearn@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/15289/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      114c3708
    • M
      MIPS: SMP: Constify smp ops · ff2c8252
      Matt Redfearn 提交于
      smp_ops providers do not modify their ops structures, so they should be
      made const for robustness. Since currently the MIPS kernel is not mapped
      with memory protection, this does not in itself provide any security
      benefit, but it still makes sense to make this change.
      
      There are also slight code size efficincies from the structure being
      made read-only, saving 128 bytes of kernel text on a
      pistachio_defconfig.
      Before:
         text	   data	    bss	    dec	    hex	filename
      7187239	1772752	 470224	9430215	 8fe4c7	vmlinux
      After:
         text	   data	    bss	    dec	    hex	filename
      7187111	1772752	 470224	9430087	 8fe447	vmlinux
      Signed-off-by: NMatt Redfearn <matt.redfearn@imgtec.com>
      Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Marcin Nowakowski <marcin.nowakowski@imgtec.com>
      Cc: Bart Van Assche <bart.vanassche@sandisk.com>
      Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
      Cc: Huacai Chen <chenhc@lemote.com>
      Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
      Cc: Kevin Cernekee <cernekee@gmail.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Doug Ledford <dledford@redhat.com>
      Cc: James Hogan <james.hogan@imgtec.com>
      Cc: Joe Perches <joe@perches.com>
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Paul Burton <paul.burton@imgtec.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Steven J. Hill <steven.hill@cavium.com>
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/16784/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      ff2c8252
  2. 07 8月, 2017 1 次提交
  3. 11 7月, 2017 5 次提交
  4. 05 7月, 2017 2 次提交
    • M
      MIPS: MIPS16e2: Subdecode extended LWSP/SWSP instructions · f3235d32
      Maciej W. Rozycki 提交于
      Implement extended LWSP/SWSP instruction subdecoding for the purpose of
      unaligned GP-relative memory access emulation.
      
      With the introduction of the MIPS16e2 ASE[1] the previously must-be-zero
      3-bit field at bits 7..5 of the extended encodings of the instructions
      selected with the LWSP and SWSP major opcodes has become a `sel' field,
      acting as an opcode extension for additional operations.  In both cases
      the `sel' value of 0 has retained the original operation, that is:
      
      	LW	rx, offset(sp)
      
      and:
      
      	SW	rx, offset(sp)
      
      for LWSP and SWSP respectively.  In hardware predating the MIPS16e2 ASE
      other values may or may not have been decoded, architecturally yielding
      unpredictable results, and in our unaligned memory access emulation we
      have treated the 3-bit field as a don't-care, that is effectively making
      all the possible encodings of the field alias to the architecturally
      defined encoding of 0.
      
      For the non-zero values of the `sel' field the MIPS16e2 ASE has in
      particular defined these GP-relative operations:
      
      	LW	rx, offset(gp)		# sel = 1
      	LH	rx, offset(gp)		# sel = 2
      	LHU	rx, offset(gp)		# sel = 4
      
      and
      
      	SW	rx, offset(gp)		# sel = 1
      	SH	rx, offset(gp)		# sel = 2
      
      for LWSP and SWSP respectively, which will trap with an Address Error
      exception if the effective address calculated is not naturally-aligned
      for the operation requested.  These operations have been selected for
      unaligned access emulation, for consistency with the corresponding
      regular MIPS and microMIPS operations.
      
      For other non-zero values of the `sel' field the MIPS16e2 ASE has
      defined further operations, which however either never trap with an
      Address Error exception, such as LWL or GP-relative SB, or are not
      supposed to be emulated, such as LL or SC.  These operations have been
      selected to exclude from unaligned access emulation, should an Address
      Error exception ever happen with them.
      
      Subdecode the `sel' field in unaligned access emulation then for the
      extended encodings of the instructions selected with the LWSP and SWSP
      major opcodes, whenever support for the MIPS16e2 ASE has been detected
      in hardware, and either emulate the operation requested or send SIGBUS
      to the originating process, according to the selection described above.
      For hardware implementing the MIPS16 ASE, however lacking MIPS16e2 ASE
      support retain the original interpretation of the `sel' field.
      
      The effects of this change are illustrated with the following user
      program:
      
      $ cat mips16e2-test.c
      #include <inttypes.h>
      #include <stdio.h>
      
      int main(void)
      {
      	int64_t scratch[16] = { 0 };
      	int32_t *tmp0, *tmp1, *tmp2;
      	int i;
      
      	scratch[0] = 0xc8c7c6c5c4c3c2c1;
      	scratch[1] = 0xd0cfcecdcccbcac9;
      
      	asm volatile(
      		"move	%0, $sp\n\t"
      		"move	%1, $gp\n\t"
      		"move	$sp, %4\n\t"
      		"addiu	%2, %4, 8\n\t"
      		"move	$gp, %2\n\t"
      
      		"lw	%2, 2($sp)\n\t"
      		"sw	%2, 16(%4)\n\t"
      		"lw	%2, 2($gp)\n\t"
      		"sw	%2, 24(%4)\n\t"
      
      		"lw	%2, 1($sp)\n\t"
      		"sw	%2, 32(%4)\n\t"
      		"lh	%2, 1($gp)\n\t"
      		"sw	%2, 40(%4)\n\t"
      
      		"lw	%2, 3($sp)\n\t"
      		"sw	%2, 48(%4)\n\t"
      		"lhu	%2, 3($gp)\n\t"
      		"sw	%2, 56(%4)\n\t"
      
      		"lw	%2, 0(%4)\n\t"
      		"sw	%2, 66($sp)\n\t"
      		"lw	%2, 8(%4)\n\t"
      		"sw	%2, 82($gp)\n\t"
      
      		"lw	%2, 0(%4)\n\t"
      		"sw	%2, 97($sp)\n\t"
      		"lw	%2, 8(%4)\n\t"
      		"sh	%2, 113($gp)\n\t"
      
      		"move	$gp, %1\n\t"
      		"move	$sp, %0"
      		: "=&d" (tmp0), "=&d" (tmp1), "=&d" (tmp2), "=m" (scratch)
      		: "d" (scratch));
      
      	for (i = 0; i < sizeof(scratch) / sizeof(*scratch); i += 2)
      		printf("%016" PRIx64 "\t%016" PRIx64 "\n",
      		       scratch[i], scratch[i + 1]);
      
      	return 0;
      }
      $
      
      to be compiled with:
      
      $ gcc -mips16 -mips32r2 -Wa,-mmips16e2 -o mips16e2-test mips16e2-test.c
      $
      
      With 74Kf hardware, which does not implement the MIPS16e2 ASE, this
      program produces the following output:
      
      $ ./mips16e2-test
      c8c7c6c5c4c3c2c1        d0cfcecdcccbcac9
      00000000c6c5c4c3        00000000c6c5c4c3
      00000000c5c4c3c2        00000000c5c4c3c2
      00000000c7c6c5c4        00000000c7c6c5c4
      0000c4c3c2c10000        0000000000000000
      0000cccbcac90000        0000000000000000
      000000c4c3c2c100        0000000000000000
      000000cccbcac900        0000000000000000
      $
      
      regardless of whether the change has been applied or not.
      
      With the change not applied and interAptive MR2 hardware[2], which does
      implement the MIPS16e2 ASE, it produces the following output:
      
      $ ./mips16e2-test
      c8c7c6c5c4c3c2c1        d0cfcecdcccbcac9
      00000000c6c5c4c3        00000000cecdcccb
      00000000c5c4c3c2        00000000cdcccbca
      00000000c7c6c5c4        00000000cfcecdcc
      0000c4c3c2c10000        0000000000000000
      0000000000000000        0000cccbcac90000
      000000c4c3c2c100        0000000000000000
      0000000000000000        000000cccbcac900
      $
      
      which shows that for GP-relative operations the correct trapping address
      calculated from $gp has been obtained from the CP0 BadVAddr register and
      so has data from the source operand, however masking and extension has
      not been applied for halfword operations.
      
      With the change applied and interAptive MR2 hardware the program
      produces the following output:
      
      $ ./mips16e2-test
      c8c7c6c5c4c3c2c1        d0cfcecdcccbcac9
      00000000c6c5c4c3        00000000cecdcccb
      00000000c5c4c3c2        00000000ffffcbca
      00000000c7c6c5c4        000000000000cdcc
      0000c4c3c2c10000        0000000000000000
      0000000000000000        0000cccbcac90000
      000000c4c3c2c100        0000000000000000
      0000000000000000        0000000000cac900
      $
      
      as expected.
      
      References:
      
      [1] "MIPS32 Architecture for Programmers: MIPS16e2 Application-Specific
          Extension Technical Reference Manual", Imagination Technologies
          Ltd., Document Number: MD01172, Revision 01.00, April 26, 2016
      
      [2] "MIPS32 interAptiv Multiprocessing System Software User's Manual",
          Imagination Technologies Ltd., Document Number: MD00904, Revision
          02.01, June 15, 2016, Chapter 24 "MIPS16e Application-Specific
          Extension to the MIPS32 Instruction Set", pp. 871-883
      Signed-off-by: NMaciej W. Rozycki <macro@imgtec.com>
      Reviewed-by: NJames Hogan <james.hogan@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/16095/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      f3235d32
    • M
      MIPS: MIPS16e2: Identify ASE presence · 8d1630f1
      Maciej W. Rozycki 提交于
      Identify the presence of the MIPS16e2 ASE as per the architecture
      specification[1], by checking for CP0 Config5.CA2 bit being 1[2].
      
      References:
      
      [1] "MIPS32 Architecture for Programmers: MIPS16e2 Application-Specific
          Extension Technical Reference Manual", Imagination Technologies
          Ltd., Document Number: MD01172, Revision 01.00, April 26, 2016,
          Section 1.2 "Software Detection of the ASE", p. 5
      
      [2] "MIPS32 interAptiv Multiprocessing System Software User's Manual",
          Imagination Technologies Ltd., Document Number: MD00904, Revision
          02.01, June 15, 2016, Section 2.2.1.6 "Device Configuration 5 --
          Config5 (CP0 Register 16, Select 5)", pp. 71-72
      Signed-off-by: NMaciej W. Rozycki <macro@imgtec.com>
      Reviewed-by: NJames Hogan <james.hogan@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/16094/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      8d1630f1
  5. 30 6月, 2017 3 次提交
    • J
      MIPS: Avoid accidental raw backtrace · 85423636
      James Hogan 提交于
      Since commit 81a76d71 ("MIPS: Avoid using unwind_stack() with
      usermode") show_backtrace() invokes the raw backtracer when
      cp0_status & ST0_KSU indicates user mode to fix issues on EVA kernels
      where user and kernel address spaces overlap.
      
      However this is used by show_stack() which creates its own pt_regs on
      the stack and leaves cp0_status uninitialised in most of the code paths.
      This results in the non deterministic use of the raw back tracer
      depending on the previous stack content.
      
      show_stack() deals exclusively with kernel mode stacks anyway, so
      explicitly initialise regs.cp0_status to KSU_KERNEL (i.e. 0) to ensure
      we get a useful backtrace.
      
      Fixes: 81a76d71 ("MIPS: Avoid using unwind_stack() with usermode")
      Signed-off-by: NJames Hogan <james.hogan@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Cc: <stable@vger.kernel.org> # 3.15+
      Patchwork: https://patchwork.linux-mips.org/patch/16656/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      85423636
    • P
      MIPS: Fix IRQ tracing & lockdep when rescheduling · d8550860
      Paul Burton 提交于
      When the scheduler sets TIF_NEED_RESCHED & we call into the scheduler
      from arch/mips/kernel/entry.S we disable interrupts. This is true
      regardless of whether we reach work_resched from syscall_exit_work,
      resume_userspace or by looping after calling schedule(). Although we
      disable interrupts in these paths we don't call trace_hardirqs_off()
      before calling into C code which may acquire locks, and we therefore
      leave lockdep with an inconsistent view of whether interrupts are
      disabled or not when CONFIG_PROVE_LOCKING & CONFIG_DEBUG_LOCKDEP are
      both enabled.
      
      Without tracing this interrupt state lockdep will print warnings such
      as the following once a task returns from a syscall via
      syscall_exit_partial with TIF_NEED_RESCHED set:
      
      [   49.927678] ------------[ cut here ]------------
      [   49.934445] WARNING: CPU: 0 PID: 1 at kernel/locking/lockdep.c:3687 check_flags.part.41+0x1dc/0x1e8
      [   49.946031] DEBUG_LOCKS_WARN_ON(current->hardirqs_enabled)
      [   49.946355] CPU: 0 PID: 1 Comm: init Not tainted 4.10.0-00439-gc9fd5d362289-dirty #197
      [   49.963505] Stack : 0000000000000000 ffffffff81bb5d6a 0000000000000006 ffffffff801ce9c4
      [   49.974431]         0000000000000000 0000000000000000 0000000000000000 000000000000004a
      [   49.985300]         ffffffff80b7e487 ffffffff80a24498 a8000000ff160000 ffffffff80ede8b8
      [   49.996194]         0000000000000001 0000000000000000 0000000000000000 0000000077c8030c
      [   50.007063]         000000007fd8a510 ffffffff801cd45c 0000000000000000 a8000000ff127c88
      [   50.017945]         0000000000000000 ffffffff801cf928 0000000000000001 ffffffff80a24498
      [   50.028827]         0000000000000000 0000000000000001 0000000000000000 0000000000000000
      [   50.039688]         0000000000000000 a8000000ff127bd0 0000000000000000 ffffffff805509bc
      [   50.050575]         00000000140084e0 0000000000000000 0000000000000000 0000000000040a00
      [   50.061448]         0000000000000000 ffffffff8010e1b0 0000000000000000 ffffffff805509bc
      [   50.072327]         ...
      [   50.076087] Call Trace:
      [   50.079869] [<ffffffff8010e1b0>] show_stack+0x80/0xa8
      [   50.086577] [<ffffffff805509bc>] dump_stack+0x10c/0x190
      [   50.093498] [<ffffffff8015dde0>] __warn+0xf0/0x108
      [   50.099889] [<ffffffff8015de34>] warn_slowpath_fmt+0x3c/0x48
      [   50.107241] [<ffffffff801c15b4>] check_flags.part.41+0x1dc/0x1e8
      [   50.114961] [<ffffffff801c239c>] lock_is_held_type+0x8c/0xb0
      [   50.122291] [<ffffffff809461b8>] __schedule+0x8c0/0x10f8
      [   50.129221] [<ffffffff80946a60>] schedule+0x30/0x98
      [   50.135659] [<ffffffff80106278>] work_resched+0x8/0x34
      [   50.142397] ---[ end trace 0cb4f6ef5b99fe21 ]---
      [   50.148405] possible reason: unannotated irqs-off.
      [   50.154600] irq event stamp: 400463
      [   50.159566] hardirqs last  enabled at (400463): [<ffffffff8094edc8>] _raw_spin_unlock_irqrestore+0x40/0xa8
      [   50.171981] hardirqs last disabled at (400462): [<ffffffff8094eb98>] _raw_spin_lock_irqsave+0x30/0xb0
      [   50.183897] softirqs last  enabled at (400450): [<ffffffff8016580c>] __do_softirq+0x4ac/0x6a8
      [   50.195015] softirqs last disabled at (400425): [<ffffffff80165e78>] irq_exit+0x110/0x128
      
      Fix this by using the TRACE_IRQS_OFF macro to call trace_hardirqs_off()
      when CONFIG_TRACE_IRQFLAGS is enabled. This is done before invoking
      schedule() following the work_resched label because:
      
       1) Interrupts are disabled regardless of the path we take to reach
          work_resched() & schedule().
      
       2) Performing the tracing here avoids the need to do it in paths which
          disable interrupts but don't call out to C code before hitting a
          path which uses the RESTORE_SOME macro that will call
          trace_hardirqs_on() or trace_hardirqs_off() as appropriate.
      
      We call trace_hardirqs_on() using the TRACE_IRQS_ON macro before calling
      syscall_trace_leave() for similar reasons, ensuring that lockdep has a
      consistent view of state after we re-enable interrupts.
      Signed-off-by: NPaul Burton <paul.burton@imgtec.com>
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Cc: linux-mips@linux-mips.org
      Cc: stable <stable@vger.kernel.org>
      Patchwork: https://patchwork.linux-mips.org/patch/15385/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      d8550860
    • P
      MIPS: pm-cps: Drop manual cache-line alignment of ready_count · 161c51cc
      Paul Burton 提交于
      We allocate memory for a ready_count variable per-CPU, which is accessed
      via a cached non-coherent TLB mapping to perform synchronisation between
      threads within the core using LL/SC instructions. In order to ensure
      that the variable is contained within its own data cache line we
      allocate 2 lines worth of memory & align the resulting pointer to a line
      boundary. This is however unnecessary, since kmalloc is guaranteed to
      return memory which is at least cache-line aligned (see
      ARCH_DMA_MINALIGN). Stop the redundant manual alignment.
      
      Besides cleaning up the code & avoiding needless work, this has the side
      effect of avoiding an arithmetic error found by Bryan on 64 bit systems
      due to the 32 bit size of the former dlinesz. This led the ready_count
      variable to have its upper 32b cleared erroneously for MIPS64 kernels,
      causing problems when ready_count was later used on MIPS64 via cpuidle.
      Signed-off-by: NPaul Burton <paul.burton@imgtec.com>
      Fixes: 3179d37e ("MIPS: pm-cps: add PM state entry code for CPS systems")
      Reported-by: NBryan O'Donoghue <bryan.odonoghue@imgtec.com>
      Reviewed-by: NBryan O'Donoghue <bryan.odonoghue@imgtec.com>
      Tested-by: NBryan O'Donoghue <bryan.odonoghue@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Cc: stable <stable@vger.kernel.org> # v3.16+
      Patchwork: https://patchwork.linux-mips.org/patch/15383/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      161c51cc
  6. 29 6月, 2017 18 次提交
  7. 28 6月, 2017 8 次提交