From patchwork Fri Jun 29 19:39:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugeniy Paltsev X-Patchwork-Id: 937124 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="atWW6L3F"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=synopsys.com header.i=@synopsys.com header.b="KDrZYLNL"; 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 41HRmd3Hfrz9s29 for ; Sat, 30 Jun 2018 05:39:29 +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=PxLODVwfFjd7BoVsIieRjiYXvxaBRG64ZbHfssBwbyI=; b=atW W6L3FcEssun3c1lZ0CYIsTdrzLpxFvvmVTNk1wcRIgxrI2bdP03PU86YHI+/47xJEOJ9E+dBkqor3 EX8oDC8lJ4kBzaKxPTuOWi2eBN+K6IfdqsIdumbdZ+8HxRqobPIh4vvmMT4pcudf2SIKNODrBF5s6 8sp0WyXovQovYS0On+ql5oFApNLp0QGRAP7bbxkBlBzrqYfzm5QpcF91zYUNA0QL37ASt1eIX1R6+ mFfsc5lVeRMWtqdDofa0fJJbk5beBfMsfIopCpzt1UswmBtam9+jIBbElU8H2P/WXhTrnoHZBCt9K gOjBLiejCl1L1g3GcsTRVj/q1kIF9fQ==; 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 1fYzEt-0000QA-C8; Fri, 29 Jun 2018 19:39:27 +0000 Received: from smtprelay4.synopsys.com ([198.182.47.9] helo=smtprelay.synopsys.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fYzEp-0000Ol-Ju for linux-snps-arc@lists.infradead.org; Fri, 29 Jun 2018 19:39:25 +0000 Received: from mailhost.synopsys.com (mailhost1.synopsys.com [10.12.238.239]) by smtprelay.synopsys.com (Postfix) with ESMTP id A519524E0710; Fri, 29 Jun 2018 12:39:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1530301151; bh=+WVB5VrNFr5ox+tYnVUXNPZoRTeKsMRfz8en9PAykJE=; h=From:To:Cc:Subject:Date:From; b=KDrZYLNLZRxz6N4mQivPNA+eKqLxcW5lGpDQzAL8kHH818IBiECZ6q0GjkDJzEpYy xWlIegcR9JhI0K3MOOi0kl17LaqwCqGnJC1enzI1TU6OaPF+3btyk97uZfLrtTc5pp XGXntcJ8c927z7n2Gk2veuxxXimq8k13lh/LDnEHrSPIq8d/F6Nw0RNOA4g4j2XMXk RwZfb+xO4qRSRBvf8fICMB8pG0ztFNTalINQY2F4/Y4IPSWrcZWYiv2YnwcunL7WnQ 0N8PzU1KxXeNWEhUY2bAatY2gDFFAjQ3WGBY4ygQBNJ2QjEEQoo+lgdkaNAEHMyL3j fwSUgv5MQlRYw== Received: from paltsev-e7480.internal.synopsys.com (paltsev-e7480.internal.synopsys.com [10.121.3.53]) by mailhost.synopsys.com (Postfix) with ESMTP id 01B065AE9; Fri, 29 Jun 2018 12:39:09 -0700 (PDT) From: Eugeniy Paltsev To: linux-snps-arc@lists.infradead.org Subject: [PATCH] ARC: prevent showing irrelevant exception info in signal message Date: Fri, 29 Jun 2018 22:39:07 +0300 Message-Id: <20180629193907.17227-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-20180629_123923_666982_61719E69 X-CRM114-Status: GOOD ( 12.94 ) 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 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [198.182.47.9 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 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..b9fd60f7d36b 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_regs(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..fe41f0d9488f 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_regs(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 783b20354f8b..313aea25e638 100644 --- a/arch/arc/kernel/troubleshoot.c +++ b/arch/arc/kernel/troubleshoot.c @@ -170,14 +170,9 @@ static void show_ecr_verbose(struct pt_regs *regs) } } -/************************************************************************ - * API called by rest of kernel - ***********************************************************************/ - -void show_regs(struct pt_regs *regs) +void show_exception_regs(struct pt_regs *regs) { struct task_struct *tsk = current; - struct callee_regs *cregs; char *buf; buf = (char *)__get_free_page(GFP_KERNEL); @@ -190,12 +185,28 @@ void show_regs(struct pt_regs *regs) show_ecr_verbose(regs); pr_info("[EFA ]: 0x%08lx\n[BLINK ]: %pS\n[ERET ]: %pS\n", - current->thread.fault_address, + tsk->thread.fault_address, (void *)regs->blink, (void *)regs->ret); if (user_mode(regs)) show_faulting_vma(regs->ret, buf); /* faulting code, not data */ + free_page((unsigned long)buf); +} + +/************************************************************************ + * API called by rest of kernel + ***********************************************************************/ + +void show_regs(struct pt_regs *regs) +{ + struct callee_regs *cregs; + char *buf; + + buf = (char *)__get_free_page(GFP_KERNEL); + if (!buf) + return; + pr_info("[STAT32]: 0x%08lx", regs->status32); #define STS_BIT(r, bit) r->status32 & STATUS_##bit##_MASK ? #bit" " : "" @@ -238,6 +249,8 @@ void show_kernel_fault_diag(const char *str, struct pt_regs *regs, /* Show fault description */ pr_info("\n%s\n", str); + show_exception_regs(regs); + /* Caller and Callee regs */ show_regs(regs); diff --git a/arch/arc/mm/fault.c b/arch/arc/mm/fault.c index a0b7bd6d030d..7e0e2591bb27 100644 --- a/arch/arc/mm/fault.c +++ b/arch/arc/mm/fault.c @@ -200,6 +200,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_regs(regs); return; } @@ -239,4 +240,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_regs(regs); }