From: maninder1.s@samsung.com (Maninder Singh)
To: linux-arm-kernel@lists.infradead.org
Subject: [EDT] [PATCH 1/1] Fix: hw watchpoint continually triggers callback
Date: Tue, 12 May 2015 11:48:13 +0000 (GMT) [thread overview]
Message-ID: <1010527489.65391431431292840.JavaMail.weblogic@ep2mlwas02a> (raw)
EP-2DAD0AFA905A4ACB804C4F82A001242F
On ARM, when a watchpoint is registered using register_wide_hw_breakpoint,
the callback handler endlessly runs until the watchpoint is unregistered.
The reason for this issue is debug interrupts gets raised before executing the instruction,
and after interrupt handling ARM tries to execute the same instruction again , which results
in interrupt getting raised again.
This patch fixes this issue by using KPROBES (getting the instruction executed and incrementing PC
to next instruction).
Signed-off-by: Vaneet Narang <v.narang@samsung.com>
Signed-off-by: Maninder Singh <maninder1.s@samsung.com>
Reviewed-by: Amit Arora <amit.arora@samsung.com>
Reviewed-by: Ajeet Yadav <ajeet.y@samsung.com>
---
arch/arm/kernel/hw_breakpoint.c | 18 ++++++++++++++++++
1 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/arch/arm/kernel/hw_breakpoint.c b/arch/arm/kernel/hw_breakpoint.c
index dc7d0a9..ec72f86 100644
--- a/arch/arm/kernel/hw_breakpoint.c
+++ b/arch/arm/kernel/hw_breakpoint.c
@@ -37,6 +37,9 @@
#include <asm/hw_breakpoint.h>
#include <asm/kdebug.h>
#include <asm/traps.h>
+#ifdef CONFIG_KPROBES
+#include <linux/kprobes.h>
+#endif
/* Breakpoint currently in use for each BRP. */
static DEFINE_PER_CPU(struct perf_event *, bp_on_reg[ARM_MAX_BRP]);
@@ -757,6 +760,21 @@ static void watchpoint_handler(unsigned long addr, unsigned int fsr,
*/
if (!wp->overflow_handler)
enable_single_step(wp, instruction_pointer(regs));
+#ifdef CONFIG_KPROBES
+ else {
+ struct kprobe kp;
+ unsigned long flags;
+
+ arch_uninstall_hw_breakpoint(wp);
+ kp.addr = (kprobe_opcode_t *)instruction_pointer(regs);
+ if (!arch_prepare_kprobe(&kp)) {
+ local_irq_save(flags);
+ kp.ainsn.insn_singlestep(&kp, regs);
+ local_irq_restore(flags);
+ }
+ arch_install_hw_breakpoint(wp);
+ }
+#endif
unlock:
rcu_read_unlock();
--
1.7.1
Thanks ,
Maninder Singh
next reply other threads:[~2015-05-12 11:48 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-12 11:48 Maninder Singh [this message]
2015-05-12 12:45 ` [EDT] [PATCH 1/1] Fix: hw watchpoint continually triggers callback Will Deacon
[not found] <1680595986.99931431494070231.JavaMail.weblogic@ep2mlwas08c>
2015-05-13 16:04 ` Will Deacon
[not found] <939613287.351841431955025734.JavaMail.weblogic@ep2mlwas08c>
2015-05-20 18:02 ` Will Deacon
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=1010527489.65391431431292840.JavaMail.weblogic@ep2mlwas02a \
--to=maninder1.s@samsung.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).