Skip to contentSkip to conversation

Patch "MIPS: Fix bnezc/jialc return address calculation" has been added to the 4.4-stable tree

PATCH [email protected] 1 participant 1 message Jun 19, 2017

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

MIPS: Fix bnezc/jialc return address calculation

to the 4.4-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
mips-fix-bnezc-jialc-return-address-calculation.patch
and it can be found in the queue-4.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From 1a73d9310e093fc3adffba4d0a67b9fab2ee3f63 Mon Sep 17 00:00:00 2001

From: Paul Burton <[email protected]>
Date: Fri, 2 Jun 2017 11:35:01 -0700
Subject: MIPS: Fix bnezc/jialc return address calculation

From: Paul Burton <[email protected]>

commit 1a73d9310e093fc3adffba4d0a67b9fab2ee3f63 upstream.

The code handling the pop76 opcode (ie. bnezc & jialc instructions) in __compute_return_epc_for_insn() needs to set the value of $31 in the jialc case, which is encoded with rs = 0. However its check to differentiate bnezc (rs != 0) from jialc (rs = 0) was unfortunately backwards, meaning that if we emulate a bnezc instruction we clobber $31 & if we emulate a jialc instruction it actually behaves like a jic instruction.

Fix this by inverting the check of rs to match the way the instructions are actually encoded.

Fixes 28d6f93d201d ("MIPS: Emulate the new MIPS R6 BNEZC and JIALC instructions")

Patchwork: https://patchwork.linux-mips.org/patch/16178/

---
 arch/mips/kernel/branch.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
arch/mips/kernel/branch.c +3 -1
@@ -816,8 +816,10 @@ int __compute_return_epc_for_insn(struct
 			break;
 		}
 		/* Compact branch: BNEZC || JIALC */
-		if (insn.i_format.rs)
+		if (!insn.i_format.rs) {
+			/* JIALC: set $31/ra */
 			regs->regs[31] = epc + 4;
+		}
 		regs->cp0_epc += 8;
 		break;
 #endif

Patches currently in stable-queue which might be from [email protected] are

queue-4.4/mips-fix-bnezc-jialc-return-address-calculation.patch