From patchwork Mon Mar 16 14:38:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Safonov X-Patchwork-Id: 11440467 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4630B1667 for ; Mon, 16 Mar 2020 14:40:10 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F18C120658 for ; Mon, 16 Mar 2020 14:40:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="P8c/HdZZ"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=arista.com header.i=@arista.com header.b="HUf43cOY" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F18C120658 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=arista.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=cUEHpECFqPi1+G+XmwVsnFnEdnFkBtNHQnX9VJ/+k+U=; b=P8c/HdZZkfASIt +nlt76+Kfc1XZACYdtOWzX7hMocunXeaFp/0e6gi2+CfGjDVzyKvh4eQDqJo8TgWd8dfiS+LyYLd4 EpmTQd3DJiP3MF94GFtzax9bvY59MGDGbU/LMTSU+hBvAUaSWuHt52Cyl4NTWtuElDL5h4X2hHYSI YHkTF5WBACaCoI/uDJ6dobHhMK+Pvl1WvC3yX7yUs6V07WJJpQHDcjXFbKPZ7Ku0UW8ex6p2g5aVG 8Jvj3Oan4+WsIYEOosX1DA/GHK/nIV24ys5IK+YvfPfCYvdyYrjdCvh+b5X9q2eRMnnFfp5I6+aBM E14PfPTc9+rWwnmOajhg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jDquS-0000dk-8d; Mon, 16 Mar 2020 14:40:04 +0000 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jDquP-0000bN-EQ for linux-arm-kernel@lists.infradead.org; Mon, 16 Mar 2020 14:40:03 +0000 Received: by mail-pg1-x541.google.com with SMTP id u12so9863330pgb.10 for ; Mon, 16 Mar 2020 07:40:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arista.com; s=googlenew; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WRycM3kvderYb9CwKZ+TYqaJ73yGSs7D+hHRot+jXvM=; b=HUf43cOYSl5Ax/fWaclU2KwFUT7Mwg2q8rOdMnZbO0gqt1/k9zjUFcbUU50Scy+R/X Tw+jrhgXncye3ZiyrJwiSk2N4oAeJKe6UCargnOwPyszZfdP44T34vJnHkuPpOQVGDbT W7rBvsVCb8BB8yO7zAuwz3cY5InPNGnmp1OBCU6fDgUj7nF172DR+CXJ7Q/+Emo059Ko KlesoY9hqusjR0Z0KiAjQoHQQu0mxWHaxSYH92FF0UC4vKSqhIbSp0RP78haFToleRlb sk9RtZfFOrrGWNZ6igKDqKw1QFdlqh7k1pKnIMeJoyiCAqwy3tNiy133z3mS926LSXMV v7bQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WRycM3kvderYb9CwKZ+TYqaJ73yGSs7D+hHRot+jXvM=; b=VZFCT3ToXg0gE8wNuxMLO6Fil0tm8iZzIOIKzKmYm09AbaYjHOKI8KLNP4tpF5/6M0 l+W1z43alBBn7Xgrt5wuyLym8SB82GyaHI/6ZGuxTeOH00RTg9zsyGDd4G4jk5+8ajBh /vG2VMJwcu8XBK+89Ujk04Mv/UlV5urIstS8y7BWMEo++TzOYue9qdPSSxmwDlsOXAl7 Uu6WsmORtHYDiL/+5Ckahu0I+HTpvn3UdKH93XXBJC4xcLoyXajKWl017z9Hs1R4R4wZ zjyxXwMMtyYJ5keIkplGSY6Jlh4ojaTbSO22PVRDZsGkMKwBopZXkaegxv8Rrr6BwADy qckQ== X-Gm-Message-State: ANhLgQ1+3hO8C5OIxUZNea93Z8n0dS8WuZoyup15iYECMs4AmA7Bv2v6 Fdmou4SmzoOc4csq31zMnLpSPQ== X-Google-Smtp-Source: ADFU+vvNGndmDLdbuAl2FMjLfkFtwyASEmyqaj7ZVt3NTnGfj55nVCmperlLspPTEWNVPpNkQ+pljg== X-Received: by 2002:a63:1862:: with SMTP id 34mr164092pgy.191.1584369600556; Mon, 16 Mar 2020 07:40:00 -0700 (PDT) Received: from Mindolluin.aristanetworks.com ([2a02:8084:e84:2480:228:f8ff:fe6f:83a8]) by smtp.gmail.com with ESMTPSA id i2sm81524pjs.21.2020.03.16.07.39.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Mar 2020 07:39:59 -0700 (PDT) From: Dmitry Safonov To: linux-kernel@vger.kernel.org Subject: [PATCHv2 04/50] arm/asm: Add loglvl to c_backtrace() Date: Mon, 16 Mar 2020 14:38:30 +0000 Message-Id: <20200316143916.195608-5-dima@arista.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200316143916.195608-1-dima@arista.com> References: <20200316143916.195608-1-dima@arista.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200316_074001_484977_3F2B74F8 X-CRM114-Status: GOOD ( 16.74 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:541 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Petr Mladek , Dmitry Safonov , Tetsuo Handa , Greg Kroah-Hartman , Dmitry Safonov <0x7f454c46@gmail.com>, Russell King , Steven Rostedt , Sergey Senozhatsky , clang-built-linux@googlegroups.com, Jiri Slaby , Andrew Morton , Will Deacon , Ingo Molnar , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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(). Cc: Russell King Cc: Will Deacon Cc: linux-arm-kernel@lists.infradead.org Cc: clang-built-linux@googlegroups.com [1]: https://lore.kernel.org/lkml/20190528002412.1625-1-dima@arista.com/T/#u Signed-off-by: Dmitry Safonov --- 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(-) diff --git a/arch/arm/include/asm/bug.h b/arch/arm/include/asm/bug.h index deef4d0cb3b5..673c7dd75ab9 100644 --- a/arch/arm/include/asm/bug.h +++ b/arch/arm/include/asm/bug.h @@ -82,7 +82,8 @@ void hook_ifault_code(int nr, int (*fn)(unsigned long, unsigned int, 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); diff --git a/arch/arm/include/asm/traps.h b/arch/arm/include/asm/traps.h index 172b08ff3760..987fefb0a4db 100644 --- a/arch/arm/include/asm/traps.h +++ b/arch/arm/include/asm/traps.h @@ -29,7 +29,8 @@ static inline int __in_irqentry_text(unsigned long ptr) } 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; diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c index 1e70e7227f0f..2030611f22b8 100644 --- a/arch/arm/kernel/traps.c +++ b/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 where, unsigned long from, 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_regs *regs, struct task_struct *tsk) 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, struct pt_regs *regs) 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 diff --git a/arch/arm/kernel/unwind.c b/arch/arm/kernel/unwind.c index 4574e6aea0a5..0a65005e10f0 100644 --- a/arch/arm/kernel/unwind.c +++ b/arch/arm/kernel/unwind.c @@ -493,7 +493,7 @@ void unwind_backtrace(struct pt_regs *regs, struct task_struct *tsk) 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); } } diff --git a/arch/arm/lib/backtrace-clang.S b/arch/arm/lib/backtrace-clang.S index 2ff375144b55..6174c45f53a5 100644 --- a/arch/arm/lib/backtrace-clang.S +++ b/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 diff --git a/arch/arm/lib/backtrace.S b/arch/arm/lib/backtrace.S index 582925238d65..872f658638d9 100644 --- a/arch/arm/lib/backtrace.S +++ b/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 for address exceptions 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 for address exceptions 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 for address exceptions 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!, {} From patchwork Mon Mar 16 14:38:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Safonov X-Patchwork-Id: 11440469 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E81871667 for ; Mon, 16 Mar 2020 14:40:28 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6057920674 for ; Mon, 16 Mar 2020 14:40:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ZamDegif"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=arista.com header.i=@arista.com header.b="Cc7unAu9" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6057920674 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=arista.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=v7ELNQKauneBf36hX1/iFyGJ8yeSiPy33ZgJc/QmbgE=; b=ZamDegifkpF8xt 7LBykU4rLueg65cFDSHadCZnTJJkWuNorhYrqm/2UonWe0YDfiOR7mnYf4g3CYh6zSypYC6M11AKM a0mTDjX818mBV8IG460/iqebP0TS08X7qqswx8CzgxdrnJ3AxDzeQpHr36Yaif9vUX2OqbAMoSGtU CQHGuMbR8g9ir7z1XnzqS+QF8/yx6tqWzy5UxvI+RqgB/qK7+nC6UvW6zDr0wehm6JL9biLMcUas0 fCI5200wTiVhL0gCTE01VzeSTQyURK+gmzNNuqBVUYfVXbLB/XrYC3Ubtdt8LnmeAaXJXZqB2upLT Yq1ij4iEkVLCg/r7b8zg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jDquj-00021B-Da; Mon, 16 Mar 2020 14:40:21 +0000 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jDquU-0000iZ-Fx for linux-arm-kernel@lists.infradead.org; Mon, 16 Mar 2020 14:40:08 +0000 Received: by mail-pg1-x541.google.com with SMTP id m5so9887253pgg.0 for ; Mon, 16 Mar 2020 07:40:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arista.com; s=googlenew; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Hoy3hKjGTKbXFgtJqdy0XVVKGayseSyt+olpDXinT2U=; b=Cc7unAu9Anwjtat9ViQI6hUMfTEEr1QN/Dk29hmYCfqmNwxS4G5mt3+ZknLVZwK9lJ Fn7kw+SwhGfcAb7zqmUQcmZD24weZEW0zbW/DoklcrkKTFtFerRcTWx5A8gRnLnpMTlT Wsgt2fqKgd4ZvGX/uMiX69EjDzE69BCoA6X/qVbPaLAgNRi7in7XhdgI3scFNC2beP6a y3OKV8DrhUnZfZRR77Df4TYIbFLZRbOEh6l9JBjHbqD6Ga+TjalZKArVThDDH+k/n36z Jnbp92mVIIMKt17zJduWtYAbxpeiRK0bjtQdu+50/oPlAiolhCUsCTWJmmAkQI3LOWpb olDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Hoy3hKjGTKbXFgtJqdy0XVVKGayseSyt+olpDXinT2U=; b=tFCcHGl5YOjoyXe+1t1sCSycChYBiFYak/IxuLqmHlE7RbIrsbsGLGfJ367UiYr+pU mLgoCCXU6JStfhH+T6J94WhBsVAC/+brxlWIax6ZD8EP9wezyY3xd7UJ4VWZI3ZgSJ3t IKQjMCf2wgB65d25nuCSJjB/zc2QYMdQqOvyyWZOh99sXFmqEM8d8zytPS448alN9dYo TcC/eA6xBZgngZJuCOIXP5Rn6afEGlIqPhtb0MvnKq0Tm0QhNwAM8e4Ur/1UUSat3vxO ySPsiU6FtAf+GsooMMF9IwXX2u+Z2z7k36k4TpFLllM7z5mNNN08FmYto4hIgW355Z+I mpBw== X-Gm-Message-State: ANhLgQ1EYoBU9/hqiK7xDvaDp4SxZoQxJw2Vk4ljbouIlGBlOVloqUwk 32Vo39suVJk31zXKCKpM065tlg== X-Google-Smtp-Source: ADFU+vsmdBTG8h+I0+57PwK8SCtkglhmlOG2yqWD9E6W5HThFUi8tikgPfVL5i1Ky7xL1/ihQ/QiLQ== X-Received: by 2002:a63:330f:: with SMTP id z15mr215975pgz.104.1584369605413; Mon, 16 Mar 2020 07:40:05 -0700 (PDT) Received: from Mindolluin.aristanetworks.com ([2a02:8084:e84:2480:228:f8ff:fe6f:83a8]) by smtp.gmail.com with ESMTPSA id i2sm81524pjs.21.2020.03.16.07.40.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Mar 2020 07:40:04 -0700 (PDT) From: Dmitry Safonov To: linux-kernel@vger.kernel.org Subject: [PATCHv2 05/50] arm: Add loglvl to unwind_backtrace() Date: Mon, 16 Mar 2020 14:38:31 +0000 Message-Id: <20200316143916.195608-6-dima@arista.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200316143916.195608-1-dima@arista.com> References: <20200316143916.195608-1-dima@arista.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200316_074006_602352_1809F709 X-CRM114-Status: GOOD ( 14.38 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:541 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Petr Mladek , Dmitry Safonov , Tetsuo Handa , Greg Kroah-Hartman , Dmitry Safonov <0x7f454c46@gmail.com>, Russell King , Steven Rostedt , Sergey Senozhatsky , clang-built-linux@googlegroups.com, Jiri Slaby , Andrew Morton , Will Deacon , Ingo Molnar , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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 unwind_backtrace() as a preparation for introducing show_stack_loglvl(). As a good side-effect arm_syscall() is now printing errors with the same log level as the backtrace. Cc: Russell King Cc: Will Deacon Cc: linux-arm-kernel@lists.infradead.org Cc: clang-built-linux@googlegroups.com [1]: https://lore.kernel.org/lkml/20190528002412.1625-1-dima@arista.com/T/#u Signed-off-by: Dmitry Safonov --- arch/arm/include/asm/unwind.h | 3 ++- arch/arm/kernel/traps.c | 6 +++--- arch/arm/kernel/unwind.c | 5 +++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/arch/arm/include/asm/unwind.h b/arch/arm/include/asm/unwind.h index 6e282c33126b..0f8a3439902d 100644 --- a/arch/arm/include/asm/unwind.h +++ b/arch/arm/include/asm/unwind.h @@ -36,7 +36,8 @@ extern struct unwind_table *unwind_table_add(unsigned long start, unsigned long text_addr, unsigned long text_size); extern void unwind_table_del(struct unwind_table *tab); -extern void unwind_backtrace(struct pt_regs *regs, struct task_struct *tsk); +extern void unwind_backtrace(struct pt_regs *regs, struct task_struct *tsk, + const char *loglvl); #endif /* !__ASSEMBLY__ */ diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c index 2030611f22b8..685e17c2e275 100644 --- a/arch/arm/kernel/traps.c +++ b/arch/arm/kernel/traps.c @@ -204,7 +204,7 @@ static void dump_instr(const char *lvl, struct pt_regs *regs) #ifdef CONFIG_ARM_UNWIND static inline void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk) { - unwind_backtrace(regs, tsk); + unwind_backtrace(regs, tsk, KERN_DEFAULT); } #else static void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk) @@ -664,10 +664,10 @@ asmlinkage int arm_syscall(int no, struct pt_regs *regs) if (user_debug & UDBG_SYSCALL) { pr_err("[%d] %s: arm syscall %d\n", task_pid_nr(current), current->comm, no); - dump_instr("", regs); + dump_instr(KERN_ERR, regs); if (user_mode(regs)) { __show_regs(regs); - c_backtrace(frame_pointer(regs), processor_mode(regs), NULL); + c_backtrace(frame_pointer(regs), processor_mode(regs), KERN_ERR); } } #endif diff --git a/arch/arm/kernel/unwind.c b/arch/arm/kernel/unwind.c index 0a65005e10f0..9222649ebe0f 100644 --- a/arch/arm/kernel/unwind.c +++ b/arch/arm/kernel/unwind.c @@ -455,7 +455,8 @@ int unwind_frame(struct stackframe *frame) return URC_OK; } -void unwind_backtrace(struct pt_regs *regs, struct task_struct *tsk) +void unwind_backtrace(struct pt_regs *regs, struct task_struct *tsk, + const char *loglvl) { struct stackframe frame; @@ -493,7 +494,7 @@ void unwind_backtrace(struct pt_regs *regs, struct task_struct *tsk) urc = unwind_frame(&frame); if (urc < 0) break; - dump_backtrace_entry(where, frame.pc, frame.sp - 4, NULL); + dump_backtrace_entry(where, frame.pc, frame.sp - 4, loglvl); } } From patchwork Mon Mar 16 14:38:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Safonov X-Patchwork-Id: 11440471 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 64B9D6CA for ; Mon, 16 Mar 2020 14:40:59 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3F8542051A for ; Mon, 16 Mar 2020 14:40:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="akqUtbM6"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=arista.com header.i=@arista.com header.b="Jk9g1oUN" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3F8542051A Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=arista.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=pZlfyW2T7oQ+2V3B7W5jpKpf3B/rGiNDttPUTmZAVt4=; b=akqUtbM6Zp+DyX N3lr+HYWgOEjsEpqRgqQLF9VIYHNIKM4VzBRGCBpBJJji71A2jd5RdwnTtPWQPHuPXpdWbmntclZK X+M77ehW+Shst1257lArKr3T/yIlPaclpcMOgKNw/40hSSFcStCTdbrbt8v4JFPWfPejAY4NHuZBH FjTGflZlGw68/qX6Ep1Yvc2WXt67QPcpyZNkfHe+aJ96KymQmAhOWu3S3oAveFjmJVdejtSBnVU04 Uygs2KBtyMkaLNlbfwOiw+Q26LVIQKY1hu1+4DvkCzxe8zCq9e39YUKmeElETghcMY1zpJGVf4Kwf qgmEWUMSfPgTCJ32al8Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jDqvF-0002ZF-60; Mon, 16 Mar 2020 14:40:53 +0000 Received: from mail-pj1-x1041.google.com ([2607:f8b0:4864:20::1041]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jDquY-00019N-P1 for linux-arm-kernel@lists.infradead.org; Mon, 16 Mar 2020 14:40:12 +0000 Received: by mail-pj1-x1041.google.com with SMTP id hg10so4525703pjb.1 for ; Mon, 16 Mar 2020 07:40:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arista.com; s=googlenew; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NTTI3yeeENs2ZgUYcRA67its707iG/GndxpZmZw7i/c=; b=Jk9g1oUNFqnrxDjJjiHsiZmC4IEi4NNiURUYTAbuBjADgpPEe2ER75XEbFXwxLgdzc EFpD7ogpTsYeloXgC70ErIaA94WpDZnQUm3mVWdn+qoLWpQIqdWn/p4RIUMFC2RgKr1S ilBB6T1nv+ru4Qg1whMKn71h3wu12lQBzNSHjJzdwYMWocfPxkp2J+YwTxr7qa5Zmh0Z bltg4MN4hrMmRefnpiBA09URG8ZTpda1kP0IwuEl5YrrPplA0kqlOgKGGxDFTgUR11QH TEkoJ3Xcls/wzi9r1CCQKbmA2JWd/t5lGLasBpMAL2yyuiaJKR2dAPyYWwoGFQUySS/Y FGbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NTTI3yeeENs2ZgUYcRA67its707iG/GndxpZmZw7i/c=; b=bGXk0V3kwypdhLP56xwWAqnN0pUeOyESd2TRCvLe0D5a6i+aEJ/Fw0pPZwkrP4Y9sX /MiIkijk96shja9OyOBu+izWYwqR57xk9lSQLsmklWMiQScVdCULKfjF5Bfl6a72CWJt 7uxmglrCD/8mONVKX4ZWVyT3iE4VfKogiIe2d6XI+gJQFOmHr5k8WzWqTTCCgIxgLJdb 44Y21IjGe6hlojkRPR7bzkEvXehRJgtUnup0A7jF1k0KlgDIYh7XckMyaQH8zsuik+o8 XTgnqDFGRfnuOTw+JjIsh1SPmk+jCO71XouenIm9vJ43MCEntd8rR4/ICrvasKgQiAUD JlGg== X-Gm-Message-State: ANhLgQ0zbDqxpipvTXlhuvacPihph6lUrEiZ8JyVtrIjHKMqdMbDN9FV kxLvP8ai/5rYsSr9fRemFB/jkg== X-Google-Smtp-Source: ADFU+vs61F04BWjvxDCeZwFtjsQYjDIVpWt/23PJlfO2bLlD7Ck7GLB062kqMhXBrKwYN+ji9n4JWg== X-Received: by 2002:a17:902:bccc:: with SMTP id o12mr5824551pls.96.1584369609808; Mon, 16 Mar 2020 07:40:09 -0700 (PDT) Received: from Mindolluin.aristanetworks.com ([2a02:8084:e84:2480:228:f8ff:fe6f:83a8]) by smtp.gmail.com with ESMTPSA id i2sm81524pjs.21.2020.03.16.07.40.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Mar 2020 07:40:09 -0700 (PDT) From: Dmitry Safonov To: linux-kernel@vger.kernel.org Subject: [PATCHv2 06/50] arm: Add loglvl to dump_backtrace() Date: Mon, 16 Mar 2020 14:38:32 +0000 Message-Id: <20200316143916.195608-7-dima@arista.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200316143916.195608-1-dima@arista.com> References: <20200316143916.195608-1-dima@arista.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200316_074011_036174_A051EA1F X-CRM114-Status: GOOD ( 13.86 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:1041 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Petr Mladek , Dmitry Safonov , Tetsuo Handa , Greg Kroah-Hartman , Dmitry Safonov <0x7f454c46@gmail.com>, Russell King , Steven Rostedt , Sergey Senozhatsky , clang-built-linux@googlegroups.com, Jiri Slaby , Andrew Morton , Will Deacon , Ingo Molnar , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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 dump_backtrace() as a preparation for introducing show_stack_loglvl(). As a good side-effect __die() now prints not only "Stack:" header with KERN_EMERG, but the backtrace itself. Cc: Russell King Cc: Will Deacon Cc: linux-arm-kernel@lists.infradead.org Cc: clang-built-linux@googlegroups.com [1]: https://lore.kernel.org/lkml/20190528002412.1625-1-dima@arista.com/T/#u Signed-off-by: Dmitry Safonov --- arch/arm/kernel/traps.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c index 685e17c2e275..0f09ace18e6c 100644 --- a/arch/arm/kernel/traps.c +++ b/arch/arm/kernel/traps.c @@ -202,17 +202,19 @@ static void dump_instr(const char *lvl, struct pt_regs *regs) } #ifdef CONFIG_ARM_UNWIND -static inline void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk) +static inline void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk, + const char *loglvl) { - unwind_backtrace(regs, tsk, KERN_DEFAULT); + unwind_backtrace(regs, tsk, loglvl); } #else -static void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk) +static void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk, + const char *loglvl) { unsigned int fp, mode; int ok = 1; - printk("Backtrace: "); + printk("%sBacktrace: ", loglvl); if (!tsk) tsk = current; @@ -239,13 +241,13 @@ static void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk) pr_cont("\n"); if (ok) - c_backtrace(fp, mode, NULL); + c_backtrace(fp, mode, loglvl); } #endif void show_stack(struct task_struct *tsk, unsigned long *sp) { - dump_backtrace(NULL, tsk); + dump_backtrace(NULL, tsk, KERN_DEFAULT); barrier(); } @@ -289,7 +291,7 @@ static int __die(const char *str, int err, struct pt_regs *regs) if (!user_mode(regs) || in_interrupt()) { dump_mem(KERN_EMERG, "Stack: ", regs->ARM_sp, THREAD_SIZE + (unsigned long)task_stack_page(tsk)); - dump_backtrace(regs, tsk); + dump_backtrace(regs, tsk, KERN_EMERG); dump_instr(KERN_EMERG, regs); } From patchwork Mon Mar 16 14:38:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Safonov X-Patchwork-Id: 11440475 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 58DF11667 for ; Mon, 16 Mar 2020 14:41:09 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2C3FC20674 for ; Mon, 16 Mar 2020 14:41:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="PaIKIg2T"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=arista.com header.i=@arista.com header.b="UffnQYQr" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2C3FC20674 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=arista.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=TSCkLvwruYdi+xEmPBkQQspswYh5/hweBEaRJQuS3EQ=; b=PaIKIg2Th7opey aM196t4cHMNGWoqCLVuFcCwejQso7ieipqzUxU/DP79oqGkNsX95dpY+OwQcSGCnisne56Jcb6uKr ZJuSDyma+oZiqOakBHtFIMr6aTmjwaE0m7VFECFvjNSOB+hFgLFV2iwj80fA+WcATqr09EzQ17O0+ mahD7uQv9cIXgAAQGmJVDg1r2mt9/Lj/og5jlwZshMGsK0Yvvt0LKDBl5TAVVfACgY0tkIg9cEhex PYEPed/pNovzJHA2RW3jFpyQ9qJg2jiNww2dxz3YhHhY0AfaE9uJF6rACvlkGd2xuxhP3cvHv1Hub J/4MWjwRzUX19WP8HZgg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jDqvS-0002mA-9I; Mon, 16 Mar 2020 14:41:06 +0000 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jDqud-0001ff-HK for linux-arm-kernel@lists.infradead.org; Mon, 16 Mar 2020 14:40:17 +0000 Received: by mail-pl1-x642.google.com with SMTP id t16so1078772plr.8 for ; Mon, 16 Mar 2020 07:40:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arista.com; s=googlenew; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=x/gCbAp+H9Fc7JriqMdSSF6E8ktWavqK5+A0swN3ZDc=; b=UffnQYQrX4Gsz0le1JAUkNrEskhQYyMx9aVo6pv/sYzRbgsZ9Ie846Y+l+3ziU4DdR 3CjCVS5kj+n3OdYgO4/HMMJIpRVeB/J8l1u+khYQcffFkGJy+FMZwW2yEjCJN/L84LiA MHrkzGrtCj9mIrHJAhMGwtJnD1aZyQb1Bi6etSTY258uU/ugk25xkkG/W29Dq+iTh6Dl VkFSfrGBRRzkn4HEBoD5ktZJd0jABrCLp0yAD7j0Ig19xr+bvMve/rE6NL+0AxPQmxOc PBKBcOfuC3RhsqLSe5kwzjpZQnGXTfzxONLW634aqtTK/ZGy2gcwaaEYFOcQz/zw4MVL 6LOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=x/gCbAp+H9Fc7JriqMdSSF6E8ktWavqK5+A0swN3ZDc=; b=mH+rNHmp0pw4wqEM409GqrFG8Xqjfo9NE8CCxc+EGuryniHT3X2ioYeZf/gyobBP4y Sh4jGWjmGWUOO+Mlez+p+vyo6tdmud7MzfHJsht6+ahTl4ecXJQTbwcOO6QwCeNQoUEb R8gSyBndSsHn/lRrELvPTt+my50vWbf4mv9pokYFuOdTODy1uNqXNWpx4UgiAO+MbOBb piRXdZIp8T4BiNaovCEfbZgJRXB+DA1A9p+Fy7h54DhKnLhBufRDvZKFPsNSMOOmTg2P W5KT4sUKUoxdsqtwyBR4wEd4G/Jrk7k5ncoyY2X+MK80l15GrnQXzkGZdIY2wBcsaeqH pQcA== X-Gm-Message-State: ANhLgQ0e9H16cwcm/c5lb6iwfdhz0dnORe+yAZArgDlc5UWZ/8DP7pEK ezSyta4hFe3oZdSKZfN3yxwNbw== X-Google-Smtp-Source: ADFU+vuP+9D4s7GPz8or+QCMJaQtRjQgHTDwkRUFWwBShfCJpkUaUxI2cOrbtLoyolvwdTEEMYe9tA== X-Received: by 2002:a17:90a:36c7:: with SMTP id t65mr25183358pjb.182.1584369614252; Mon, 16 Mar 2020 07:40:14 -0700 (PDT) Received: from Mindolluin.aristanetworks.com ([2a02:8084:e84:2480:228:f8ff:fe6f:83a8]) by smtp.gmail.com with ESMTPSA id i2sm81524pjs.21.2020.03.16.07.40.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Mar 2020 07:40:13 -0700 (PDT) From: Dmitry Safonov To: linux-kernel@vger.kernel.org Subject: [PATCHv2 07/50] arm: Wire up dump_backtrace_{entry,stm} Date: Mon, 16 Mar 2020 14:38:33 +0000 Message-Id: <20200316143916.195608-8-dima@arista.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200316143916.195608-1-dima@arista.com> References: <20200316143916.195608-1-dima@arista.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200316_074015_685880_F6B749D9 X-CRM114-Status: GOOD ( 12.93 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:642 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Petr Mladek , Dmitry Safonov , Tetsuo Handa , Greg Kroah-Hartman , Dmitry Safonov <0x7f454c46@gmail.com>, Russell King , Steven Rostedt , Sergey Senozhatsky , clang-built-linux@googlegroups.com, Jiri Slaby , Andrew Morton , Will Deacon , Ingo Molnar , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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. Now that c_backtrace() always emits correct loglvl, use it for printing. Cc: Russell King Cc: Will Deacon Cc: linux-arm-kernel@lists.infradead.org Cc: clang-built-linux@googlegroups.com [1]: https://lore.kernel.org/lkml/20190528002412.1625-1-dima@arista.com/T/#u Signed-off-by: Dmitry Safonov --- arch/arm/kernel/traps.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c index 0f09ace18e6c..e1be6c85327c 100644 --- a/arch/arm/kernel/traps.c +++ b/arch/arm/kernel/traps.c @@ -68,13 +68,15 @@ void dump_backtrace_entry(unsigned long where, unsigned long from, unsigned long end = frame + 4 + sizeof(struct pt_regs); #ifdef CONFIG_KALLSYMS - printk("[<%08lx>] (%ps) from [<%08lx>] (%pS)\n", where, (void *)where, from, (void *)from); + printk("%s[<%08lx>] (%ps) from [<%08lx>] (%pS)\n", + loglvl, where, (void *)where, from, (void *)from); #else - printk("Function entered at [<%08lx>] from [<%08lx>]\n", where, from); + printk("%sFunction entered at [<%08lx>] from [<%08lx>]\n", + loglvl, where, from); #endif if (in_entry_text(from) && end <= ALIGN(frame, THREAD_SIZE)) - dump_mem("", "Exception stack", frame + 4, end); + dump_mem(loglvl, "Exception stack", frame + 4, end); } void dump_backtrace_stm(u32 *stack, u32 instruction, const char *loglvl) @@ -89,12 +91,12 @@ void dump_backtrace_stm(u32 *stack, u32 instruction, const char *loglvl) if (++x == 6) { x = 0; p = str; - printk("%s\n", str); + printk("%s%s\n", loglvl, str); } } } if (p != str) - printk("%s\n", str); + printk("%s%s\n", loglvl, str); } #ifndef CONFIG_ARM_UNWIND From patchwork Mon Mar 16 14:38:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Safonov X-Patchwork-Id: 11440479 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A8E306CA for ; Mon, 16 Mar 2020 14:41:26 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5FB2A20658 for ; Mon, 16 Mar 2020 14:41:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="i+tZool0"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=arista.com header.i=@arista.com header.b="CZszvrzm" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5FB2A20658 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=arista.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ap9Owb/P9Y9zf49473Uo6B/LBvQOA6NhvbJmXbibH2I=; b=i+tZool0u1ex62 8/XYtGcl5u+SxSmtbRuYgfD1JE0fghZTLxVX2Zg/5eUuYDaNhaeLmTzfPyaOob0NlA37+295MILtx r8KAB0LQNBXubuXdh2DPgDY15oiAy5f7FKWYlExztKnerl14PrI6DQAbfi5vrM/WIV60EqnPRJ5ko m6HNs3HGyMsFNtWIKs7RjL2IiHoIGiaJ+dV1rG2i1q29Jp2Eo/Km5KvPCmVzLfQRE2XAXjJ9+My4/ qfJmfEgpIOoIKcZV8uFh2FmrlLrZbKbdOK3tkhIgwd0lMRYjKtrvjbgbXmP5Gnvz9/tIMtKeC6TzI JaNlKv15YHwyZAwd+aQA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jDqvi-00031u-AG; Mon, 16 Mar 2020 14:41:22 +0000 Received: from mail-pj1-x1044.google.com ([2607:f8b0:4864:20::1044]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jDquh-0001zJ-PE for linux-arm-kernel@lists.infradead.org; Mon, 16 Mar 2020 14:40:21 +0000 Received: by mail-pj1-x1044.google.com with SMTP id o23so2702494pjp.0 for ; Mon, 16 Mar 2020 07:40:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arista.com; s=googlenew; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=QHtnMaoK5O9FegkpkkwNmoxCiRNZGD2z9MaeDc0+/xc=; b=CZszvrzmIRvERN2PlRfmNYaxq7wc0KrRfRp+ZUcwArxYqFLQDjiJyKC0N3hjkUHKKz HaU/VFm68qpJWzdHlhTZHI5ax7L23gtlENHvgWiRZmTlFvS6VVKkekfJ+OWUot4LKwAz V1RTs/vDsTw9ZUxE9K8lwEMCNWIWS7T3Giko+Vvy+YsAAnc4tM5wptSLlXVpIYQLe+zs ocnbJoahMUAwCosYsTR1CeARHLJE3nNy26/UAQHvAinQ8kTGLjY/sA6ypsPDk+pshlCi YTjCevn2ykVc4DODRIutQNGktScrUEwI/gcH02xw4H7+Nr7swysCIKXWySAPQdJcZWvI GhrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QHtnMaoK5O9FegkpkkwNmoxCiRNZGD2z9MaeDc0+/xc=; b=NfFQIcKMZCQAV48YmVegUFjlkXA43NcA58VSzY/iuBybRDD8xwe7VTqoZsUxB2LdXv oQfURMRfneWJHnIPl2cIfL3MeMvRk8NKi/MlItZZFtpaG0VlAQLKYBdThn2BKG1WKYd9 VmDWqDfDzCQxtGuHfn7vV6yBuUPX6FGFm1r8zY61MgV5qdMK5tLoBrLMIz6RP6QkWTIP N9I5IRolkBl3yXvZlEZugAe9S/HyIKU3CsPFxFDBK35hsEYn0/LZHMIFgSfAMhuniG+X Q7f50M5m1QSJAabujTQ5xop+2LysbIAOhxmFVh3OTEwl4p9m7yIRdDeZoKVheQhF78I4 gUeA== X-Gm-Message-State: ANhLgQ1i807KSoIfMRO3IIMb/2LP5XeiIW38Ioab3C1y1+rvWx2X/IqB NpNbRtbrUyVABfDqTYGW3rAp9g== X-Google-Smtp-Source: ADFU+vuv0p+9CyDCn7sGloFjTFfHxbeMZbOZDt3pRLhru+RDD2KBw7DzGtWo4ZzXWPme/uj8Q70fIQ== X-Received: by 2002:a17:90a:2a89:: with SMTP id j9mr25550721pjd.64.1584369618925; Mon, 16 Mar 2020 07:40:18 -0700 (PDT) Received: from Mindolluin.aristanetworks.com ([2a02:8084:e84:2480:228:f8ff:fe6f:83a8]) by smtp.gmail.com with ESMTPSA id i2sm81524pjs.21.2020.03.16.07.40.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Mar 2020 07:40:18 -0700 (PDT) From: Dmitry Safonov To: linux-kernel@vger.kernel.org Subject: [PATCHv2 08/50] arm: Add show_stack_loglvl() Date: Mon, 16 Mar 2020 14:38:34 +0000 Message-Id: <20200316143916.195608-9-dima@arista.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200316143916.195608-1-dima@arista.com> References: <20200316143916.195608-1-dima@arista.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200316_074020_007343_1D8DF4B6 X-CRM114-Status: GOOD ( 12.04 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:1044 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Petr Mladek , Dmitry Safonov , Tetsuo Handa , Greg Kroah-Hartman , Dmitry Safonov <0x7f454c46@gmail.com>, Russell King , Steven Rostedt , Sergey Senozhatsky , clang-built-linux@googlegroups.com, Jiri Slaby , Andrew Morton , Will Deacon , Ingo Molnar , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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. Introduce show_stack_loglvl(), that eventually will substitute show_stack(). Cc: Russell King Cc: Will Deacon Cc: linux-arm-kernel@lists.infradead.org Cc: clang-built-linux@googlegroups.com [1]: https://lore.kernel.org/lkml/20190528002412.1625-1-dima@arista.com/T/#u Signed-off-by: Dmitry Safonov --- arch/arm/kernel/traps.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c index e1be6c85327c..00455b5bbf8a 100644 --- a/arch/arm/kernel/traps.c +++ b/arch/arm/kernel/traps.c @@ -247,12 +247,18 @@ static void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk, } #endif -void show_stack(struct task_struct *tsk, unsigned long *sp) +void show_stack_loglvl(struct task_struct *tsk, unsigned long *sp, + const char *loglvl) { - dump_backtrace(NULL, tsk, KERN_DEFAULT); + dump_backtrace(NULL, tsk, loglvl); barrier(); } +void show_stack(struct task_struct *tsk, unsigned long *sp) +{ + show_stack_loglvl(tsk, sp, KERN_DEFAULT); +} + #ifdef CONFIG_PREEMPT #define S_PREEMPT " PREEMPT" #elif defined(CONFIG_PREEMPT_RT) From patchwork Mon Mar 16 14:38:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Safonov X-Patchwork-Id: 11440483 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BC99617E6 for ; Mon, 16 Mar 2020 14:41:46 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 954E62051A for ; Mon, 16 Mar 2020 14:41:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Osu8kl3J"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=arista.com header.i=@arista.com header.b="Gne+q2gY" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 954E62051A Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=arista.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=fbGyscp13f1Q683jPWjLW6rOkK/0jUZciixFpOx7iIY=; b=Osu8kl3JxFXNso 2uUCA2IAaMp6OmzViL81E3ojgAsHE9grWn5EPSNXjjcYmm0zzJhKG8jl5FvEqZk5vk+T5ZNaYXSVd 6xYYak2F09QQK3+DruDJuSir3Aao9EXs89zsSGuLADM+8LoRxgLNp0sjn/molfKdbJObo8qIbQne7 nDzOYpfX6aGPDga8xfsy2bBwb+/lyFt9TULS4tynv3cG6n90j388WGnRB8ooJQGBks13WrTUsXmrm BW0BHiPLlEhzwobnq9Fl2o6UDGV5Nx6ZtdAbZcvn9dPg/l0tQ4chyfrt3sZr95OU536wkiUoKmNQU Z8f42VEzDaps2F2VjTIA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jDqvz-0003Ht-Dy; Mon, 16 Mar 2020 14:41:39 +0000 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jDqun-00025C-WA for linux-arm-kernel@lists.infradead.org; Mon, 16 Mar 2020 14:40:28 +0000 Received: by mail-pl1-x644.google.com with SMTP id t3so8094877plz.9 for ; Mon, 16 Mar 2020 07:40:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arista.com; s=googlenew; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Kscgl6LMW8fnhvnht43GSfN2W2mDU+MdbGlTg6HKa0I=; b=Gne+q2gYLPZmQpw2g8GRgQzskeppT1C+fJCqkoXNdVYmIZQjpev41BEdLNF1jjIQjG bGjjMFxo5Gkn1Q6mgz4J6CKJTMSKDZbkqxPsKKCyL04HIEt0Sil53pBRzeTo6GIXZMq0 /o+sZrqei2DdmSDlTsng/iEneFCOSu/ri3/3ZvVa64ByrypgmIPwqhdio/XJZJ3akJcK v+Eyy3Tivuc/8IbuEDxriEyeuOjFT1/o70jxvSmW+LjyHiOiCv3pL/yxTHjm3ewO+Kdf GVr9RSJWpKaWctz4YEi5W/j4l93ItRFd4l+7ZK+rQP8/nEqazAWa2tUwHrzQiJgwWZ9W AvOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Kscgl6LMW8fnhvnht43GSfN2W2mDU+MdbGlTg6HKa0I=; b=osVGgpzQMzJq5z+/aDiwSJ3TG8V4YILSIsI5vfaZMP4VxE524HDPnGukRgKugVOLVx vFf2nTK218m0T2bzkKlhnGwjXyg32LaIKjN8VSdp8bNQrp1HDEId7EVFPmHL2BE1uPwx M9He5P+SWoCLugl/iaHqv9BMuOAj5Ox4OJCc8WefN2XIf3Cak1+v5EiXsfsrMEAK7pw8 ytslFtnUIasQ9cqCWyObdik8QOo6yPdZDG+oKoIeV3wYV1Q2/2mRlUrtqUrqxphBVOyL DDoby2u+JVCfZUlSMny7JFuQLmDjsDdiN5MB1oMLJnMcEuonhnFjHCJz+dynW6v07swx TcHQ== X-Gm-Message-State: ANhLgQ2uivROIiZ7E2/gp0HhsaHptNSdrzQv41GVqKOOr/6B2ipULP/A dfj1G8aLoDvGinEHdkwOI7q1YQ== X-Google-Smtp-Source: ADFU+vsPJUeIS/9K8JoSoRdTLtr8Qnr3nNiYpumTfiHTDVGAp6UAnWBdhmDA7OEr/ZotrD9OuoakaQ== X-Received: by 2002:a17:902:724c:: with SMTP id c12mr3070339pll.60.1584369623471; Mon, 16 Mar 2020 07:40:23 -0700 (PDT) Received: from Mindolluin.aristanetworks.com ([2a02:8084:e84:2480:228:f8ff:fe6f:83a8]) by smtp.gmail.com with ESMTPSA id i2sm81524pjs.21.2020.03.16.07.40.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Mar 2020 07:40:22 -0700 (PDT) From: Dmitry Safonov To: linux-kernel@vger.kernel.org Subject: [PATCHv2 09/50] arm64: Add loglvl to dump_backtrace() Date: Mon, 16 Mar 2020 14:38:35 +0000 Message-Id: <20200316143916.195608-10-dima@arista.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200316143916.195608-1-dima@arista.com> References: <20200316143916.195608-1-dima@arista.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200316_074026_523861_215B5A8A X-CRM114-Status: GOOD ( 16.33 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:644 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Petr Mladek , Catalin Marinas , Dmitry Safonov , Tetsuo Handa , Greg Kroah-Hartman , Dmitry Safonov <0x7f454c46@gmail.com>, Russell King , Steven Rostedt , Sergey Senozhatsky , Jiri Slaby , Andrew Morton , Will Deacon , Ingo Molnar , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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 dump_backtrace() as a preparation for introducing show_stack_loglvl(). Cc: Catalin Marinas Cc: Russell King Cc: Will Deacon Cc: linux-arm-kernel@lists.infradead.org [1]: https://lore.kernel.org/lkml/20190528002412.1625-1-dima@arista.com/T/#u Signed-off-by: Dmitry Safonov --- arch/arm64/include/asm/stacktrace.h | 3 ++- arch/arm64/kernel/process.c | 2 +- arch/arm64/kernel/traps.c | 15 ++++++++------- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/arch/arm64/include/asm/stacktrace.h b/arch/arm64/include/asm/stacktrace.h index 4d9b1f48dc39..fdb913cc0bcb 100644 --- a/arch/arm64/include/asm/stacktrace.h +++ b/arch/arm64/include/asm/stacktrace.h @@ -64,7 +64,8 @@ struct stackframe { extern int unwind_frame(struct task_struct *tsk, struct stackframe *frame); extern void walk_stackframe(struct task_struct *tsk, struct stackframe *frame, int (*fn)(struct stackframe *, void *), void *data); -extern void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk); +extern void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk, + const char *loglvl); DECLARE_PER_CPU(unsigned long *, irq_stack_ptr); diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c index 00626057a384..2ee44d95f023 100644 --- a/arch/arm64/kernel/process.c +++ b/arch/arm64/kernel/process.c @@ -291,7 +291,7 @@ void __show_regs(struct pt_regs *regs) void show_regs(struct pt_regs * regs) { __show_regs(regs); - dump_backtrace(regs, NULL); + dump_backtrace(regs, NULL, KERN_DEFAULT); } static void tls_thread_flush(void) diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c index cf402be5c573..6e777cbd4eb5 100644 --- a/arch/arm64/kernel/traps.c +++ b/arch/arm64/kernel/traps.c @@ -53,9 +53,9 @@ static const char *handler[]= { int show_unhandled_signals = 0; -static void dump_backtrace_entry(unsigned long where) +static void dump_backtrace_entry(unsigned long where, const char *loglvl) { - printk(" %pS\n", (void *)where); + printk("%s %pS\n", loglvl, (void *)where); } static void dump_kernel_instr(const char *lvl, struct pt_regs *regs) @@ -83,7 +83,8 @@ static void dump_kernel_instr(const char *lvl, struct pt_regs *regs) printk("%sCode: %s\n", lvl, str); } -void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk) +void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk, + const char *loglvl) { struct stackframe frame; int skip = 0; @@ -115,11 +116,11 @@ void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk) thread_saved_pc(tsk)); } - printk("Call trace:\n"); + printk("%sCall trace:\n", loglvl); do { /* skip until specified stack frame */ if (!skip) { - dump_backtrace_entry(frame.pc); + dump_backtrace_entry(frame.pc, loglvl); } else if (frame.fp == regs->regs[29]) { skip = 0; /* @@ -129,7 +130,7 @@ void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk) * at which an exception has taken place, use regs->pc * instead. */ - dump_backtrace_entry(regs->pc); + dump_backtrace_entry(regs->pc, loglvl); } } while (!unwind_frame(tsk, &frame)); @@ -138,7 +139,7 @@ void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk) void show_stack(struct task_struct *tsk, unsigned long *sp) { - dump_backtrace(NULL, tsk); + dump_backtrace(NULL, tsk, KERN_DEFAULT); barrier(); } From patchwork Mon Mar 16 14:38:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Safonov X-Patchwork-Id: 11440495 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0EF186CA for ; Mon, 16 Mar 2020 14:42:18 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DF9A02051A for ; Mon, 16 Mar 2020 14:42:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="QjpsrqH6"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=arista.com header.i=@arista.com header.b="VuXFV4S0" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DF9A02051A Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=arista.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=3UY7/tA5iyXdRvsQc7rAaIaQJUwReSnOd/xigDCjhRI=; b=QjpsrqH6kRJn8N 3WEO4+smXSR6HzHv7GMJpcMBxHaGtoHnkHDt/wZYjZcbJuMTiOw3TmfCDVqhLsITipi/iAhGkmsbf HwJDxbjo3tAxvl+0pI9FChuYPp/phIlTs+fYPjk01GJ9YXqaLEoFEZG1k+YsQy+FRUD8MuVEb4/76 G56tUZqDJdW2gXhpQ67o5l60dbcqgmMhrHjr2P5Z4FQb0ZW/8Tk3iXWBzXxanWrmkGbz4mKbhsJzi hRzv/20aofq1g+C0GzBNoRXNQ8ZXBknQqD7DhNfDt5vdGWH++SvMNQQS/bPJAPeDorQq4pxFZkGO9 KV4Y4n/V1JclmwaVnAiw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jDqwW-0003pn-IJ; Mon, 16 Mar 2020 14:42:12 +0000 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jDqur-0002HU-Le for linux-arm-kernel@lists.infradead.org; Mon, 16 Mar 2020 14:40:35 +0000 Received: by mail-pg1-x543.google.com with SMTP id z72so30077pgz.3 for ; Mon, 16 Mar 2020 07:40:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arista.com; s=googlenew; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=urHNLfQhgSZxhId56CerdA8qI/pTbhkDosMJIMc+96U=; b=VuXFV4S0p0zJmT/b+BXBnIRAf1LhgKRfV+wV0VKglRwBXnyYsZ+d/LLoFN9TM94zgr WaR17JqMlUJ+8g6UmGbhdYsuQmZ97yoo3xfFPTrWl2mOrNWT/0G0RctGc6XyIJO/PkF/ fec1+IeB7QaFr+T8k9/1vEkm/zWL/TCZVG9ZLlcdIDsK7rcmbRtNI+lAWScVc+paWYyZ wcvOwUcaUWUxbALtVG0cagwlZA+zEN3O6whFXkuK1Rw3lkn3NSg+zw1viytV7bZhJCyo lsPfOYuqPwqPhLoFFwOB3Eij2tAYAKEJL0hcNjqCf2hxscyrl6CFrVrMVgTJ2oGc1Lc4 5k+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=urHNLfQhgSZxhId56CerdA8qI/pTbhkDosMJIMc+96U=; b=sLx17sQbf5gET6gJMe/jMPeEgB/JABzcTjxQvUnt5ji2weD3c+xL9lCJi2RzLwdtkK EdFY48KLeGRGF1XQbRrmQy/PCyy83CuV+TaKK3wCqMkAhIspB5S6Ie+RRR4EKx6L1TPu YP8qxExAtvWK6zmyo9gocGoc5WIeqskj2+XGsqlswaHmC8WjnaytWQgSMH0iQf9AbsYt 6kTbBIaH6HhxOulbjXo2cBq0RvnNYnOkHV3dfm0t+Q/E5Rx1j4v2L784aBa0tBcuehnp rx/hr346pAjwmpmrNDjkOYoeVFg9sRn0GytIPE4jgNK+Hlw01XB4IohEpY3rx2kA1ObZ NlLA== X-Gm-Message-State: ANhLgQ3MdPUN6T7+gvOcwBPTy2YocdpDFm7uFInx7pKS+BxMQ5WrTkcA 1WYx+okNiyruCtQY3i/qQUVMc4PsvW1V4g== X-Google-Smtp-Source: ADFU+vvLU6h1iizXDZ/c/OPZjgMmyqrH0GBzKwotMVtaEeH10SOiZn0xdM5t+Ga+ptP79KwZ0D1zPw== X-Received: by 2002:a63:ff20:: with SMTP id k32mr138425pgi.371.1584369628536; Mon, 16 Mar 2020 07:40:28 -0700 (PDT) Received: from Mindolluin.aristanetworks.com ([2a02:8084:e84:2480:228:f8ff:fe6f:83a8]) by smtp.gmail.com with ESMTPSA id i2sm81524pjs.21.2020.03.16.07.40.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Mar 2020 07:40:27 -0700 (PDT) From: Dmitry Safonov To: linux-kernel@vger.kernel.org Subject: [PATCHv2 10/50] arm64: Add show_stack_loglvl() Date: Mon, 16 Mar 2020 14:38:36 +0000 Message-Id: <20200316143916.195608-11-dima@arista.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200316143916.195608-1-dima@arista.com> References: <20200316143916.195608-1-dima@arista.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200316_074029_832772_F6254C1B X-CRM114-Status: GOOD ( 11.69 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:543 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Petr Mladek , Catalin Marinas , Dmitry Safonov , Tetsuo Handa , Greg Kroah-Hartman , Dmitry Safonov <0x7f454c46@gmail.com>, Russell King , Steven Rostedt , Sergey Senozhatsky , Jiri Slaby , Andrew Morton , Will Deacon , Ingo Molnar , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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. Introduce show_stack_loglvl(), that eventually will substitute show_stack(). Cc: Catalin Marinas Cc: Russell King Cc: Will Deacon Cc: linux-arm-kernel@lists.infradead.org [1]: https://lore.kernel.org/lkml/20190528002412.1625-1-dima@arista.com/T/#u Signed-off-by: Dmitry Safonov --- arch/arm64/kernel/traps.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c index 6e777cbd4eb5..516e92332fd0 100644 --- a/arch/arm64/kernel/traps.c +++ b/arch/arm64/kernel/traps.c @@ -137,12 +137,18 @@ void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk, put_task_stack(tsk); } -void show_stack(struct task_struct *tsk, unsigned long *sp) +void show_stack_loglvl(struct task_struct *tsk, unsigned long *sp, + const char *loglvl) { - dump_backtrace(NULL, tsk, KERN_DEFAULT); + dump_backtrace(NULL, tsk, loglvl); barrier(); } +void show_stack(struct task_struct *tsk, unsigned long *sp) +{ + show_stack_loglvl(tsk, sp, KERN_DEFAULT); +} + #ifdef CONFIG_PREEMPT #define S_PREEMPT " PREEMPT" #elif defined(CONFIG_PREEMPT_RT)