debug-monitors.c (946e0f6ffcaa614012d646f4cf84efdd62628c8b) debug-monitors.c (2dd0e8d2d2a157dbc83295a78336c2217110f2f8)
1/*
2 * ARMv8 single-step debug support and mdscr context switching.
3 *
4 * Copyright (C) 2012 ARM Limited
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.

--- 9 unchanged lines hidden (view full) ---

18 * Author: Will Deacon <will.deacon@arm.com>
19 */
20
21#include <linux/cpu.h>
22#include <linux/debugfs.h>
23#include <linux/hardirq.h>
24#include <linux/init.h>
25#include <linux/ptrace.h>
1/*
2 * ARMv8 single-step debug support and mdscr context switching.
3 *
4 * Copyright (C) 2012 ARM Limited
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.

--- 9 unchanged lines hidden (view full) ---

18 * Author: Will Deacon <will.deacon@arm.com>
19 */
20
21#include <linux/cpu.h>
22#include <linux/debugfs.h>
23#include <linux/hardirq.h>
24#include <linux/init.h>
25#include <linux/ptrace.h>
26#include <linux/kprobes.h>
26#include <linux/stat.h>
27#include <linux/uaccess.h>
28
29#include <asm/cpufeature.h>
30#include <asm/cputype.h>
31#include <asm/debug-monitors.h>
32#include <asm/system_misc.h>
33

--- 227 unchanged lines hidden (view full) ---

261 /*
262 * ptrace will disable single step unless explicitly
263 * asked to re-enable it. For other clients, it makes
264 * sense to leave it enabled (i.e. rewind the controls
265 * to the active-not-pending state).
266 */
267 user_rewind_single_step(current);
268 } else {
27#include <linux/stat.h>
28#include <linux/uaccess.h>
29
30#include <asm/cpufeature.h>
31#include <asm/cputype.h>
32#include <asm/debug-monitors.h>
33#include <asm/system_misc.h>
34

--- 227 unchanged lines hidden (view full) ---

262 /*
263 * ptrace will disable single step unless explicitly
264 * asked to re-enable it. For other clients, it makes
265 * sense to leave it enabled (i.e. rewind the controls
266 * to the active-not-pending state).
267 */
268 user_rewind_single_step(current);
269 } else {
270#ifdef CONFIG_KPROBES
271 if (kprobe_single_step_handler(regs, esr) == DBG_HOOK_HANDLED)
272 return 0;
273#endif
269 if (call_step_hook(regs, esr) == DBG_HOOK_HANDLED)
270 return 0;
271
272 pr_warning("Unexpected kernel single-step exception at EL1\n");
273 /*
274 * Re-enable stepping since we know that we will be
275 * returning to regs.
276 */

--- 40 unchanged lines hidden (view full) ---

317 return fn ? fn(regs, esr) : DBG_HOOK_ERROR;
318}
319
320static int brk_handler(unsigned long addr, unsigned int esr,
321 struct pt_regs *regs)
322{
323 if (user_mode(regs)) {
324 send_user_sigtrap(TRAP_BRKPT);
274 if (call_step_hook(regs, esr) == DBG_HOOK_HANDLED)
275 return 0;
276
277 pr_warning("Unexpected kernel single-step exception at EL1\n");
278 /*
279 * Re-enable stepping since we know that we will be
280 * returning to regs.
281 */

--- 40 unchanged lines hidden (view full) ---

322 return fn ? fn(regs, esr) : DBG_HOOK_ERROR;
323}
324
325static int brk_handler(unsigned long addr, unsigned int esr,
326 struct pt_regs *regs)
327{
328 if (user_mode(regs)) {
329 send_user_sigtrap(TRAP_BRKPT);
325 } else if (call_break_hook(regs, esr) != DBG_HOOK_HANDLED) {
326 pr_warning("Unexpected kernel BRK exception at EL1\n");
330 }
331#ifdef CONFIG_KPROBES
332 else if ((esr & BRK64_ESR_MASK) == BRK64_ESR_KPROBES) {
333 if (kprobe_breakpoint_handler(regs, esr) != DBG_HOOK_HANDLED)
334 return -EFAULT;
335 }
336#endif
337 else if (call_break_hook(regs, esr) != DBG_HOOK_HANDLED) {
338 pr_warn("Unexpected kernel BRK exception at EL1\n");
327 return -EFAULT;
328 }
329
330 return 0;
331}
332
333int aarch32_break_handler(struct pt_regs *regs)
334{

--- 94 unchanged lines hidden ---
339 return -EFAULT;
340 }
341
342 return 0;
343}
344
345int aarch32_break_handler(struct pt_regs *regs)
346{

--- 94 unchanged lines hidden ---