MIPS: Fix MFC1 & MFHC1 emulation for 64-bit MIPS systems
Commit bbd426f542
"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>
This commit is contained in:
parent
0f33be009b
commit
c8c0da6bdf
1 changed files with 3 additions and 3 deletions
|
@ -650,9 +650,9 @@ static inline int cop1_64bit(struct pt_regs *xcp)
|
||||||
#define SIFROMREG(si, x) \
|
#define SIFROMREG(si, x) \
|
||||||
do { \
|
do { \
|
||||||
if (cop1_64bit(xcp)) \
|
if (cop1_64bit(xcp)) \
|
||||||
(si) = get_fpr32(&ctx->fpr[x], 0); \
|
(si) = (int)get_fpr32(&ctx->fpr[x], 0); \
|
||||||
else \
|
else \
|
||||||
(si) = get_fpr32(&ctx->fpr[(x) & ~1], (x) & 1); \
|
(si) = (int)get_fpr32(&ctx->fpr[(x) & ~1], (x) & 1); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define SITOREG(si, x) \
|
#define SITOREG(si, x) \
|
||||||
|
@ -667,7 +667,7 @@ do { \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define SIFROMHREG(si, x) ((si) = get_fpr32(&ctx->fpr[x], 1))
|
#define SIFROMHREG(si, x) ((si) = (int)get_fpr32(&ctx->fpr[x], 1))
|
||||||
|
|
||||||
#define SITOHREG(si, x) \
|
#define SITOHREG(si, x) \
|
||||||
do { \
|
do { \
|
||||||
|
|
Loading…
Reference in a new issue