diff options
author | Luis Machado <luisgpm@linux.vnet.ibm.com> | 2008-07-23 12:10:41 -0400 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2008-07-25 01:44:39 -0400 |
commit | d6a61bfc06d6f2248f3e75f208d64e794082013c (patch) | |
tree | d46aec6b68e30f9d7d9198bd9102fcf1c054ab7e /arch/powerpc/kernel/process.c | |
parent | 00bf6e906156b07cd641fe154ad0efe78f989692 (diff) |
powerpc: BookE hardware watchpoint support
This patch implements support for HW based watchpoint via the
DBSR_DAC (Data Address Compare) facility of the BookE processors.
It does so by interfacing with the existing DABR breakpoint code
and adding the necessary bits and pieces for the new bits to
be properly set or cleared
Signed-off-by: Luis Machado <luisgpm@br.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc/kernel/process.c')
-rw-r--r-- | arch/powerpc/kernel/process.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c index 219f3634115e..db2497ccc111 100644 --- a/arch/powerpc/kernel/process.c +++ b/arch/powerpc/kernel/process.c | |||
@@ -47,6 +47,8 @@ | |||
47 | #ifdef CONFIG_PPC64 | 47 | #ifdef CONFIG_PPC64 |
48 | #include <asm/firmware.h> | 48 | #include <asm/firmware.h> |
49 | #endif | 49 | #endif |
50 | #include <linux/kprobes.h> | ||
51 | #include <linux/kdebug.h> | ||
50 | 52 | ||
51 | extern unsigned long _get_SP(void); | 53 | extern unsigned long _get_SP(void); |
52 | 54 | ||
@@ -239,6 +241,35 @@ void discard_lazy_cpu_state(void) | |||
239 | } | 241 | } |
240 | #endif /* CONFIG_SMP */ | 242 | #endif /* CONFIG_SMP */ |
241 | 243 | ||
244 | void do_dabr(struct pt_regs *regs, unsigned long address, | ||
245 | unsigned long error_code) | ||
246 | { | ||
247 | siginfo_t info; | ||
248 | |||
249 | if (notify_die(DIE_DABR_MATCH, "dabr_match", regs, error_code, | ||
250 | 11, SIGSEGV) == NOTIFY_STOP) | ||
251 | return; | ||
252 | |||
253 | if (debugger_dabr_match(regs)) | ||
254 | return; | ||
255 | |||
256 | /* Clear the DAC and struct entries. One shot trigger */ | ||
257 | #if (defined(CONFIG_44x) || defined(CONFIG_BOOKE)) | ||
258 | mtspr(SPRN_DBCR0, mfspr(SPRN_DBCR0) & ~(DBSR_DAC1R | DBSR_DAC1W | ||
259 | | DBCR0_IDM)); | ||
260 | #endif | ||
261 | |||
262 | /* Clear the DABR */ | ||
263 | set_dabr(0); | ||
264 | |||
265 | /* Deliver the signal to userspace */ | ||
266 | info.si_signo = SIGTRAP; | ||
267 | info.si_errno = 0; | ||
268 | info.si_code = TRAP_HWBKPT; | ||
269 | info.si_addr = (void __user *)address; | ||
270 | force_sig_info(SIGTRAP, &info, current); | ||
271 | } | ||
272 | |||
242 | static DEFINE_PER_CPU(unsigned long, current_dabr); | 273 | static DEFINE_PER_CPU(unsigned long, current_dabr); |
243 | 274 | ||
244 | int set_dabr(unsigned long dabr) | 275 | int set_dabr(unsigned long dabr) |
@@ -254,6 +285,11 @@ int set_dabr(unsigned long dabr) | |||
254 | #if defined(CONFIG_PPC64) || defined(CONFIG_6xx) | 285 | #if defined(CONFIG_PPC64) || defined(CONFIG_6xx) |
255 | mtspr(SPRN_DABR, dabr); | 286 | mtspr(SPRN_DABR, dabr); |
256 | #endif | 287 | #endif |
288 | |||
289 | #if defined(CONFIG_44x) || defined(CONFIG_BOOKE) | ||
290 | mtspr(SPRN_DAC1, dabr); | ||
291 | #endif | ||
292 | |||
257 | return 0; | 293 | return 0; |
258 | } | 294 | } |
259 | 295 | ||
@@ -337,6 +373,12 @@ struct task_struct *__switch_to(struct task_struct *prev, | |||
337 | if (unlikely(__get_cpu_var(current_dabr) != new->thread.dabr)) | 373 | if (unlikely(__get_cpu_var(current_dabr) != new->thread.dabr)) |
338 | set_dabr(new->thread.dabr); | 374 | set_dabr(new->thread.dabr); |
339 | 375 | ||
376 | #if defined(CONFIG_44x) || defined(CONFIG_BOOKE) | ||
377 | /* If new thread DAC (HW breakpoint) is the same then leave it */ | ||
378 | if (new->thread.dabr) | ||
379 | set_dabr(new->thread.dabr); | ||
380 | #endif | ||
381 | |||
340 | new_thread = &new->thread; | 382 | new_thread = &new->thread; |
341 | old_thread = ¤t->thread; | 383 | old_thread = ¤t->thread; |
342 | 384 | ||
@@ -525,6 +567,10 @@ void flush_thread(void) | |||
525 | if (current->thread.dabr) { | 567 | if (current->thread.dabr) { |
526 | current->thread.dabr = 0; | 568 | current->thread.dabr = 0; |
527 | set_dabr(0); | 569 | set_dabr(0); |
570 | |||
571 | #if defined(CONFIG_44x) || defined(CONFIG_BOOKE) | ||
572 | current->thread.dbcr0 &= ~(DBSR_DAC1R | DBSR_DAC1W); | ||
573 | #endif | ||
528 | } | 574 | } |
529 | } | 575 | } |
530 | 576 | ||