From patchwork Tue May 12 11:48:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maninder Singh X-Patchwork-Id: 6387351 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 428EA9F32B for ; Tue, 12 May 2015 11:51:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6F0A9203B5 for ; Tue, 12 May 2015 11:51:13 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9E28F20382 for ; Tue, 12 May 2015 11:51:12 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Ys8gA-00018p-Tf; Tue, 12 May 2015 11:48:54 +0000 Received: from mailout4.samsung.com ([203.254.224.34]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Ys8g5-00012O-I7 for linux-arm-kernel@lists.infradead.org; Tue, 12 May 2015 11:48:50 +0000 Received: from epcpsbgr4.samsung.com (u144.gpu120.samsung.co.kr [203.254.230.144]) by mailout4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NO800JMIJGDNLA0@mailout4.samsung.com> for linux-arm-kernel@lists.infradead.org; Tue, 12 May 2015 20:48:13 +0900 (KST) Received: from epcpsbgx4.samsung.com ( [172.20.52.126]) by epcpsbgr4.samsung.com (EPCPMTA) with SMTP id 68.15.20564.D78E1555; Tue, 12 May 2015 20:48:13 +0900 (KST) X-AuditID: cbfee690-f796f6d000005054-25-5551e87d2f13 Received: from epmailer02 ( [203.254.219.142]) by epcpsbgx4.samsung.com (EPCPMTA) with SMTP id 9D.CE.25195.D78E1555; Tue, 12 May 2015 20:48:13 +0900 (KST) Date: Tue, 12 May 2015 11:48:13 +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 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 MIME-version: 1.0 Message-id: <1010527489.65391431431292840.JavaMail.weblogic@ep2mlwas02a> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrKIsWRmVeSWpSXmKPExsWyRsSkTrf2RWCowasJKhabHl9jdWD02Lyk PoAxissmJTUnsyy1SN8ugStjxs7Z7AV3RCr+bGlib2CcItLFyMkhJKAmsWjvYzYQW0LARGL2 sq0sELaYxIV764HiXEA1Sxkltu58zAxT1L9iOQtEYg6jxPeOeewgCRYBVYmXGy+B2WwC+hJn 964DaxAW8JZ4NH8fO0iDiEAvo8S8HUvAupkF1jFKHOtrYYG4Q1Fi/Y0njCA2r4CgxMmZT6Du UJH4ffUvUDcHUFxVoq3PGyIsJ7Fk6mUmCJtXYkb7UxaY+LSva6AulZY4P2sDI8w7i7/DfMAv cez2DqheAYmpZw4ygoyXENCUmPtZECLMJ7Fm4VsWmPJdp5Yzw6y6v2UuVKuExNaWJ6wgNjPQ 9VO6H7JD2AYSRxbNYUX1Ccj1HhLHN1aCfC4hMJVD4sPWncwTGJVmISmbhWTULCSjkNUsYGRZ xSia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OFeFMSK6tSi/Lji0pzUosPMZoCI20is5Rocj4wReaV xBsam5ibGptaGBiam5spifP+P5cbIiSQnliSmp2aWpBaBNPHxMEp1cC4MFh4060J1p2Gs9w1 3descf4V1ZzIGPGAMzU3aXl8wCtWRbk0k8NpF+7ca56drNHzIVh500GRrymPNJaw5deHmUYv eqXWyZizYOasE4ZfqyNDjLSO8i/M7FBZmypwKXNDuSonuzvXN5elEzuVLjtdVrR3cn9SNW/X AVuT6vjyjq9PdtzafkmJpTgj0VCLuag4EQD3cTVlWQMAAA== DLP-Filter: Pass X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150512_044849_750481_A9F1992A X-CRM114-Status: GOOD ( 11.81 ) X-Spam-Score: -5.0 (-----) Cc: "v.narang@samsung.com" , AJEET YADAV , AKHILESH KUMAR , Amit Arora X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: maninder1.s@samsung.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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();