diff options
author | Keshavamurthy Anil S <anil.s.keshavamurthy@intel.com> | 2005-09-06 18:19:35 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-09-07 19:58:01 -0400 |
commit | deac66ae454cacf942c051b86d9232af546fb187 (patch) | |
tree | 17a72e7a2dcf2d1a93a6afdef661f290b1888f1c /arch/ia64/kernel/kprobes.c | |
parent | bce0649417d6e71f6df8ab7b11103d247913b142 (diff) |
[PATCH] kprobes: fix bug when probed on task and isr functions
This patch fixes a race condition where in system used to hang or sometime
crash within minutes when kprobes are inserted on ISR routine and a task
routine.
The fix has been stress tested on i386, ia64, pp64 and on x86_64. To
reproduce the problem insert kprobes on schedule() and do_IRQ() functions
and you should see hang or system crash.
Signed-off-by: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
Signed-off-by: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Acked-by: Prasanna S Panchamukhi <prasanna@in.ibm.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/ia64/kernel/kprobes.c')
-rw-r--r-- | arch/ia64/kernel/kprobes.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/arch/ia64/kernel/kprobes.c b/arch/ia64/kernel/kprobes.c index 4b1bd539ec47..471086b808a4 100644 --- a/arch/ia64/kernel/kprobes.c +++ b/arch/ia64/kernel/kprobes.c | |||
@@ -95,6 +95,17 @@ static void __kprobes update_kprobe_inst_flag(uint template, uint slot, | |||
95 | p->ainsn.inst_flag = 0; | 95 | p->ainsn.inst_flag = 0; |
96 | p->ainsn.target_br_reg = 0; | 96 | p->ainsn.target_br_reg = 0; |
97 | 97 | ||
98 | /* Check for Break instruction | ||
99 | * Bits 37:40 Major opcode to be zero | ||
100 | * Bits 27:32 X6 to be zero | ||
101 | * Bits 32:35 X3 to be zero | ||
102 | */ | ||
103 | if ((!major_opcode) && (!((kprobe_inst >> 27) & 0x1FF)) ) { | ||
104 | /* is a break instruction */ | ||
105 | p->ainsn.inst_flag |= INST_FLAG_BREAK_INST; | ||
106 | return; | ||
107 | } | ||
108 | |||
98 | if (bundle_encoding[template][slot] == B) { | 109 | if (bundle_encoding[template][slot] == B) { |
99 | switch (major_opcode) { | 110 | switch (major_opcode) { |
100 | case INDIRECT_CALL_OPCODE: | 111 | case INDIRECT_CALL_OPCODE: |
@@ -542,8 +553,11 @@ static void __kprobes prepare_ss(struct kprobe *p, struct pt_regs *regs) | |||
542 | unsigned long bundle_addr = (unsigned long) &p->opcode.bundle; | 553 | unsigned long bundle_addr = (unsigned long) &p->opcode.bundle; |
543 | unsigned long slot = (unsigned long)p->addr & 0xf; | 554 | unsigned long slot = (unsigned long)p->addr & 0xf; |
544 | 555 | ||
545 | /* Update instruction pointer (IIP) and slot number (IPSR.ri) */ | 556 | /* single step inline if break instruction */ |
546 | regs->cr_iip = bundle_addr & ~0xFULL; | 557 | if (p->ainsn.inst_flag == INST_FLAG_BREAK_INST) |
558 | regs->cr_iip = (unsigned long)p->addr & ~0xFULL; | ||
559 | else | ||
560 | regs->cr_iip = bundle_addr & ~0xFULL; | ||
547 | 561 | ||
548 | if (slot > 2) | 562 | if (slot > 2) |
549 | slot = 0; | 563 | slot = 0; |
@@ -599,7 +613,9 @@ static int __kprobes pre_kprobes_handler(struct die_args *args) | |||
599 | if (kprobe_running()) { | 613 | if (kprobe_running()) { |
600 | p = get_kprobe(addr); | 614 | p = get_kprobe(addr); |
601 | if (p) { | 615 | if (p) { |
602 | if (kprobe_status == KPROBE_HIT_SS) { | 616 | if ( (kprobe_status == KPROBE_HIT_SS) && |
617 | (p->ainsn.inst_flag == INST_FLAG_BREAK_INST)) { | ||
618 | ia64_psr(regs)->ss = 0; | ||
603 | unlock_kprobes(); | 619 | unlock_kprobes(); |
604 | goto no_kprobe; | 620 | goto no_kprobe; |
605 | } | 621 | } |