From patchwork Wed Nov 2 09:10:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pratyush Anand X-Patchwork-Id: 9408819 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 5510F60585 for ; Wed, 2 Nov 2016 09:13:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3ADD529F9E for ; Wed, 2 Nov 2016 09:13:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2F4FD29FA4; Wed, 2 Nov 2016 09:13:54 +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 C6ED929F9E for ; Wed, 2 Nov 2016 09:13:53 +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 1c1raZ-0002Wl-I4; Wed, 02 Nov 2016 09:12:07 +0000 Received: from mail-qk0-f172.google.com ([209.85.220.172]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1c1ra1-0002AZ-Vw for linux-arm-kernel@lists.infradead.org; Wed, 02 Nov 2016 09:11:36 +0000 Received: by mail-qk0-f172.google.com with SMTP id x190so8728037qkb.0 for ; Wed, 02 Nov 2016 02:11:13 -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=ZA4qPs7KYvmF1JXYsVqISs4NLODe9WGGYJS/h3/hWIkWsOAiExPZPFatHKMY8l/o33 7kH1CrFzjI20OsQ/EPU/Ee8HXPugbmksHTiynjvbBqC3BULGnOgjsrKp6lHnPJ1fjTyw +vsx4yH5FnTI+mBpvwqvDsOp6QYR3me8NaqxZm5gXeELhrREuUHY9Tm/nVt9bRQkzNUg fTENnAQ+Vt7J9Uwao4jwlrZ/led8tu+LKp9BuC9ASme/fvTHkVwwxgcKJTeUSNLwQuDl yOvzISIpg3KdB5INzUboH8Un1wCiffdSkJdMCNcMtGHPA8k0OgbEMBM/E1UBa1exoJaR DLDg== X-Gm-Message-State: ABUngvdX1iIFAWx2RD+vjA9xR09RX1cONbVH5a2RXVhtrRU6432tcdg1XrGw/+zuxhVxcErY X-Received: by 10.55.27.141 with SMTP id m13mr2484663qkh.28.1478077872776; Wed, 02 Nov 2016 02:11:12 -0700 (PDT) Received: from localhost ([122.180.204.166]) by smtp.gmail.com with ESMTPSA id w8sm627115qtc.3.2016.11.02.02.11.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 02 Nov 2016 02:11:12 -0700 (PDT) From: Pratyush Anand To: linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com Subject: [PATCH V3 3/6] arm64: Handle TRAP_TRACE for user mode as well Date: Wed, 2 Nov 2016 14:40:43 +0530 Message-Id: <40e120135d57be79f36ef70a4adc8ce179c6caed.1478068479.git.panand@redhat.com> 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-20161102_021134_355950_6309359C X-CRM114-Status: GOOD ( 14.54 ) 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, steve.capper@linaro.org, srikar@linux.vnet.ibm.com, vijaya.kumar@caviumnetworks.com, will.deacon@arm.com, linux-kernel@vger.kernel.org, oleg@redhat.com, wcohen@redhat.com, dave.long@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.