From patchwork Tue Aug 7 13:59:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugeniy Paltsev X-Patchwork-Id: 954524 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=synopsys.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="e8Xf7BXb"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=synopsys.com header.i=@synopsys.com header.b="T7Z+ctA+"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41lGP73MVRz9s3x for ; Wed, 8 Aug 2018 00:00:11 +1000 (AEST) 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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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:In-Reply-To: References:List-Owner; bh=4COrqwKNF8xS06LWArgIyND9c+T9S4OKREDQYc3/zW4=; b=e8X f7BXbp1rtIBZigrSM067QP93UyJMMHEiLIcI2liwPvmY+5B6F3rB+4ys71wUgmNpqmf+lhp48E2J2 FD6b0WFD/Iqr6lfpo6iRGcqAyoZoAfDYi5GzmRXgvQDS2Nrkt2WyuYPB4WuUd8fn8T40iuAOdPV1C jvWomV1IB/lpITKCRkECDp7zqByXp0OoVqbcZWY1CV+M80FLh2OTqsUQb4tbWEFlmU0jQSv9BeE6j 7ld7ArZoyxgIxprKv6gEXOZpT23ieDdLNCwUMGwAzDqL39e2jOiHJcVcot43IuU+c2+bP+kR3FRuP X7NdoUVjvmJofA379YyCRD4V3aLwMbA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fn2Wv-0002RA-Bn; Tue, 07 Aug 2018 14:00:09 +0000 Received: from smtprelay2.synopsys.com ([198.182.60.111] helo=smtprelay.synopsys.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fn2Wr-0001C3-J6 for linux-snps-arc@lists.infradead.org; Tue, 07 Aug 2018 14:00:07 +0000 Received: from mailhost.synopsys.com (mailhost3.synopsys.com [10.12.238.238]) by smtprelay.synopsys.com (Postfix) with ESMTP id 376ED10C0FAC; Tue, 7 Aug 2018 06:59:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1533650390; bh=4o19958GKQmmJBaUI34s+VPBXc4afI7y5fkP0F8/lrU=; h=From:To:Cc:Subject:Date:From; b=T7Z+ctA+lfSTGSel/Xyo+kAL9UgI12+HTNLrM4lNh1ZjJhtajjqsFeS5c3dH5I+Vr IQVmuxmMX0oqqr1Co5/nFktSRCqRR7qjZEpYLaYF392zJOWz+CdiQbr6jHvp31QGiZ JREgLkff/gr1sQaJCuPndHZ1BG+7fJiP8YjBi+UX6++uDu7YuNyUp7rFzRY9XUGtqE v3zapr+HJSrMMqInMUoNvSNQr+uv42CdJbgMLVNCarNSL4mPSBQ4WP3ZsCYsiWliak 9hvYpvt5Lxx5tgMkQBINnTwhBSxDYtStHLbgRpRCSjmIj09PHkjL6ui4DLWmSjM8Ne mhgkCBgfDANBQ== Received: from paltsev-e7480.internal.synopsys.com (unknown [10.121.8.86]) by mailhost.synopsys.com (Postfix) with ESMTP id C44EE3B69; Tue, 7 Aug 2018 06:59:48 -0700 (PDT) From: Eugeniy Paltsev To: linux-snps-arc@lists.infradead.org Subject: [PATCH v2] ARC: prevent showing irrelevant exception info in signal message Date: Tue, 7 Aug 2018 16:59:45 +0300 Message-Id: <20180807135945.2948-1-Eugeniy.Paltsev@synopsys.com> X-Mailer: git-send-email 2.14.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180807_070005_660564_EBE030C9 X-CRM114-Status: GOOD ( 15.28 ) X-Spam-Score: -0.1 (/) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-0.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [198.182.60.111 listed in list.dnswl.org] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-snps-arc@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux on Synopsys ARC Processors List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vineet Gupta , Alexey Brodkin , Eugeniy Paltsev , linux-kernel@vger.kernel.org MIME-Version: 1.0 Sender: "linux-snps-arc" Errors-To: linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org We process signals in the end of syscall/exception handler. It the signal is fatal we print register's content using show_regs function. show_regs() also prints information about last exception happened. In case of multicore system we can catch the situation when we will print wrong information about exception. See the example: diff --git a/arch/arc/include/asm/bug.h b/arch/arc/include/asm/bug.h index 21ec82466d62..b68f7f82f2d8 100644 --- a/arch/arc/include/asm/bug.h +++ b/arch/arc/include/asm/bug.h @@ -16,6 +16,7 @@ struct task_struct; void show_regs(struct pt_regs *regs); +void show_exception_mesg(struct pt_regs *regs); void show_stacktrace(struct task_struct *tsk, struct pt_regs *regs); void show_kernel_fault_diag(const char *str, struct pt_regs *regs, unsigned long address); diff --git a/arch/arc/kernel/traps.c b/arch/arc/kernel/traps.c index b123558bf0bb..5d83b2fe5f12 100644 --- a/arch/arc/kernel/traps.c +++ b/arch/arc/kernel/traps.c @@ -50,6 +50,7 @@ unhandled_exception(const char *str, struct pt_regs *regs, siginfo_t *info) tsk->thread.fault_address = (__force unsigned int)info->si_addr; force_sig_info(info->si_signo, info, tsk); + show_exception_mesg(regs); } else { /* If not due to copy_(to|from)_user, we are doomed */ diff --git a/arch/arc/kernel/troubleshoot.c b/arch/arc/kernel/troubleshoot.c index e8d9fb452346..fdfba1942a06 100644 --- a/arch/arc/kernel/troubleshoot.c +++ b/arch/arc/kernel/troubleshoot.c @@ -101,13 +101,13 @@ static void show_faulting_vma(unsigned long address, char *buf) if (IS_ERR(nm)) nm = "?"; } - pr_info(" @off 0x%lx in [%s]\n" - " VMA: 0x%08lx to 0x%08lx\n", + + pr_cont("[off 0x%lx in %s, VMA: %08lx:%08lx] ", vma->vm_start < TASK_UNMAPPED_BASE ? address : address - vma->vm_start, nm, vma->vm_start, vma->vm_end); } else - pr_info(" @No matching VMA found\n"); + pr_cont("[No matching VMA found] "); up_read(&active_mm->mmap_sem); } @@ -117,7 +117,7 @@ static void show_ecr_verbose(struct pt_regs *regs) unsigned int vec, cause_code; unsigned long address; - pr_info("\n[ECR ]: 0x%08lx => ", regs->event); + pr_cont("\n ECR: 0x%08lx => ", regs->event); /* For Data fault, this is data address not instruction addr */ address = current->thread.fault_address; @@ -165,10 +165,42 @@ static void show_ecr_verbose(struct pt_regs *regs) } } +static inline void show_exception_mesg_u(struct pt_regs *regs) +{ + struct task_struct *tsk = current; + char *buf; + + pr_info("Exception: %s[%d]: at %pS ", + tsk->comm, task_pid_nr(tsk), (void *)regs->ret); + + buf = (char *)__get_free_page(GFP_NOWAIT); + if (buf) { + show_faulting_vma(regs->ret, buf); + free_page((unsigned long)buf); + } + + show_ecr_verbose(regs); +} + +static inline void show_exception_mesg_k(struct pt_regs *regs) +{ + pr_info("Exception: at %pS:", (void *)regs->ret); + + show_ecr_verbose(regs); +} + /************************************************************************ * API called by rest of kernel ***********************************************************************/ +void show_exception_mesg(struct pt_regs *regs) +{ + if (user_mode(regs)) + show_exception_mesg_u(regs); + else + show_exception_mesg_k(regs); +} + void show_regs(struct pt_regs *regs) { struct task_struct *tsk = current; @@ -182,15 +214,10 @@ void show_regs(struct pt_regs *regs) print_task_path_n_nm(tsk, buf); show_regs_print_info(KERN_INFO); - show_ecr_verbose(regs); - - pr_info("[EFA ]: 0x%08lx\n[BLINK ]: %pS\n[ERET ]: %pS\n", - current->thread.fault_address, + pr_info("[ECR ]: 0x%08lx\n[EFA ]: 0x%08lx\n[BLINK ]: %pS\n[ERET ]: %pS\n", + regs->event, current->thread.fault_address, (void *)regs->blink, (void *)regs->ret); - if (user_mode(regs)) - show_faulting_vma(regs->ret, buf); /* faulting code, not data */ - pr_info("[STAT32]: 0x%08lx", regs->status32); #define STS_BIT(r, bit) r->status32 & STATUS_##bit##_MASK ? #bit" " : "" @@ -233,6 +260,8 @@ void show_kernel_fault_diag(const char *str, struct pt_regs *regs, /* Show fault description */ pr_info("\n%s\n", str); + show_exception_mesg(regs); + /* Caller and Callee regs */ show_regs(regs); diff --git a/arch/arc/mm/fault.c b/arch/arc/mm/fault.c index b884bbd6f354..d9c6958a1702 100644 --- a/arch/arc/mm/fault.c +++ b/arch/arc/mm/fault.c @@ -202,6 +202,7 @@ void do_page_fault(unsigned long address, struct pt_regs *regs) /* info.si_code has been set above */ info.si_addr = (void __user *)address; force_sig_info(SIGSEGV, &info, tsk); + show_exception_mesg(regs); return; } @@ -241,4 +242,5 @@ void do_page_fault(unsigned long address, struct pt_regs *regs) info.si_code = BUS_ADRERR; info.si_addr = (void __user *)address; force_sig_info(SIGBUS, &info, tsk); + show_exception_mesg(regs); }