1. 13 5月, 2016 2 次提交
  2. 03 4月, 2016 1 次提交
  3. 24 1月, 2016 6 次提交
    • M
      MIPS: math-emu: dsemul: Reduce `get_isa16_mode' clutter · 6d7b1415
      Maciej W. Rozycki 提交于
      Signed-off-by: NMaciej W. Rozycki <macro@imgtec.com>
      Cc: Aurelien Jarno <aurelien@aurel32.net>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/12178/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      6d7b1415
    • M
      MIPS: math-emu: dsemul: Correct description of the emulation frame · 6e1715f7
      Maciej W. Rozycki 提交于
      Remove irrelevant content from the description of the emulation frame in
      `mips_dsemul', referring to bare-metal configurations.  Update the text,
      reflecting the change made with commit ba3049ed ("MIPS: Switch FPU
      emulator trap to BREAK instruction."), where we switched from using an
      address error exception on an unaligned access to the use of a BREAK 514
      instruction causing a breakpoint exception instead.
      Signed-off-by: NMaciej W. Rozycki <macro@imgtec.com>
      Cc: Aurelien Jarno <aurelien@aurel32.net>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/12176/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      6e1715f7
    • M
      MIPS: math-emu: Correct the emulation of microMIPS ADDIUPC instruction · 69a1e6cb
      Maciej W. Rozycki 提交于
      Emulate the microMIPS ADDIUPC instruction directly in `mips_dsemul'.  If
      executed in the emulation frame, this instruction produces an incorrect
      result, because the value of the PC there is not the same as where the
      instruction originated.
      
      Reshape code so as to handle all microMIPS cases together.
      Signed-off-by: NMaciej W. Rozycki <macro@imgtec.com>
      Cc: Aurelien Jarno <aurelien@aurel32.net>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/12175/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      69a1e6cb
    • M
      MIPS: math-emu: Make microMIPS branch delay slot emulation work · 733b8bc1
      Maciej W. Rozycki 提交于
      Complement commit 102cedc3 ("MIPS: microMIPS: Floating point
      support.") which introduced microMIPS FPU emulation, but did not adjust
      the encoding of the BREAK instruction used to terminate the branch delay
      slot emulation frame.  Consequently the execution of any such frame is
      indeterminate and, depending on CPU configuration, will result in random
      code execution or an offending program being terminated with SIGILL.
      
      This is because the regular MIPS BREAK instruction is encoded with the 0
      major and the 0xd minor opcode, however in the microMIPS instruction set
      this major/minor opcode pair denotes an encoding reserved for the DSP
      ASE.  Instead the microMIPS BREAK instruction is encoded with the 0
      major and the 0x7 minor opcode.
      
      Use the correct BREAK encoding for microMIPS FPU emulation then.
      Signed-off-by: NMaciej W. Rozycki <macro@imgtec.com>
      Cc: Aurelien Jarno <aurelien@aurel32.net>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/12174/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      733b8bc1
    • M
      MIPS: math-emu: dsemul: Fix ill formatting of microMIPS part · a87265cf
      Maciej W. Rozycki 提交于
      Correct formatting breakage introduced with commit 102cedc3 ("MIPS:
      microMIPS: Floating point support."), so that further changes to this
      code can be consistent.
      Signed-off-by: NMaciej W. Rozycki <macro@imgtec.com>
      Cc: Aurelien Jarno <aurelien@aurel32.net>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/12173/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      a87265cf
    • M
      MIPS: math-emu: Correctly handle NOP emulation · e4553573
      Maciej W. Rozycki 提交于
      Fix an issue introduced with commit 9ab4471c ("MIPS: math-emu:
      Correct delay-slot exception propagation") where the emulation of a NOP
      instruction signals the need to terminate the emulation loop.  This in
      turn, if the PC has not changed from the entry to the loop, will cause
      the kernel to terminate the program with SIGILL.
      
      Consider this program:
      
      static double div(double d)
      {
      	do
      		d /= 2.0;
      	while (d > .5);
      	return d;
      }
      
      int main(int argc, char **argv)
      {
      	return div(argc);
      }
      
      which gets compiled to the following binary code:
      
      00400490 <main>:
        400490:	44840000 	mtc1	a0,$f0
        400494:	3c020040 	lui	v0,0x40
        400498:	d44207f8 	ldc1	$f2,2040(v0)
        40049c:	46800021 	cvt.d.w	$f0,$f0
        4004a0:	46220002 	mul.d	$f0,$f0,$f2
        4004a4:	4620103c 	c.lt.d	$f2,$f0
        4004a8:	4501fffd 	bc1t	4004a0 <main+0x10>
        4004ac:	00000000 	nop
        4004b0:	4620000d 	trunc.w.d	$f0,$f0
        4004b4:	03e00008 	jr	ra
        4004b8:	44020000 	mfc1	v0,$f0
        4004bc:	00000000 	nop
      
      Where the FPU emulator is used, depending on the number of command-line
      arguments this code will either run to completion or terminate with
      SIGILL.
      
      If no arguments are specified, then BC1T will not be taken, NOP will not
      be emulated and code will complete successfully.
      
      If one argument is specified, then BC1T will be taken once and NOP will
      be emulated.  At this point the entry PC value will be 0x400498 and the
      new PC value, set by `mips_dsemul' will be 0x4004a0, the target of BC1T.
      The emulation loop will terminate, but SIGILL will not be issued,
      because the PC has changed.  The FPU emulator will be entered again and
      on the second execution BC1T will not be taken, NOP will not be emulated
      and code will complete successfully.
      
      If two or more arguments are specified, then the first execution of BC1T
      will proceed as above.  Upon reentering the FPU emulator the emulation
      loop will continue to BC1T, at which point the branch will be taken and
      NOP emulated again.  At this point however the entry PC value will be
      0x4004a0, the same as the target of BC1T.  This will make the emulator
      conclude that execution has not advanced and therefore an unsupported
      FPU instruction has been encountered, and SIGILL will be sent to the
      process.
      
      Fix the problem by extending the internal API of `mips_dsemul', making
      it return -1 if no delay slot emulation frame has been made, the
      instruction has been handled and execution of the emulation loop needs
      to continue as if nothing happened.  Remove code from `mips_dsemul' to
      reproduce steps made by the emulation loop at the conclusion of each
      iteration, as those will be reached normally now.  Adjust call sites
      accordingly.  Document the API.
      Signed-off-by: NMaciej W. Rozycki <macro@imgtec.com>
      Cc: Aurelien Jarno <aurelien@aurel32.net>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/12172/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      e4553573
  4. 20 1月, 2016 2 次提交
    • M
      MIPS: math-emu: Add IEEE Std 754-2008 NaN encoding emulation · 90d53a91
      Maciej W. Rozycki 提交于
      Implement IEEE Std 754-2008 NaN encoding wired to the state of the
      FCSR.NAN2008 bit.  Make the interpretation of the quiet bit in NaN data
      as follows:
      
      * in the legacy mode originally defined by the MIPS architecture the
        value of 1 denotes an sNaN whereas the value of 0 denotes a qNaN,
      
      * in the 2008 mode introduced with revision 5 of the MIPS architecture
        the value of 0 denotes an sNaN whereas the value of 1 denotes a qNaN,
        following the definition of the preferred NaN encoding introduced with
        IEEE Std 754-2008.
      
      In the 2008 mode, following the requirement of the said standard, quiet
      an sNaN where needed by setting the quiet bit to 1 and leaving all the
      NaN payload bits unchanged.
      
      Update format conversion operations according to the rules set by IEEE
      Std 754-2008 and the MIPS architecture.  Specifically:
      
      * propagate NaN payload bits through conversions between floating-point
        formats such that as much information as possible is preserved and
        specifically a conversion from a narrower format to a wider format and
        then back to the original format does not change a qNaN payload in any
        way,
      
      * conversions from a floating-point to an integer format where the
        source is a NaN, infinity or a value that would convert to an integer
        outside the range of the result format produce, under the default
        exception handling, the respective values defined by the MIPS
        architecture.
      
      In full FPU emulation set the FIR.HAS2008 bit to 1, however do not make
      any further FCSR bits writable.
      Signed-off-by: NMaciej W. Rozycki <macro@imgtec.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Matthew Fortune <Matthew.Fortune@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/11477/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      90d53a91
    • M
      MIPS: math-emu: Add IEEE Std 754-2008 ABS.fmt and NEG.fmt emulation · 198f7058
      Maciej W. Rozycki 提交于
      Implement IEEE Std 754-2008 non-arithmetic ABS.fmt and NEG.fmt emulation
      wired to the state of the FCSR.ABS2008 bit.  In the non-arithmetic mode
      the sign bit is altered according to the operation requested regardless
      of the datum encoded in the input operand, no other bits are changed,
      the resulting bit pattern is written to the output operand and no
      exception is ever signalled.
      Signed-off-by: NMaciej W. Rozycki <macro@imgtec.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Matthew Fortune <Matthew.Fortune@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/11476/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      198f7058
  5. 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
  6. 03 9月, 2015 15 次提交
  7. 09 7月, 2015 2 次提交
  8. 13 5月, 2015 1 次提交
  9. 08 4月, 2015 10 次提交
    • M
      MIPS: Respect the ISA level in FCSR handling · 9b26616c
      Maciej W. Rozycki 提交于
      Define the central place the default FCSR value is set from, initialised
      in `cpu_probe'.  Determine the FCSR mask applied to values written to
      the register with CTC1 in the full emulation mode and via ptrace(2),
      according to the ISA level of processor hardware or the writability of
      bits 31:18 if actual FPU hardware is used.
      
      Software may rely on FCSR bits whose functions our emulator does not
      implement, so it should not allow them to be set or software may get
      confused.  For ptrace(2) it's just sanity.
      
      [ralf@linux-mips.org: Fixed double inclusion of <asm/current.h>.]
      Signed-off-by: NMaciej W. Rozycki <macro@linux-mips.org>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/9711/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      9b26616c
    • M
      MIPS: math-emu: Make ABS.fmt and NEG.fmt arithmetic again · 232b6ec5
      Maciej W. Rozycki 提交于
      The ABS.fmt and NEG.fmt instructions have been specified as arithmetic
      in the MIPS architecture, which in particular implies handling NaN data
      in the usual way with qNaN bit patterns propagated unchanged and sNaN
      bit patterns signalling the usual IEEE 754 Invalid Operation exception
      and quieted by default.
      
      A series of changes applied over time to our implementation:
      
      c5033d78 [MIPS] ieee754[sd]p_neg workaround
      cea2be44 MIPS: Fix abs.[sd] and neg.[sd] emulation for NaN operands
      
      has led to the current situation where the sign bit is updated according
      to the operation requested even for NaN inputs.  This is according to
      these commits a workaround so that broken binaries produced by GCC
      disregarding the properties of these instructions have a chance to work.
      
      For sNaN inputs this remains within IEEE Std 754 as the standard leaves
      the choice of output qNaN bit patterns produced under the default
      Invalid Operation exception handling for individual sNaN input bit
      patterns to implementer's discretion, even though it still recommends as
      much NaN input information to be preserved in NaN outputs.
      
      For qNaN inputs however it violates the standard as it requires a qNaN
      input bit patterns to propagate unchanged to output.
      
      This is also unlike real MIPS FPU hardware behaves where sNaN and/or
      qNaN processing has been fully implemented with no Unimplemented
      Operation exception signalled.  Such hardware propagates any input qNaN
      bit pattern unchanged.  It also quiets any input sNaN bit pattern in an
      implementer-specific manner, for example the MIPS 74Kf processor returns
      the default qNaN pattern with the sign bit always clear and the Broadcom
      SB-1 and BMIPS5000 processors propagate the input sNaN bit pattern with
      the sign bit unchanged and the quiet bit first cleared in the trailing
      significand field and then the next lower bit set if clearing the quiet
      bit left the field with no other bit set.
      
      Especially the latter observation indicates the limited usefulness of
      the workaround as it will cover many hardware configurations, but not
      all of them, only making it harder to discover such broken binaries that
      need to be recompiled with GCC told to avoid the use of ABS.fmt and
      NEG.fmt instructions where non-arithmetic semantics is required by the
      algorithm used.
      
      Revert the damage done by the series of changes then, and take the
      opportunity to simplify implementation by calling `ieee754dp_sub' and
      `ieee754dp_add' as required and also the rounding mode set towards -Inf
      temporarily so that the sign of 0 is correctly handled.
      Signed-off-by: NMaciej W. Rozycki <macro@linux-mips.org>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/9710/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      232b6ec5
    • M
      MIPS: math-emu: Define IEEE 754-2008 feature control bits · f1f3b7eb
      Maciej W. Rozycki 提交于
      Define IEEE 754-2008 feature control bits: FIR.HAS2008, FCSR.ABS2008 and
      FCSR.NAN2008, and update the `_ieee754_csr' structure accordingly.
      
      For completeness define FIR.UFRP too.
      Signed-off-by: NMaciej W. Rozycki <macro@linux-mips.org>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/9709/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      f1f3b7eb
    • M
      MIPS: math-emu: Implement the FCCR, FEXR and FENR registers · c491cfa2
      Maciej W. Rozycki 提交于
      Implement the FCCR, FEXR and FENR "shadow" FPU registers for the
      architecture levels that include them, for the CFC1 and CTC1
      instructions in the full emulation mode.
      
      For completeness add macros for the CP1 UFR and UNFR registers too, no
      actual implementation though.
      Signed-off-by: NMaciej W. Rozycki <macro@linux-mips.org>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/9708/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      c491cfa2
    • M
      MIPS: math-emu: Set FIR feature flags for full emulation · f6843626
      Maciej W. Rozycki 提交于
      Implement FIR feature flags in the FPU emulator according to features
      supported and architecture level requirements.  The W, L and F64 bits
      have only been added at level #2 even though the features they refer to
      were also included with the MIPS64r1 ISA and the W fixed-point format
      also with the MIPS32r1 ISA.
      
      This is only relevant for the full emulation mode and the emulated CFC1
      instruction as well as ptrace(2) accesses.
      Signed-off-by: NMaciej W. Rozycki <macro@linux-mips.org>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/9707/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      f6843626
    • M
      MIPS: math-emu: Move long fixed-point support into an `ar' library · cfafc4fe
      Maciej W. Rozycki 提交于
      Complement 593d33fe [MIPS: math-emu: Move various objects into an ar
      library.] and also move sp_tlong.o, sp_flong.o, dp_tlong.o, and
      dp_flong.o into an `ar' library.  These objects implement long
      fixed-point format support that can be omitted from MIPS I, MIPS II and
      MIPS32r1 configurations.
      Signed-off-by: NMaciej W. Rozycki <macro@linux-mips.org>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/9702/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      cfafc4fe
    • M
      MIPS: math-emu: Correct delay-slot exception propagation · 9ab4471c
      Maciej W. Rozycki 提交于
      Restore EPC at the branch whose delay slot is emulated if the delay-slot
      instruction signals.  This is so that code in `fpu_emulator_cop1Handler'
      does not see EPC having advanced and mistakenly successfully resume
      userland execution from the location at the branch target in that case.
      Restoring EPC guarantees an immediate exit from the emulation loop and
      if EPC hasn't advanced at all since entering the loop, also issuing the
      signal reported by the delay-slot instruction.
      Signed-off-by: NMaciej W. Rozycki <macro@linux-mips.org>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/9701/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      9ab4471c
    • M
      MIPS: Correct FP ISA requirements · 2d83fea7
      Maciej W. Rozycki 提交于
      Correct ISA requirements for floating-point instructions:
      
      * the CU3 exception signifies a real COP3 instruction in MIPS I & II,
      
      * the BC1FL and BC1TL instructions are not supported in MIPS I,
      
      * the SQRT.fmt instructions are indeed supported in MIPS II,
      
      * the LDC1 and SDC1 instructions are indeed supported in MIPS32r1,
      
      * the CEIL.W.fmt, FLOOR.W.fmt, ROUND.W.fmt and TRUNC.W.fmt instructions
        are indeed supported in MIPS32,
      
      * the CVT.L.fmt and CVT.fmt.L instructions are indeed supported in
        MIPS32r2 and MIPS32r6,
      
      * the CEIL.L.fmt, FLOOR.L.fmt, ROUND.L.fmt and TRUNC.L.fmt instructions
        are indeed supported in MIPS32r2 and MIPS32r6,
      
      * the RSQRT.fmt and RECIP.fmt instructions are indeed supported in
        MIPS64r1,
      
      Also simplify conditionals for MIPS III and MIPS IV FPU instructions and
      the handling of the MOVCI minor opcode.
      Signed-off-by: NMaciej W. Rozycki <macro@linux-mips.org>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/9700/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      2d83fea7
    • M
      MIPS: math-emu: Fix delay-slot emulation cache incoherency · 7737b20b
      Maciej W. Rozycki 提交于
      Correct a cache coherency regression introduced with be1664c4 [Another
      round of fixes for the fp emulator.] for the emulation frame used in
      delay-slot emulation.
      
      Two instructions are copied into the frame and as from the commit
      referred a cache synchronisation call is made for the second instruction
      aka `badinst' of the two only.  The `flush_cache_sigtramp' interface is
      reused that guarantees that synchronisation will be made for 8 bytes or
      2 instructions starting from the address requested, although if cache
      lines are wider then a larger area may be synchronised.
      
      Change the call to point to the first of the two instructions aka `emul'
      instead, removing unpredictable behaviour resulting from cache
      incoherency.
      
      This bug only ever manifested itself on systems implementing 4-byte
      cache lines, typically MIPS I systems, causing all kinds of weirdness.
      This is because the sequence of two instructions starting from `emul' is
      8-byte aligned and for 8-byte or wider cache lines the line synchronised
      will span both, so the vast majority of systems have escaped unharmed.
      Signed-off-by: NMaciej W. Rozycki <macro@linux-mips.org>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/9698/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      7737b20b
    • M
      MIPS: math-emu: Make NaN classifiers static · e06b530b
      Maciej W. Rozycki 提交于
      The `ieee754sp_isnan' and `ieee754dp_isnan' NaN classifiers are now no
      longer externally referred, remove their header prototypes and make them
      local to the two only respective places still making use of them.
      Signed-off-by: NMaciej W. Rozycki <macro@linux-mips.org>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/9693/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      e06b530b