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 07/10] arm64: Handle TRAP_BRKPT for user mode as well
Date: Thu, 18 Jun 2015 09:28:54 +0530	[thread overview]
Message-ID: <89bd3896c313cc803b108da3328b38e55d813a33.1434598237.git.panand@redhat.com> (raw)
In-Reply-To: <cover.1434598237.git.panand@redhat.com>

uprobe is registered at break_hook with a unique ESR code. So, when a
TRAP_BRKPT occurs, call_break_hook checks if it was for uprobe. If not,
then send a SIGTRAP to user.

Signed-off-by: Pratyush Anand <panand@redhat.com>
---
 arch/arm64/kernel/debug-monitors.c | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/arch/arm64/kernel/debug-monitors.c b/arch/arm64/kernel/debug-monitors.c
index 7eb13dcf09fa..1fe912e77f62 100644
--- a/arch/arm64/kernel/debug-monitors.c
+++ b/arch/arm64/kernel/debug-monitors.c
@@ -311,8 +311,18 @@ static int brk_handler(unsigned long addr, unsigned int esr,
 		       struct pt_regs *regs)
 {
 	siginfo_t info;
+	bool handler_found = false;
+
+#ifdef	CONFIG_KPROBES
+	if ((esr & BRK64_ESR_MASK) == BRK64_ESR_KPROBES) {
+		if (kprobe_breakpoint_handler(regs, esr) == DBG_HOOK_HANDLED)
+			handler_found = true;
+	}
+#endif
+	if (!handler_found && call_break_hook(regs, esr) == DBG_HOOK_HANDLED)
+		handler_found = true;
 
-	if (user_mode(regs)) {
+	if (!handler_found && user_mode(regs)) {
 		info = (siginfo_t) {
 			.si_signo = SIGTRAP,
 			.si_errno = 0,
@@ -321,15 +331,8 @@ static int brk_handler(unsigned long addr, unsigned int esr,
 		};
 
 		force_sig_info(SIGTRAP, &info, current);
-	}
-#ifdef	CONFIG_KPROBES
-	else if ((esr & BRK64_ESR_MASK) == BRK64_ESR_KPROBES) {
-		if (kprobe_breakpoint_handler(regs, esr) != DBG_HOOK_HANDLED)
-			return -EFAULT;
-	}
-#endif
-	else if (call_break_hook(regs, esr) != DBG_HOOK_HANDLED) {
-		pr_warn("Unexpected kernel BRK exception at EL1\n");
+	} else if (!handler_found) {
+		pr_warning("Unexpected kernel BRK exception at EL1\n");
 		return -EFAULT;
 	}
 
-- 
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 ` [RFC PATCH V2 06/10] arm64: Handle TRAP_HWBRKPT for user mode as well Pratyush Anand
2015-06-18  3:58 ` Pratyush Anand [this message]
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=89bd3896c313cc803b108da3328b38e55d813a33.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).