1. 29 8月, 2017 5 次提交
    • 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
    • K
      MIPS: defconfig: Cleanup from non-existing options · b879c801
      Krzysztof Kozlowski 提交于
      Remove options which do not exist anymore:
       - CPU_FREQ_DEBUG is gone since commit 2d06d8c4  ("[CPUFREQ] use
         dynamic debug instead of custom infrastructure").
      
       - ECONET is gone since commit 349f29d8 ("econet: remove ancient bug
         ridden protocol");
      
       - IPDDP_DECAP is gone since commit 9b5645b5 ("appletalk: remove
         "config IPDDP_DECAP"");
      Signed-off-by: NKrzysztof Kozlowski <krzk@kernel.org>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/16770/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      b879c801
    • R
      MIPS: Convert to using %pOF instead of full_name · 7f27b5b8
      Rob Herring 提交于
      Now that we have a custom printf format specifier, convert users of
      full_name to use %pOF instead. This is preparation to remove storing
      of the full path string for each node.
      Signed-off-by: NRob Herring <robh@kernel.org>
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Cc: devicetree@vger.kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/16783/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      7f27b5b8
  2. 08 8月, 2017 4 次提交
    • P
      MIPS: Set ISA bit in entry-y for microMIPS kernels · 5fc9484f
      Paul Burton 提交于
      When building a kernel for the microMIPS ISA, ensure that the ISA bit
      (ie. bit 0) in the entry address is set. Otherwise we may include an
      entry address in images which bootloaders will jump to as MIPS32 code.
      
      I originally tried using "objdump -f" to obtain the entry address, which
      works for microMIPS but it always outputs a 32 bit address for a 32 bit
      ELF whilst nm will sign extend to 64 bit. That matters for systems where
      we might want to run a MIPS32 kernel on a MIPS64 CPU & load it with a
      MIPS64 bootloader, which would then jump to a non-canonical
      (non-sign-extended) address.
      
      This works in all cases as it only changes the behaviour for microMIPS
      kernels, but isn't the prettiest solution. A possible alternative would
      be to write a custom tool to just extract, sign extend & print the entry
      point of an ELF executable. I'm open to feedback if that would be
      preferred.
      Signed-off-by: NPaul Burton <paul.burton@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/16950/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      5fc9484f
    • P
      MIPS: Prevent building MT support for microMIPS kernels · 527f1028
      Paul Burton 提交于
      We don't currently support the MT ASE for microMIPS kernels, and there
      are no CPUs currently in existence that use both. They can however both
      be enabled in Kconfig, resulting in build failures such as:
      
        AS      arch/mips/kernel/cps-vec.o
      arch/mips/kernel/cps-vec.S: Assembler messages:
      arch/mips/kernel/cps-vec.S:242: Warning: the 32-bit microMIPS architecture does not support the `mt' extension
      arch/mips/kernel/cps-vec.S:276: Error: unrecognized opcode `mttc0 $13,$2,2'
      arch/mips/kernel/cps-vec.S:282: Error: unrecognized opcode `mttc0 $8,$1,2'
      arch/mips/kernel/cps-vec.S:285: Error: unrecognized opcode `mttc0 $0,$2,1'
      ...
      
      Fix this by preventing MT from being enabled when targeting microMIPS.
      Signed-off-by: NPaul Burton <paul.burton@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/16951/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      527f1028
    • M
      MIPS: PCI: Fix smp_processor_id() in preemptible · 73530266
      Matt Redfearn 提交于
      Commit 1c3c5eab ("sched/core: Enable might_sleep() and
      smp_processor_id() checks early") enables checks for might_sleep() and
      smp_processor_id() being used in preemptible code earlier in the boot
      than before. This results in a new BUG from
      pcibios_set_cache_line_size().
      
      BUG: using smp_processor_id() in preemptible [00000000] code:
      swapper/0/1 caller is pcibios_set_cache_line_size+0x10/0x70
      CPU: 1 PID: 1 Comm: swapper/0 Not tainted 4.13.0-rc1-00007-g3ce3e4ba4275 #615
      Stack: 0000000000000000 ffffffff81189694 0000000000000000 ffffffff81822318
             000000000000004e 0000000000000001 800000000e20bd08 20c49ba5e3540000
             0000000000000000 0000000000000000 ffffffff818d0000 0000000000000000
             0000000000000000 ffffffff81189328 ffffffff818ce692 0000000000000000
             0000000000000000 ffffffff81189bc8 ffffffff818d0000 0000000000000000
             ffffffff81828907 ffffffff81769970 800000020ec78d80 ffffffff818c7b48
             0000000000000001 0000000000000001 ffffffff818652b0 ffffffff81896268
             ffffffff818c0000 800000020ec7fb40 800000020ec7fc58 ffffffff81684cac
             0000000000000000 ffffffff8118ab50 0000000000000030 ffffffff81769970
             0000000000000001 ffffffff81122a58 0000000000000000 0000000000000000 ...
      Call Trace:
      [<ffffffff81122a58>] show_stack+0x90/0xb0
      [<ffffffff81684cac>] dump_stack+0xac/0xf0
      [<ffffffff813f7050>] check_preemption_disabled+0x120/0x128
      [<ffffffff818855e8>] pcibios_set_cache_line_size+0x10/0x70
      [<ffffffff81100578>] do_one_initcall+0x48/0x140
      [<ffffffff81865dc4>] kernel_init_freeable+0x194/0x24c
      [<ffffffff8169c534>] kernel_init+0x14/0x118
      [<ffffffff8111ca84>] ret_from_kernel_thread+0x14/0x1c
      
      Fix this by using the cpu_*cache_line_size() macros instead. These
      macros are the "proper" way to determine the CPU cache sizes.
      This makes use of the newly added cpu_tcache_line_size.
      
      Fixes: 1c3c5eab ("sched/core: Enable might_sleep() and smp_processor_id() checks early")
      Signed-off-by: NMatt Redfearn <matt.redfearn@imgtec.com>
      Suggested-by: NJames Hogan <james.hogan@imgtec.com>
      Reviewed-by: NJames Hogan <james.hogan@imgtec.com>
      Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      73530266
    • M
      MIPS: Introduce cpu_tcache_line_size · 21da5332
      Matt Redfearn 提交于
      There exist macros to return the cache line size of the L1 dcache and L2
      scache but there is currently no macro for the L3 tcache. Add this macro
      which will be used by the following patch "MIPS: PCI: Fix
      smp_processor_id() in preemptible"
      Signed-off-by: NMatt Redfearn <matt.redfearn@imgtec.com>
      Cc: Maciej W. Rozycki <macro@imgtec.com>
      Cc: James Hogan <james.hogan@imgtec.com>
      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/16871/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      21da5332
  3. 07 8月, 2017 8 次提交
  4. 05 8月, 2017 1 次提交
  5. 20 7月, 2017 1 次提交
  6. 19 7月, 2017 2 次提交
    • H
      MIPS: ralink: mt7620: Add missing header · f13343e8
      Harvey Hunt 提交于
      Fix a build error caused by not including <linux/bug.h>.
      
      The following compilation errors are caused by the missing header:
      
      arch/mips/ralink/mt7620.c: In function ‘mt7620_get_cpu_pll_rate’:
      arch/mips/ralink/mt7620.c:431:2: error: implicit declaration of function ‘WARN_ON’ [-Werror=implicit-function-declaration]
        WARN_ON(div >= ARRAY_SIZE(mt7620_clk_divider));
        ^
      arch/mips/ralink/mt7620.c: In function ‘mt7620_get_sys_rate’:
      arch/mips/ralink/mt7620.c:500:2: error: implicit declaration of function ‘WARN’ [-Werror=implicit-function-declaration]
        if (WARN(!div, "invalid divider for OCP ratio %u", ocp_ratio))
        ^
      arch/mips/ralink/mt7620.c: In function ‘mt7620_dram_init’:
      arch/mips/ralink/mt7620.c:619:3: error: implicit declaration of function ‘BUG’ [-Werror=implicit-function-declaration]
         BUG();
         ^
      cc1: some warnings being treated as errors
      scripts/Makefile.build:302: recipe for target 'arch/mips/ralink/mt7620.o' failed
      Signed-off-by: NHarvey Hunt <harvey.hunt@imgtec.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/16781/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      f13343e8
    • H
      MIPS: ralink: Fix build error due to missing header · e3ccf1d1
      Harvey Hunt 提交于
      Previously, <linux/module.h> was included before ralink_regs.h in all
      ralink files - leading to <linux/io.h> being implicitly included.
      
      After commit 26dd3e4f ("MIPS: Audit and remove any unnecessary
      uses of module.h") removed the inclusion of module.h from multiple
      places, some ralink platforms failed to build with the following error:
      
      In file included from arch/mips/ralink/mt7620.c:17:0:
      ./arch/mips/include/asm/mach-ralink/ralink_regs.h: In function ‘rt_sysc_w32’:
      ./arch/mips/include/asm/mach-ralink/ralink_regs.h:38:2: error: implicit declaration of function ‘__raw_writel’ [-Werror=implicit-function-declaration]
        __raw_writel(val, rt_sysc_membase + reg);
        ^
      ./arch/mips/include/asm/mach-ralink/ralink_regs.h: In function ‘rt_sysc_r32’:
      ./arch/mips/include/asm/mach-ralink/ralink_regs.h:43:2: error: implicit declaration of function ‘__raw_readl’ [-Werror=implicit-function-declaration]
        return __raw_readl(rt_sysc_membase + reg);
      
      Fix this by including <linux/io.h>.
      Signed-off-by: NHarvey Hunt <harvey.hunt@imgtec.com>
      Fixes: 26dd3e4f ("MIPS: Audit and remove any unnecessary uses of module.h")
      Cc: John Crispin <john@phrozen.org>
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Cc: <stable@vger.kernel.org> #4.11+
      Patchwork: https://patchwork.linux-mips.org/patch/16780/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      e3ccf1d1
  7. 17 7月, 2017 1 次提交
  8. 13 7月, 2017 2 次提交
    • J
      MIPS: SMP: move asmlinkage before return type · b745fcb9
      Joe Perches 提交于
      Make the code like the rest of the kernel.
      
      Link: http://lkml.kernel.org/r/756d3fb543e981b9284e756fa27616725a354b28.1499284835.git.joe@perches.comSigned-off-by: NJoe Perches <joe@perches.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      b745fcb9
    • M
      MIPS: do not use __GFP_REPEAT for order-0 request · 473738eb
      Michal Hocko 提交于
      Patch series "mm: give __GFP_REPEAT a better semantic".
      
      The main motivation for the change is that the current implementation of
      __GFP_REPEAT is not very much useful.
      
      The documentation says:
       * __GFP_REPEAT: Try hard to allocate the memory, but the allocation attempt
       *   _might_ fail.  This depends upon the particular VM implementation.
      
      It just fails to mention that this is true only for large (costly) high
      order which has been the case since the flag was introduced.  A similar
      semantic would be really helpful for smal orders as well, though,
      because we have places where a failure with a specific fallback error
      handling is preferred to a potential endless loop inside the page
      allocator.
      
      The earlier cleanup dropped __GFP_REPEAT usage for low (!costly) order
      users so only those which might use larger orders have stayed.  One new
      user added in the meantime is addressed in patch 1.
      
      Let's rename the flag to something more verbose and use it for existing
      users.  Semantic for those will not change.  Then implement low
      (!costly) orders failure path which is hit after the page allocator is
      about to invoke the oom killer.  With that we have a good counterpart
      for __GFP_NORETRY and finally can tell try as hard as possible without
      the OOM killer.
      
      Xfs code already has an existing annotation for allocations which are
      allowed to fail and we can trivially map them to the new gfp flag
      because it will provide the semantic KM_MAYFAIL wants.  Christoph didn't
      consider the new flag really necessary but didn't respond to the OOM
      killer aspect of the change so I have kept the patch.  If this is still
      seen as not really needed I can drop the patch.
      
      kvmalloc will allow also !costly high order allocations to retry hard
      before falling back to the vmalloc.
      
      drm/i915 asked for the new semantic explicitly.
      
      Memory migration code, especially for the memory hotplug, should back
      off rather than invoking the OOM killer as well.
      
      This patch (of 6):
      
      Commit 3377e227 ("MIPS: Add 48-bit VA space (and 4-level page
      tables) for 4K pages.") has added a new __GFP_REPEAT user but using this
      flag doesn't really make any sense for order-0 request which is the case
      here because PUD_ORDER is 0.  __GFP_REPEAT has historically effect only
      on allocation requests with order > PAGE_ALLOC_COSTLY_ORDER.
      
      This doesn't introduce any functional change.  This is a preparatory
      patch for later work which renames the flag and redefines its semantic.
      
      Link: http://lkml.kernel.org/r/20170623085345.11304-2-mhocko@kernel.orgSigned-off-by: NMichal Hocko <mhocko@suse.com>
      Acked-by: NVlastimil Babka <vbabka@suse.cz>
      Cc: Alex Belits <alex.belits@cavium.com>
      Cc: David Daney <david.daney@cavium.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Johannes Weiner <hannes@cmpxchg.org>
      Cc: Mel Gorman <mgorman@suse.de>
      Cc: NeilBrown <neilb@suse.com>
      Cc: Christoph Hellwig <hch@infradead.org>
      Cc: Chris Wilson <chris@chris-wilson.co.uk>
      Cc: Darrick J. Wong <darrick.wong@oracle.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      473738eb
  9. 11 7月, 2017 11 次提交
  10. 07 7月, 2017 1 次提交
    • P
      mm/hugetlb: add size parameter to huge_pte_offset() · 7868a208
      Punit Agrawal 提交于
      A poisoned or migrated hugepage is stored as a swap entry in the page
      tables.  On architectures that support hugepages consisting of
      contiguous page table entries (such as on arm64) this leads to ambiguity
      in determining the page table entry to return in huge_pte_offset() when
      a poisoned entry is encountered.
      
      Let's remove the ambiguity by adding a size parameter to convey
      additional information about the requested address.  Also fixup the
      definition/usage of huge_pte_offset() throughout the tree.
      
      Link: http://lkml.kernel.org/r/20170522133604.11392-4-punit.agrawal@arm.comSigned-off-by: NPunit Agrawal <punit.agrawal@arm.com>
      Acked-by: NSteve Capper <steve.capper@arm.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: Tony Luck <tony.luck@intel.com>
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: James Hogan <james.hogan@imgtec.com> (odd fixer:METAG ARCHITECTURE)
      Cc: Ralf Baechle <ralf@linux-mips.org> (supporter:MIPS)
      Cc: "James E.J. Bottomley" <jejb@parisc-linux.org>
      Cc: Helge Deller <deller@gmx.de>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Cc: Rich Felker <dalias@libc.org>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Chris Metcalf <cmetcalf@mellanox.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Alexander Viro <viro@zeniv.linux.org.uk>
      Cc: Michal Hocko <mhocko@suse.com>
      Cc: Mike Kravetz <mike.kravetz@oracle.com>
      Cc: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
      Cc: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
      Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
      Cc: Hillf Danton <hillf.zj@alibaba-inc.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      7868a208
  11. 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
  12. 04 7月, 2017 1 次提交
  13. 30 6月, 2017 1 次提交
    • 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