|
41 | 41 | #include <asm/switch_to.h>
|
42 | 42 | #include <asm/tm.h>
|
43 | 43 | #include <asm/asm-prototypes.h>
|
| 44 | +#include <asm/debug.h> |
44 | 45 |
|
45 | 46 | #define CREATE_TRACE_POINTS
|
46 | 47 | #include <trace/events/syscalls.h>
|
@@ -2378,6 +2379,7 @@ static int ptrace_set_debugreg(struct task_struct *task, unsigned long addr,
|
2378 | 2379 | struct perf_event_attr attr;
|
2379 | 2380 | #endif /* CONFIG_HAVE_HW_BREAKPOINT */
|
2380 | 2381 | #ifndef CONFIG_PPC_ADV_DEBUG_REGS
|
| 2382 | + bool set_bp = true; |
2381 | 2383 | struct arch_hw_breakpoint hw_brk;
|
2382 | 2384 | #endif
|
2383 | 2385 |
|
@@ -2411,9 +2413,10 @@ static int ptrace_set_debugreg(struct task_struct *task, unsigned long addr,
|
2411 | 2413 | hw_brk.address = data & (~HW_BRK_TYPE_DABR);
|
2412 | 2414 | hw_brk.type = (data & HW_BRK_TYPE_DABR) | HW_BRK_TYPE_PRIV_ALL;
|
2413 | 2415 | hw_brk.len = 8;
|
| 2416 | + set_bp = (data) && (hw_brk.type & HW_BRK_TYPE_RDWR); |
2414 | 2417 | #ifdef CONFIG_HAVE_HW_BREAKPOINT
|
2415 | 2418 | bp = thread->ptrace_bps[0];
|
2416 |
| - if ((!data) || !(hw_brk.type & HW_BRK_TYPE_RDWR)) { |
| 2419 | + if (!set_bp) { |
2417 | 2420 | if (bp) {
|
2418 | 2421 | unregister_hw_breakpoint(bp);
|
2419 | 2422 | thread->ptrace_bps[0] = NULL;
|
@@ -2450,6 +2453,9 @@ static int ptrace_set_debugreg(struct task_struct *task, unsigned long addr,
|
2450 | 2453 | return PTR_ERR(bp);
|
2451 | 2454 | }
|
2452 | 2455 |
|
| 2456 | +#else /* !CONFIG_HAVE_HW_BREAKPOINT */ |
| 2457 | + if (set_bp && (!ppc_breakpoint_available())) |
| 2458 | + return -ENODEV; |
2453 | 2459 | #endif /* CONFIG_HAVE_HW_BREAKPOINT */
|
2454 | 2460 | task->thread.hw_brk = hw_brk;
|
2455 | 2461 | #else /* CONFIG_PPC_ADV_DEBUG_REGS */
|
@@ -2904,6 +2910,9 @@ static long ppc_set_hwdebug(struct task_struct *child,
|
2904 | 2910 | if (child->thread.hw_brk.address)
|
2905 | 2911 | return -ENOSPC;
|
2906 | 2912 |
|
| 2913 | + if (!ppc_breakpoint_available()) |
| 2914 | + return -ENODEV; |
| 2915 | + |
2907 | 2916 | child->thread.hw_brk = brk;
|
2908 | 2917 |
|
2909 | 2918 | return 1;
|
@@ -3052,7 +3061,10 @@ long arch_ptrace(struct task_struct *child, long request,
|
3052 | 3061 | #endif
|
3053 | 3062 | #else /* !CONFIG_PPC_ADV_DEBUG_REGS */
|
3054 | 3063 | dbginfo.num_instruction_bps = 0;
|
3055 |
| - dbginfo.num_data_bps = 1; |
| 3064 | + if (ppc_breakpoint_available()) |
| 3065 | + dbginfo.num_data_bps = 1; |
| 3066 | + else |
| 3067 | + dbginfo.num_data_bps = 0; |
3056 | 3068 | dbginfo.num_condition_regs = 0;
|
3057 | 3069 | #ifdef CONFIG_PPC64
|
3058 | 3070 | dbginfo.data_bp_alignment = 8;
|
|
0 commit comments