From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0418FC3A5A0 for ; Sat, 18 Apr 2020 20:20:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CFB8922242 for ; Sat, 18 Apr 2020 20:20:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=arista.com header.i=@arista.com header.b="PVxE82lm" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728369AbgDRUUE (ORCPT ); Sat, 18 Apr 2020 16:20:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728309AbgDRUT7 (ORCPT ); Sat, 18 Apr 2020 16:19:59 -0400 Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B3F5C061A0C for ; Sat, 18 Apr 2020 13:19:59 -0700 (PDT) Received: by mail-wr1-x443.google.com with SMTP id j2so7147122wrs.9 for ; Sat, 18 Apr 2020 13:19:59 -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=9gJWg9flNrZ5TbihOoh/z3AJf3d2tqOa4g2mAiThDeM=; b=PVxE82lm6zbJXbMlOBH7658BN1LsmSNhLelmCSYXbCLzMKXqjTZVdq6I18YXHTLKE/ D2dhd++/3+gAA3ytlUmItZdaIHfuzKaaiC+57QTDrsosqrFpUS/1mJ0ygyE8pGwat5PE nngmmT3wXVtmunDk+UBSuYjIUANSD9Cq93k2oNIyRt0/U4GEMs/irJoXa1JFpU7SWyX4 AT2k90PUslP4Cfb0gO+z37SG7WRMImujj+Df6z1CwN1jmhx43WF3e7N8GJzRS6HOkVUr teCLTNUBqt6xuUfX6x/qTW/fjF4z3+BgqKx5k13N2iWJ9nMdDgeYooRmorapGeOEo/3f 3sFw== 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=9gJWg9flNrZ5TbihOoh/z3AJf3d2tqOa4g2mAiThDeM=; b=YmxoqQKvB0ATWa1329Ab6pcetQdvQnZnAGB/0Cpb0kBuITLT9J3doTZBiK2lTa5Q+P 3n7gdMHLH36sUBEsols7f4lzu9a3ttA9WA7R0NnyhdzkROwxIBex0sYI8O7sld/SRfuK Xwo9WQR+EPJ01F3mfiTSbH7gfKfiEAmibYPH4aA4EeEpOKj+g8U9UIpv/7LczmLO+01a MmAmYZ6iw5y0pca9+6u7ZRIXo2vQxvVBkXXK2FNKRYy61Xw1flAn8IuRfmq2CKg7NTu2 AZYYRtEgrFUkHJaia/8Y/6RmSzt4neTmHxFToXDI9gepiQ42GWWJHJYsoZzXGF2/vIai 8bmg== X-Gm-Message-State: AGi0PubT+bQCyePP2kPOnn5GWOAraeJoFN13GDnbZTnXPRKCNQI8BzB1 aa/iodKBPCdU1bx/AVC8UqQz7V0mxXk= X-Google-Smtp-Source: APiQypKRG49fXk4T9AfC+xyEPdGlqmTjbP7MwJqjfc6m6jwOkEUzENR06R4k2aboxmy2IHqqdJKvHA== X-Received: by 2002:a05:6000:12c5:: with SMTP id l5mr10920553wrx.185.1587241197758; Sat, 18 Apr 2020 13:19:57 -0700 (PDT) Received: from localhost.localdomain ([2a02:8084:e84:2480:228:f8ff:fe6f:83a8]) by smtp.gmail.com with ESMTPSA id m1sm31735255wro.64.2020.04.18.13.19.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Apr 2020 13:19:56 -0700 (PDT) From: Dmitry Safonov To: linux-kernel@vger.kernel.org Cc: Dmitry Safonov <0x7f454c46@gmail.com>, Dmitry Safonov , Andrew Morton , Greg Kroah-Hartman , Ingo Molnar , Jiri Slaby , Petr Mladek , Sergey Senozhatsky , Steven Rostedt , Tetsuo Handa , Russell King , Will Deacon , linux-arm-kernel@lists.infradead.org, clang-built-linux@googlegroups.com Subject: [PATCHv3 05/50] arm: Add loglvl to unwind_backtrace() Date: Sat, 18 Apr 2020 21:18:59 +0100 Message-Id: <20200418201944.482088-6-dima@arista.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200418201944.482088-1-dima@arista.com> References: <20200418201944.482088-1-dima@arista.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 343cc27b36c4..d2bd0df2318d 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); } } -- 2.26.0 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7114EC3A5A0 for ; Sat, 18 Apr 2020 20:20:40 +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 39BA122240 for ; Sat, 18 Apr 2020 20:20:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="hiKvO5cF"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=arista.com header.i=@arista.com header.b="PVxE82lm" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 39BA122240 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+infradead-linux-arm-kernel=archiver.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=RkEkxdKZHPNSRXMgc4H8OkbX99E37DcNeE35E06R87s=; b=hiKvO5cF4avQqy VPraxnqzMuA9oJe+xLkGsS9uMJW9ajnULtnKBnkVHYJ/E23BwTAMr2rjDop9Hb+GQzpCdN5Yyp+rm 7M0AFVONCLEZglwZAkIAaUYSnwKKz6r6ZstWIuLPtqi3kZZVd/uLmCVhtT1V2/F1R6Q9qO6fDeYO5 DQPuXk0KPIk5cplvl6eRir0TtDQfEFMqVLmrZbzNrQJaxFimMj3XP5+dwDLZJgfcPiTybbr5WsUP5 IrW7huQwaMm+RTVy4rUM7V8c9xt+Wry07euuuUpNYC1gSC2ruzs836KjQbiILgOSRwXnQzJv7tfT3 E3lkKNNm2/uo4QypuSSQ==; 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 1jPtx5-0004Gi-S5; Sat, 18 Apr 2020 20:20:35 +0000 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jPtwV-0001UZ-0c for linux-arm-kernel@lists.infradead.org; Sat, 18 Apr 2020 20:20:00 +0000 Received: by mail-wr1-x444.google.com with SMTP id d17so7133359wrg.11 for ; Sat, 18 Apr 2020 13:19:58 -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=9gJWg9flNrZ5TbihOoh/z3AJf3d2tqOa4g2mAiThDeM=; b=PVxE82lm6zbJXbMlOBH7658BN1LsmSNhLelmCSYXbCLzMKXqjTZVdq6I18YXHTLKE/ D2dhd++/3+gAA3ytlUmItZdaIHfuzKaaiC+57QTDrsosqrFpUS/1mJ0ygyE8pGwat5PE nngmmT3wXVtmunDk+UBSuYjIUANSD9Cq93k2oNIyRt0/U4GEMs/irJoXa1JFpU7SWyX4 AT2k90PUslP4Cfb0gO+z37SG7WRMImujj+Df6z1CwN1jmhx43WF3e7N8GJzRS6HOkVUr teCLTNUBqt6xuUfX6x/qTW/fjF4z3+BgqKx5k13N2iWJ9nMdDgeYooRmorapGeOEo/3f 3sFw== 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=9gJWg9flNrZ5TbihOoh/z3AJf3d2tqOa4g2mAiThDeM=; b=a5y1XNw7G0NoD8zPEwvgdl761B1AENWjDQp+u84LMivKFscw4V5JPUUMRcUpS+5qzY Ky8yY7EXRHAQOxkULqU9GNNw6OSz3HKyqRH07J10UL0KqPt7KFJ56ytozRKjjR3Le2Vv mTmUA8Gj1fzWIzcJALw7MHOtVWuIuCSECjdDhrcOGcvovkqfFxEmJNN25vHiCZ/xGPpn cM05l8zHQnk0b9sQ0zqp9fVcnE56ACuqMN1UMq+uHs45PShiVm0bnNN/dXeSIINt+5P8 Clm6JImeNlKtZDQpUabV0jddsDvJ/O0h/e2pD6zONOeGhO3Sx2KUfAonMJxKr9pTSTXR b/aw== X-Gm-Message-State: AGi0PuZ//DdzT++spvWqtVzxoRlfYDq1tA9+CT0WCi0Omkxp2NPVIAzA HMnzwYdbckm8OkK3jUx52JFjSg== X-Google-Smtp-Source: APiQypKRG49fXk4T9AfC+xyEPdGlqmTjbP7MwJqjfc6m6jwOkEUzENR06R4k2aboxmy2IHqqdJKvHA== X-Received: by 2002:a05:6000:12c5:: with SMTP id l5mr10920553wrx.185.1587241197758; Sat, 18 Apr 2020 13:19:57 -0700 (PDT) Received: from localhost.localdomain ([2a02:8084:e84:2480:228:f8ff:fe6f:83a8]) by smtp.gmail.com with ESMTPSA id m1sm31735255wro.64.2020.04.18.13.19.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Apr 2020 13:19:56 -0700 (PDT) From: Dmitry Safonov To: linux-kernel@vger.kernel.org Subject: [PATCHv3 05/50] arm: Add loglvl to unwind_backtrace() Date: Sat, 18 Apr 2020 21:18:59 +0100 Message-Id: <20200418201944.482088-6-dima@arista.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200418201944.482088-1-dima@arista.com> References: <20200418201944.482088-1-dima@arista.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200418_131959_085023_E6DC7B98 X-CRM114-Status: GOOD ( 14.91 ) 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.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 343cc27b36c4..d2bd0df2318d 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); } } -- 2.26.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel