Skip to content

Commit 88b0fe1

Browse files
mopsfeldermpe
authored andcommitted
powerpc: Add show_user_instructions()
show_user_instructions() is a slightly modified version of show_instructions() that allows userspace instruction dump. This will be useful within show_signal_msg() to dump userspace instructions of the faulty location. Here is a sample of what show_user_instructions() outputs: pandafault[10850]: code: 4bfffee 4bfffee8 3c401002 38427f00 fbe1fff8 f821ffc1 7c3f0b78 3d22fffe pandafault[10850]: code: 392988d0 f93f0020 e93f0020 39400048 <99490000> 39200000 7d234b78 383f0040 The current->comm and current->pid printed can serve as a glue that links the instructions dump to its originator, allowing messages to be interleaved in the logs. Signed-off-by: Murilo Opsfelder Araujo <muriloo@linux.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
1 parent 0f642d6 commit 88b0fe1

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

arch/powerpc/include/asm/stacktrace.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
/*
3+
* Stack trace functions.
4+
*
5+
* Copyright 2018, Murilo Opsfelder Araujo, IBM Corporation.
6+
*/
7+
8+
#ifndef _ASM_POWERPC_STACKTRACE_H
9+
#define _ASM_POWERPC_STACKTRACE_H
10+
11+
void show_user_instructions(struct pt_regs *regs);
12+
13+
#endif /* _ASM_POWERPC_STACKTRACE_H */

arch/powerpc/kernel/process.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,6 +1299,38 @@ static void show_instructions(struct pt_regs *regs)
12991299
pr_cont("\n");
13001300
}
13011301

1302+
void show_user_instructions(struct pt_regs *regs)
1303+
{
1304+
unsigned long pc;
1305+
int i;
1306+
1307+
pc = regs->nip - (instructions_to_print * 3 / 4 * sizeof(int));
1308+
1309+
pr_info("%s[%d]: code: ", current->comm, current->pid);
1310+
1311+
for (i = 0; i < instructions_to_print; i++) {
1312+
int instr;
1313+
1314+
if (!(i % 8) && (i > 0)) {
1315+
pr_cont("\n");
1316+
pr_info("%s[%d]: code: ", current->comm, current->pid);
1317+
}
1318+
1319+
if (probe_kernel_address((unsigned int __user *)pc, instr)) {
1320+
pr_cont("XXXXXXXX ");
1321+
} else {
1322+
if (regs->nip == pc)
1323+
pr_cont("<%08x> ", instr);
1324+
else
1325+
pr_cont("%08x ", instr);
1326+
}
1327+
1328+
pc += sizeof(int);
1329+
}
1330+
1331+
pr_cont("\n");
1332+
}
1333+
13021334
struct regbit {
13031335
unsigned long bit;
13041336
const char *name;

0 commit comments

Comments
 (0)