From patchwork Fri Oct 19 13:26:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugeniy Paltsev X-Patchwork-Id: 986820 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="PCzTsn/I"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=synopsys.com header.i=@synopsys.com header.b="WTJOgC+L"; 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 42c6g31tlwz9s4Z for ; Sat, 20 Oct 2018 00:47:43 +1100 (AEDT) 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=VTwyDvIVji93jJpy7gZ/fZ5G+0syzq/hbjuZ3TXtriw=; b=PCz Tsn/IzGJFoOGHcbrb6JzUBt2An/w6qOj4AucqgvPNe7xMnsV0SctmfG8MKc/yKa0vgpXxhtVw+tjC jeu21MYRmVesQCkeRc4VBcM7spEqiKnB/moD6gQMv7n6l2CyvCG2GcqfYmo3wwuAJisn7gvaxCF1D SxfbWzVn6SXAiHi/N9K59wkEMbIrcS6EhGKrAxN2THO8+sH38+Ip5WhFoUs5hmXRYRBMsnbWjnTP4 dSv7bD1m2hjmswnBTjRhscesJCy52xdGSVOyDprROCTR5K4oN5Xq0aAg08yoNf3afmKQdIuJwD0Ne eSP0lRfgG7zGUiNThiKQYAdrYCLaS5A==; 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 1gDV7o-0005le-6n; Fri, 19 Oct 2018 13:47:36 +0000 Received: from smtprelay.synopsys.com ([198.182.47.9]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gDUnV-0000Ce-S3 for linux-snps-arc@lists.infradead.org; Fri, 19 Oct 2018 13:28:38 +0000 Received: from mailhost.synopsys.com (mailhost2.synopsys.com [10.13.184.66]) by smtprelay.synopsys.com (Postfix) with ESMTP id 89CEE24E11D9; Fri, 19 Oct 2018 06:26:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1539955584; bh=hGtYIVzK4Jx1v4SLBeS8EZNeJ7rppMsr8WZKCxP2WBU=; h=From:To:Cc:Subject:Date:From; b=WTJOgC+LNshGFIJPARIBZzZfPj5jFvMAEHpyhhqaG7wv5PCprQNQWWFtIZt5g2GlJ X8L5rprTSg0SDRkkOfCs1/SK+M5Aw49DJBKoEsoLvN5bEvV0cx9PxdilMHA9FaRSK7 HjKhthWe/R6kTIyOMLvlOKOEDkZpwluJ06s44txVVdo0fUCTvK6syR4tqX3Y1rKua1 FCcDJzV93Z52bvb/6JOM+3qCM23cTpvbC354g+t8vrRe95A8Pc5jDB6Mg4KvBeZOmz EcUsBNYMqnkSFuFKqh9bNfeN1E5zC+xv8KIVXrS0eo9UmLC6XGfopJzVOpzRuGSCA0 iki2altbtRLHw== Received: from paltsev-e7480.internal.synopsys.com (paltsev-e7480.internal.synopsys.com [10.121.3.38]) by mailhost.synopsys.com (Postfix) with ESMTP id DBC46309C; Fri, 19 Oct 2018 06:26:22 -0700 (PDT) From: Eugeniy Paltsev To: linux-snps-arc@lists.infradead.org, Vineet Gupta Subject: [PATCH v3] ARC: prevent showing irrelevant exception info in signal message Date: Fri, 19 Oct 2018 16:26:20 +0300 Message-Id: <20181019132620.27368-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-20181019_062637_971953_1F5F0EE0 X-CRM114-Status: GOOD ( 18.08 ) X-Spam-Note: SpamAssassin invocation failed 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: 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..e66fd40296b3 100644 --- a/arch/arc/kernel/traps.c +++ b/arch/arc/kernel/traps.c @@ -49,6 +49,9 @@ unhandled_exception(const char *str, struct pt_regs *regs, siginfo_t *info) tsk->thread.fault_address = (__force unsigned int)info->si_addr; + if (unhandled_signal(tsk, info->si_signo)) + show_exception_mesg(regs); + force_sig_info(info->si_signo, info, tsk); } else { 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 db6913094be3..026d662a7668 100644 --- a/arch/arc/mm/fault.c +++ b/arch/arc/mm/fault.c @@ -203,6 +203,10 @@ void do_page_fault(unsigned long address, struct pt_regs *regs) info.si_errno = 0; /* info.si_code has been set above */ info.si_addr = (void __user *)address; + + if (unhandled_signal(tsk, info.si_signo)) + show_exception_mesg(regs); + force_sig_info(SIGSEGV, &info, tsk); return; } @@ -242,5 +246,9 @@ void do_page_fault(unsigned long address, struct pt_regs *regs) info.si_errno = 0; info.si_code = BUS_ADRERR; info.si_addr = (void __user *)address; + + if (unhandled_signal(tsk, info.si_signo)) + show_exception_mesg(regs); + force_sig_info(SIGBUS, &info, tsk); }