aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel/hw_breakpoint.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/powerpc/kernel/hw_breakpoint.c')
-rw-r--r--arch/powerpc/kernel/hw_breakpoint.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/arch/powerpc/kernel/hw_breakpoint.c b/arch/powerpc/kernel/hw_breakpoint.c
index 7bd01a56d194..ed39805a3b84 100644
--- a/arch/powerpc/kernel/hw_breakpoint.c
+++ b/arch/powerpc/kernel/hw_breakpoint.c
@@ -204,6 +204,7 @@ int __kprobes hw_breakpoint_handler(struct die_args *args)
204 int stepped = 1; 204 int stepped = 1;
205 struct arch_hw_breakpoint *info; 205 struct arch_hw_breakpoint *info;
206 unsigned int instr; 206 unsigned int instr;
207 unsigned long dar = regs->dar;
207 208
208 /* Disable breakpoints during exception handling */ 209 /* Disable breakpoints during exception handling */
209 set_dabr(0); 210 set_dabr(0);
@@ -234,6 +235,22 @@ int __kprobes hw_breakpoint_handler(struct die_args *args)
234 goto out; 235 goto out;
235 } 236 }
236 237
238 /*
239 * Verify if dar lies within the address range occupied by the symbol
240 * being watched to filter extraneous exceptions.
241 */
242 if (!((bp->attr.bp_addr <= dar) &&
243 (dar <= (bp->attr.bp_addr + bp->attr.bp_len)))) {
244 /*
245 * This exception is triggered not because of a memory access
246 * on the monitored variable but in the double-word address
247 * range in which it is contained. We will consume this
248 * exception, considering it as 'noise'.
249 */
250 info->extraneous_interrupt = true;
251 } else
252 info->extraneous_interrupt = false;
253
237 /* Do not emulate user-space instructions, instead single-step them */ 254 /* Do not emulate user-space instructions, instead single-step them */
238 if (user_mode(regs)) { 255 if (user_mode(regs)) {
239 bp->ctx->task->thread.last_hit_ubp = bp; 256 bp->ctx->task->thread.last_hit_ubp = bp;
@@ -261,7 +278,8 @@ int __kprobes hw_breakpoint_handler(struct die_args *args)
261 * As a policy, the callback is invoked in a 'trigger-after-execute' 278 * As a policy, the callback is invoked in a 'trigger-after-execute'
262 * fashion 279 * fashion
263 */ 280 */
264 perf_bp_event(bp, regs); 281 if (!info->extraneous_interrupt)
282 perf_bp_event(bp, regs);
265 283
266 set_dabr(info->address | info->type | DABR_TRANSLATION); 284 set_dabr(info->address | info->type | DABR_TRANSLATION);
267out: 285out:
@@ -292,7 +310,8 @@ int __kprobes single_step_dabr_instruction(struct die_args *args)
292 * We shall invoke the user-defined callback function in the single 310 * We shall invoke the user-defined callback function in the single
293 * stepping handler to confirm to 'trigger-after-execute' semantics 311 * stepping handler to confirm to 'trigger-after-execute' semantics
294 */ 312 */
295 perf_bp_event(bp, regs); 313 if (!bp_info->extraneous_interrupt)
314 perf_bp_event(bp, regs);
296 315
297 /* 316 /*
298 * Do not disable MSR_SE if the process was already in 317 * Do not disable MSR_SE if the process was already in