From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936228AbcIFQek (ORCPT ); Tue, 6 Sep 2016 12:34:40 -0400 Received: from foss.arm.com ([217.140.101.70]:57910 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935027AbcIFQek (ORCPT ); Tue, 6 Sep 2016 12:34:40 -0400 Date: Tue, 6 Sep 2016 17:34:34 +0100 From: Catalin Marinas To: Pratyush Anand Cc: linux-arm-kernel@lists.infradead.org, linux@arm.linux.org.uk, will.deacon@arm.com, Yang Shi , steve.capper@linaro.org, srikar@linux.vnet.ibm.com, Suzuki K Poulose , vijaya.kumar@caviumnetworks.com, linux-kernel@vger.kernel.org, oleg@redhat.com, dave.long@linaro.org, Sandeepa Prabhu , wcohen@redhat.com Subject: Re: [PATCH 4/5] arm64: Handle TRAP_BRKPT for user mode as well Message-ID: <20160906163434.GH19605@e104818-lin.cambridge.arm.com> References: <9737ec351e2f9f2e7472d8d7133568f7915f20aa.1470114993.git.panand@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9737ec351e2f9f2e7472d8d7133568f7915f20aa.1470114993.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 Tue, Aug 02, 2016 at 11:00:08AM +0530, Pratyush Anand wrote: > --- a/arch/arm64/kernel/debug-monitors.c > +++ b/arch/arm64/kernel/debug-monitors.c > @@ -326,16 +326,20 @@ NOKPROBE_SYMBOL(call_break_hook); > static int brk_handler(unsigned long addr, unsigned int esr, > struct pt_regs *regs) > { > - if (user_mode(regs)) { > - send_user_sigtrap(TRAP_BRKPT); > - } > + bool handler_found = false; > + > #ifdef CONFIG_KPROBES > - else if ((esr & BRK64_ESR_MASK) == BRK64_ESR_KPROBES) { > - if (kprobe_breakpoint_handler(regs, esr) != DBG_HOOK_HANDLED) > - return -EFAULT; > + if ((esr & BRK64_ESR_MASK) == BRK64_ESR_KPROBES) { > + if (kprobe_breakpoint_handler(regs, esr) == DBG_HOOK_HANDLED) > + handler_found = true; > } > #endif > - else if (call_break_hook(regs, esr) != DBG_HOOK_HANDLED) { > + if (!handler_found && call_break_hook(regs, esr) == DBG_HOOK_HANDLED) > + handler_found = true; > + > + if (!handler_found && user_mode(regs)) { > + send_user_sigtrap(TRAP_BRKPT); > + } else if (!handler_found) { > pr_warn("Unexpected kernel BRK exception at EL1\n"); > return -EFAULT; > } I think we could do the same here with a single call_break_hook() and making sure that the corresponding handlers check the esr for the corresponding BRK encoding. -- Catalin