From patchwork Tue Sep 27 07:47:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pratyush Anand X-Patchwork-Id: 9351561 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3F4996077A for ; Tue, 27 Sep 2016 07:50:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 323F128AD0 for ; Tue, 27 Sep 2016 07:50:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 26E5E290D0; Tue, 27 Sep 2016 07:50:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.7 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B90E828AD0 for ; Tue, 27 Sep 2016 07:50:57 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bon90-0006qK-Rr; Tue, 27 Sep 2016 07:49:38 +0000 Received: from mail-yw0-f169.google.com ([209.85.161.169]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bon83-0006Ko-Vy for linux-arm-kernel@lists.infradead.org; Tue, 27 Sep 2016 07:48:45 +0000 Received: by mail-yw0-f169.google.com with SMTP id g192so3412984ywh.1 for ; Tue, 27 Sep 2016 00:48:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=VPtU10rphqz8kUL0yLXC9yAvMBU784mMAx3U6B6kpKI=; b=UIv7IwjDZhwOmhS2NsG3o4klVqjvEVev0iLQF8GsCkJnBn127TEnmbPcLlZon1OTzc YFyRYKYq+80kE7wH0TWf5ykNMN9duT0t7u6bGba5GyE22VgoFwDfOU2eKjAhW/wOHYie ItTU2lmXF8FOHKtoaYST6YrWs7iN69BfMWXdTTRaZDP3AqgGxGCLV9UPLkeSQVbSU/kt TWck6dHW9TsEiboxI5JgkjEy6POknTm3NCNf3Qa3OD/V+CeX2PNllEPyr9tda3jEXr/H gfPuf38iA35GRlQjwv+IdUo3kBCZV9cq42AI0LOL26UeSkgYGG1x5q37pO+I/FRgGYhM A9HA== X-Gm-Message-State: AE9vXwP6reJlaH+z/M4zrHm8naxQEKBe26vwblltO6bgyxNK529UaTL1eyCQ08d/yBKQgUB0 X-Received: by 10.13.220.1 with SMTP id f1mr19817790ywe.289.1474962498921; Tue, 27 Sep 2016 00:48:18 -0700 (PDT) Received: from localhost ([182.68.8.143]) by smtp.gmail.com with ESMTPSA id g63sm489024ywe.53.2016.09.27.00.48.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Sep 2016 00:48:17 -0700 (PDT) From: Pratyush Anand To: linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com Subject: [PATCH V2 3/6] arm64: Handle TRAP_TRACE for user mode as well Date: Tue, 27 Sep 2016 13:17:57 +0530 Message-Id: X-Mailer: git-send-email 2.7.4 In-Reply-To: References: In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160927_004840_237002_FEF82F77 X-CRM114-Status: GOOD ( 14.20 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: panand@redhat.com, linux@arm.linux.org.uk, srikar@linux.vnet.ibm.com, vijaya.kumar@caviumnetworks.com, will.deacon@arm.com, linux-kernel@vger.kernel.org, oleg@redhat.com, dave.long@linaro.org, steve.capper@linaro.org, wcohen@redhat.com 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 uprobe registers a handler at step_hook. So, single_step_handler now checks for user mode as well if there is a valid hook. Signed-off-by: Pratyush Anand --- arch/arm64/kernel/debug-monitors.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/arch/arm64/kernel/debug-monitors.c b/arch/arm64/kernel/debug-monitors.c index 73ae90ef434c..a8f8de012250 100644 --- a/arch/arm64/kernel/debug-monitors.c +++ b/arch/arm64/kernel/debug-monitors.c @@ -226,6 +226,8 @@ static void send_user_sigtrap(int si_code) static int single_step_handler(unsigned long addr, unsigned int esr, struct pt_regs *regs) { + bool handler_found = false; + /* * If we are stepping a pending breakpoint, call the hw_breakpoint * handler first. @@ -233,7 +235,14 @@ static int single_step_handler(unsigned long addr, unsigned int esr, if (!reinstall_suspended_bps(regs)) return 0; - if (user_mode(regs)) { +#ifdef CONFIG_KPROBES + if (kprobe_single_step_handler(regs, esr) == DBG_HOOK_HANDLED) + handler_found = true; +#endif + if (!handler_found && call_step_hook(regs, esr) == DBG_HOOK_HANDLED) + handler_found = true; + + if (!handler_found && user_mode(regs)) { send_user_sigtrap(TRAP_TRACE); /* @@ -243,15 +252,8 @@ static int single_step_handler(unsigned long addr, unsigned int esr, * to the active-not-pending state). */ user_rewind_single_step(current); - } else { -#ifdef CONFIG_KPROBES - if (kprobe_single_step_handler(regs, esr) == DBG_HOOK_HANDLED) - return 0; -#endif - if (call_step_hook(regs, esr) == DBG_HOOK_HANDLED) - return 0; - - pr_warning("Unexpected kernel single-step exception at EL1\n"); + } else if (!handler_found) { + pr_warn("Unexpected kernel single-step exception at EL1\n"); /* * Re-enable stepping since we know that we will be * returning to regs.