From: Jordan Niethe <jniethe5@gmail.com>
To: linuxppc-dev@ozlabs.org
Cc: Jordan Niethe <jniethe5@gmail.com>, alistair@popple.id.au
Subject: [PATCH 3/4] powerpc: Handle prefixed instructions in show_user_instructions()
Date: Tue, 2 Jun 2020 15:27:27 +1000 [thread overview]
Message-ID: <20200602052728.18227-3-jniethe5@gmail.com> (raw)
In-Reply-To: <20200602052728.18227-1-jniethe5@gmail.com>
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 <jniethe5@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
next prev parent reply other threads:[~2020-06-02 5:36 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-02 5:27 [PATCH 1/4] powerpc: Add a ppc_inst_as_str() helper Jordan Niethe
2020-06-02 5:27 ` [PATCH 2/4] powerpc/xmon: Improve dumping prefixed instructions Jordan Niethe
2020-06-02 5:27 ` Jordan Niethe [this message]
2022-02-22 14:34 ` [PATCH 3/4] powerpc: Handle prefixed instructions in show_user_instructions() Christophe Leroy
2022-03-14 23:00 ` Jordan Niethe
2020-06-02 5:27 ` [PATCH 4/4] powerpc: Handle prefixed instructions in show_instructions() Jordan Niethe
2020-06-02 7:43 ` [PATCH 1/4] powerpc: Add a ppc_inst_as_str() helper Joel Stanley
2020-06-02 19:41 ` Segher Boessenkool
2020-07-24 13:24 ` Michael Ellerman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200602052728.18227-3-jniethe5@gmail.com \
--to=jniethe5@gmail.com \
--cc=alistair@popple.id.au \
--cc=linuxppc-dev@ozlabs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).