Currently show_instructions() treats prefixed instructions as two
separate word instructions. '<' and '>' are placed around the
instruction at the NIP, but as a result they only wrap around the
prefix. Make '<' and '>' straddle the whole prefixed instruction.

Currently showing a prefixed instruction looks like:

Instruction dump:
60000000 60000000 60000000 60000000 60000000 60000000 60000000 60000000
60000000 60000000 60000000 60000000 <04000000> 00000000 60000000 60000000

Make it look like:
Instruction dump:
0x60000000 0x60000000 0x60000000 0x60000000 0x60000000 0x60000000 0x60000000 
0x60000000
0x60000000 0x60000000 0x60000000 0x60000000 <0x04000000 0x00000000> 0x60000000 
0x60000000 0x60000000

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

diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index b3f73e398d00..bcd7277a9395 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -1258,7 +1258,7 @@ static void show_instructions(struct pt_regs *regs)
        printk("Instruction dump:");
 
        for (i = 0; i < NR_INSN_TO_PRINT; i++) {
-               int instr;
+               struct ppc_inst instr;
 
                if (!(i % 8))
                        pr_cont("\n");
@@ -1272,16 +1272,17 @@ static void show_instructions(struct pt_regs *regs)
 #endif
 
                if (!__kernel_text_address(pc) ||
-                   probe_kernel_address((const void *)pc, instr)) {
+                   probe_kernel_read_inst(&instr, (struct ppc_inst *)pc)) {
+                       instr = ppc_inst(PPC_INST_NOP);
                        pr_cont("XXXXXXXX ");
                } else {
                        if (regs->nip == pc)
-                               pr_cont("<%08x> ", instr);
+                               pr_cont("<%s> ", ppc_inst_as_str(instr));
                        else
-                               pr_cont("%08x ", instr);
+                               pr_cont("%s ", ppc_inst_as_str(instr));
                }
 
-               pc += sizeof(int);
+               pc += ppc_inst_len(instr);
        }
 
        pr_cont("\n");
-- 
2.17.1

Reply via email to