10 Jan, 2019

1 commit

  • commit adcc81f148d733b7e8e641300c5590a2cdc13bf3 upstream.

    Mapping the delay slot emulation page as both writeable & executable
    presents a security risk, in that if an exploit can write to & jump into
    the page then it can be used as an easy way to execute arbitrary code.

    Prevent this by mapping the page read-only for userland, and using
    access_process_vm() with the FOLL_FORCE flag to write to it from
    mips_dsemul().

    This will likely be less efficient due to copy_to_user_page() performing
    cache maintenance on a whole page, rather than a single line as in the
    previous use of flush_cache_sigtramp(). However this delay slot
    emulation code ought not to be running in any performance critical paths
    anyway so this isn't really a problem, and we can probably do better in
    copy_to_user_page() anyway in future.

    A major advantage of this approach is that the fix is small & simple to
    backport to stable kernels.

    Reported-by: Andy Lutomirski
    Signed-off-by: Paul Burton
    Fixes: 432c6bacbd0c ("MIPS: Use per-mm page to execute branch delay slot instructions")
    Cc: stable@vger.kernel.org # v4.8+
    Cc: linux-mips@vger.kernel.org
    Cc: linux-kernel@vger.kernel.org
    Cc: Rich Felker
    Cc: David Daney
    Signed-off-by: Greg Kroah-Hartman

    Paul Burton
     

13 Dec, 2017

6 commits

  • Mark intentional fall throughs in switch statements with a consistent
    comment.

    In most of the cases, a new comment line containing text "fall through"
    is inserted. In some of the cases, existing comment contained a variation
    of the text "fall through" (for example, "FALL THROUGH" or "drop through").
    In such cases, the existing comment is modified to contain "fall through".
    Lastly, in two cases, code segments were described in comments as "fall
    througs", but were in reality "breaks out" of switch statement. In such
    cases, existing comments are accordingly modified.

    Apart from making code easier to follow and debug, this change enables
    some static code analysers to interpret newly inserted comments as their
    annotations (and, therefore, not issue warnings of type "fall through in
    switch statement", which is desireable, since marked fallthroughs are
    intentional).

    Signed-off-by: Aleksandar Markovic
    Cc: Douglas Leung
    Cc: Goran Ferenc
    Cc: James Hogan
    Cc: Maciej W. Rozycki
    Cc: Manuel Lauss
    Cc: Miodrag Dinic
    Cc: Paul Burton
    Cc: Petar Jovanovic
    Cc: Raghu Gandham
    Cc: linux-kernel@vger.kernel.org
    Cc: linux-mips@linux-mips.org
    Patchwork: https://patchwork.linux-mips.org/patch/17588/
    Signed-off-by: Ralf Baechle

    Aleksandar Markovic
     
  • Replace several instances of multiple assignment with individual
    assignments.

    Signed-off-by: Aleksandar Markovic
    Cc: Douglas Leung
    Cc: Goran Ferenc
    Cc: James Hogan
    Cc: Maciej W. Rozycki
    Cc: Manuel Lauss
    Cc: Miodrag Dinic
    Cc: Paul Burton
    Cc: Petar Jovanovic
    Cc: Raghu Gandham
    Cc: linux-mips@linux-mips.org
    Cc: linux-kernel@vger.kernel.org
    Patchwork: https://patchwork.linux-mips.org/patch/17587/
    Signed-off-by: Ralf Baechle

    Aleksandar Markovic
     
  • Move invocation of fpu_emu() to be out of if statement condition.

    This makes code easier to follow and debug, and fixes a checkpatch
    warning.

    Signed-off-by: Aleksandar Markovic
    Cc: Douglas Leung
    Cc: Goran Ferenc
    Cc: James Hogan
    Cc: Maciej W. Rozycki
    Cc: Miodrag Dinic
    Cc: Paul Burton
    Cc: Petar Jovanovic
    Cc: Raghu Gandham
    Cc: linux-mips@linux-mips.org
    Cc: linux-kernel@vger.kernel.org
    Patchwork: https://patchwork.linux-mips.org/patch/17586/
    Signed-off-by: Ralf Baechle

    Aleksandar Markovic
     
  • Declare function srl128() as static, since it it used just locally
    to the source file.

    This also removes a sparse warning for corresponding file.

    Signed-off-by: Aleksandar Markovic
    Cc: Douglas Leung
    Cc: Goran Ferenc
    Cc: James Hogan
    Cc: Miodrag Dinic
    Cc: Paul Burton
    Cc: Petar Jovanovic
    Cc: Raghu Gandham
    Cc: linux-mips@linux-mips.org
    Cc: linux-kernel@vger.kernel.org
    Patchwork: https://patchwork.linux-mips.org/patch/17585/
    Signed-off-by: Ralf Baechle

    Aleksandar Markovic
     
  • Avoid duplicate definition of macro DPXMULT(). Move its definition
    to a header.

    Signed-off-by: Aleksandar Markovic
    Cc: Douglas Leung
    Cc: Goran Ferenc
    Cc: James Hogan
    Cc: Miodrag Dinic
    Cc: Paul Burton
    Cc: Petar Jovanovic
    Cc: Raghu Gandham
    Cc: linux-mips@linux-mips.org
    Cc: linux-kernel@vger.kernel.org
    Patchwork: https://patchwork.linux-mips.org/patch/17584/
    Signed-off-by: Ralf Baechle

    Aleksandar Markovic
     
  • Remove an unnecessary header inclusion of "ieee754dp.h".

    Signed-off-by: Aleksandar Markovic
    Cc: Douglas Leung
    Cc: Goran Ferenc
    Cc: James Hogan
    Cc: Miodrag Dinic
    Cc: Paul Burton
    Cc: Petar Jovanovic
    Cc: Raghu Gandham
    Cc: linux-mips@linux-mips.org
    Cc: linux-kernel@vger.kernel.org
    Patchwork: https://patchwork.linux-mips.org/patch/17583/
    Signed-off-by: Ralf Baechle

    Aleksandar Markovic
     

16 Nov, 2017

