lkml.org 
[lkml]   [2016]   [Sep]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 4/5] arm64: Handle TRAP_BRKPT for user mode as well
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

\
 
 \ /
  Last update: 2016-09-17 09:58    [W:0.159 / U:1.476 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site