Skip to content

Commit e5c388b

Browse files
committed
ARC: show_regs: fix r12 printing and simplify
when working on ARC64, spotted an issue in ARCv2 reg file printing. print_reg_file() assumes contiguous reg-file whereas in ARCv2 they are not: r12 comes before r0-r11 due to hardware auto-save. Apparently this issue has been present since v2 port submission. To avoid bolting hacks for this discontinuity while looping through pt_regs, just ditching the loop and print pt_regs directly. Signed-off-by: Vineet Gupta <[email protected]>
1 parent fe81d92 commit e5c388b

File tree

1 file changed

+30
-47
lines changed

1 file changed

+30
-47
lines changed

arch/arc/kernel/troubleshoot.c

Lines changed: 30 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -18,44 +18,37 @@
1818

1919
#define ARC_PATH_MAX 256
2020

21-
/*
22-
* Common routine to print scratch regs (r0-r12) or callee regs (r13-r25)
23-
* -Prints 3 regs per line and a CR.
24-
* -To continue, callee regs right after scratch, special handling of CR
25-
*/
26-
static noinline void print_reg_file(long *reg_rev, int start_num)
21+
static noinline void print_regs_scratch(struct pt_regs *regs)
2722
{
28-
unsigned int i;
29-
char buf[512];
30-
int n = 0, len = sizeof(buf);
31-
32-
for (i = start_num; i < start_num + 13; i++) {
33-
n += scnprintf(buf + n, len - n, "r%02u: 0x%08lx\t",
34-
i, (unsigned long)*reg_rev);
35-
36-
if (((i + 1) % 3) == 0)
37-
n += scnprintf(buf + n, len - n, "\n");
38-
39-
/* because pt_regs has regs reversed: r12..r0, r25..r13 */
40-
if (is_isa_arcv2() && start_num == 0)
41-
reg_rev++;
42-
else
43-
reg_rev--;
44-
}
45-
46-
if (start_num != 0)
47-
n += scnprintf(buf + n, len - n, "\n\n");
23+
pr_cont("BTA: 0x%08lx\n SP: 0x%08lx FP: 0x%08lx BLK: %pS\n",
24+
regs->bta, regs->sp, regs->fp, (void *)regs->blink);
25+
pr_cont("LPS: 0x%08lx\tLPE: 0x%08lx\tLPC: 0x%08lx\n",
26+
regs->lp_start, regs->lp_end, regs->lp_count);
4827

49-
/* To continue printing callee regs on same line as scratch regs */
50-
if (start_num == 0)
51-
pr_info("%s", buf);
52-
else
53-
pr_cont("%s\n", buf);
28+
pr_info("r00: 0x%08lx\tr01: 0x%08lx\tr02: 0x%08lx\n" \
29+
"r03: 0x%08lx\tr04: 0x%08lx\tr05: 0x%08lx\n" \
30+
"r06: 0x%08lx\tr07: 0x%08lx\tr08: 0x%08lx\n" \
31+
"r09: 0x%08lx\tr10: 0x%08lx\tr11: 0x%08lx\n" \
32+
"r12: 0x%08lx\t",
33+
regs->r0, regs->r1, regs->r2,
34+
regs->r3, regs->r4, regs->r5,
35+
regs->r6, regs->r7, regs->r8,
36+
regs->r9, regs->r10, regs->r11,
37+
regs->r12);
5438
}
5539

56-
static void show_callee_regs(struct callee_regs *cregs)
40+
static void print_regs_callee(struct callee_regs *regs)
5741
{
58-
print_reg_file(&(cregs->r13), 13);
42+
pr_cont("r13: 0x%08lx\tr14: 0x%08lx\n" \
43+
"r15: 0x%08lx\tr16: 0x%08lx\tr17: 0x%08lx\n" \
44+
"r18: 0x%08lx\tr19: 0x%08lx\tr20: 0x%08lx\n" \
45+
"r21: 0x%08lx\tr22: 0x%08lx\tr23: 0x%08lx\n" \
46+
"r24: 0x%08lx\tr25: 0x%08lx\n",
47+
regs->r13, regs->r14,
48+
regs->r15, regs->r16, regs->r17,
49+
regs->r18, regs->r19, regs->r20,
50+
regs->r21, regs->r22, regs->r23,
51+
regs->r24, regs->r25);
5952
}
6053

6154
static void print_task_path_n_nm(struct task_struct *tsk)
@@ -175,7 +168,7 @@ static void show_ecr_verbose(struct pt_regs *regs)
175168
void show_regs(struct pt_regs *regs)
176169
{
177170
struct task_struct *tsk = current;
178-
struct callee_regs *cregs;
171+
struct callee_regs *cregs = (struct callee_regs *)tsk->thread.callee_reg;
179172

180173
/*
181174
* generic code calls us with preemption disabled, but some calls
@@ -204,25 +197,15 @@ void show_regs(struct pt_regs *regs)
204197
STS_BIT(regs, A2), STS_BIT(regs, A1),
205198
STS_BIT(regs, E2), STS_BIT(regs, E1));
206199
#else
207-
pr_cont(" [%2s%2s%2s%2s]",
200+
pr_cont(" [%2s%2s%2s%2s] ",
208201
STS_BIT(regs, IE),
209202
(regs->status32 & STATUS_U_MASK) ? "U " : "K ",
210203
STS_BIT(regs, DE), STS_BIT(regs, AE));
211204
#endif
212-
pr_cont(" BTA: 0x%08lx\n SP: 0x%08lx FP: 0x%08lx BLK: %pS\n",
213-
regs->bta, regs->sp, regs->fp, (void *)regs->blink);
214-
pr_info("LPS: 0x%08lx\tLPE: 0x%08lx\tLPC: 0x%08lx\n",
215-
regs->lp_start, regs->lp_end, regs->lp_count);
216-
217-
/* print regs->r0 thru regs->r12
218-
* Sequential printing was generating horrible code
219-
*/
220-
print_reg_file(&(regs->r0), 0);
221205

222-
/* If Callee regs were saved, display them too */
223-
cregs = (struct callee_regs *)current->thread.callee_reg;
206+
print_regs_scratch(regs);
224207
if (cregs)
225-
show_callee_regs(cregs);
208+
print_regs_callee(cregs);
226209

227210
preempt_disable();
228211
}

0 commit comments

Comments
 (0)