1 commit

  • Pull MIPS updates from James Hogan:
    "These are the main MIPS changes for 4.15.

    Fixes:
    - ralink: Fix MT7620 PCI build issues (4.5)
    - Disable cmpxchg64() and HAVE_VIRT_CPU_ACCOUNTING_GEN for 32-bit SMP
    (4.1)
    - Fix MIPS64 FP save/restore on 32-bit kernels (4.0)
    - ptrace: Pick up ptrace/seccomp changed syscall numbers (3.19)
    - ralink: Fix MT7628 pinmux (3.19)
    - BCM47XX: Fix LED inversion on WRT54GSv1 (3.17)
    - Fix n32 core dumping as o32 since regset support (3.13)
    - ralink: Drop obsolete USB_ARCH_HAS_HCD select

    Build system:
    - Default to "generic" (multiplatform) system type instead of IP22
    - Use generic little endian MIPS32 r2 configuration as default
    defconfig instead of ip22_defconfig

    FPU emulation:
    - Fix exception generation for certain R6 FPU instructions

    SMP:
    - Allow __cpu_number_map to be larger than NR_CPUS for sparse CPU id
    spaces

    Miscellaneous:
    - Add iomem resource for kernel bss section for kexec/kdump
    - Atomics: Nudge writes on bit unlock
    - DT files: Standardise "ok" -> "okay"

    Minor cleanups:
    - Define virt_to_pfn()
    - Make thread_saved_pc static
    - Simplify 32-bit sign extension in __read_64bit_c0_split()
    - DMA: Use vma_pages() helper
    - FPU emulation: Replace unsigned with unsigned int
    - MM: Removed unused lastpfn
    - Alchemy: Make clk_ops const
    - Lasat: Use setup_timer() helper
    - ralink: Use BIT() in MT7620 PCI driver

    Platform support:

    BMIPS:
    - Enable HARDIRQS_SW_RESEND

    Broadcom BCM63XX:
    - Add clkdev lookup support
    - Update clk driver, UART driver, DTs to handle named refclk from DTs
    - Split apart various clocks to more closely match hardware
    - Add ethernet clocks

    Cavium Octeon:
    - Remove usage of cvmx_wait() in favour of __delay()

    ImgTec Pistachio:
    - DT: Drop deprecated dwmmc num-slots property

    Ingenic JZ4780:
    - Add NFS root to Ci20 defconfig
    - Add watchdog to Ci20 DT & defconfig, and allow building of watchdog
    driver with this SoC

    Generic (multiplatform):
    - Migrate xilfpga (MIPSfpga) platform to the generic platform

    Lantiq xway:
    - Fix ASC0/ASC1 clocks"

    * tag 'mips_4.15' of git://git.kernel.org/pub/scm/linux/kernel/git/jhogan/mips: (46 commits)
    MIPS: Add iomem resource for kernel bss section.
    MIPS: cmpxchg64() and HAVE_VIRT_CPU_ACCOUNTING_GEN don't work for 32-bit SMP
    MIPS: BMIPS: Enable HARDIRQS_SW_RESEND
    MIPS: pci: Make use of the BIT() macro inside the mt7620 driver
    MIPS: pci: Remove KERN_WARN instance inside the mt7620 driver
    MIPS: pci: Remove duplicate define in mt7620 driver
    MIPS: ralink: Fix typo in mt7628 pinmux function
    MIPS: ralink: Fix MT7628 pinmux
    MIPS: Fix odd fp register warnings with MIPS64r2
    watchdog: jz4780: Allow selection of jz4740-wdt driver
    MIPS/ptrace: Update syscall nr on register changes
    MIPS/ptrace: Pick up ptrace/seccomp changed syscalls
    MIPS: Fix an n32 core file generation regset support regression
    MIPS: Fix MIPS64 FP save/restore on 32-bit kernels
    MIPS: page.h: Define virt_to_pfn()
    MIPS: Xilfpga: Switch to using generic defconfigs
    MIPS: generic: Add support for MIPSfpga
    MIPS: Set defconfig target to a generic system for 32r2el
    MIPS: Kconfig: Set default MIPS system type as generic
    MIPS: DTS: Remove num-slots from Pistachio SoC
    ...

    Linus Torvalds
     

08 Nov, 2017

2 commits

  • Fix occurences of unsigned integer variable declarations that are
    not preferred by standards of checkpatch scripts. This removes a
    significant number of checkpatch warnings for files in math-emu
    directory (several files become completely warning-free), and thus
    makes easier to spot (now and in the future) other, perhaps more
    significant, checkpatch errors and warnings.

    Signed-off-by: Aleksandar Markovic
    Reviewed-by: James Hogan
    Cc: Ralf Baechle
    Cc: Douglas Leung
    Cc: Goran Ferenc
    Cc: "Maciej W. Rozycki"
    Cc: Manuel Lauss
    Cc: Miodrag Dinic
    Cc: Paul Burton
    Cc: Petar Jovanovic
    Cc: Raghu Gandham
    Cc: linux-mips@linux-mips.org
    Patchwork: https://patchwork.linux-mips.org/patch/17582/
    Signed-off-by: James Hogan

    Aleksandar Markovic
     
  • Fix final phase of .
    emulation. Provide proper generation of SIGFPE signal and updating
    debugfs FP exception stats in cases of any exception flags set in
    preceding phases of emulation.

    CLASS. instruction may generate "Unimplemented Operation" FP
    exception. . instructions may generate "Inexact",
    "Unimplemented Operation", "Invalid Operation", "Overflow", and
    "Underflow" FP exceptions. . instructions
    can generate "Unimplemented Operation" and "Invalid Operation" FP
    exceptions.

    The proper final processing of the cases when any FP exception
    flag is set is achieved by replacing "break" statement with "goto
    copcsr" statement. With such solution, this patch brings the final
    phase of emulation of the above instructions consistent with the
    one corresponding to the previously implemented emulation of other
    related FPU instructions (ADD, SUB, etc.).

    Fixes: 38db37ba069f ("MIPS: math-emu: Add support for the MIPS R6 CLASS FPU instruction")
    Fixes: e24c3bec3e8e ("MIPS: math-emu: Add support for the MIPS R6 MADDF FPU instruction")
    Fixes: 83d43305a1df ("MIPS: math-emu: Add support for the MIPS R6 MSUBF FPU instruction")
    Fixes: a79f5f9ba508 ("MIPS: math-emu: Add support for the MIPS R6 MAX{, A} FPU instruction")
    Fixes: 4e9561b20e2f ("MIPS: math-emu: Add support for the MIPS R6 MIN{, A} FPU instruction")
    Signed-off-by: Aleksandar Markovic
    Cc: Ralf Baechle
    Cc: Douglas Leung
    Cc: Goran Ferenc
    Cc: "Maciej W. Rozycki"
    Cc: Miodrag Dinic
    Cc: Paul Burton
    Cc: Petar Jovanovic
    Cc: Raghu Gandham
    Cc: linux-mips@linux-mips.org
    Cc: # 4.3+
    Patchwork: https://patchwork.linux-mips.org/patch/17581/
    Signed-off-by: James Hogan

    Aleksandar Markovic
     

02 Nov, 2017

