• Matt Redfearn's avatar
    MIPS: Stacktrace: Fix microMIPS stack unwinding on big endian systems · 41885b02
    Matt Redfearn authored
    The stack unwinding code uses the mips_instuction union to decode the
    instructions it finds. That union uses the __BITFIELD_FIELD macro to
    reorder depending on endianness. The stack unwinding code always places
    16bit instructions in halfword 1 of the union. This makes the union
    accesses correct for little endian systems. Similarly, 32bit
    instructions are reordered such that they are correct for little endian
    systems. This handling leaves unwinding the stack on big endian systems
    broken, as the mips_instruction union will then look for the fields in
    the wrong halfword.
    
    To fix this, use a logical shift to place the 16bit instruction into the
    correct position in the word field of the union. Use the same shifting
    to order the 2 halfwords of 32bit instuctions. Then replace accesses to
    the halfword with accesses to the shifted word.
    In the case of the ADDIUS5 instruction, switch to using the
    mm16_r5_format union member to avoid the need for a 16bit shift.
    
    Fixes: 34c2f668 ("MIPS: microMIPS: Add unaligned access support.")
    Signed-off-by: default avatarMatt Redfearn <matt.redfearn@imgtec.com>
    Reviewed-by: default avatarJames Hogan <james.hogan@imgtec.com>
    Cc: Marcin Nowakowski <marcin.nowakowski@imgtec.com>
    Cc: Ingo Molnar <mingo@kernel.org>
    Cc: Paul Burton <paul.burton@imgtec.com>
    Cc: linux-mips@linux-mips.org
    Cc: linux-kernel@vger.kernel.org
    Patchwork: https://patchwork.linux-mips.org/patch/16956/Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
    41885b02
process.c 19.5 KB