From: Pratyush Anand <panand@redhat.com>
To: linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com
Cc: will.deacon@arm.com, linux-kernel@vger.kernel.org,
wcohen@redhat.com, oleg@redhat.com, dave.long@redhat.com,
steve.capper@linaro.org, srikar@linux.vnet.ibm.com,
vijaya.kumar@caviumnetworks.com, panand@redhat.com
Subject: [PATCH V3 4/6] arm64: Handle TRAP_BRKPT for user mode as well
Date: Wed, 2 Nov 2016 14:40:44 +0530 [thread overview]
Message-ID: <9cf3a89ff215155b355e65da7061dfa736b9a012.1478068479.git.panand@redhat.com> (raw)
In-Reply-To: <cover.1478068479.git.panand@redhat.com>
In-Reply-To: <cover.1478068479.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 | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/arch/arm64/kernel/debug-monitors.c b/arch/arm64/kernel/debug-monitors.c
index a8f8de012250..605df76f0a06 100644
--- a/arch/arm64/kernel/debug-monitors.c
+++ b/arch/arm64/kernel/debug-monitors.c
@@ -306,16 +306,20 @@ NOKPROBE_SYMBOL(call_break_hook);
static int brk_handler(unsigned long addr, unsigned int esr,
struct pt_regs *regs)
{
- if (user_mode(regs)) {
- send_user_sigtrap(TRAP_BRKPT);
- }
+ bool handler_found = false;
+
#ifdef CONFIG_KPROBES
- else if ((esr & BRK64_ESR_MASK) == BRK64_ESR_KPROBES) {
- if (kprobe_breakpoint_handler(regs, esr) != DBG_HOOK_HANDLED)
- return -EFAULT;
+ if ((esr & BRK64_ESR_MASK) == BRK64_ESR_KPROBES) {
+ if (kprobe_breakpoint_handler(regs, esr) == DBG_HOOK_HANDLED)
+ handler_found = true;
}
#endif
- else if (call_break_hook(regs, esr) != DBG_HOOK_HANDLED) {
+ if (!handler_found && call_break_hook(regs, esr) == DBG_HOOK_HANDLED)
+ handler_found = true;
+
+ if (!handler_found && user_mode(regs)) {
+ send_user_sigtrap(TRAP_BRKPT);
+ } else if (!handler_found) {
pr_warn("Unexpected kernel BRK exception at EL1\n");
return -EFAULT;
}
--
2.7.4
next prev parent reply other threads:[~2016-11-02 9:11 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-02 9:10 [PATCH V3 0/6] ARM64: Uprobe support added Pratyush Anand
2016-11-02 9:10 ` [PATCH V3 1/6] arm64: kprobe: protect/rename few definitions to be reused by uprobe Pratyush Anand
2016-11-02 9:10 ` [PATCH V3 2/6] arm64: kgdb_step_brk_fn: ignore other's exception Pratyush Anand
[not found] ` <CAMNZz5Bjr1f-uzgCx-svFXV_u8xfKudChURVULAqFzu158cxfg@mail.gmail.com>
2016-11-02 10:14 ` Pratyush Anand
2016-11-02 9:10 ` [PATCH V3 3/6] arm64: Handle TRAP_TRACE for user mode as well Pratyush Anand
2016-11-02 9:10 ` Pratyush Anand [this message]
2016-11-02 9:10 ` [PATCH V3 5/6] arm64: introduce mm context flag to keep 32 bit task information Pratyush Anand
2016-11-02 9:10 ` [PATCH V3 6/6] arm64: Add uprobe support Pratyush Anand
2016-11-04 17:49 ` [PATCH V3 0/6] ARM64: Uprobe support added Catalin Marinas
2016-11-04 18:46 ` Catalin Marinas
2016-11-05 5:31 ` Pratyush Anand
2016-11-07 11:39 ` Catalin Marinas
2016-11-07 17:33 ` Pratyush Anand
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=9cf3a89ff215155b355e65da7061dfa736b9a012.1478068479.git.panand@redhat.com \
--to=panand@redhat.com \
--cc=catalin.marinas@arm.com \
--cc=dave.long@redhat.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=oleg@redhat.com \
--cc=srikar@linux.vnet.ibm.com \
--cc=steve.capper@linaro.org \
--cc=vijaya.kumar@caviumnetworks.com \
--cc=wcohen@redhat.com \
--cc=will.deacon@arm.com \
/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
all inboxes | Powered by JetHome®