linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: panand@redhat.com (Pratyush Anand)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC PATCH V2 06/10] arm64: Handle TRAP_HWBRKPT for user mode as well
Date: Thu, 18 Jun 2015 09:28:53 +0530	[thread overview]
Message-ID: <a8c7a05683635bf86a3f90d8e420862950d7ac6c.1434598237.git.panand@redhat.com> (raw)
In-Reply-To: <cover.1434598237.git.panand@redhat.com>

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 <panand@redhat.com>
---
 arch/arm64/kernel/debug-monitors.c | 32 +++++++++++++++-----------------
 1 file changed, 15 insertions(+), 17 deletions(-)

diff --git a/arch/arm64/kernel/debug-monitors.c b/arch/arm64/kernel/debug-monitors.c
index 486ee94304a0..7eb13dcf09fa 100644
--- a/arch/arm64/kernel/debug-monitors.c
+++ b/arch/arm64/kernel/debug-monitors.c
@@ -238,7 +238,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)) {
 		info.si_signo = SIGTRAP;
 		info.si_errno = 0;
 		info.si_code  = TRAP_HWBKPT;
@@ -252,22 +259,13 @@ 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)
-			handler_found = true;
-#endif
-		if (call_step_hook(regs, esr) == DBG_HOOK_HANDLED)
-			handler_found = true;
-
-		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.
-			 */
-			set_regs_spsr_ss(regs);
-		}
+	} else if (!handler_found) {
+		pr_warning("Unexpected kernel single-step exception at EL1\n");
+		/*
+		 * Re-enable stepping since we know that we will be
+		 * returning to regs.
+		 */
+		set_regs_spsr_ss(regs);
 	}
 
 	return 0;
-- 
2.1.0

  parent reply	other threads:[~2015-06-18  3:58 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-18  3:58 [RFC PATCH V2 00/10] ARM64: Uprobe support added Pratyush Anand
2015-06-18  3:58 ` [RFC PATCH V2 01/10] arm64: kprobe: Make prepare and handler function independent of 'struct kprobe' Pratyush Anand
2015-06-18  3:58 ` [RFC PATCH V2 02/10] arm64: fix kgdb_step_brk_fn to ignore other's exception Pratyush Anand
2015-06-18  3:58 ` [RFC PATCH V2 03/10] arm64: include asm-generic/ptrace.h in asm/ptrace.h Pratyush Anand
2015-06-18  3:58 ` [RFC PATCH V2 04/10] arm64: Add helper for link pointer Pratyush Anand
2015-06-18  3:58 ` [RFC PATCH V2 05/10] arm64: Re-factor flush_ptrace_access Pratyush Anand
2015-06-18  3:58 ` Pratyush Anand [this message]
2015-06-18  3:58 ` [RFC PATCH V2 07/10] arm64: Handle TRAP_BRKPT for user mode as well Pratyush Anand
2015-06-18  3:58 ` [RFC PATCH V2 08/10] arm64: rename enum debug_el to enum debug_elx to fix "wrong kind of tag" Pratyush Anand
2015-06-18  3:58 ` [RFC PATCH V2 09/10] arm64: Add uprobe support Pratyush Anand
2015-06-18  3:58 ` [RFC PATCH V2 10/10] arm64: uprobes: check conditions before simulating instructions Pratyush Anand
2015-08-03 11:09 ` [RFC PATCH V2 00/10] ARM64: Uprobe support added Will Deacon
2015-08-03 13:43   ` David Long
2015-08-03 13:45     ` David Long
2015-08-04 15:07       ` William Cohen
2015-08-04 15:36         ` David Long
2015-08-04 15:43         ` David Long

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a8c7a05683635bf86a3f90d8e420862950d7ac6c.1434598237.git.panand@redhat.com \
    --to=panand@redhat.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).