Currently prefixed instructions are treated as two word instructions by
show_user_instructions(), treat them as a single instruction. '<' and
'>' are placed around the instruction at the NIP, and for prefixed
instructions this is placed around the prefix only. Make the '<' and '>'
wrap the prefix and suffix.

Currently showing a prefixed instruction looks like:
fbe1fff8 39200000 06000000 a3e30000 <04000000> f7e40000 ebe1fff8 4e800020

Make it look like:
0xfbe1fff8 0x39200000 0x06000000 0xa3e30000 <0x04000000 0xf7e40000> 0xebe1fff8 
0x4e800020 0x00000000 0x00000000

Signed-off-by: Jordan Niethe <jniet...@gmail.com>
---
 arch/powerpc/kernel/process.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index 048d64c4e115..b3f73e398d00 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -1292,7 +1292,8 @@ void show_user_instructions(struct pt_regs *regs)
        unsigned long pc;
        int n = NR_INSN_TO_PRINT;
        struct seq_buf s;
-       char buf[96]; /* enough for 8 times 9 + 2 chars */
+       char buf[8 * sizeof("0x00000000 0x00000000") + 2];
+       struct ppc_inst instr;
 
        pc = regs->nip - (NR_INSN_TO_PRINT * 3 / 4 * sizeof(int));
 
@@ -1303,14 +1304,15 @@ void show_user_instructions(struct pt_regs *regs)
 
                seq_buf_clear(&s);
 
-               for (i = 0; i < 8 && n; i++, n--, pc += sizeof(int)) {
-                       int instr;
+               for (i = 0; i < 8 && n; i++, n--, pc += ppc_inst_len(instr)) {
 
-                       if (probe_user_read(&instr, (void __user *)pc, 
sizeof(instr))) {
+                       if (probe_user_read_inst(&instr, (void __user *)pc)) {
                                seq_buf_printf(&s, "XXXXXXXX ");
+                               instr = ppc_inst(PPC_INST_NOP);
                                continue;
                        }
-                       seq_buf_printf(&s, regs->nip == pc ? "<%08x> " : "%08x 
", instr);
+                       seq_buf_printf(&s, regs->nip == pc ? "<%s> " : "%s ",
+                                      ppc_inst_as_str(instr));
                }
 
                if (!seq_buf_has_overflowed(&s))
-- 
2.17.1

Reply via email to