1. 19 10月, 2017 1 次提交
  2. 09 10月, 2017 5 次提交
    • P
      MIPS: math-emu: Remove pr_err() calls from fpu_emu() · ca8eb05b
      Paul Burton 提交于
      The FPU emulator includes 2 calls to pr_err() which are triggered by
      invalid instruction encodings for MIPSr6 cmp.cond.fmt instructions.
      These cases are not kernel errors, merely invalid instructions which are
      already handled by delivering a SIGILL which will provide notification
      that something failed in cases where that makes sense.
      
      In cases where that SIGILL is somewhat expected & being handled, for
      example when crashme happens to generate one of the affected bad
      encodings, the message is printed with no useful context about what
      triggered it & spams the kernel log for no good reason.
      
      Remove the pr_err() calls to make crashme run silently & treat the bad
      encodings the same way we do others, with a SIGILL & no further kernel
      log output.
      Signed-off-by: NPaul Burton <paul.burton@imgtec.com>
      Fixes: f8c3c671 ("MIPS: math-emu: Add support for the CMP.condn.fmt R6 instruction")
      Cc: linux-mips@linux-mips.org
      Cc: stable <stable@vger.kernel.org> # v4.3+
      Patchwork: https://patchwork.linux-mips.org/patch/17253/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      ca8eb05b
    • P
      MIPS: Fix generic-board-config.sh for builds using O= · e1270575
      Paul Burton 提交于
      When configuring the kernel using one of the generic MIPS defconfig
      targets, the generic-board-config.sh script is used to check
      requirements listed in board config fragments against a reference config
      in order to determine which board config fragments to merge into the
      final config.
      
      When specifying O= to configure in a directory other than the kernel
      source directory, this generic-board-config.sh script is invoked in the
      directory that we are configuring in (ie. the directory that O equals),
      and the path to the reference config is relative to the current
      directory. The script then changes the current directory to the source
      tree, which unfortunately breaks later access to the reference file
      since its path is relative to a directory that is no longer the current
      working directory. This results in configuration failing with errors
      such as:
      
        $ make ARCH=mips O=tmp 32r2_defconfig
        make[1]: Entering directory '/home/pburton/src/linux/tmp'
        Using ../arch/mips/configs/generic_defconfig as base
        Merging ../arch/mips/configs/generic/32r2.config
        Merging ../arch/mips/configs/generic/eb.config
        grep: ./.config.32r2_defconfig: No such file or directory
        grep: ./.config.32r2_defconfig: No such file or directory
        The base file '.config' does not exist.  Exit.
        make[1]: *** [arch/mips/Makefile:505: 32r2_defconfig] Error 1
        make[1]: Leaving directory '/home/pburton/src/linux-ingenic/tmp'
        make: *** [Makefile:145: sub-make] Error 2
      
      Fix this by avoiding changing the working directory in
      generic-board-config.sh, instead using full paths to files under
      $(srctree)/ where necessary.
      Signed-off-by: NPaul Burton <paul.burton@imgtec.com>
      Fixes: 27e0d4b0 ("MIPS: generic: Allow filtering enabled boards by requirements")
      Cc: linux-mips@linux-mips.org
      Cc: kbuild test robot <fengguang.wu@intel.com>
      Cc: kbuild-all@01.org
      Patchwork: https://patchwork.linux-mips.org/patch/17231/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      e1270575
    • P
      MIPS: Fix cmpxchg on 32b signed ints for 64b kernel with !kernel_uses_llsc · 133d68e0
      Paul Burton 提交于
      Commit 8263db4d ("MIPS: cmpxchg: Implement __cmpxchg() as a
      function") refactored our implementation of __cmpxchg() to be a function
      rather than a macro, with the aim of making it easier to read & modify.
      Unfortunately the commit breaks use of cmpxchg() for signed 32 bit
      values when we have a 64 bit kernel with kernel_uses_llsc == false,
      because:
      
       - In cmpxchg_local() we cast the old value to the type the pointer
         points to, and then to an unsigned long. If the pointer points to a
         signed type smaller than 64 bits then the old value will be sign
         extended to 64 bits. That is, bits beyond the size of the pointed to
         type will be set to 1 if the old value is negative. In the case of a
         signed 32 bit integer with a negative value, bits 63:32 will all be
         set.
      
       - In __cmpxchg_asm() we load the value from memory, ie. dereference the
         pointer, and store the value as an unsigned integer (__ret) whose
         size matches the pointer. For a 32 bit cmpxchg() this means we store
         the value in a u32, because the pointer provided to __cmpxchg_asm()
         by __cmpxchg() is of type volatile u32 *.
      
       - __cmpxchg_asm() then checks whether the value in memory (__ret)
         matches the provided old value, by comparing the two values. This
         results in the u32 being promoted to a 64 bit unsigned long to match
         the old argument - however because both types are unsigned the value
         is zero extended, which does not match the sign extension performed
         on the old value in cmpxchg_local() earlier.
      
      This mismatch means that unfortunate cmpxchg() calls can incorrectly
      fail for 64 bit kernels with kernel_uses_llsc == false. This is the case
      on at least non-SMP Cavium Octeon kernels, which hardcode
      kernel_uses_llsc in their cpu-feature-overrides.h header. Using a
      v4.13-rc7 kernel configured using cavium_octeon_defconfig with SMP
      manually disabled, this presents itself as oddity when we reach
      userland - for example:
      
        can't run '/bin/mount': Text file busy
        can't run '/bin/mkdir': Text file busy
        can't run '/bin/mkdir': Text file busy
        can't run '/bin/mount': Text file busy
        can't run '/bin/hostname': Text file busy
        can't run '/etc/init.d/rcS': Text file busy
        can't run '/sbin/getty': Text file busy
        can't run '/sbin/getty': Text file busy
      
      It appears that some part of the init process, which is in this case
      buildroot's busybox init, is running successfully. It never manages to
      reach the login prompt though, and complains about /sbin/getty being
      busy repeatedly and indefinitely.
      
      Fix this by casting the old value provided to __cmpxchg_asm() to an
      appropriately sized unsigned integer, such that we consistently
      zero-extend avoiding the mismatch. The __cmpxchg_small() case for 8 & 16
      bit values is unaffected because __cmpxchg_small() already masks
      provided values appropriately.
      Signed-off-by: NPaul Burton <paul.burton@imgtec.com>
      Fixes: 8263db4d ("MIPS: cmpxchg: Implement __cmpxchg() as a function")
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/17226/
      Cc: linux-mips@linux-mips.org
      Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      133d68e0
    • K
      MIPS: loongson1: set default number of rx and tx queues for stmmac · 1b6ad6df
      Kelvin Cheung 提交于
      Set the default number of RX and TX queues due to
      the recent changes of stmmac driver.
      Otherwise the ethernet will crash once it starts.
      Signed-off-by: NKelvin Cheung <keguang.zhang@gmail.com>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/17452/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      1b6ad6df
    • M
      MIPS: bpf: Fix uninitialised target compiler error · 94c3390a
      Matt Redfearn 提交于
      Compiling ebpf_jit.c with gcc 4.9 results in a (likely spurious)
      compiler warning, as gcc has detected that the variable "target" may be
      used uninitialised. Since -Werror is active, this is treated as an error
      and causes a kernel build failure whenever CONFIG_MIPS_EBPF_JIT is
      enabled.
      
      arch/mips/net/ebpf_jit.c: In function 'build_one_insn':
      arch/mips/net/ebpf_jit.c:1118:80: error: 'target' may be used
      uninitialized in this function [-Werror=maybe-uninitialized]
          emit_instr(ctx, j, target);
                                                                                      ^
      cc1: all warnings being treated as errors
      
      Fix this by initialising "target" to 0. If it really is used
      uninitialised this would result in a jump to 0 and a detectable run time
      failure.
      Signed-off-by: NMatt Redfearn <matt.redfearn@imgtec.com>
      Fixes: b6bd53f9 ("MIPS: Add missing file for eBPF JIT.")
      Cc: James Hogan <james.hogan@imgtec.com>
      Cc: David Daney <david.daney@cavium.com>
      Cc: David S. Miller <davem@davemloft.net>
      Cc: Colin Ian King <colin.king@canonical.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Cc: <stable@vger.kernel.org> # v4.13+
      Patchwork: https://patchwork.linux-mips.org/patch/17375/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      94c3390a
  3. 21 9月, 2017 3 次提交
    • M
      MIPS: PCI: fix pcibios_map_irq section mismatch · 8eba3651
      Manuel Lauss 提交于
      Drop  the __init from pcibios_map_irq() to make this section mis-
      match go away:
      
      WARNING: vmlinux.o(.text+0x56acd4): Section mismatch in reference from the function pcibios_scanbus() to the function .init.text:pcibios_map_irq()
      The function pcibios_scanbus() references
      the function __init pcibios_map_irq().
      This is often because pcibios_scanbus lacks a __init
      annotation or the annotation of pcibios_map_irq is wrong.
      
      Run-Tested only on Alchemy.
      Signed-off-by: NManuel Lauss <manuel.lauss@gmail.com>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/17267/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      8eba3651
    • J
      MIPS: Fix input modify in __write_64bit_c0_split() · c22c8043
      James Hogan 提交于
      The inline asm in __write_64bit_c0_split() modifies the 64-bit input
      operand by shifting the high register left by 32, and constructing the
      full 64-bit value in the low register (even on a 32-bit kernel), so if
      that value is used again it could cause breakage as GCC would assume the
      registers haven't changed when they have.
      
      To quote the GCC extended asm documentation:
      > Warning: Do not modify the contents of input-only operands (except for
      > inputs tied to outputs). The compiler assumes that on exit from the
      > asm statement these operands contain the same values as they had
      > before executing the statement.
      
      Avoid modifying the input by using a temporary variable as an output
      which is modified instead of the input and not otherwise used. The asm
      is always __volatile__ so GCC shouldn't optimise it out. The low
      register of the temporary output is written before the high register of
      the input is read, so we have two constraint alternatives, one where
      both use the same registers (for when the input value isn't subsequently
      used), and one with an early clobber on the output in case the low
      output uses the same register as the high input. This allows the
      resulting assembly to remain mostly unchanged.
      
      A diff of a MIPS32r6 kernel reveals only three differences, two in
      relation to write_c0_r10k_diag() in cpu_probe() (register allocation
      rearranged slightly but otherwise identical), and one in relation to
      write_c0_cvmmemctl2() in kvm_vz_local_flush_guesttlb_all(), but the
      octeon CPU is only supported on 64-bit kernels where
      __write_64bit_c0_split() isn't used so that shouldn't matter in
      practice. So there currently doesn't appear to be anything broken by
      this bug.
      Signed-off-by: NJames Hogan <james.hogan@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/17315/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      c22c8043
    • A
      MIPS: MSP71xx: Include asm/setup.h · 9bbe7dc0
      Arnd Bergmann 提交于
      msp71xx_defconfig can not be built at the in v4.14-rc1
      
      arch/mips/pmcs-msp71xx/msp_smp.c:72:2: error: implicit declaration of function 'set_vi_handler' [-Werror=implicit-function-declaration]
      
      I don't know what caused the regression, but including the right
      header is the obvious fix.
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/17309/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      9bbe7dc0
  4. 20 9月, 2017 2 次提交
    • P
      MIPS: Fix perf event init · fd0b19ed
      Paul Burton 提交于
      Commit c311c797 ("cpumask: make "nr_cpumask_bits" unsigned")
      modified mipspmu_event_init() to cast the struct perf_event cpu field to
      an unsigned integer before it is compared with nr_cpumask_bits (and
      *ahem* did so without copying the linux-mips mailing list or any MIPS
      developers...). This is broken because the cpu field may be -1 for
      events which follow a process rather than being affine to a particular
      CPU. When this is the case the cast to an unsigned int results in a
      value equal to ULONG_MAX, which is always greater than nr_cpumask_bits
      so we always fail mipspmu_event_init() and return -ENODEV.
      
      The check against nr_cpumask_bits seems nonsensical anyway, so this
      patch simply removes it. The cpu field is going to either be -1 or a
      valid CPU number. Comparing it with nr_cpumask_bits is effectively
      checking that it's a valid cpu number, but it seems safe to rely on the
      core perf events code to ensure that's the case.
      
      The end result is that this fixes use of perf on MIPS when not
      constraining events to a particular CPU, and fixes the "perf list hw"
      command which fails to list any events without this.
      Signed-off-by: NPaul Burton <paul.burton@imgtec.com>
      Fixes: c311c797 ("cpumask: make "nr_cpumask_bits" unsigned")
      Cc: Alexey Dobriyan <adobriyan@gmail.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: linux-mips@linux-mips.org
      Cc: stable <stable@vger.kernel.org> # v4.12+
      Patchwork: https://patchwork.linux-mips.org/patch/17323/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      fd0b19ed
    • L
      MIPS: PCI: Move map_irq() hooks out of initdata · 19a8d6b7
      Lorenzo Pieralisi 提交于
      04c81c72 ("MIPS: PCI: Replace pci_fixup_irqs() call with host bridge
      IRQ mapping hooks") moved the PCI IRQ fixup to the new host bridge
      map/swizzle_irq() hooks mechanism. Those hooks can also be called after
      boot, when all the __init/__initdata/__initconst sections have been freed.
      Therefore, functions called by them (and the data they refer to) must not
      be marked as __init/__initdata/__initconst lest compilation trigger section
      mismatch warnings.
      
      Fix all the board files map_irq() hooks by simply removing the respective
      __init/__initdata/__initconst section markers and by adding another
      persistent hook IRQ map for the txx9 board files.
      
      Fixes: 04c81c72 ("MIPS: PCI: Replace pci_fixup_irqs() call with host bridge IRQ mapping hooks")
      Signed-off-by: NLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      Reviewed-by: NArnd Bergmann <arnd@arndb.de>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Steve French <smfrench@gmail.com>
      19a8d6b7
  5. 15 9月, 2017 1 次提交
  6. 09 9月, 2017 1 次提交
    • M
      vga: optimise console scrolling · ac036f95
      Matthew Wilcox 提交于
      Where possible, call memset16(), memmove() or memcpy() instead of using
      open-coded loops.  I don't like the calling convention that uses a byte
      count instead of a count of u16s, but it's a little late to change that.
      Reduces code size of fbcon.o by almost 400 bytes on my laptop build.
      
      [akpm@linux-foundation.org: fix build]
      Link: http://lkml.kernel.org/r/20170720184539.31609-9-willy@infradead.orgSigned-off-by: NMatthew Wilcox <mawilcox@microsoft.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: David Miller <davem@davemloft.net>
      Cc: Sam Ravnborg <sam@ravnborg.org>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: "James E.J. Bottomley" <jejb@linux.vnet.ibm.com>
      Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
      Cc: Matt Turner <mattst88@gmail.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Minchan Kim <minchan@kernel.org>
      Cc: Richard Henderson <rth@twiddle.net>
      Cc: Russell King <rmk+kernel@armlinux.org.uk>
      Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      ac036f95
  7. 07 9月, 2017 2 次提交
    • R
      mm,fork: introduce MADV_WIPEONFORK · d2cd9ede
      Rik van Riel 提交于
      Introduce MADV_WIPEONFORK semantics, which result in a VMA being empty
      in the child process after fork.  This differs from MADV_DONTFORK in one
      important way.
      
      If a child process accesses memory that was MADV_WIPEONFORK, it will get
      zeroes.  The address ranges are still valid, they are just empty.
      
      If a child process accesses memory that was MADV_DONTFORK, it will get a
      segmentation fault, since those address ranges are no longer valid in
      the child after fork.
      
      Since MADV_DONTFORK also seems to be used to allow very large programs
      to fork in systems with strict memory overcommit restrictions, changing
      the semantics of MADV_DONTFORK might break existing programs.
      
      MADV_WIPEONFORK only works on private, anonymous VMAs.
      
      The use case is libraries that store or cache information, and want to
      know that they need to regenerate it in the child process after fork.
      
      Examples of this would be:
       - systemd/pulseaudio API checks (fail after fork) (replacing a getpid
         check, which is too slow without a PID cache)
       - PKCS#11 API reinitialization check (mandated by specification)
       - glibc's upcoming PRNG (reseed after fork)
       - OpenSSL PRNG (reseed after fork)
      
      The security benefits of a forking server having a re-inialized PRNG in
      every child process are pretty obvious.  However, due to libraries
      having all kinds of internal state, and programs getting compiled with
      many different versions of each library, it is unreasonable to expect
      calling programs to re-initialize everything manually after fork.
      
      A further complication is the proliferation of clone flags, programs
      bypassing glibc's functions to call clone directly, and programs calling
      unshare, causing the glibc pthread_atfork hook to not get called.
      
      It would be better to have the kernel take care of this automatically.
      
      The patch also adds MADV_KEEPONFORK, to undo the effects of a prior
      MADV_WIPEONFORK.
      
      This is similar to the OpenBSD minherit syscall with MAP_INHERIT_ZERO:
      
          https://man.openbsd.org/minherit.2
      
      [akpm@linux-foundation.org: numerically order arch/parisc/include/uapi/asm/mman.h #defines]
      Link: http://lkml.kernel.org/r/20170811212829.29186-3-riel@redhat.comSigned-off-by: NRik van Riel <riel@redhat.com>
      Reported-by: NFlorian Weimer <fweimer@redhat.com>
      Reported-by: NColm MacCártaigh <colm@allcosts.net>
      Reviewed-by: NMike Kravetz <mike.kravetz@oracle.com>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: "Kirill A. Shutemov" <kirill@shutemov.name>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Dave Hansen <dave.hansen@intel.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Helge Deller <deller@gmx.de>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Will Drewry <wad@chromium.org>
      Cc: <linux-api@vger.kernel.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      d2cd9ede
    • M
      mm: arch: consolidate mmap hugetlb size encodings · aafd4562
      Mike Kravetz 提交于
      A non-default huge page size can be encoded in the flags argument of the
      mmap system call.  The definitions for these encodings are in arch
      specific header files.  However, all architectures use the same values.
      
      Consolidate all the definitions in the primary user header file
      (uapi/linux/mman.h).  Include definitions for all known huge page sizes.
      Use the generic encoding definitions in hugetlb_encode.h as the basis
      for these definitions.
      
      Link: http://lkml.kernel.org/r/1501527386-10736-3-git-send-email-mike.kravetz@oracle.comSigned-off-by: NMike Kravetz <mike.kravetz@oracle.com>
      Acked-by: NMichal Hocko <mhocko@suse.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Andrea Arcangeli <aarcange@redhat.com>
      Cc: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
      Cc: Anshuman Khandual <khandual@linux.vnet.ibm.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Davidlohr Bueso <dbueso@suse.de>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Michael Kerrisk <mtk.manpages@gmail.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      aafd4562
  8. 06 9月, 2017 17 次提交
    • M
      MIPS: Refactor handling of stack pointer in get_frame_info · 56dfb700
      Matt Redfearn 提交于
      Commit 34c2f668 ("MIPS: microMIPS: Add unaligned access support.")
      added handling of microMIPS instructions to manipulate the stack
      pointer. The code that was added violates code style rules with long
      lines caused by lots of nested conditionals.
      
      The added code interprets (inline) any known stack pointer manipulation
      instruction to find the stack frame size. Handling the microMIPS cases
      added quite a bit of complication to this function.
      
      Refactor is_sp_move_ins to perform the interpretation of the immediate
      as the instruction manipulating the stack pointer is found. This reduces
      the amount of indentation required in get_frame_info, and more closely
      matches the operation of is_ra_save_ins.
      Suggested-by: NMaciej W. Rozycki <macro@imgtec.com>
      Signed-off-by: NMatt Redfearn <matt.redfearn@imgtec.com>
      Cc: Marcin Nowakowski <marcin.nowakowski@imgtec.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Paul Burton <paul.burton@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/16958/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      56dfb700
    • M
      MIPS: Stacktrace: Fix microMIPS stack unwinding on big endian systems · 41885b02
      Matt Redfearn 提交于
      The stack unwinding code uses the mips_instuction union to decode the
      instructions it finds. That union uses the __BITFIELD_FIELD macro to
      reorder depending on endianness. The stack unwinding code always places
      16bit instructions in halfword 1 of the union. This makes the union
      accesses correct for little endian systems. Similarly, 32bit
      instructions are reordered such that they are correct for little endian
      systems. This handling leaves unwinding the stack on big endian systems
      broken, as the mips_instruction union will then look for the fields in
      the wrong halfword.
      
      To fix this, use a logical shift to place the 16bit instruction into the
      correct position in the word field of the union. Use the same shifting
      to order the 2 halfwords of 32bit instuctions. Then replace accesses to
      the halfword with accesses to the shifted word.
      In the case of the ADDIUS5 instruction, switch to using the
      mm16_r5_format union member to avoid the need for a 16bit shift.
      
      Fixes: 34c2f668 ("MIPS: microMIPS: Add unaligned access support.")
      Signed-off-by: NMatt Redfearn <matt.redfearn@imgtec.com>
      Reviewed-by: NJames Hogan <james.hogan@imgtec.com>
      Cc: Marcin Nowakowski <marcin.nowakowski@imgtec.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Paul Burton <paul.burton@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/16956/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      41885b02
    • M
      MIPS: microMIPS: Fix decoding of swsp16 instruction · cea8cd49
      Matt Redfearn 提交于
      When the immediate encoded in the instruction is accessed, it is sign
      extended due to being a signed value being assigned to a signed integer.
      The ISA specifies that this operation is an unsigned operation.
      The sign extension leads us to incorrectly decode:
      
      801e9c8e:       cbf1            sw      ra,68(sp)
      
      As having an immediate of 1073741809.
      
      Since the instruction format does not specify signed/unsigned, and this
      is currently the only location to use this instuction format, change it
      to an unsigned immediate.
      
      Fixes: bb9bc468 ("MIPS: Calculate microMIPS ra properly when unwinding the stack")
      Suggested-by: NPaul Burton <paul.burton@imgtec.com>
      Signed-off-by: NMatt Redfearn <matt.redfearn@imgtec.com>
      Reviewed-by: NJames Hogan <james.hogan@imgtec.com>
      Cc: Marcin Nowakowski <marcin.nowakowski@imgtec.com>
      Cc: Miodrag Dinic <miodrag.dinic@imgtec.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: David Daney <david.daney@cavium.com>
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/16957/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      cea8cd49
    • M
      MIPS: microMIPS: Fix decoding of addiusp instruction · a0ae2b08
      Matt Redfearn 提交于
      Commit 34c2f668 ("MIPS: microMIPS: Add unaligned access support.")
      added handling of microMIPS instructions to manipulate the stack
      pointer. Unfortunately the decoding of the addiusp instruction was
      incorrect, and performed a left shift by 2 bits to the raw immediate,
      rather than decoding the immediate and then performing the shift, as
      documented in the ISA.
      
      This led to incomplete stack traces, due to incorrect frame sizes being
      calculated. For example the instruction:
      801faee0 <do_sys_poll>:
      801faee0:       4e25            addiu   sp,sp,-952
      
      As decoded by objdump, would be interpreted by the existing code as
      having manipulated the stack pointer by +1096.
      
      Fix this by changing the order of decoding the immediate and applying
      the left shift. Also change to accessing the instuction through the
      union to avoid the endianness problem of accesing halfword[0], which
      will fail on big endian systems.
      
      Cope with the special behaviour of immediates 0x0, 0x1, 0x1fe and 0x1ff
      by XORing with 0x100 again if mod(immediate) < 4. This logic was tested
      with the following test code:
      
      int main(int argc, char **argv)
      {
      	unsigned int enc;
      	int imm;
      
      	for (enc = 0; enc < 512; ++enc) {
      		int tmp = enc << 2;
      		imm = -(signed short)(tmp | ((tmp & 0x100) ? 0xfe00 : 0));
      		unsigned short tmp = enc;
      		tmp = (tmp ^ 0x100) - 0x100;
      		if ((unsigned short)(tmp + 2) < 4)
      			tmp ^= 0x100;
      		imm = -(signed short)(tmp << 2);
      		printf("%#x\t%d\t->\t(%#x\t%d)\t%#x\t%d\n",
      		       enc, enc,
      		       (short)tmp, (short)tmp,
      		       imm, imm);
      	}
      	return EXIT_SUCCESS;
      }
      
      Which generates the table:
      
      input encoding	->	tmp (matching manual)	frame size
      -----------------------------------------------------------------------
      0	0	->	(0x100		256)	0xfffffc00	-1024
      0x1	1	->	(0x101		257)	0xfffffbfc	-1028
      0x2	2	->	(0x2		2)	0xfffffff8	-8
      0x3	3	->	(0x3		3)	0xfffffff4	-12
      ...
      0xfe	254	->	(0xfe		254)	0xfffffc08	-1016
      0xff	255	->	(0xff		255)	0xfffffc04	-1020
      0x100	256	->	(0xffffff00	-256)	0x400		1024
      0x101	257	->	(0xffffff01	-255)	0x3fc		1020
      ...
      0x1fc	508	->	(0xfffffffc	-4)	0x10		16
      0x1fd	509	->	(0xfffffffd	-3)	0xc		12
      0x1fe	510	->	(0xfffffefe	-258)	0x408		1032
      0x1ff	511	->	(0xfffffeff	-257)	0x404		1028
      
      Thanks to James Hogan for the test code & verifying the logic.
      
      Fixes: 34c2f668 ("MIPS: microMIPS: Add unaligned access support.")
      Suggested-by: NJames Hogan <james.hogan@imgtec.com>
      Signed-off-by: NMatt Redfearn <matt.redfearn@imgtec.com>
      Cc: Marcin Nowakowski <marcin.nowakowski@imgtec.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Paul Burton <paul.burton@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/16955/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      a0ae2b08
    • M
      MIPS: microMIPS: Fix detection of addiusp instruction · b332fec0
      Matt Redfearn 提交于
      The addiusp instruction uses the pool16d opcode, with bit 0 of the
      immediate set. The test for the addiusp opcode erroneously did a logical
      and of the immediate with mm_addiusp_func, which has value 1, so this
      test always passes when the immediate is non-zero.
      
      Fix the test by replacing the logical and with a bitwise and.
      
      Fixes: 34c2f668 ("MIPS: microMIPS: Add unaligned access support.")
      Signed-off-by: NMatt Redfearn <matt.redfearn@imgtec.com>
      Cc: Marcin Nowakowski <marcin.nowakowski@imgtec.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Paul Burton <paul.burton@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/16954/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      b332fec0
    • M
      MIPS: Handle non word sized instructions when examining frame · 11887ed1
      Matt Redfearn 提交于
      Commit 34c2f668 ("MIPS: microMIPS: Add unaligned access support.")
      added fairly broken support for handling 16bit microMIPS instructions in
      get_frame_info(). It adjusts the instruction pointer by 16bits in the
      case of a 16bit sp move instruction, but not any other 16bit
      instruction.
      
      Commit b6c7a324 ("MIPS: Fix get_frame_info() handling of microMIPS
      function size") goes some way to fixing get_frame_info() to iterate over
      microMIPS instuctions, but the instruction pointer is still manipulated
      using a postincrement, and is of union mips_instruction type. Since the
      union is sized to the largest member (a word), but microMIPS
      instructions are a mix of halfword and word sizes, the function does not
      always iterate correctly, ending up misaligned with the instruction
      stream and interpreting it incorrectly.
      
      Since the instruction modifying the stack pointer is usually the first
      in the function, that one is usually handled correctly. But the
      instruction which saves the return address to the sp is some variable
      number of instructions into the frame and is frequently missed due to
      not being on a word boundary, leading to incomplete walking of the
      stack.
      
      Fix this by incrementing the instruction pointer based on the size of
      the previously decoded instruction (& remove the hack introduced by
      commit 34c2f668 ("MIPS: microMIPS: Add unaligned access support.")
      which adjusts the instruction pointer in the case of a 16bit sp move
      instruction, but not any other).
      
      Fixes: 34c2f668 ("MIPS: microMIPS: Add unaligned access support.")
      Signed-off-by: NMatt Redfearn <matt.redfearn@imgtec.com>
      Cc: Marcin Nowakowski <marcin.nowakowski@imgtec.com>
      Cc: James Hogan <james.hogan@imgtec.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Paul Burton <paul.burton@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/16953/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      11887ed1
    • J
      MIPS: ralink: allow NULL clock for clk_get_rate · a18097b7
      Jonas Gorski 提交于
      Make the behaviour of clk_get_rate consistent with common clk's
      clk_get_rate by accepting NULL clocks as parameter. Some device
      drivers rely on this, and will cause an OOPS otherwise.
      
      Fixes: 3f0a06b0 ("MIPS: ralink: adds clkdev code")
      Reported-by: NMathias Kresin <dev@kresin.me>
      Signed-off-by: NJonas Gorski <jonas.gorski@gmail.com>
      Cc: John Crispin <john@phrozen.org>
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/16778/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      a18097b7
    • J
      MIPS: Loongson 2F: allow NULL clock for clk_get_rate · 386787b1
      Jonas Gorski 提交于
      Make the behaviour of clk_get_rate consistent with common clk's
      clk_get_rate by accepting NULL clocks as parameter, as some device
      drivers rely on this.
      
      Make the behaviour of clk_get_rate consistent with common clk's
      clk_get_rate by accepting NULL clocks as parameter. Some device
      drivers rely on this, and will cause an OOPS otherwise.
      
      Fixes: f8ede0f7 ("MIPS: Loongson 2F: Add CPU frequency scaling support")
      Reported-by: NMathias Kresin <dev@kresin.me>
      Signed-off-by: NJonas Gorski <jonas.gorski@gmail.com>
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/16777/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      386787b1
    • J
      MIPS: BCM63XX: allow NULL clock for clk_get_rate · 1b495fae
      Jonas Gorski 提交于
      Make the behaviour of clk_get_rate consistent with common clk's
      clk_get_rate by accepting NULL clocks as parameter. Some device
      drivers rely on this, and will cause an OOPS otherwise.
      
      Fixes: e7300d04 ("MIPS: BCM63xx: Add support for the Broadcom BCM63xx family of SOCs.")
      Reported-by: NMathias Kresin <dev@kresin.me>
      Signed-off-by: NJonas Gorski <jonas.gorski@gmail.com>
      Reviewed-by: NFlorian Fainelli <f.fainelli@gmail.com>
      Cc: bcm-kernel-feedback-list@broadcom.com
      Cc: James Hogan <james.hogan@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/16776/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      1b495fae
    • J
      MIPS: AR7: allow NULL clock for clk_get_rate · 585e0e9d
      Jonas Gorski 提交于
      Make the behaviour of clk_get_rate consistent with common clk's
      clk_get_rate by accepting NULL clocks as parameter. Some device
      drivers rely on this, and will cause an OOPS otherwise.
      
      Fixes: 780019dd ("MIPS: AR7: Implement clock API")
      Signed-off-by: NJonas Gorski <jonas.gorski@gmail.com>
      Reported-by: NMathias Kresin <dev@kresin.me>
      Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
      Cc: James Hogan <james.hogan@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/16775/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      585e0e9d
    • J
      MIPS: BCM63XX: fix ENETDMA_6345_MAXBURST_REG offset · eebc6056
      Jonas Gorski 提交于
      The channels are only 0x40 bytes large, so 0x40 would be the next one's
      CHANCFG_REG. Also the position makes it clear that this was intended to
      be 0x04. So clearly a typo.
      Signed-off-by: NJonas Gorski <jonas.gorski@gmail.com>
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: linux-mips@linux-mips.org
      Cc: bcm-kernel-feedback-list@broadcom.com
      Patchwork: https://patchwork.linux-mips.org/patch/15316/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      eebc6056
    • C
      mips: Save all registers when saving the frame · 5b6b0847
      Corey Minyard 提交于
      The MIPS frame save code was just saving a few registers, enough to
      do a backtrace if every function set up a frame.  However, this is
      not working if you are using DWARF unwinding, because most of the
      registers are wrong.  This was causing kdump backtraces to be short
      or bogus.
      
      So save all the registers.
      Signed-off-by: NCorey Minyard <cminyard@mvista.com>
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/16989/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      5b6b0847
    • C
      MIPS: Add DWARF unwinding to assembly · 866b6a89
      Corey Minyard 提交于
      This will allow kdump dumps to work correclty with MIPS and
      future DWARF unwinding of the stack to give accurate tracebacks.
      Signed-off-by: NCorey Minyard <cminyard@mvista.com>
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/16990/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      866b6a89
    • C
      MIPS: Make SAVE_SOME more standard · 9fef6868
      Corey Minyard 提交于
      Modify the SAVE_SOME macro to look more like a standard
      function, doing the arithmetic for the frame on the SP
      register instead of copying it from K1, and by saving
      the stored EPC from the RA.  This lets the get_frame_info()
      function process this function like any other.  It also
      remove an instruction or two from the kernel entry,
      making it more efficient.
      
      unwind_stack_by_address() has special handling for
      the top of the interrupt stack, but without this change
      unwinding will still fail if you get an interrupt while
      handling an interrupt and try to do a traceback from
      the second interrupt.
      
      This change modifies the get_saved_sp macro to
      optionally store the fetched value right into sp and store the
      old SP value into K0.  Then it's just a matter of subtracting
      the frame from SP and storing the old SP from K0.
      
      This required changing the DADDI workaround a bit, since K0
      holds the SP, we had to use K1 for AT.  But it eliminated
      some of the special handling for the DADDI workaround.
      
      Saving the RA register was moved up to before fetching the
      CP0_EPC register, so the CP0_EPC register could be stored
      into RA and the saved.  This lets the traceback code know
      where RA is actually stored.
      Signed-off-by: NCorey Minyard <cminyard@mvista.com>
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/16991/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      9fef6868
    • C
      MIPS: Fix issues in backtraces · aee16625
      Corey Minyard 提交于
      I saw two problems when doing backtraces:
      
      The compiler was putting a "fast return" at the top of some
      functions, before it set up the frame.  The backtrace code
      would stop when it saw a jump instruction, so it would never
      get to the stack frame setup and would thus misinterpret it.
      To fix this, don't look for jump instructions until the
      frame setup has been seen.
      
      The assembly code here is:
      
      ffffffff80b885a0 <serial8250_handle_irq>:
      ffffffff80b885a0:       c8a00003        bbit0   a1,0x0,ffffffff80b885b0 <serial8250_handle_irq+0x10>
      ffffffff80b885a4:       0000102d        move    v0,zero
      ffffffff80b885a8:       03e00008        jr      ra
      ffffffff80b885ac:       00000000        nop
      ffffffff80b885b0:       67bdffd0        daddiu  sp,sp,-48
      ffffffff80b885b4:       ffb00008        sd      s0,8(sp)
      
      The second problem was the compiler was putting the last
      instruction of the frame save in the delay slot of the
      jump instruction.  If it saved the RA in there, the
      backtrace could would miss it and misinterpret the frame.
      To fix this, make sure to process the instruction after
      the first jump seen.
      
      The assembly code for this is:
      
      ffffffff80806fd0 <plat_irq_dispatch>:
      ffffffff80806fd0:       67bdffd0        daddiu  sp,sp,-48
      ffffffff80806fd4:       ffb30020        sd      s3,32(sp)
      ffffffff80806fd8:       24130018        li      s3,24
      ffffffff80806fdc:       ffb20018        sd      s2,24(sp)
      ffffffff80806fe0:       3c12811c        lui     s2,0x811c
      ffffffff80806fe4:       ffb10010        sd      s1,16(sp)
      ffffffff80806fe8:       3c11811c        lui     s1,0x811c
      ffffffff80806fec:       ffb00008        sd      s0,8(sp)
      ffffffff80806ff0:       3c10811c        lui     s0,0x811c
      ffffffff80806ff4:       08201c03        j       ffffffff8080700c <plat_irq_dispa
      tch+0x3c>
      ffffffff80806ff8:       ffbf0028        sd      ra,40(sp)
      Signed-off-by: NCorey Minyard <cminyard@mvista.com>
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/16992/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      aee16625
    • M
      MIPS: jz4780: DTS: Probe the jz4740-rtc driver from devicetree · ed326616
      Mathieu Malaterre 提交于
      The jz4740-rtc driver supports both jz4740 & jz4780, setup the compatible
      string to jz4780.
      Signed-off-by: NMathieu Malaterre <malat@debian.org>
      Cc: Rob Herring <robh+dt@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Linus Walleij <linus.walleij@linaro.org>
      Cc: Paul Cercueil <paul@crapouillou.net>
      Cc: Krzysztof Kozlowski <krzk@kernel.org>
      Cc: devicetree@vger.kernel.org
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/17237/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      ed326616
    • M
      MIPS: Ci20: Enable RTC driver · c76a5ba2
      Mathieu Malaterre 提交于
      Update the Ci20's defconfig to enable the JZ4780's RTC driver.
      Signed-off-by: NMathieu Malaterre <malat@debian.org>
      Cc: Rob Herring <robh+dt@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Linus Walleij <linus.walleij@linaro.org>
      Cc: Paul Cercueil <paul@crapouillou.net>
      Cc: Krzysztof Kozlowski <krzk@kernel.org>
      Cc: devicetree@vger.kernel.org
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/17236/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      c76a5ba2
  9. 05 9月, 2017 8 次提交