From: Andrew Morton <akpm@linux-foundation.org>
To: akpm@linux-foundation.org, dima@arista.com, linux-mm@kvack.org,
linux@armlinux.org.uk, mm-commits@vger.kernel.org,
torvalds@linux-foundation.org, will@kernel.org
Subject: [patch 04/93] arm/asm: add loglvl to c_backtrace()
Date: Mon, 08 Jun 2020 21:30:07 -0700 [thread overview]
Message-ID: <20200609043007.KcV14EbSN%akpm@linux-foundation.org> (raw)
In-Reply-To: <20200608212922.5b7fa74ca3f4e2444441b7f9@linux-foundation.org>
From: Dmitry Safonov <dima@arista.com>
Subject: arm/asm: 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 argument 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
Link: http://lkml.kernel.org/r/20200418201944.482088-5-dima@arista.com
Signed-off-by: Dmitry Safonov <dima@arista.com>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Will Deacon <will@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
arch/arm/include/asm/bug.h | 3 ++-
arch/arm/include/asm/traps.h | 3 ++-
arch/arm/kernel/traps.c | 9 +++++----
arch/arm/kernel/unwind.c | 2 +-
arch/arm/lib/backtrace-clang.S | 9 +++++++--
arch/arm/lib/backtrace.S | 14 ++++++++++----
6 files changed, 27 insertions(+), 13 deletions(-)
--- a/arch/arm/include/asm/bug.h~arm-asm-add-loglvl-to-c_backtrace
+++ a/arch/arm/include/asm/bug.h
@@ -82,7 +82,8 @@ void hook_ifault_code(int nr, int (*fn)(
struct pt_regs *),
int sig, int code, const char *name);
-extern asmlinkage void c_backtrace(unsigned long fp, int pmode);
+extern asmlinkage void c_backtrace(unsigned long fp, int pmode,
+ const char *loglvl);
struct mm_struct;
void show_pte(const char *lvl, struct mm_struct *mm, unsigned long addr);
--- a/arch/arm/include/asm/traps.h~arm-asm-add-loglvl-to-c_backtrace
+++ a/arch/arm/include/asm/traps.h
@@ -29,7 +29,8 @@ static inline int __in_irqentry_text(uns
}
extern void __init early_trap_init(void *);
-extern void dump_backtrace_entry(unsigned long where, unsigned long from, unsigned long frame);
+extern void dump_backtrace_entry(unsigned long where, unsigned long from,
+ unsigned long frame, const char *loglvl);
extern void ptrace_break(struct pt_regs *regs);
extern void *vectors_page;
--- a/arch/arm/kernel/traps.c~arm-asm-add-loglvl-to-c_backtrace
+++ a/arch/arm/kernel/traps.c
@@ -62,7 +62,8 @@ __setup("user_debug=", user_debug_setup)
static void dump_mem(const char *, const char *, unsigned long, unsigned long);
-void dump_backtrace_entry(unsigned long where, unsigned long from, unsigned long frame)
+void dump_backtrace_entry(unsigned long where, unsigned long from,
+ unsigned long frame, const char *loglvl)
{
unsigned long end = frame + 4 + sizeof(struct pt_regs);
@@ -76,7 +77,7 @@ void dump_backtrace_entry(unsigned long
dump_mem("", "Exception stack", frame + 4, end);
}
-void dump_backtrace_stm(u32 *stack, u32 instruction)
+void dump_backtrace_stm(u32 *stack, u32 instruction, const char *loglvl)
{
char str[80], *p;
unsigned int x;
@@ -238,7 +239,7 @@ static void dump_backtrace(struct pt_reg
pr_cont("\n");
if (ok)
- c_backtrace(fp, mode);
+ c_backtrace(fp, mode, NULL);
}
#endif
@@ -666,7 +667,7 @@ asmlinkage int arm_syscall(int no, struc
dump_instr("", regs);
if (user_mode(regs)) {
__show_regs(regs);
- c_backtrace(frame_pointer(regs), processor_mode(regs));
+ c_backtrace(frame_pointer(regs), processor_mode(regs), NULL);
}
}
#endif
--- a/arch/arm/kernel/unwind.c~arm-asm-add-loglvl-to-c_backtrace
+++ a/arch/arm/kernel/unwind.c
@@ -493,7 +493,7 @@ void unwind_backtrace(struct pt_regs *re
urc = unwind_frame(&frame);
if (urc < 0)
break;
- dump_backtrace_entry(where, frame.pc, frame.sp - 4);
+ dump_backtrace_entry(where, frame.pc, frame.sp - 4, NULL);
}
}
--- a/arch/arm/lib/backtrace-clang.S~arm-asm-add-loglvl-to-c_backtrace
+++ a/arch/arm/lib/backtrace-clang.S
@@ -17,6 +17,7 @@
#define sv_pc r6
#define mask r7
#define sv_lr r8
+#define loglvl r9
ENTRY(c_backtrace)
@@ -99,6 +100,7 @@ ENDPROC(c_backtrace)
@ to ensure 8 byte alignment
movs frame, r0 @ if frame pointer is zero
beq no_frame @ we have no stack frames
+ mov loglvl, r2
tst r1, #0x10 @ 26 or 32-bit mode?
moveq mask, #0xfc000003
movne mask, #0 @ mask for 32-bit
@@ -167,6 +169,7 @@ finished_setup:
mov r1, sv_lr
mov r2, frame
bic r1, r1, mask @ mask PC/LR for the mode
+ mov r3, loglvl
bl dump_backtrace_entry
/*
@@ -183,6 +186,7 @@ finished_setup:
ldr r0, [frame] @ locals are stored in
@ the preceding frame
subeq r0, r0, #4
+ mov r2, loglvl
bleq dump_backtrace_stm @ dump saved registers
/*
@@ -196,7 +200,8 @@ finished_setup:
bhi for_each_frame
1006: adr r0, .Lbad
- mov r1, frame
+ mov r1, loglvl
+ mov r2, frame
bl printk
no_frame: ldmfd sp!, {r4 - r9, fp, pc}
ENDPROC(c_backtrace)
@@ -209,7 +214,7 @@ ENDPROC(c_backtrace)
.long 1005b, 1006b
.popsection
-.Lbad: .asciz "Backtrace aborted due to bad frame pointer <%p>\n"
+.Lbad: .asciz "%sBacktrace aborted due to bad frame pointer <%p>\n"
.align
.Lopcode: .word 0xe92d4800 >> 11 @ stmfd sp!, {... fp, lr}
.word 0x0b000000 @ bl if these bits are set
--- a/arch/arm/lib/backtrace.S~arm-asm-add-loglvl-to-c_backtrace
+++ a/arch/arm/lib/backtrace.S
@@ -18,6 +18,7 @@
#define sv_pc r6
#define mask r7
#define offset r8
+#define loglvl r9
ENTRY(c_backtrace)
@@ -25,9 +26,10 @@ ENTRY(c_backtrace)
ret lr
ENDPROC(c_backtrace)
#else
- stmfd sp!, {r4 - r8, lr} @ Save an extra register so we have a location...
+ stmfd sp!, {r4 - r9, lr} @ Save an extra register so we have a location...
movs frame, r0 @ if frame pointer is zero
beq no_frame @ we have no stack frames
+ mov loglvl, r2
tst r1, #0x10 @ 26 or 32-bit mode?
ARM( moveq mask, #0xfc000003 )
@@ -73,6 +75,7 @@ for_each_frame: tst frame, mask @ Check
ldr r1, [frame, #-4] @ get saved lr
mov r2, frame
bic r1, r1, mask @ mask PC/LR for the mode
+ mov r3, loglvl
bl dump_backtrace_entry
ldr r1, [sv_pc, #-4] @ if stmfd sp!, {args} exists,
@@ -80,12 +83,14 @@ for_each_frame: tst frame, mask @ Check
teq r3, r1, lsr #11
ldreq r0, [frame, #-8] @ get sp
subeq r0, r0, #4 @ point at the last arg
+ mov r2, loglvl
bleq dump_backtrace_stm @ dump saved registers
1004: ldr r1, [sv_pc, #0] @ if stmfd sp!, {..., fp, ip, lr, pc}
ldr r3, .Ldsi @ instruction exists,
teq r3, r1, lsr #11
subeq r0, frame, #16
+ mov r2, loglvl
bleq dump_backtrace_stm @ dump saved registers
teq sv_fp, #0 @ zero saved fp means
@@ -96,9 +101,10 @@ for_each_frame: tst frame, mask @ Check
bhi for_each_frame
1006: adr r0, .Lbad
- mov r1, frame
+ mov r1, loglvl
+ mov r2, frame
bl printk
-no_frame: ldmfd sp!, {r4 - r8, pc}
+no_frame: ldmfd sp!, {r4 - r9, pc}
ENDPROC(c_backtrace)
.pushsection __ex_table,"a"
@@ -109,7 +115,7 @@ ENDPROC(c_backtrace)
.long 1004b, 1006b
.popsection
-.Lbad: .asciz "Backtrace aborted due to bad frame pointer <%p>\n"
+.Lbad: .asciz "%sBacktrace aborted due to bad frame pointer <%p>\n"
.align
.Ldsi: .word 0xe92dd800 >> 11 @ stmfd sp!, {... fp, ip, lr, pc}
.word 0xe92d0000 >> 11 @ stmfd sp!, {}
_
next prev parent reply other threads:[~2020-06-09 4:30 UTC|newest]
Thread overview: 127+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-09 4:29 incoming Andrew Morton
2020-06-09 4:29 ` [patch 01/93] kallsyms/printk: add loglvl to print_ip_sym() Andrew Morton
2020-06-09 4:29 ` Andrew Morton
2020-06-09 4:30 ` [patch 02/93] alpha: add show_stack_loglvl() Andrew Morton
2020-06-09 4:30 ` [patch 03/93] arc: " Andrew Morton
2020-06-09 4:30 ` Andrew Morton [this message]
2020-06-09 4:30 ` [patch 05/93] arm: add loglvl to unwind_backtrace() Andrew Morton
2020-06-09 4:30 ` [patch 06/93] arm: add loglvl to dump_backtrace() Andrew Morton
2020-06-09 4:30 ` [patch 07/93] arm: wire up dump_backtrace_{entry,stm} Andrew Morton
2020-06-09 4:30 ` [patch 08/93] arm: add show_stack_loglvl() Andrew Morton
2020-06-09 4:30 ` [patch 09/93] arm64: add loglvl to dump_backtrace() Andrew Morton
2020-06-09 4:30 ` [patch 10/93] arm64: add show_stack_loglvl() Andrew Morton
2020-06-09 4:30 ` [patch 11/93] c6x: " Andrew Morton
2020-06-09 4:30 ` [patch 12/93] csky: " Andrew Morton
2020-06-09 4:30 ` [patch 13/93] h8300: " Andrew Morton
2020-06-09 4:30 ` [patch 14/93] hexagon: " Andrew Morton
2020-06-09 4:30 ` [patch 15/93] ia64: pass log level as arg into ia64_do_show_stack() Andrew Morton
2020-06-09 4:30 ` [patch 16/93] ia64: add show_stack_loglvl() Andrew Morton
2020-06-09 4:30 ` [patch 17/93] m68k: " Andrew Morton
2020-06-09 4:30 ` [patch 18/93] microblaze: add loglvl to microblaze_unwind_inner() Andrew Morton
2020-06-09 4:30 ` [patch 19/93] microblaze: add loglvl to microblaze_unwind() Andrew Morton
2020-06-09 4:30 ` Andrew Morton
2020-06-09 4:30 ` [patch 20/93] microblaze: add show_stack_loglvl() Andrew Morton
2020-06-09 4:30 ` [patch 21/93] mips: " Andrew Morton
2020-06-09 4:31 ` [patch 22/93] nds32: " Andrew Morton
2020-06-09 4:31 ` [patch 23/93] nios2: " Andrew Morton
2020-06-09 4:31 ` [patch 24/93] openrisc: " Andrew Morton
2020-06-09 4:31 ` [patch 25/93] parisc: " Andrew Morton
2020-06-09 4:31 ` [patch 26/93] powerpc: " Andrew Morton
2020-06-09 4:31 ` [patch 27/93] riscv: " Andrew Morton
2020-06-09 4:31 ` [patch 28/93] s390: " Andrew Morton
2020-06-09 4:31 ` [patch 29/93] sh: add loglvl to dump_mem() Andrew Morton
2020-06-09 4:31 ` [patch 30/93] sh: remove needless printk() Andrew Morton
2020-06-09 4:31 ` [patch 31/93] sh: add loglvl to printk_address() Andrew Morton
2020-06-09 4:31 ` [patch 32/93] sh: add loglvl to show_trace() Andrew Morton
2020-06-09 4:31 ` [patch 33/93] sh: add show_stack_loglvl() Andrew Morton
2020-06-09 4:31 ` [patch 34/93] sparc: " Andrew Morton
2020-06-09 4:31 ` [patch 35/93] um/sysrq: remove needless variable sp Andrew Morton
2020-06-09 4:31 ` [patch 36/93] um: add show_stack_loglvl() Andrew Morton
2020-06-09 4:31 ` [patch 37/93] unicore32: remove unused pmode argument in c_backtrace() Andrew Morton
2020-06-09 4:31 ` [patch 38/93] unicore32: add loglvl to c_backtrace() Andrew Morton
2020-06-09 4:31 ` [patch 39/93] unicore32: add show_stack_loglvl() Andrew Morton
2020-06-09 4:31 ` [patch 40/93] x86: add missing const qualifiers for log_lvl Andrew Morton
2020-06-09 4:32 ` [patch 41/93] x86: add show_stack_loglvl() Andrew Morton
2020-06-09 4:32 ` [patch 42/93] xtensa: add loglvl to show_trace() Andrew Morton
2020-06-09 4:32 ` [patch 43/93] xtensa: add show_stack_loglvl() Andrew Morton
2020-06-09 4:32 ` [patch 44/93] sysrq: use show_stack_loglvl() Andrew Morton
2020-06-09 4:32 ` [patch 45/93] x86/amd_gart: print stacktrace for a leak with KERN_ERR Andrew Morton
2020-06-09 4:32 ` [patch 46/93] power: use show_stack_loglvl() Andrew Morton
2020-06-09 4:32 ` [patch 47/93] kdb: don't play with console_loglevel Andrew Morton
2020-06-09 4:32 ` Andrew Morton
2020-06-09 4:32 ` [patch 48/93] sched: print stack trace with KERN_INFO Andrew Morton
2020-06-09 4:32 ` [patch 49/93] kernel: use show_stack_loglvl() Andrew Morton
2020-06-09 4:32 ` [patch 50/93] kernel: rename show_stack_loglvl() => show_stack() Andrew Morton
2020-06-09 4:32 ` [patch 51/93] mm: don't include asm/pgtable.h if linux/mm.h is already included Andrew Morton
2020-06-09 4:32 ` Andrew Morton
2020-06-09 4:32 ` [patch 52/93] mm: introduce include/linux/pgtable.h Andrew Morton
2020-06-09 4:32 ` Andrew Morton
2020-06-09 4:32 ` [patch 53/93] mm: reorder includes after introduction of linux/pgtable.h Andrew Morton
2020-06-09 4:32 ` Andrew Morton
2020-06-09 4:32 ` [patch 54/93] csky: replace definitions of __pXd_offset() with pXd_index() Andrew Morton
2020-06-09 4:32 ` Andrew Morton
2020-06-09 4:32 ` [patch 55/93] m68k/mm/motorola: move comment about page table allocation funcitons Andrew Morton
2020-06-09 4:32 ` Andrew Morton
2020-06-09 4:32 ` [patch 56/93] m68k/mm: move {cache,nocahe}_page() definitions close to their user Andrew Morton
2020-06-09 4:32 ` Andrew Morton
2020-06-09 4:33 ` [patch 57/93] x86/mm: simplify init_trampoline() and surrounding logic Andrew Morton
2020-06-09 4:33 ` Andrew Morton
2020-06-09 4:33 ` [patch 58/93] mm: pgtable: add shortcuts for accessing kernel PMD and PTE Andrew Morton
2020-06-09 4:33 ` Andrew Morton
2020-06-09 4:33 ` [patch 59/93] mm: consolidate pte_index() and pte_offset_*() definitions Andrew Morton
2020-06-09 4:33 ` Andrew Morton
2020-06-09 4:33 ` [patch 60/93] mmap locking API: initial implementation as rwsem wrappers Andrew Morton
2020-06-09 4:33 ` [patch 61/93] MMU notifier: use the new mmap locking API Andrew Morton
2020-06-09 4:33 ` [patch 62/93] DMA reservations: " Andrew Morton
2020-06-09 4:33 ` [patch 63/93] mmap locking API: use coccinelle to convert mmap_sem rwsem call sites Andrew Morton
2020-06-09 4:33 ` [patch 64/93] mmap locking API: convert mmap_sem call sites missed by coccinelle Andrew Morton
2020-06-09 4:33 ` [patch 65/93] mmap locking API: convert nested write lock sites Andrew Morton
2020-06-09 4:33 ` [patch 66/93] mmap locking API: add mmap_read_trylock_non_owner() Andrew Morton
2020-06-09 4:33 ` [patch 67/93] mmap locking API: add MMAP_LOCK_INITIALIZER Andrew Morton
2020-06-09 4:33 ` [patch 68/93] mmap locking API: add mmap_assert_locked() and mmap_assert_write_locked() Andrew Morton
2020-06-09 4:33 ` [patch 69/93] mmap locking API: rename mmap_sem to mmap_lock Andrew Morton
2020-06-09 4:33 ` [patch 70/93] mmap locking API: convert mmap_sem API comments Andrew Morton
2020-06-09 4:33 ` [patch 71/93] mmap locking API: convert mmap_sem comments Andrew Morton
2020-06-09 4:33 ` [patch 72/93] maccess: unexport probe_kernel_write() Andrew Morton
2020-06-09 4:34 ` [patch 73/93] maccess: remove various unused weak aliases Andrew Morton
2020-06-09 4:34 ` Andrew Morton
2020-06-09 4:34 ` [patch 74/93] maccess: remove duplicate kerneldoc comments Andrew Morton
2020-06-09 4:34 ` Andrew Morton
2020-06-09 4:34 ` [patch 75/93] maccess: clarify " Andrew Morton
2020-06-09 4:34 ` [patch 76/93] maccess: update the top of file comment Andrew Morton
2020-06-09 4:34 ` [patch 77/93] maccess: rename strncpy_from_unsafe_user to strncpy_from_user_nofault Andrew Morton
2020-06-09 4:34 ` [patch 78/93] maccess: rename strncpy_from_unsafe_strict to strncpy_from_kernel_nofault Andrew Morton
2020-06-09 4:34 ` [patch 79/93] maccess: rename strnlen_unsafe_user to strnlen_user_nofault Andrew Morton
2020-06-09 4:34 ` [patch 80/93] maccess: remove probe_read_common and probe_write_common Andrew Morton
2020-06-09 4:34 ` [patch 81/93] maccess: unify the probe kernel arch hooks Andrew Morton
2020-06-09 4:34 ` [patch 82/93] bpf: factor out a bpf_trace_copy_string helper Andrew Morton
2020-06-09 4:34 ` [patch 83/93] bpf: handle the compat string in bpf_trace_copy_string better Andrew Morton
2020-06-09 4:34 ` [patch 84/93] bpf:bpf_seq_printf(): handle potentially unsafe format string better Andrew Morton
2020-06-09 4:34 ` [patch 85/93] bpf: rework the compat kernel probe handling Andrew Morton
2020-06-09 4:34 ` [patch 86/93] tracing/kprobes: handle mixed kernel/userspace probes better Andrew Morton
2020-06-09 4:34 ` Andrew Morton
2020-06-09 4:34 ` [patch 87/93] maccess: remove strncpy_from_unsafe Andrew Morton
2020-06-09 4:34 ` Andrew Morton
2020-06-09 4:34 ` [patch 88/93] maccess: always use strict semantics for probe_kernel_read Andrew Morton
2020-06-09 4:34 ` [patch 89/93] maccess: move user access routines together Andrew Morton
2020-06-09 4:34 ` [patch 90/93] maccess: allow architectures to provide kernel probing directly Andrew Morton
2020-06-09 4:35 ` [patch 91/93] x86: use non-set_fs based maccess routines Andrew Morton
2020-06-09 18:01 ` Linus Torvalds
2020-06-09 18:06 ` Linus Torvalds
2020-06-10 6:57 ` Christoph Hellwig
2020-06-09 4:35 ` [patch 92/93] maccess: return -ERANGE when probe_kernel_read() fails Andrew Morton
2020-06-09 4:35 ` [patch 93/93] include/linux/cache.h: expand documentation over __read_mostly Andrew Morton
2020-06-17 15:51 ` Christopher Lameter
2020-06-09 4:44 ` + linux-next-rejects.patch added to -mm tree Andrew Morton
2020-06-09 5:34 ` mmotm 2020-06-08-22-33 uploaded Andrew Morton
2020-06-09 5:34 ` Andrew Morton
2020-06-09 5:36 ` mmotm 2020-06-08-22-35 uploaded Andrew Morton
2020-06-09 16:58 ` incoming Linus Torvalds
2020-06-09 22:26 ` + arch-sparc-mm-srmmuc-fix-build.patch added to -mm tree Andrew Morton
2020-06-09 22:49 ` + lib-fix-bitmap_parse-on-64-bit-big-endian-archs-fix.patch " Andrew Morton
2020-06-09 22:53 ` + scripts-spelling-recommend-blocklist-allowlist-instead-of-blacklist-whitelist.patch " Andrew Morton
2020-06-10 3:59 ` [folded-merged] ipc-convert-ipcs_idr-to-xarray-update.patch removed from " Andrew Morton
2020-06-10 3:59 ` [folded-merged] ipc-convert-ipcs_idr-to-xarray-update-fix.patch " Andrew Morton
2020-06-10 4:00 ` [to-be-updated] ipc-convert-ipcs_idr-to-xarray.patch " Andrew Morton
2020-06-10 21:03 ` [to-be-updated] scripts-spelling-recommend-blocklist-allowlist-instead-of-blacklist-whitelist.patch " Andrew Morton
2020-06-10 21:33 ` + arch-powerpc-mm-pgtablec-another-missed-conversion.patch added to " Andrew Morton
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=20200609043007.KcV14EbSN%akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=dima@arista.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux@armlinux.org.uk \
--cc=mm-commits@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=will@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.