From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752542AbdHBRO6 (ORCPT ); Wed, 2 Aug 2017 13:14:58 -0400 Received: from foss.arm.com ([217.140.101.70]:57754 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751197AbdHBROf (ORCPT ); Wed, 2 Aug 2017 13:14:35 -0400 Message-ID: <59820835.1020301@arm.com> Date: Wed, 02 Aug 2017 18:13:25 +0100 From: James Morse User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.6.0 MIME-Version: 1.0 To: Pratyush Anand CC: mark.rutland@arm.com, Alexander Shishkin , will.deacon@arm.com, linux-kernel@vger.kernel.org, Arnaldo Carvalho de Melo , takahiro.akashi@linaro.org, Peter Zijlstra , Ingo Molnar , huawei.libin@huawei.com, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v3 0/5] ARM64: disable irq between breakpoint and step exception References: <597F65BD.3070200@arm.com> In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Pratyush, On 01/08/17 05:18, Pratyush Anand wrote: > On Monday 31 July 2017 10:45 PM, James Morse wrote: >> On 31/07/17 11:40, Pratyush Anand wrote: >>> samples/hw_breakpoint/data_breakpoint.c passes with x86_64 but fails with >>> ARM64. Even though it has been NAKed previously on upstream [1, 2], I have >>> tried to come up with patches which can resolve it for ARM64 as well. >>> >>> I noticed that even perf step exception can go into an infinite loop if CPU >>> receives an interrupt while executing breakpoint/watchpoint handler. So, >>> event though we are not concerned about above test, we will have to find a >>> solution for the perf issue. > You can easily reproduce the issue with following: > # insmod data_breakpoint.ko ksym=__sysrq_enabled > # cat /proc/sys/kernel/sysrq Thanks, that happily dump-stacks forever. Your first three patches fix the stepping over the watchpoint, I've had a go at fixing the interrupt interaction, (instead of just masking interrupts). gdb single-step works, as does kprobes, FWIW for those three: Tested-by: James Morse >> What causes your infinite loop? > Flow is like this: > - A SW or HW breakpoint exception is being generated on a cpu lets say CPU5 > - Breakpoint handler does something which causes an interrupt to be active on > the same CPU. In fact there might be many other reasons for an interrupt to be > active on a CPU while breakpoint handler was being executed. > - So, as soon as we return from breakpoint exception, we go to the IRQ exception > handler, while we were expecting a single step exception. What breaks when this happens? With your reproducer and the first three patches I see it hitting the watchpoint multiple times and stepping the irq handler. I think we have two or three interacting bugs here. I'm not convinced masking interrupts is the best fix as the data abort handler inherits this value. We might mask interrupts for a fault that can't be handled with interrupts masked. I will post some RFC/fixes, but need to get my head round the debug/exception interaction in the ARM-ARM first! Thanks, James