aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorK.Prasad <prasad@linux.vnet.ibm.com>2010-06-15 02:06:12 -0400
committerPaul Mackerras <paulus@samba.org>2010-06-22 05:40:51 -0400
commite3e94084adb5610987283367574ebc771e8206e1 (patch)
tree2787caa5a5f657a218d199b7dff8c7dcd326eb7f
parent06532a6743d83fac4b79389fc8c86c88cb4e3302 (diff)
powerpc, hw_breakpoint: Discard extraneous interrupt due to accesses outside symbol length
Many a times, the requested breakpoint length can be less than the fixed breakpoint length i.e. 8 bytes supported by PowerPC 64-bit server (Book III S) processors. This could lead to extraneous interrupts resulting in false breakpoint notifications. This detects and discards such interrupts for non-ptrace requests. We don't change ptrace behaviour to avoid breaking compatability. [Suggestion from Paul Mackerras <paulus@samba.org> to add a new flag in 'struct arch_hw_breakpoint' to identify extraneous interrupts] Signed-off-by: K.Prasad <prasad@linux.vnet.ibm.com> Signed-off-by: Paul Mackerras <paulus@samba.org>
-rw-r--r--arch/powerpc/include/asm/hw_breakpoint.h1
-rw-r--r--arch/powerpc/kernel/hw_breakpoint.c23
2 files changed, 22 insertions, 2 deletions
diff --git a/arch/powerpc/include/asm/hw_breakpoint.h b/arch/powerpc/include/asm/hw_breakpoint.h
index 6576bad1069c..ea87f8ae7bdb 100644
--- a/arch/powerpc/include/asm/hw_breakpoint.h
+++ b/arch/powerpc/include/asm/hw_breakpoint.h
@@ -27,6 +27,7 @@
27#ifdef CONFIG_HAVE_HW_BREAKPOINT 27#ifdef CONFIG_HAVE_HW_BREAKPOINT
28 28
29struct arch_hw_breakpoint { 29struct arch_hw_breakpoint {
30 bool extraneous_interrupt;
30 u8 len; /* length of the target data symbol */ 31 u8 len; /* length of the target data symbol */
31 int type; 32 int type;
32 unsigned long address; 33 unsigned long address;
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