Skip to content

Commit de985dd

Browse files
0x7f454c46torvalds
authored andcommitted
unicore32: add loglvl to c_backtrace()
Currently, the log-level of show_stack() depends on a platform realization. It creates situations where the headers are printed with lower log level or higher than the stacktrace (depending on a platform or user). Furthermore, it forces the logic decision from user to an architecture side. In result, some users as sysrq/kdb/etc are doing tricks with temporary rising console_loglevel while printing their messages. And in result it not only may print unwanted messages from other CPUs, but also omit printing at all in the unlucky case where the printk() was deferred. Introducing log-level parameter and KERN_UNSUPPRESSED [1] seems an easier approach than introducing more printk buffers. Also, it will consolidate printings with headers. Add log level parameter to c_backtrace() as a preparation for introducing show_stack_loglvl() [1]: https://lore.kernel.org/lkml/20190528002412.1625-1-dima@arista.com/T/#u Signed-off-by: Dmitry Safonov <dima@arista.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Cc: Guan Xuetao <gxt@pku.edu.cn> Link: http://lkml.kernel.org/r/20200418201944.482088-39-dima@arista.com Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent ee1e990 commit de985dd

3 files changed

Lines changed: 18 additions & 10 deletions

File tree

‎arch/unicore32/kernel/setup.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ extern void kernel_thread_helper(void);
2929
extern void __init early_signal_init(void);
3030

3131
extern asmlinkage void __backtrace(void);
32-
extern asmlinkage void c_backtrace(unsigned long fp);
32+
extern asmlinkage void c_backtrace(unsigned long fp, const char *loglvl);
3333

3434
extern void __show_regs(struct pt_regs *);
3535

‎arch/unicore32/kernel/traps.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ static void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk)
163163
printk("\n");
164164

165165
if (ok)
166-
c_backtrace(fp);
166+
c_backtrace(fp, KERN_DEFAULT);
167167
}
168168

169169
void show_stack(struct task_struct *tsk, unsigned long *sp)

‎arch/unicore32/lib/backtrace.S‎

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#define sv_fp v5
1717
#define sv_pc v6
1818
#define offset v8
19+
#define loglvl v9
1920

2021
ENTRY(__backtrace)
2122
mov r0, fp
@@ -27,10 +28,11 @@ ENTRY(c_backtrace)
2728
ENDPROC(__backtrace)
2829
ENDPROC(c_backtrace)
2930
#else
30-
stm.w (v4 - v8, lr), [sp-] @ Save an extra register
31+
stm.w (v4 - v10, lr), [sp-] @ Save an extra register
3132
@ so we have a location...
3233
mov.a frame, r0 @ if frame pointer is zero
3334
beq no_frame @ we have no stack frames
35+
mov loglvl, r1
3436

3537
1: stm.w (pc), [sp-] @ calculate offset of PC stored
3638
ldw.w r0, [sp]+, #4 @ by stmfd for this CPU
@@ -95,9 +97,10 @@ for_each_frame:
9597
bua for_each_frame
9698

9799
1006: adr r0, .Lbad
98-
mov r1, frame
100+
mov r1, loglvl
101+
mov r2, frame
99102
b.l printk
100-
no_frame: ldm.w (v4 - v8, pc), [sp]+
103+
no_frame: ldm.w (v4 - v10, pc), [sp]+
101104
ENDPROC(__backtrace)
102105
ENDPROC(c_backtrace)
103106

@@ -128,8 +131,11 @@ ENDPROC(c_backtrace)
128131
add v7, v7, #1
129132
cxor.a v7, #6
130133
cmoveq v7, #1
131-
cmoveq r1, #'\n'
132-
cmovne r1, #' '
134+
bne 201f
135+
adr r0, .Lcr
136+
mov r1, loglvl
137+
b.l printk
138+
201:
133139
ldw.w r3, [stack]+, #-4
134140
mov r2, reg
135141
csub.a r2, #8
@@ -141,18 +147,20 @@ ENDPROC(c_backtrace)
141147
add r2, r2, #0x10 @ so r2 need add 16
142148
201:
143149
adr r0, .Lfp
150+
mov r1, loglvl
144151
b.l printk
145152
2: sub.a reg, reg, #1
146153
bns 1b
147154
cxor.a v7, #0
148155
beq 201f
149156
adr r0, .Lcr
157+
mov r1, loglvl
150158
b.l printk
151159
201: ldm.w (instr, reg, stack, v7, pc), [sp]+
152160

153-
.Lfp: .asciz "%cr%d:%08x"
154-
.Lcr: .asciz "\n"
155-
.Lbad: .asciz "Backtrace aborted due to bad frame pointer <%p>\n"
161+
.Lfp: .asciz "%sr%d:%08x "
162+
.Lcr: .asciz "%s\n"
163+
.Lbad: .asciz "%sBacktrace aborted due to bad frame pointer <%p>\n"
156164
.align
157165
.Ldsi: .word 0x92eec000 >> 14 @ stm.w sp, (... fp, ip, lr, pc)
158166
.word 0x92e10000 >> 14 @ stm.w sp, ()

0 commit comments

Comments
 (0)