From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751964AbdGYNZp (ORCPT ); Tue, 25 Jul 2017 09:25:45 -0400 Received: from foss.arm.com ([217.140.101.70]:47202 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750861AbdGYNZo (ORCPT ); Tue, 25 Jul 2017 09:25:44 -0400 Date: Tue, 25 Jul 2017 14:25:51 +0100 From: Will Deacon To: Pratyush Anand Cc: linux-arm-kernel@lists.infradead.org, mark.rutland@arm.com, huawei.libin@huawei.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH V2 4/4] arm64: disable irq between breakpoint and step exception Message-ID: <20170725132551.GB28815@arm.com> References: <8f9c3073792c107e3d928e413499572ec75c5175.1499416107.git.panand@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8f9c3073792c107e3d928e413499572ec75c5175.1499416107.git.panand@redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 07, 2017 at 05:34:00PM +0530, Pratyush Anand wrote: > If an interrupt is generated between breakpoint and step handler then > step handler can not get correct step address. This situation can easily > be invoked by samples/hw_breakpoint/data_breakpoint.c. It can also be > reproduced if we insert any printk() statement or dump_stack() in perf > overflow_handler. So, it seems that perf is working fine just luckily. > If the CPU which is handling perf breakpoint handler receives any > interrupt then, perf step handler will not execute sanely. > > This patch improves do_debug_exception() handling, which enforces now, > that exception handler function: > - should return 0 for any software breakpoint and hw > breakpoint/watchpoint handler if it does not expect a single step stage > - should return 1 if it expects single step. > - A single step handler should always return 0. > - All handler should return a -ve error in any other case. > > Now, we can know in do_debug_exception() that whether a step exception > will be followed or not. If there will a step exception then disable > irq. Re-enable it after single step handling. AFAICT, this is only a problem for kernel-mode breakpoints where we end up stepping into the interrupt handler when trying to step over a breakpoint. We'd probably be better off getting all users of kernel step (kprobes, kgdb and perf) to run the step with irqs disabled, but I still have reservations about that: http://lists.infradead.org/pipermail/linux-arm-kernel/2017-May/508066.html http://lists.infradead.org/pipermail/linux-arm-kernel/2017-June/510814.html Wouldn't it be better to follow kprobes/kgdb and have perf run the step with irqs disabled? Will