1 commit

  • Many source files in the tree are missing licensing information, which
    makes it harder for compliance tools to determine the correct license.

    By default all files without license information are under the default
    license of the kernel, which is GPL version 2.

    Update the files which contain no license information with the 'GPL-2.0'
    SPDX license identifier. The SPDX identifier is a legally binding
    shorthand, which can be used instead of the full boiler plate text.

    This patch is based on work done by Thomas Gleixner and Kate Stewart and
    Philippe Ombredanne.

    How this work was done:

    Patches were generated and checked against linux-4.14-rc6 for a subset of
    the use cases:
    - file had no licensing information it it.
    - file was a */uapi/* one with no licensing information in it,
    - file was a */uapi/* one with existing licensing information,

    Further patches will be generated in subsequent months to fix up cases
    where non-standard license headers were used, and references to license
    had to be inferred by heuristics based on keywords.

    The analysis to determine which SPDX License Identifier to be applied to
    a file was done in a spreadsheet of side by side results from of the
    output of two independent scanners (ScanCode & Windriver) producing SPDX
    tag:value files created by Philippe Ombredanne. Philippe prepared the
    base worksheet, and did an initial spot review of a few 1000 files.

    The 4.13 kernel was the starting point of the analysis with 60,537 files
    assessed. Kate Stewart did a file by file comparison of the scanner
    results in the spreadsheet to determine which SPDX license identifier(s)
    to be applied to the file. She confirmed any determination that was not
    immediately clear with lawyers working with the Linux Foundation.

    Criteria used to select files for SPDX license identifier tagging was:
    - Files considered eligible had to be source code files.
    - Make and config files were included as candidates if they contained >5
    lines of source
    - File already had some variant of a license header in it (even if
    Reviewed-by: Philippe Ombredanne
    Reviewed-by: Thomas Gleixner
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

09 Oct, 2017

1 commit

  • 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: Paul Burton
    Fixes: f8c3c6717a71 ("MIPS: math-emu: Add support for the CMP.condn.fmt R6 instruction")
    Cc: linux-mips@linux-mips.org
    Cc: stable # v4.3+
    Patchwork: https://patchwork.linux-mips.org/patch/17253/
    Signed-off-by: Ralf Baechle

    Paul Burton
     

29 Aug, 2017

20 commits

  • Add FP emulation debugfs statistics for individual instructions. The
    debugfs files that contain counter values are placed in a separate
    directory called "instructions". This means that the default path for
    these new stat is "/sys/kernel/debug/mips/fpuemustats/instructions".

    Each instruction counter is mapped to the debugfs file that has the
    same name as instruction name. The lowercase is choosen as more
    commonly used case for instruction names.

    One example of usage:

    mips_host::/sys/kernel/debug/mips/fpuemustats/instructions # grep "" *

    The shortened output of this command is:

    abs.d:34
    abs.s:5711
    add.d:10401
    add.s:399307
    bc1eqz:3199
    ...
    ...
    ...
    sub.s:167211
    trunc.l.d:375
    trunc.l.s:8054
    trunc.w.d:421
    trunc.w.s:27032

    The limitation of this patch is that it handles R6 FP emulation
    instructions only. There are altogether 114 handled instructions.

    Signed-off-by: Miodrag Dinic
    Signed-off-by: Goran Ferenc
    Signed-off-by: Aleksandar Markovic
    Cc: Douglas Leung
    Cc: James Hogan
    Cc: Maciej W. Rozycki
    Cc: Masahiro Yamada
    Cc: Paul Burton
    Cc: Petar Jovanovic
    Cc: Raghu Gandham
    Cc: linux-mips@linux-mips.org
    Cc: linux-kernel@vger.kernel.org
    Patchwork: https://patchwork.linux-mips.org/patch/17145/
    Signed-off-by: Ralf Baechle

    Aleksandar Markovic
     
  • Add capability for the user to clear all FP emu debugfs counters.

    This is achieved by having a special debugfs file "fpuemustats_clear"
    (under default location "/sys/kernel/debug/mips"). Each access to the
    file results in setting all counters to zero (it is enough, let's say,
    to issue a "cat /sys/kernel/debug/mips/fpuemustats_clear").

    This functionality already exists for R2 emulation statistics,
    but was missing for FP emulation statistics. The implementation in
    this patch is consistent with its R2 emulation counterpart.

    Signed-off-by: Miodrag Dinic
    Signed-off-by: Goran Ferenc
    Signed-off-by: Aleksandar Markovic
    Cc: Douglas Leung
    Cc: James Hogan
    Cc: Paul Burton
    Cc: Petar Jovanovic
    Cc: Raghu Gandham
    Cc: linux-mips@linux-mips.org
    Cc: linux-kernel@vger.kernel.org
    Patchwork: https://patchwork.linux-mips.org/patch/17144/
    Signed-off-by: Ralf Baechle

    Aleksandar Markovic
     
  • Add FP emu debugfs counter for branches.

    The new counter is displayed the same way as existing counter, and
    its default path is /sys/kernel/debug/mips/fpuemustats/.

    The limitation of this counter is that it counts only R6 branch
    instructions BC1NEZ and BC1EQZ.

    Signed-off-by: Miodrag Dinic
    Signed-off-by: Goran Ferenc
    Signed-off-by: Aleksandar Markovic
    Cc: Douglas Leung
    Cc: James Hogan
    Cc: Maciej W. Rozycki
    Cc: Masahiro Yamada
    Cc: Paul Burton
    Cc: Petar Jovanovic
    Cc: Raghu Gandham
    Cc: linux-mips@linux-mips.org
    Cc: linux-kernel@vger.kernel.org
    Patchwork: https://patchwork.linux-mips.org/patch/17143/
    Signed-off-by: Ralf Baechle

    Aleksandar Markovic
     
  • Fix content of CLASS.D output bits 32-63 to match hardware behavior.

    Prior to this patch, bits 32-63 of CLASS.D output were not
    initialized, causing different 32-63 bits content of CLASS.D, based on
    circumstances. However, the hardware consistently returns all these
    bits zeroed. The documentation is not clear whether these bits should
    be zero or unpredictable. Since technically "all zero" case still can
    be viewed as belonging to "unpredictable" class of results, it is
    better to zero bits 32-63.

    Signed-off-by: Miodrag Dinic
    Signed-off-by: Goran Ferenc
    Signed-off-by: Aleksandar Markovic
    Cc: Douglas Leung
    Cc: James Hogan
    Cc: Maciej W. Rozycki
    Cc: Masahiro Yamada
    Cc: Paul Burton
    Cc: Petar Jovanovic
    Cc: Raghu Gandham
    Cc: linux-mips@linux-mips.org
    Cc: linux-kernel@vger.kernel.org
    Patchwork: https://patchwork.linux-mips.org/patch/17142/
    Signed-off-by: Ralf Baechle

    Aleksandar Markovic
     
  • Reimplement RINT. kernel emulation so that all RINT.
    specifications are met.

    For the sake of simplicity, let's analyze RINT.S only. Prior to
    this patch, RINT.S emulation was essentially implemented as (in
    pseudocode) = ieee754sp_flong(ieee754sp_tlong()),
    where ieee754sp_tlong() and ieee754sp_flong() are functions
    providing conversion from double to integer, and from integer
    to double, respectively. On surface, this implementation looks
    correct, but actually fails in many cases. Following problems
    were detected:

    1. NaN and infinity cases will not be handled properly. The
    function ieee754sp_flong() never returns NaN nor infinity.
    2. For RINT.S, for all inputs larger than LONG_MAX, and smaller
    than FLT_MAX, the result will be wrong, and the overflow
    exception will be erroneously set. A similar problem for
    negative inputs exists as well.
    3. For some rounding modes, for some negative inputs close to zero,
    the return value will be zero, and should be -zero. This is
    because ieee754sp_flong() never returns -zero.

    This patch removes the problems above by implementing dedicated
    functions for RINT. emulation.

    The core of the new function functionality is adapted version of
    the core of the function ieee754sp_tlong(). However, there are many
    details that are implemented to match RINT. specification. It
    should be said that the functionality of ieee754sp_tlong() actually
    closely corresponds to CVT.L.S instruction, and it is used while
    emulating CVT.L.S. However, RINT.S and CVT.L.S instructions differ
    in many aspects. This patch fulfills missing support for RINT..

    Signed-off-by: Miodrag Dinic
    Signed-off-by: Goran Ferenc
    Signed-off-by: Aleksandar Markovic
    Cc: David S. Miller
    Cc: Douglas Leung
    Cc: Greg Kroah-Hartman
    Cc: Hans Verkuil
    Cc: James Hogan
    Cc: Maciej W. Rozycki
    Cc: Masahiro Yamada
    Cc: Mauro Carvalho Chehab
    Cc: Paul Burton
    Cc: Petar Jovanovic
    Cc: Raghu Gandham
    Cc: Randy Dunlap
    Cc: linux-mips@linux-mips.org
    Cc: linux-kernel@vger.kernel.org
    Patchwork: https://patchwork.linux-mips.org/patch/17141/
    Signed-off-by: Ralf Baechle

    Aleksandar Markovic
     
  • Fix CMP.Sxxx. SIGILL crashes by fixing main switch/case statement
    in fpu_emul() function so that inadvertent fall-troughs are prevented.

    Consider, let's say, CMP.SAF.S instruction when one of inputs is zero
    and another input is a signaling NaN. The desired output is zero, and
    the exception flag "invalid operation" set. For such case, the main
    portion of the implementation is within "d_fmt" case of the main
    "switch/case" statement in fpu_emul() function. The execution will
    follow one of "if-else" branches that doesn't contain "goto cop1scr;"
    statement, and will therefore reach the end of "d_fmt" case. It will
    subsequently fall through to the next case, "l_fmt". After following
    similar pattern, the execution will fall through to the succeeding
    case, which is "default". The "default" case contains "return SIGILL;"
    statement only. This means that the caller application will crash
    with "illegal instruction" message.

    It is obvious that above described fall-throughs are unnecessary and
    harmful. This patch rectifies that behavior by providing "break;"
    statements at the end of cases "d_fmt" and "l_fmt".

    There are 22 instructions affected by this problem:

    CMP...

    Signed-off-by: Miodrag Dinic
    Signed-off-by: Goran Ferenc
    Signed-off-by: Aleksandar Markovic
    Cc: Douglas Leung
    Cc: James Hogan
    Cc: Maciej W. Rozycki
    Cc: Masahiro Yamada
    Cc: Paul Burton
    Cc: Petar Jovanovic
    Cc: Raghu Gandham
    Cc: linux-mips@linux-mips.org
    Cc: linux-kernel@vger.kernel.org
    Patchwork: https://patchwork.linux-mips.org/patch/17140/
    Signed-off-by: Ralf Baechle

    Aleksandar Markovic
     
  • Implement fused multiply-add with correct accuracy.

    Fused multiply-add operation has better accuracy than respective
    sequential execution of multiply and add operations applied on the
    same inputs. This is because accuracy errors accumulate in latter
    case.

    This patch implements fused multiply-add with the same accuracy
    as it is implemented in hardware, using 128-bit intermediate
    calculations.

    One test case example (raw bits) that this patch fixes:

    MADDF.D fd,fs,ft:
    fd = 0x00000ca000000000
    fs = ft = 0x3f40624dd2f1a9fc

    Fixes: e24c3bec3e8e ("MIPS: math-emu: Add support for the MIPS R6 MADDF FPU instruction")
    Fixes: 83d43305a1df ("MIPS: math-emu: Add support for the MIPS R6 MSUBF FPU instruction")

    Signed-off-by: Douglas Leung
    Signed-off-by: Miodrag Dinic
    Signed-off-by: Goran Ferenc
    Signed-off-by: Aleksandar Markovic
    Cc: Douglas Leung
    Cc: Bo Hu
    Cc: James Hogan
    Cc: Jin Qian
    Cc: Paul Burton
    Cc: Petar Jovanovic
    Cc: Raghu Gandham
    Cc: # 4.7+
    Cc: linux-mips@linux-mips.org
    Cc: linux-kernel@vger.kernel.org
    Patchwork: https://patchwork.linux-mips.org/patch/16891/
    Signed-off-by: Ralf Baechle

    Douglas Leung
     
  • Implement fused multiply-add with correct accuracy.

    Fused multiply-add operation has better accuracy than respective
    sequential execution of multiply and add operations applied on the
    same inputs. This is because accuracy errors accumulate in latter
    case.

    This patch implements fused multiply-add with the same accuracy
    as it is implemented in hardware, using 64-bit intermediate
    calculations.

    One test case example (raw bits) that this patch fixes:

    MADDF.S fd,fs,ft:
    fd = 0x22575225
    fs = ft = 0x3727c5ac

    Fixes: e24c3bec3e8e ("MIPS: math-emu: Add support for the MIPS R6 MADDF FPU instruction")
    Fixes: 83d43305a1df ("MIPS: math-emu: Add support for the MIPS R6 MSUBF FPU instruction")

    Signed-off-by: Douglas Leung
    Signed-off-by: Miodrag Dinic
    Signed-off-by: Goran Ferenc
    Signed-off-by: Aleksandar Markovic
    Cc: Douglas Leung
    Cc: Bo Hu
    Cc: James Hogan
    Cc: Jin Qian
    Cc: Paul Burton
    Cc: Petar Jovanovic
    Cc: Raghu Gandham
    Cc: # 4.7+
    Cc: linux-mips@linux-mips.org
    Cc: linux-kernel@vger.kernel.org
    Patchwork: https://patchwork.linux-mips.org/patch/16890/
    Signed-off-by: Ralf Baechle

    Douglas Leung
     
  • Fix definition and usage of "maddf_flags" enumeration. Avoid duplicate
    definition and apply more common capitalization.

    This patch does not change any scenario. It just makes MADDF and
    MSUBF emulation code more readable and easier to maintain, and
    hopefully prevents future bugs as well.

    Signed-off-by: Miodrag Dinic
    Signed-off-by: Goran Ferenc
    Signed-off-by: Aleksandar Markovic
    Reviewed-by: James Hogan
    Cc: Bo Hu
    Cc: Douglas Leung
    Cc: Jin Qian
    Cc: Paul Burton
    Cc: Petar Jovanovic
    Cc: Raghu Gandham
    Cc: # 4.7+
    Cc: linux-mips@linux-mips.org
    Cc: linux-kernel@vger.kernel.org
    Patchwork: https://patchwork.linux-mips.org/patch/16889/
    Signed-off-by: Ralf Baechle

    Aleksandar Markovic
     
  • Fix the cases of . when any of two multiplicands is
    +0 or -0, and the third input is also +0 or -0. Depending on the signs
    of inputs, certain special cases must be handled.

    A relevant example:

    MADDF.S fd,fs,ft:
    If fs contains +0.0, ft contains -0.0, and fd contains 0.0, fd is
    going to contain +0.0 (without this patch, it used to contain -0.0).

    Fixes: e24c3bec3e8e ("MIPS: math-emu: Add support for the MIPS R6 MADDF FPU instruction")
    Fixes: 83d43305a1df ("MIPS: math-emu: Add support for the MIPS R6 MSUBF FPU instruction")

    Signed-off-by: Miodrag Dinic
    Signed-off-by: Goran Ferenc
    Signed-off-by: Aleksandar Markovic
    Reviewed-by: James Hogan
    Cc: Bo Hu
    Cc: Douglas Leung
    Cc: Jin Qian
    Cc: Paul Burton
    Cc: Petar Jovanovic
    Cc: Raghu Gandham
    Cc: # 4.7+
    Cc: linux-mips@linux-mips.org
    Cc: linux-kernel@vger.kernel.org
    Patchwork: https://patchwork.linux-mips.org/patch/16888/
    Signed-off-by: Ralf Baechle

    Aleksandar Markovic
     
  • Fix the cases of . when any of two multiplicands is
    infinity. The correct behavior in such cases is affected by the nature
    of third input. Cases of addition of infinities with opposite signs
    and subtraction of infinities with same signs may arise and must be
    handles separately. Also, the value od flags argument (that determines
    whether the instruction is MADDF or MSUBF) affects the outcome.

    Relevant examples:

    MADDF.S fd,fs,ft:
    If fs contains +inf, ft contains +inf, and fd contains -inf, fd is
    going to contain indef (without this patch, it used to contain
    -inf).

    MSUBF.S fd,fs,ft:
    If fs contains +inf, ft contains 1.0, and fd contains +0.0, fd is
    going to contain -inf (without this patch, it used to contain +inf).

    Fixes: e24c3bec3e8e ("MIPS: math-emu: Add support for the MIPS R6 MADDF FPU instruction")
    Fixes: 83d43305a1df ("MIPS: math-emu: Add support for the MIPS R6 MSUBF FPU instruction")

    Signed-off-by: Douglas Leung
    Signed-off-by: Miodrag Dinic
    Signed-off-by: Goran Ferenc
    Signed-off-by: Aleksandar Markovic
    Reviewed-by: James Hogan
    Cc: Douglas Leung
    Cc: Bo Hu
    Cc: Jin Qian
    Cc: Paul Burton
    Cc: Petar Jovanovic
    Cc: Raghu Gandham
    Cc: # 4.7+
    Cc: linux-mips@linux-mips.org
    Cc: linux-kernel@vger.kernel.org
    Patchwork: https://patchwork.linux-mips.org/patch/16887/
    Signed-off-by: Ralf Baechle

    Aleksandar Markovic
     
  • Fix the cases of . when any of three inputs is any
    NaN. Correct behavior of . fd, fs, ft is following:

    - if any of inputs is sNaN, return a sNaN using following rules: if
    only one input is sNaN, return that one; if more than one input is
    sNaN, order of precedence for return value is fd, fs, ft
    - if no input is sNaN, but at least one of inputs is qNaN, return a
    qNaN using following rules: if only one input is qNaN, return that
    one; if more than one input is qNaN, order of precedence for
    return value is fd, fs, ft

    The previous code contained correct handling of some above cases, but
    not all. Also, such handling was scattered into various cases of
    "switch (CLPAIR(xc, yc))" statement, and elsewhere. With this patch,
    this logic is placed in one place, and "switch (CLPAIR(xc, yc))" is
    significantly simplified.

    A relevant example:

    MADDF.S fd,fs,ft:
    If fs contains qNaN1, ft contains qNaN2, and fd contains qNaN3, fd
    is going to contain qNaN3 (without this patch, it used to contain
    qNaN1).

    Fixes: e24c3bec3e8e ("MIPS: math-emu: Add support for the MIPS R6 MADDF FPU instruction")
    Fixes: 83d43305a1df ("MIPS: math-emu: Add support for the MIPS R6 MSUBF FPU instruction")

    Signed-off-by: Miodrag Dinic
    Signed-off-by: Goran Ferenc
    Signed-off-by: Aleksandar Markovic
    Reviewed-by: James Hogan
    Cc: Bo Hu
    Cc: Douglas Leung
    Cc: Jin Qian
    Cc: Paul Burton
    Cc: Petar Jovanovic
    Cc: Raghu Gandham
    Cc: # 4.7+
    Cc: linux-mips@linux-mips.org
    Cc: linux-kernel@vger.kernel.org
    Patchwork: https://patchwork.linux-mips.org/patch/16886/
    Signed-off-by: Ralf Baechle

    Aleksandar Markovic
     
  • Fix following special cases for MINA>.:

    - if one of the inputs is zero, and the other is subnormal, normal,
    or infinity, the value of the former should be returned (that is,
    a zero).
    - if one of the inputs is infinity, and the other input is normal,
    or subnormal, the value of the latter should be returned.

    The previous implementation's logic for such cases was incorrect - it
    appears as if it implements MAXA, and not MINA instruction.

    A relevant example:

    MINA.S fd,fs,ft:
    If fs contains 100.0, and ft contains 0.0, fd is going to contain
    0.0 (without this patch, it used to contain 100.0).

    Fixes: a79f5f9ba508 ("MIPS: math-emu: Add support for the MIPS R6 MAX{, A} FPU instruction")
    Fixes: 4e9561b20e2f ("MIPS: math-emu: Add support for the MIPS R6 MIN{, A} FPU instruction")

    Signed-off-by: Miodrag Dinic
    Signed-off-by: Goran Ferenc
    Signed-off-by: Aleksandar Markovic
    Reviewed-by: James Hogan
    Cc: Bo Hu
    Cc: Douglas Leung
    Cc: Jin Qian
    Cc: Paul Burton
    Cc: Petar Jovanovic
    Cc: Raghu Gandham
    Cc: # 4.3+
    Cc: linux-mips@linux-mips.org
    Cc: linux-kernel@vger.kernel.org
    Patchwork: https://patchwork.linux-mips.org/patch/16885/
    Signed-off-by: Ralf Baechle

    Aleksandar Markovic
     
  • Fix the value returned by . fd,fs,ft, if both inputs
    are infinite. The previous implementation returned always the value
    contained in ft in such cases. The correct behavior is specified
    in Mips instruction set manual and is as follows:

    fs ft MAXA MINA
    ---------------------------------
    inf inf inf inf
    inf -inf inf -inf
    -inf inf inf -inf
    -inf -inf -inf -inf

    A relevant example:

    MAXA.S fd,fs,ft:
    If fs contains +inf, and ft contains -inf, fd is going to contain
    +inf (without this patch, it used to contain -inf).

    Fixes: a79f5f9ba508 ("MIPS: math-emu: Add support for the MIPS R6 MAX{, A} FPU instruction")
    Fixes: 4e9561b20e2f ("MIPS: math-emu: Add support for the MIPS R6 MIN{, A} FPU instruction")

    Signed-off-by: Miodrag Dinic
    Signed-off-by: Goran Ferenc
    Signed-off-by: Aleksandar Markovic
    Reviewed-by: James Hogan
    Cc: Bo Hu
    Cc: Douglas Leung
    Cc: Jin Qian
    Cc: Paul Burton
    Cc: Petar Jovanovic
    Cc: Raghu Gandham
    Cc: # 4.3+
    Cc: linux-mips@linux-mips.org
    Cc: linux-kernel@vger.kernel.org
    Patchwork: https://patchwork.linux-mips.org/patch/16884/
    Signed-off-by: Ralf Baechle

    Aleksandar Markovic
     
  • Fix the value returned by ., if the inputs are normal
    fp numbers of the same absolute value, but opposite signs.

    A relevant example:

    MAXA.S fd,fs,ft:
    If fs contains -3.0, and ft contains +3.0, fd is going to contain
    +3.0 (without this patch, it used to contain -3.0).

    Fixes: a79f5f9ba508 ("MIPS: math-emu: Add support for the MIPS R6 MAX{, A} FPU instruction")
    Fixes: 4e9561b20e2f ("MIPS: math-emu: Add support for the MIPS R6 MIN{, A} FPU instruction")

    Signed-off-by: Miodrag Dinic
    Signed-off-by: Goran Ferenc
    Signed-off-by: Aleksandar Markovic
    Reviewed-by: James Hogan
    Cc: Bo Hu
    Cc: Douglas Leung
    Cc: Jin Qian
    Cc: Paul Burton
    Cc: Petar Jovanovic
    Cc: Raghu Gandham
    Cc: # 4.3+
    Cc: linux-mips@linux-mips.org
    Cc: linux-kernel@vger.kernel.org
    Patchwork: https://patchwork.linux-mips.org/patch/16883/
    Signed-off-by: Ralf Baechle

    Aleksandar Markovic
     
  • Fix the value returned by ., if both inputs are negative
    normal fp numbers. The previous logic did not take into account that
    if both inputs have the same sign, there should be separate treatment
    of the cases when both inputs are negative and when both inputs are
    positive.

    A relevant example:

    MAX.S fd,fs,ft:
    If fs contains -5.0, and ft contains -7.0, fd is going to contain
    -5.0 (without this patch, it used to contain -7.0).

    Fixes: a79f5f9ba508 ("MIPS: math-emu: Add support for the MIPS R6 MAX{, A} FPU instruction")
    Fixes: 4e9561b20e2f ("MIPS: math-emu: Add support for the MIPS R6 MIN{, A} FPU instruction")

    Signed-off-by: Miodrag Dinic
    Signed-off-by: Goran Ferenc
    Signed-off-by: Aleksandar Markovic
    Reviewed-by: James Hogan
    Cc: Bo Hu
    Cc: Douglas Leung
    Cc: Jin Qian
    Cc: Paul Burton
    Cc: Petar Jovanovic
    Cc: Raghu Gandham
    Cc: # 4.3+
    Cc: linux-mips@linux-mips.org
    Cc: linux-kernel@vger.kernel.org
    Patchwork: https://patchwork.linux-mips.org/patch/16882/
    Signed-off-by: Ralf Baechle

    Aleksandar Markovic
     
  • Fix the value returned by ., if both inputs
    are zeros. The right behavior in such cases is stated in instruction
    reference manual and is as follows:

    fs ft MAX MIN MAXA MINA
    ---------------------------------------------
    0 0 0 0 0 0
    0 -0 0 -0 0 -0
    -0 0 0 -0 0 -0
    -0 -0 -0 -0 -0 -0

    Prior to this patch, some of the above cases were yielding correct
    results. However, for the sake of code consistency, all such cases
    are rewritten in this patch.

    A relevant example:

    MAX.S fd,fs,ft:
    If fs contains +0.0, and ft contains -0.0, fd is going to contain
    +0.0 (without this patch, it used to contain -0.0).

    Fixes: a79f5f9ba508 ("MIPS: math-emu: Add support for the MIPS R6 MAX{, A} FPU instruction")
    Fixes: 4e9561b20e2f ("MIPS: math-emu: Add support for the MIPS R6 MIN{, A} FPU instruction")

    Signed-off-by: Miodrag Dinic
    Signed-off-by: Goran Ferenc
    Signed-off-by: Aleksandar Markovic
    Reviewed-by: James Hogan
    Cc: Bo Hu
    Cc: Douglas Leung
    Cc: Jin Qian
    Cc: Paul Burton
    Cc: Petar Jovanovic
    Cc: Raghu Gandham
    Cc: # 4.3+
    Cc: linux-mips@linux-mips.org
    Cc: linux-kernel@vger.kernel.org
    Patchwork: https://patchwork.linux-mips.org/patch/16881/
    Signed-off-by: Ralf Baechle

    Aleksandar Markovic
     
  • Fix the value returned by . fd,fs,ft, if both
    inputs are quiet NaNs. The . specifications
    state that the returned value in such cases should be the quiet NaN
    contained in register fs.

    A relevant example:

    MAX.S fd,fs,ft:
    If fs contains qNaN1, and ft contains qNaN2, fd is going to contain
    qNaN1 (without this patch, it used to contain qNaN2).

    Fixes: a79f5f9ba508 ("MIPS: math-emu: Add support for the MIPS R6 MAX{, A} FPU instruction")
    Fixes: 4e9561b20e2f ("MIPS: math-emu: Add support for the MIPS R6 MIN{, A} FPU instruction")

    Signed-off-by: Miodrag Dinic
    Signed-off-by: Goran Ferenc
    Signed-off-by: Aleksandar Markovic
    Reviewed-by: James Hogan
    Cc: Bo Hu
    Cc: Douglas Leung
    Cc: Jin Qian
    Cc: Paul Burton
    Cc: Petar Jovanovic
    Cc: Raghu Gandham
    Cc: # 4.3+
    Cc: linux-mips@linux-mips.org
    Cc: linux-kernel@vger.kernel.org
    Patchwork: https://patchwork.linux-mips.org/patch/16880/
    Signed-off-by: Ralf Baechle

    Aleksandar Markovic
     
  • The fault_addr argument to fpu_emulator_cop1Handler(), fpux_emu() and
    cop1Emulate() has up until now been declared as:

    void *__user *fault_addr

    This is essentially a pointer in user memory which points to a pointer
    to void. This is not the intent for our code, which is actually
    operating on a pointer to a pointer to void where the pointer to void is
    pointing at user memory. ie. the pointer is in kernel memory & points to
    user memory.

    This mismatch produces a lot of sparse warnings that look like this:

    arch/mips/math-emu/cp1emu.c:1485:45:
    warning: incorrect type in assignment (different address spaces)
    expected void *[noderef]
    got unsigned int [noderef] [usertype] *[assigned] va

    Fix these by modifying the declaration of the fault_addr argument to:

    void __user **fault_addr

    Signed-off-by: Paul Burton
    Cc: linux-mips@linux-mips.org
    Cc: trivial@kernel.org
    Patchwork: https://patchwork.linux-mips.org/patch/17173/
    Signed-off-by: Ralf Baechle

    Paul Burton
     
  • GCC-7 complains about a boolean value being used with an arithmetic
    AND:

    arch/mips/math-emu/cp1emu.c: In function 'cop1Emulate':
    arch/mips/math-emu/cp1emu.c:838:14: warning: '~' on a boolean expression [-Wbool-operation]
    fpr = (x) & ~(cop1_64bit(xcp) == 0); \
    ^
    arch/mips/math-emu/cp1emu.c:1068:3: note: in expansion of macro 'DITOREG'
    DITOREG(dval, MIPSInst_RT(ir));
    ^~~~~~~
    arch/mips/math-emu/cp1emu.c:838:14: note: did you mean to use logical not?
    fpr = (x) & ~(cop1_64bit(xcp) == 0); \

    Since cop1_64bit() returns and int, just flip the LSB.

    Suggested-by: Maciej W. Rozycki
    Signed-off-by: Manuel Lauss
    Reviewed-by: Maciej W. Rozycki
    Cc: linux-mips@linux-mips.org
    Patchwork: https://patchwork.linux-mips.org/patch/17058/
    Signed-off-by: Ralf Baechle

    Manuel Lauss
     

16 Jul, 2017

1 commit

  • Pull MIPS updates from Ralf Baechle:
    "Boston platform support:
    - Document DT bindings
    - Add CLK driver for board clocks

    CM:
    - Avoid per-core locking with CM3 & higher
    - WARN on attempt to lock invalid VP, not BUG

    CPS:
    - Select CONFIG_SYS_SUPPORTS_SCHED_SMT for MIPSr6
    - Prevent multi-core with dcache aliasing
    - Handle cores not powering down more gracefully
    - Handle spurious VP starts more gracefully

    DSP:
    - Add lwx & lhx missaligned access support

    eBPF:
    - Add MIPS support along with many supporting change to add the
    required infrastructure

    Generic arch code:
    - Misc sysmips MIPS_ATOMIC_SET fixes
    - Drop duplicate HAVE_SYSCALL_TRACEPOINTS
    - Negate error syscall return in trace
    - Correct forced syscall errors
    - Traced negative syscalls should return -ENOSYS
    - Allow samples/bpf/tracex5 to access syscall arguments for sane
    traces
    - Cleanup from old Kconfig options in defconfigs
    - Fix PREF instruction usage by memcpy for MIPS R6
    - Fix various special cases in the FPU eulation
    - Fix some special cases in MIPS16e2 support
    - Fix MIPS I ISA /proc/cpuinfo reporting
    - Sort MIPS Kconfig alphabetically
    - Fix minimum alignment requirement of IRQ stack as required by
    ABI / GCC
    - Fix special cases in the module loader
    - Perform post-DMA cache flushes on systems with MAARs
    - Probe the I6500 CPU
    - Cleanup cmpxchg and add support for 1 and 2 byte operations
    - Use queued read/write locks (qrwlock)
    - Use queued spinlocks (qspinlock)
    - Add CPU shared FTLB feature detection
    - Handle tlbex-tlbp race condition
    - Allow storing pgd in C0_CONTEXT for MIPSr6
    - Use current_cpu_type() in m4kc_tlbp_war()
    - Support Boston in the generic kernel

    Generic platform:
    - yamon-dt: Pull YAMON DT shim code out of SEAD-3 board
    - yamon-dt: Support > 256MB of RAM
    - yamon-dt: Use serial* rather than uart* aliases
    - Abstract FDT fixup application
    - Set RTC_ALWAYS_BCD to 0
    - Add a MAINTAINERS entry

    core kernel:
    - qspinlock.c: include linux/prefetch.h

    Loongson 3:
    - Add support

    Perf:
    - Add I6500 support

    SEAD-3:
    - Remove GIC timer from DT
    - Set interrupt-parent per-device, not at root node
    - Fix GIC interrupt specifiers

    SMP:
    - Skip IPI setup if we only have a single CPU

    VDSO:
    - Make comment match reality
    - Improvements to time code in VDSO"

    * 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upstream-linus: (86 commits)
    locking/qspinlock: Include linux/prefetch.h
    MIPS: Fix MIPS I ISA /proc/cpuinfo reporting
    MIPS: Fix minimum alignment requirement of IRQ stack
    MIPS: generic: Support MIPS Boston development boards
    MIPS: DTS: img: Don't attempt to build-in all .dtb files
    clk: boston: Add a driver for MIPS Boston board clocks
    dt-bindings: Document img,boston-clock binding
    MIPS: Traced negative syscalls should return -ENOSYS
    MIPS: Correct forced syscall errors
    MIPS: Negate error syscall return in trace
    MIPS: Drop duplicate HAVE_SYSCALL_TRACEPOINTS select
    MIPS16e2: Provide feature overrides for non-MIPS16 systems
    MIPS: MIPS16e2: Report ASE presence in /proc/cpuinfo
    MIPS: MIPS16e2: Subdecode extended LWSP/SWSP instructions
    MIPS: MIPS16e2: Identify ASE presence
    MIPS: VDSO: Fix a mismatch between comment and preprocessor constant
    MIPS: VDSO: Add implementation of gettimeofday() fallback
    MIPS: VDSO: Add implementation of clock_gettime() fallback
    MIPS: VDSO: Fix conversions in do_monotonic()/do_monotonic_coarse()
    MIPS: Use current_cpu_type() in m4kc_tlbp_war()
    ...

    Linus Torvalds
     

29 Jun, 2017

2 commits

  • Update commit 1ac944007bed ("MIPS: math-emu: Add mfhc1 & mthc1
    support.") and like done throughout `cop1Emulate' for other cases also
    for the MFHC1 and MTHC1 instructions return SIGILL right away rather
    than jumping to a single `return' statement.

    Signed-off-by: Maciej W. Rozycki
    Cc: James Hogan
    Cc: linux-mips@linux-mips.org
    Patchwork: https://patchwork.linux-mips.org/patch/16401/
    Signed-off-by: Ralf Baechle

    Maciej W. Rozycki
     
  • Terminate FPU emulation immediately whenever an ISA mode switch has been
    observed. This is so that we do not interpret machine code in the wrong
    mode, for example when a regular MIPS FPU instruction has been placed in
    a delay slot of a jump that switches into the MIPS16 mode, as with the
    following code (taken from a GCC test suite case):

    00400650 :
    400650: 3c020100 lui v0,0x100
    400654: 03e00008 jr ra
    400658: 44c2f800 ctc1 v0,c1_fcsr
    40065c: 00000000 nop

    [...]

    004012d0 :
    4012d0: f000 6a02 li v0,2
    4012d4: f150 0b1c la v1,3f9430
    4012d8: f400 3240 sll v0,16
    4012dc: e269 addu v0,v1
    4012de: 659a move gp,v0
    4012e0: f00c 64f6 save a0-a2,48,ra,s0-s1
    4012e4: 673c move s1,gp
    4012e6: f010 9978 lw v1,-32744(s1)
    4012ea: d204 sw v0,16(sp)
    4012ec: eb40 jalr v1
    4012ee: 653b move t9,v1
    4012f0: f010 997c lw v1,-32740(s1)
    4012f4: f030 9920 lw s1,-32736(s1)
    4012f8: e32f subu v1,s1
    4012fa: 326b sra v0,v1,2
    4012fc: d206 sw v0,24(sp)
    4012fe: 220c beqz v0,401318
    401300: 6800 li s0,0
    401302: 99e0 lw a3,0(s1)
    401304: 4801 addiu s0,1
    401306: 960e lw a2,56(sp)
    401308: 4904 addiu s1,4
    40130a: 950d lw a1,52(sp)
    40130c: 940c lw a0,48(sp)
    40130e: ef40 jalr a3
    401310: 653f move t9,a3
    401312: 9206 lw v0,24(sp)
    401314: ea0a cmp v0,s0
    401316: 61f5 btnez 401302
    401318: 6476 restore 48,ra,s0-s1
    40131a: e8a0 jrc ra

    Here `set_fast_math' is called from `40130e' (`40130f' with the ISA bit)
    and emulation triggers for the CTC1 instruction. As it is in a jump
    delay slot emulation continues from `401312' (`401313' with the ISA
    bit). However we have no path to handle MIPS16 FPU code emulation,
    because there are no MIPS16 FPU instructions. So the default emulation
    path is taken, interpreting a 32-bit word fetched by `get_user' from
    `401313' as a regular MIPS instruction, which is:

    401313: f5ea0a92 sdc1 $f10,2706(t7)

    This makes the FPU emulator proceed with the supposed SDC1 instruction
    and consequently makes the program considered here terminate with
    SIGSEGV.

    A similar although less severe issue exists with pure-microMIPS
    processors in the case where similarly an FPU instruction is emulated in
    a delay slot of a register jump that (incorrectly) switches into the
    regular MIPS mode. A subsequent instruction fetch from the jump's
    target is supposed to cause an Address Error exception, however instead
    we proceed with regular MIPS FPU emulation.

    For simplicity then, always terminate the emulation loop whenever a mode
    change is detected, denoted by an ISA mode bit flip. As from commit
    377cb1b6c16a ("MIPS: Disable MIPS16/microMIPS crap for platforms not
    supporting these ASEs.") the result of `get_isa16_mode' can be hardcoded
    to 0, so we need to examine the ISA mode bit by hand.

    This complements commit 102cedc32a6e ("MIPS: microMIPS: Floating point
    support.") which added JALX decoding to FPU emulation.

    Fixes: 102cedc32a6e ("MIPS: microMIPS: Floating point support.")
    Signed-off-by: Maciej W. Rozycki
    Cc: James Hogan
    Cc: linux-mips@linux-mips.org
    Cc: stable@vger.kernel.org # 3.9+
    Patchwork: https://patchwork.linux-mips.org/patch/16393/
    Signed-off-by: Ralf Baechle

    Maciej W. Rozycki
     

28 Jun, 2017

1 commit

  • If accumulator value is zero, just return the value of previously
    calculated product. This brings logic in MADDF/MSUBF implementation
    closer to the logic in ADD/SUB case.

    Signed-off-by: Miodrag Dinic
    Signed-off-by: Goran Ferenc
    Signed-off-by: Aleksandar Markovic
    Cc: James.Hogan@imgtec.com
    Cc: Paul.Burton@imgtec.com
    Cc: Raghu.Gandham@imgtec.com
    Cc: Leonid.Yegoshin@imgtec.com
    Cc: Douglas.Leung@imgtec.com
    Cc: Petar.Jovanovic@imgtec.com
    Cc: linux-mips@linux-mips.org
    Patchwork: https://patchwork.linux-mips.org/patch/16512/
    Signed-off-by: Ralf Baechle

    Aleksandar Markovic
     

10 Apr, 2017

1 commit

  • Correct the treatment of branching conditions for BC1EQZ and BC1NEZ
    instructions in function isBranchInstr().

    Previously, corresponding conditions were swapped, which in turn meant
    that, for these two instructions, function isBranchInstr() returned
    wrong value in its output parameter contpc.

    This change is actually an extension of the fix done by the commit
    93583e178ebf ("MIPS: math-emu: Fix BC1{EQ,NE}Z emulation"). That commit
    dealt with a similar problem in function cop1Emulate(), while this
    commit deals with condition handling in function isBranchInstr().
    The code styles of changes in these two commits are kept as
    consistent as possible.

    Signed-off-by: Douglas Leung
    Signed-off-by: Miodrag Dinic
    Signed-off-by: Aleksandar Markovic
    Reviewed-by: Paul Burton
    Cc: james.hogan@imgtec.com
    Cc: leonid.yegoshin@imgtec.com
    Cc: petar.jovanovic@imgtec.com
    Cc: goran.ferenc@imgtec.com
    Cc: linux-mips@linux-mips.org
    Patchwork: https://patchwork.linux-mips.org/patch/15489/
    Signed-off-by: Ralf Baechle

    Douglas Leung
     

02 Mar, 2017

2 commits


25 Dec, 2016

1 commit