MIPS: math-emu: Fix jalr emulation when rd == $0
authorPaul Burton <paul.burton@imgtec.com>
Thu, 21 Apr 2016 13:04:55 +0000 (14:04 +0100)
committerWilly Tarreau <w@1wt.eu>
Sun, 21 Aug 2016 21:22:40 +0000 (23:22 +0200)
commit2c767daebacb87a6b308f86f2112fc7b4793cbf0
tree5407bdbe79dd6800ea570e61cc96f5e64b5fea28
parent5928125348d6d78867bc5a5171cc13a958eb6e01
MIPS: math-emu: Fix jalr emulation when rd == $0

commit ab4a92e66741b35ca12f8497896bafbe579c28a1 upstream.

When emulating a jalr instruction with rd == $0, the code in
isBranchInstr was incorrectly writing to GPR $0 which should actually
always remain zeroed. This would lead to any further instructions
emulated which use $0 operating on a bogus value until the task is next
context switched, at which point the value of $0 in the task context
would be restored to the correct zero by a store in SAVE_SOME. Fix this
by not writing to rd if it is $0.

Fixes: 102cedc32a6e ("MIPS: microMIPS: Floating point support.")
Signed-off-by: Paul Burton <paul.burton@imgtec.com>
Cc: Maciej W. Rozycki <macro@imgtec.com>
Cc: James Hogan <james.hogan@imgtec.com>
Cc: linux-mips@linux-mips.org
Cc: linux-kernel@vger.kernel.org
Patchwork: https://patchwork.linux-mips.org/patch/13160/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Willy Tarreau <w@1wt.eu>
arch/mips/math-emu/cp1emu.c