• Paul Burton's avatar
    MIPS: Fix bnezc/jialc return address calculation · 1a73d931
    Paul Burton authored
    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.
    Signed-off-by: default avatarPaul Burton <paul.burton@imgtec.com>
    Fixes: 28d6f93d ("MIPS: Emulate the new MIPS R6 BNEZC and JIALC instructions")
    Cc: stable <stable@vger.kernel.org> # v4.0+
    Cc: linux-mips@linux-mips.org
    Patchwork: https://patchwork.linux-mips.org/patch/16178/Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
    1a73d931
branch.c 21.2 KB