Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932620AbbELLsR (ORCPT ); Tue, 12 May 2015 07:48:17 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:59910 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932339AbbELLsP (ORCPT ); Tue, 12 May 2015 07:48:15 -0400 X-AuditID: cbfee68f-f793b6d000005f66-64-5551e87c4088 Date: Tue, 12 May 2015 11:48:12 +0000 (GMT) From: Maninder Singh Subject: [EDT] [PATCH 1/1] Fix: hw watchpoint continually triggers callback To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux@arm.linux.org.uk, will.deacon@arm.com Cc: "v.narang@samsung.com" , AJEET YADAV , Amit Arora , AKHILESH KUMAR Reply-to: maninder1.s@samsung.com MIME-version: 1.0 X-MTR: 20150512114506680@maninder1.s Msgkey: 20150512114506680@maninder1.s X-EPLocale: en_US.windows-1252 X-Priority: 3 X-EPWebmail-Msg-Type: personal X-EPWebmail-Reply-Demand: 0 X-EPApproval-Locale: X-EPHeader: ML X-MLAttribute: X-RootMTR: 20150512114506680@maninder1.s X-ParentMTR: X-ArchiveUser: X-CPGSPASS: N X-ConfirmMail: N,general Content-type: text/plain; charset=windows-1252 MIME-version: 1.0 Message-id: <1010527489.65391431431292840.JavaMail.weblogic@ep2mlwas02a> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrKIsWRmVeSWpSXmKPExsWyRsSkSrf2RWCowaHTrBaXd81hc2D0+LxJ LoAxissmJTUnsyy1SN8ugStjxs7Z7AV3RCr+bGlib2CcItLFyMkhJKAmsWjvYzYQW0LARGLm 97MsELaYxIV764HiXEA1Sxkljp1fwAJTdHzydWaIxBxGif8dd5lBEiwCqhLHZs8Gm8QmoC9x du86sLiwgLfEo/n72EEaRAR6GSXm7VjCAuIwC6wDGtvXwgJxh6LE+htPGEFsXgFBiZMzn0Ct U5H4ffUvUDcHUFxVoq3PGyIsJ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P0sCBHmk1iz8C0LTPmu U8uZYVbd3zIXqlVCYmvLE1YQmxno+indD9khbAOJI4vmsKL6BOR6D4njGysnMMrOQpKZhaR7 FpJuZDULGFlWMYqmFiQXFCelV5joFSfmFpfmpesl5+duYgSnoWdLdjA2XLA+xCjAwajEw9tx yT9UiDWxrLgy9xCjBAezkgjv9vuBoUK8KYmVValF+fFFpTmpxYcYTYGRNpFZSjQ5H5gi80ri DY1NzE2NTS0MDM3NzZTEef+fyw0REkhPLEnNTk0tSC2C6WPi4JRqYHzSrhf/kKH63JyzYSU8 PPuX7TzzOpDr11E71cMSb71dtPvfrpHZ26K4MjdDsr2Evcpkr3BrgtDxiomFK151q9+3fBey 40y7a8W9xcdll7IvV5lnrrM30/t+QLnE2+zba47/idat8b7gJSuR41nl53V7e8zBruVeW+Xz +xIX3PuwY1rmLXf2+UosxRmJhlrMRcWJAB8sJCpZAwAA DLP-Filter: Pass X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by nfs id t4CBmM8D016851 Content-Length: 2095 Lines: 61 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 Signed-off-by: Maninder Singh Reviewed-by: Amit Arora Reviewed-by: Ajeet Yadav --- 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 #include #include +#ifdef CONFIG_KPROBES +#include +#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????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?