From patchwork Wed Apr 9 01:45:08 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laura Abbott X-Patchwork-Id: 3952111 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 440E3BFF02 for ; Wed, 9 Apr 2014 01:45:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 69B152034B for ; Wed, 9 Apr 2014 01:45:58 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7F2B420320 for ; Wed, 9 Apr 2014 01:45:56 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WXhaA-00067i-24; Wed, 09 Apr 2014 01:45:42 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WXha7-0005fS-AK; Wed, 09 Apr 2014 01:45:39 +0000 Received: from smtp.codeaurora.org ([198.145.11.231]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WXha3-0005dy-4r for linux-arm-kernel@lists.infradead.org; Wed, 09 Apr 2014 01:45:36 +0000 Received: from smtp.codeaurora.org (localhost [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id BE2C813EF08; Wed, 9 Apr 2014 01:45:13 +0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 486) id B19FC13F001; Wed, 9 Apr 2014 01:45:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from lauraa-linux1.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: lauraa@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 4CCD813EF24; Wed, 9 Apr 2014 01:45:13 +0000 (UTC) From: Laura Abbott To: Catalin Marinas Subject: [PATCH] arm64: Add user_debug command line option Date: Tue, 8 Apr 2014 18:45:08 -0700 Message-Id: <1397007908-17993-1-git-send-email-lauraa@codeaurora.org> X-Mailer: git-send-email 1.8.2.1 X-Virus-Scanned: ClamAV using ClamSMTP X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140408_214535_324836_FB5B0B7E X-CRM114-Status: GOOD ( 17.88 ) X-Spam-Score: -2.2 (--) Cc: Laura Abbott , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP arm had a useful command line option to print out debug information on user signals. This is somewhat like a more verbose version of show_unhandled_signals. Add the user_debug command line option to print out more information in a similar manner to arm. Signed-off-by: Laura Abbott --- arch/arm64/include/asm/system_misc.h | 25 +++++++++++++++++++++++++ arch/arm64/kernel/traps.c | 13 ++++++++++--- arch/arm64/mm/fault.c | 3 +-- 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/arch/arm64/include/asm/system_misc.h b/arch/arm64/include/asm/system_misc.h index 7a18fab..2f95589 100644 --- a/arch/arm64/include/asm/system_misc.h +++ b/arch/arm64/include/asm/system_misc.h @@ -50,6 +50,31 @@ extern void (*arm_pm_restart)(enum reboot_mode reboot_mode, const char *cmd); #define UDBG_SEGV (1 << 3) #define UDBG_BUS (1 << 4) +extern unsigned int user_debug; +extern int show_unhandled_signals; + +static inline bool print_user_debug(unsigned int signum, unsigned int mask) +{ + int ret = 0; + bool sig_assert = false; + + ret |= show_unhandled_signals && + (signum ? unhandled_signal(current, signum) : 1); + if (mask & UDBG_SEGV) { + sig_assert = true; + ret |= (user_debug & mask) && signum == SIGSEGV; + } + if (mask & UDBG_BUS) { + sig_assert = true; + ret |= (user_debug & mask) && signum == SIGBUS; + } + if (sig_assert) + ret |= (user_debug & mask); + + return ret ? printk_ratelimit() : false; +} + + #endif /* __ASSEMBLY__ */ #endif /* __ASM_SYSTEM_MISC_H */ diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c index a6740d0..5519ef1 100644 --- a/arch/arm64/kernel/traps.c +++ b/arch/arm64/kernel/traps.c @@ -48,6 +48,14 @@ static const char *handler[]= { }; int show_unhandled_signals = 1; +unsigned int user_debug; + +static int __init user_debug_setup(char *str) +{ + get_option(&str, &user_debug); + return 1; +} +__setup("user_debug=", user_debug_setup); /* * Dump out the contents of some memory nicely... @@ -270,8 +278,7 @@ asmlinkage void __exception do_undefinstr(struct pt_regs *regs) trace_undef_instr(regs, (void *)pc); - if (show_unhandled_signals && unhandled_signal(current, SIGILL) && - printk_ratelimit()) { + if (print_user_debug(SIGILL, UDBG_UNDEFINED)) { pr_info("%s[%d]: undefined instruction: pc=%p\n", current->comm, task_pid_nr(current), pc); dump_instr(KERN_INFO, regs); @@ -298,7 +305,7 @@ asmlinkage long do_ni_syscall(struct pt_regs *regs) } #endif - if (show_unhandled_signals && printk_ratelimit()) { + if (print_user_debug(0, UDBG_SYSCALL)) { pr_info("%s[%d]: syscall %d\n", current->comm, task_pid_nr(current), (int)regs->syscallno); dump_instr("", regs); diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c index 8e783eb..bbef0b5 100644 --- a/arch/arm64/mm/fault.c +++ b/arch/arm64/mm/fault.c @@ -117,8 +117,7 @@ static void __do_user_fault(struct task_struct *tsk, unsigned long addr, trace_user_fault(tsk, addr, esr); - if (show_unhandled_signals && unhandled_signal(tsk, sig) && - printk_ratelimit()) { + if (print_user_debug(sig, UDBG_BUS | UDBG_SEGV)) { pr_info("%s[%d]: unhandled %s (%d) at 0x%08lx, esr 0x%03x\n", tsk->comm, task_pid_nr(tsk), fault_name(esr), sig, addr, esr);