diff options
author | Paul Burton <paul.burton@imgtec.com> | 2014-09-24 05:45:37 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2014-09-26 05:33:11 -0400 |
commit | c8c0da6bdf0f0d6f59fc23aab6ee373a131df82d (patch) | |
tree | f90e0aaa79c1337055460cb7c7bd8a4575ffcae9 /arch/mips/math-emu | |
parent | 0f33be009b89d2268e94194dc4fd01a7851b6d51 (diff) |
MIPS: Fix MFC1 & MFHC1 emulation for 64-bit MIPS systems
Commit bbd426f542cb "MIPS: Simplify FP context access" modified the
SIFROMREG & SIFROMHREG macros such that they return unsigned rather
than signed 32b integers. I had believed that to be fine, but
inadvertently missed the MFC1 & MFHC1 cases which write to a struct
pt_regs regs element. On MIPS32 this is fine, but on 64 bit those
saved regs' fields are 64 bit wide. Using unsigned values caused the
32 bit value from the FP register to be zero rather than sign extended
as the architecture specifies, causing incorrect emulation of the
MFC1 & MFHc1 instructions. Fix by reintroducing the casts to signed
integers, and therefore the sign extension.
Signed-off-by: Paul Burton <paul.burton@imgtec.com>
Cc: stable@vger.kernel.org # v3.15+
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/7848/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/math-emu')
-rw-r--r-- | arch/mips/math-emu/cp1emu.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/arch/mips/math-emu/cp1emu.c b/arch/mips/math-emu/cp1emu.c index bf0fc6b16ad9..7a4727795a70 100644 --- a/arch/mips/math-emu/cp1emu.c +++ b/arch/mips/math-emu/cp1emu.c | |||
@@ -650,9 +650,9 @@ static inline int cop1_64bit(struct pt_regs *xcp) | |||
650 | #define SIFROMREG(si, x) \ | 650 | #define SIFROMREG(si, x) \ |
651 | do { \ | 651 | do { \ |
652 | if (cop1_64bit(xcp)) \ | 652 | if (cop1_64bit(xcp)) \ |
653 | (si) = get_fpr32(&ctx->fpr[x], 0); \ | 653 | (si) = (int)get_fpr32(&ctx->fpr[x], 0); \ |
654 | else \ | 654 | else \ |
655 | (si) = get_fpr32(&ctx->fpr[(x) & ~1], (x) & 1); \ | 655 | (si) = (int)get_fpr32(&ctx->fpr[(x) & ~1], (x) & 1); \ |
656 | } while (0) | 656 | } while (0) |
657 | 657 | ||
658 | #define SITOREG(si, x) \ | 658 | #define SITOREG(si, x) \ |
@@ -667,7 +667,7 @@ do { \ | |||
667 | } \ | 667 | } \ |
668 | } while (0) | 668 | } while (0) |
669 | 669 | ||
670 | #define SIFROMHREG(si, x) ((si) = get_fpr32(&ctx->fpr[x], 1)) | 670 | #define SIFROMHREG(si, x) ((si) = (int)get_fpr32(&ctx->fpr[x], 1)) |
671 | 671 | ||
672 | #define SITOHREG(si, x) \ | 672 | #define SITOHREG(si, x) \ |
673 | do { \ | 673 | do { \ |