Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752145AbdGaKlZ (ORCPT ); Mon, 31 Jul 2017 06:41:25 -0400 Received: from mail-pg0-f44.google.com ([74.125.83.44]:36073 "EHLO mail-pg0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751884AbdGaKlW (ORCPT ); Mon, 31 Jul 2017 06:41:22 -0400 From: Pratyush Anand To: linux-arm-kernel@lists.infradead.org Cc: mark.rutland@arm.com, will.deacon@arm.com, huawei.libin@huawei.com, takahiro.akashi@linaro.org, Pratyush Anand , linux-kernel@vger.kernel.org Subject: [PATCH v3 5/5] arm64: fault: re-enable irq if it was disabled for single stepping Date: Mon, 31 Jul 2017 16:10:33 +0530 Message-Id: <9975fac37c34fcc83a43fc797d0dbf7e463a038f.1501496603.git.panand@redhat.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1505 Lines: 48 We disable irq before single stepping and re-enable it after it. However, if stepped instruction will cause a fault then we will enter into fault handler with interrupt disabled, which is not desired. But, we should be safe if we re-enable interrupt in fault handler if it was disabled for single stepping. Signed-off-by: Pratyush Anand --- arch/arm64/mm/fault.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c index ce5290dacba3..2b88807eb964 100644 --- a/arch/arm64/mm/fault.c +++ b/arch/arm64/mm/fault.c @@ -589,6 +589,8 @@ static const struct fault_info fault_info[] = { { do_bad, SIGBUS, 0, "unknown 63" }, }; +static DEFINE_PER_CPU(bool, irq_enable_needed); + /* * Dispatch a data abort to the relevant handler. */ @@ -597,6 +599,12 @@ asmlinkage void __exception do_mem_abort(unsigned long addr, unsigned int esr, { const struct fault_info *inf = esr_to_fault_info(esr); struct siginfo info; + bool *irq_en_needed = this_cpu_ptr(&irq_enable_needed); + + if (*irq_en_needed) { + regs->pstate &= ~PSR_I_BIT; + *irq_en_needed = false; + } if (!inf->fn(addr, esr, regs)) return; @@ -672,8 +680,6 @@ void __init hook_debug_fault_code(int nr, debug_fault_info[nr].name = name; } -static DEFINE_PER_CPU(bool, irq_enable_needed); - asmlinkage int __exception do_debug_exception(unsigned long addr, unsigned int esr, struct pt_regs *regs) -- 2.9.4