1. 29 8月, 2017 1 次提交
    • P
      MIPS: Declare various variables & functions static · b7fc2cc5
      Paul Burton 提交于
      We currently have various variables & functions which are only used
      within a single translation unit, but which we don't declare static.
      This causes various sparse warnings of the form:
      
        arch/mips/kernel/mips-r2-to-r6-emul.c:49:1: warning: symbol
          'mipsr2emustats' was not declared. Should it be static?
      
        arch/mips/kernel/unaligned.c:1381:11: warning: symbol 'reg16to32st'
          was not declared. Should it be static?
      
        arch/mips/mm/mmap.c:146:15: warning: symbol 'arch_mmap_rnd' was not
          declared. Should it be static?
      
      Fix these & others by declaring various affected variables & functions
      static, avoiding the sparse warnings & redundant symbols.
      
      [ralf@linux-mips.org: Add Marcin's build fix.]
      Signed-off-by: NPaul Burton <paul.burton@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Cc: trivial@kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/17176/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      b7fc2cc5
  2. 05 7月, 2017 1 次提交
    • 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
  3. 29 6月, 2017 1 次提交
  4. 29 3月, 2017 1 次提交
  5. 25 12月, 2016 1 次提交
  6. 04 8月, 2016 1 次提交
    • M
      tree-wide: replace config_enabled() with IS_ENABLED() · 97f2645f
      Masahiro Yamada 提交于
      The use of config_enabled() against config options is ambiguous.  In
      practical terms, config_enabled() is equivalent to IS_BUILTIN(), but the
      author might have used it for the meaning of IS_ENABLED().  Using
      IS_ENABLED(), IS_BUILTIN(), IS_MODULE() etc.  makes the intention
      clearer.
      
      This commit replaces config_enabled() with IS_ENABLED() where possible.
      This commit is only touching bool config options.
      
      I noticed two cases where config_enabled() is used against a tristate
      option:
      
       - config_enabled(CONFIG_HWMON)
        [ drivers/net/wireless/ath/ath10k/thermal.c ]
      
       - config_enabled(CONFIG_BACKLIGHT_CLASS_DEVICE)
        [ drivers/gpu/drm/gma500/opregion.c ]
      
      I did not touch them because they should be converted to IS_BUILTIN()
      in order to keep the logic, but I was not sure it was the authors'
      intention.
      
      Link: http://lkml.kernel.org/r/1465215656-20569-1-git-send-email-yamada.masahiro@socionext.comSigned-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Acked-by: NKees Cook <keescook@chromium.org>
      Cc: Stas Sergeev <stsp@list.ru>
      Cc: Matt Redfearn <matt.redfearn@imgtec.com>
      Cc: Joshua Kinard <kumba@gentoo.org>
      Cc: Jiri Slaby <jslaby@suse.com>
      Cc: Bjorn Helgaas <bhelgaas@google.com>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: Markos Chandras <markos.chandras@imgtec.com>
      Cc: "Dmitry V. Levin" <ldv@altlinux.org>
      Cc: yu-cheng yu <yu-cheng.yu@intel.com>
      Cc: James Hogan <james.hogan@imgtec.com>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Johannes Berg <johannes@sipsolutions.net>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Will Drewry <wad@chromium.org>
      Cc: Nikolay Martynov <mar.kolya@gmail.com>
      Cc: Huacai Chen <chenhc@lemote.com>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Leonid Yegoshin <Leonid.Yegoshin@imgtec.com>
      Cc: Rafal Milecki <zajec5@gmail.com>
      Cc: James Cowgill <James.Cowgill@imgtec.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Alex Smith <alex.smith@imgtec.com>
      Cc: Adam Buchbinder <adam.buchbinder@gmail.com>
      Cc: Qais Yousef <qais.yousef@imgtec.com>
      Cc: Jiang Liu <jiang.liu@linux.intel.com>
      Cc: Mikko Rapeli <mikko.rapeli@iki.fi>
      Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: Brian Norris <computersforpeace@gmail.com>
      Cc: Hidehiro Kawai <hidehiro.kawai.ez@hitachi.com>
      Cc: "Luis R. Rodriguez" <mcgrof@do-not-panic.com>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
      Cc: Roland McGrath <roland@hack.frob.com>
      Cc: Paul Burton <paul.burton@imgtec.com>
      Cc: Kalle Valo <kvalo@qca.qualcomm.com>
      Cc: Viresh Kumar <viresh.kumar@linaro.org>
      Cc: Tony Wu <tung7970@gmail.com>
      Cc: Huaitong Han <huaitong.han@intel.com>
      Cc: Sumit Semwal <sumit.semwal@linaro.org>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Juergen Gross <jgross@suse.com>
      Cc: Jason Cooper <jason@lakedaemon.net>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Andrea Gelmini <andrea.gelmini@gelma.net>
      Cc: David Woodhouse <dwmw2@infradead.org>
      Cc: Marc Zyngier <marc.zyngier@arm.com>
      Cc: Rabin Vincent <rabin@rab.in>
      Cc: "Maciej W. Rozycki" <macro@imgtec.com>
      Cc: David Daney <david.daney@cavium.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      97f2645f
  7. 13 5月, 2016 1 次提交
  8. 29 3月, 2016 1 次提交
    • P
      MIPS: Fix MSA ld unaligned failure cases · fa8ff601
      Paul Burton 提交于
      Copying the content of an MSA vector from user memory may involve TLB
      faults & mapping in pages. This will fail when preemption is disabled
      due to an inability to acquire mmap_sem from do_page_fault, which meant
      such vector loads to unmapped pages would always fail to be emulated.
      Fix this by disabling preemption later only around the updating of
      vector register state.
      
      This change does however introduce a race between performing the load
      into thread context & the thread being preempted, saving its current
      live context & clobbering the loaded value. This should be a rare
      occureence, so optimise for the fast path by simply repeating the load if
      we are preempted.
      
      Additionally if the copy failed then the failure path was taken with
      preemption left disabled, leading to the kernel typically encountering
      further issues around sleeping whilst atomic. The change to where
      preemption is disabled avoids this issue.
      
      Fixes: e4aa1f15 "MIPS: MSA unaligned memory access support"
      Reported-by: NJames Hogan <james.hogan@imgtec.com>
      Signed-off-by: NPaul Burton <paul.burton@imgtec.com>
      Reviewed-by: NJames Hogan <james.hogan@imgtec.com>
      Cc: Leonid Yegoshin <Leonid.Yegoshin@imgtec.com>
      Cc: Maciej W. Rozycki <macro@linux-mips.org>
      Cc: James Cowgill <James.Cowgill@imgtec.com>
      Cc: Markos Chandras <markos.chandras@imgtec.com>
      Cc: stable <stable@vger.kernel.org> # v4.3
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/12345/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      fa8ff601
  9. 26 10月, 2015 1 次提交
    • P
      MIPS: Declare mips_debugfs_dir in a header · 75dcfc1d
      Paul Burton 提交于
      We have many extern declarations of mips_debugfs_dir through arch/mips/
      in various C files. Unify them by declaring mips_debugfs_dir in a
      header, including it in each affected C file & removing the duplicate
      declarations.
      Signed-off-by: NPaul Burton <paul.burton@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Cc: Steven J. Hill <Steven.Hill@imgtec.com>
      Cc: Alexander Sverdlin <alexander.sverdlin@nokia.com>
      Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
      Cc: Leonid Yegoshin <Leonid.Yegoshin@imgtec.com>
      Cc: Maciej W. Rozycki <macro@linux-mips.org>
      Cc: linux-kernel@vger.kernel.org
      Cc: Joe Perches <joe@perches.com>
      Cc: Jaedon Shin <jaedon.shin@gmail.com>
      Cc: James Hogan <james.hogan@imgtec.com>
      Cc: David Daney <david.daney@cavium.com>
      Cc: Zubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com>
      Cc: Markos Chandras <markos.chandras@imgtec.com>
      Cc: James Cowgill <James.Cowgill@imgtec.com>
      Patchwork: https://patchwork.linux-mips.org/patch/11181/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      75dcfc1d
  10. 03 9月, 2015 2 次提交
    • R
    • 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
  11. 03 8月, 2015 1 次提交
  12. 10 4月, 2015 3 次提交
  13. 08 4月, 2015 2 次提交
  14. 17 2月, 2015 1 次提交
  15. 31 7月, 2014 1 次提交
    • H
      MIPS: Remove BUG_ON(!is_fpu_owner()) in do_ade() · 2e5767a2
      Huacai Chen 提交于
      In do_ade(), is_fpu_owner() isn't preempt-safe. For example, when an
      unaligned ldc1 is executed, do_cpu() is called and then FPU will be
      enabled (and TIF_USEDFPU will be set for the current process). Then,
      do_ade() is called because the access is unaligned.  If the current
      process is preempted at this time, TIF_USEDFPU will be cleard.  So when
      the process is scheduled again, BUG_ON(!is_fpu_owner()) is triggered.
      
      This small program can trigger this BUG in a preemptible kernel:
      
      int main (int argc, char *argv[])
      {
              double u64[2];
      
              while (1) {
                      asm volatile (
                              ".set push \n\t"
                              ".set noreorder \n\t"
                              "ldc1 $f3, 4(%0) \n\t"
                              ".set pop \n\t"
                              ::"r"(u64):
                      );
              }
      
              return 0;
      }
      
      V2: Remove the BUG_ON() unconditionally due to Paul's suggestion.
      Signed-off-by: NHuacai Chen <chenhc@lemote.com>
      Signed-off-by: NJie Chen <chenj@lemote.com>
      Signed-off-by: NRui Wang <wangr@lemote.com>
      Cc: <stable@vger.kernel.org>
      Cc: John Crispin <john@phrozen.org>
      Cc: Steven J. Hill <Steven.Hill@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Cc: Fuxin Zhang <zhangfx@lemote.com>
      Cc: Zhangjin Wu <wuzhangjin@gmail.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      2e5767a2
  16. 27 3月, 2014 2 次提交
  17. 01 7月, 2013 2 次提交
  18. 11 6月, 2013 1 次提交
  19. 09 5月, 2013 3 次提交
  20. 01 2月, 2013 1 次提交
  21. 29 3月, 2012 1 次提交
  22. 01 11月, 2011 1 次提交
  23. 01 7月, 2011 1 次提交
    • P
      perf: Remove the nmi parameter from the swevent and overflow interface · a8b0ca17
      Peter Zijlstra 提交于
      The nmi parameter indicated if we could do wakeups from the current
      context, if not, we would set some state and self-IPI and let the
      resulting interrupt do the wakeup.
      
      For the various event classes:
      
        - hardware: nmi=0; PMI is in fact an NMI or we run irq_work_run from
          the PMI-tail (ARM etc.)
        - tracepoint: nmi=0; since tracepoint could be from NMI context.
        - software: nmi=[0,1]; some, like the schedule thing cannot
          perform wakeups, and hence need 0.
      
      As one can see, there is very little nmi=1 usage, and the down-side of
      not using it is that on some platforms some software events can have a
      jiffy delay in wakeup (when arch_irq_work_raise isn't implemented).
      
      The up-side however is that we can remove the nmi parameter and save a
      bunch of conditionals in fast paths.
      Signed-off-by: NPeter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Michael Cree <mcree@orcon.net.nz>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: Deng-Cheng Zhu <dengcheng.zhu@gmail.com>
      Cc: Anton Blanchard <anton@samba.org>
      Cc: Eric B Munson <emunson@mgebm.net>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Paul Mundt <lethal@linux-sh.org>
      Cc: David S. Miller <davem@davemloft.net>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jason Wessel <jason.wessel@windriver.com>
      Cc: Don Zickus <dzickus@redhat.com>
      Link: http://lkml.kernel.org/n/tip-agjev8eu666tvknpb3iaj0fg@git.kernel.orgSigned-off-by: NIngo Molnar <mingo@elte.hu>
      a8b0ca17
  24. 30 10月, 2010 1 次提交
  25. 18 10月, 2010 1 次提交
  26. 17 12月, 2009 1 次提交
  27. 14 5月, 2009 1 次提交
  28. 30 10月, 2008 1 次提交
  29. 28 10月, 2008 1 次提交
  30. 12 10月, 2007 1 次提交
  31. 01 8月, 2007 2 次提交