aboutsummaryrefslogtreecommitdiffstats
path: root/arch/ia64/kernel/kprobes.c
diff options
context:
space:
mode:
authorTony Luck <tony.luck@intel.com>2006-11-14 12:33:38 -0500
committerTony Luck <tony.luck@intel.com>2006-12-12 15:00:55 -0500
commit08ed38b68099f2a492196414b08a7f5dd8dc3537 (patch)
tree1be49040ba10db0fefc16a31c4ee13461c50e131 /arch/ia64/kernel/kprobes.c
parent75f6a1de41f90543792403bf0ffb3ead59d0d8cc (diff)
[IA64] enable trap code on slot 1
Because slot 1 of one instr bundle crosses border of two consecutive 8-bytes, kprobe on slot 1 is disabled. This patch enables kprobe on slot1, it only replaces higher 8-bytes of the instruction bundle and changes the exception code to ignore the low 12 bits of the break number (which is across the border in the lower 8-bytes of the bundle). For those instructions which must execute regardless qp bits, kprobe on slot 1 is still disabled. Signed-off-by: bibo,mao <bibo.mao@intel.com> Signed-off-by: Tony Luck <tony.luck@intel.com>
Diffstat (limited to 'arch/ia64/kernel/kprobes.c')
-rw-r--r--arch/ia64/kernel/kprobes.c51
1 files changed, 37 insertions, 14 deletions
diff --git a/arch/ia64/kernel/kprobes.c b/arch/ia64/kernel/kprobes.c
index 76e778951e20..8406d24d516b 100644
--- a/arch/ia64/kernel/kprobes.c
+++ b/arch/ia64/kernel/kprobes.c
@@ -88,6 +88,7 @@ static void __kprobes update_kprobe_inst_flag(uint template, uint slot,
88{ 88{
89 p->ainsn.inst_flag = 0; 89 p->ainsn.inst_flag = 0;
90 p->ainsn.target_br_reg = 0; 90 p->ainsn.target_br_reg = 0;
91 p->ainsn.slot = slot;
91 92
92 /* Check for Break instruction 93 /* Check for Break instruction
93 * Bits 37:40 Major opcode to be zero 94 * Bits 37:40 Major opcode to be zero
@@ -296,12 +297,6 @@ static int __kprobes valid_kprobe_addr(int template, int slot,
296 return -EINVAL; 297 return -EINVAL;
297 } 298 }
298 299
299 if (slot == 1 && bundle_encoding[template][1] != L) {
300 printk(KERN_WARNING "Inserting kprobes on slot #1 "
301 "is not supported\n");
302 return -EINVAL;
303 }
304
305 return 0; 300 return 0;
306} 301}
307 302
@@ -458,23 +453,49 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p)
458 453
459void __kprobes arch_arm_kprobe(struct kprobe *p) 454void __kprobes arch_arm_kprobe(struct kprobe *p)
460{ 455{
461 unsigned long addr = (unsigned long)p->addr; 456 unsigned long arm_addr;
462 unsigned long arm_addr = addr & ~0xFULL; 457 bundle_t *src, *dest;
458
459 arm_addr = ((unsigned long)p->addr) & ~0xFUL;
460 dest = &((kprobe_opcode_t *)arm_addr)->bundle;
461 src = &p->opcode.bundle;
463 462
464 flush_icache_range((unsigned long)p->ainsn.insn, 463 flush_icache_range((unsigned long)p->ainsn.insn,
465 (unsigned long)p->ainsn.insn + sizeof(kprobe_opcode_t)); 464 (unsigned long)p->ainsn.insn + sizeof(kprobe_opcode_t));
466 memcpy((char *)arm_addr, &p->opcode, sizeof(kprobe_opcode_t)); 465 switch (p->ainsn.slot) {
466 case 0:
467 dest->quad0.slot0 = src->quad0.slot0;
468 break;
469 case 1:
470 dest->quad1.slot1_p1 = src->quad1.slot1_p1;
471 break;
472 case 2:
473 dest->quad1.slot2 = src->quad1.slot2;
474 break;
475 }
467 flush_icache_range(arm_addr, arm_addr + sizeof(kprobe_opcode_t)); 476 flush_icache_range(arm_addr, arm_addr + sizeof(kprobe_opcode_t));
468} 477}
469 478
470void __kprobes arch_disarm_kprobe(struct kprobe *p) 479void __kprobes arch_disarm_kprobe(struct kprobe *p)
471{ 480{
472 unsigned long addr = (unsigned long)p->addr; 481 unsigned long arm_addr;
473 unsigned long arm_addr = addr & ~0xFULL; 482 bundle_t *src, *dest;
474 483
484 arm_addr = ((unsigned long)p->addr) & ~0xFUL;
485 dest = &((kprobe_opcode_t *)arm_addr)->bundle;
475 /* p->ainsn.insn contains the original unaltered kprobe_opcode_t */ 486 /* p->ainsn.insn contains the original unaltered kprobe_opcode_t */
476 memcpy((char *) arm_addr, (char *) p->ainsn.insn, 487 src = &p->ainsn.insn->bundle;
477 sizeof(kprobe_opcode_t)); 488 switch (p->ainsn.slot) {
489 case 0:
490 dest->quad0.slot0 = src->quad0.slot0;
491 break;
492 case 1:
493 dest->quad1.slot1_p1 = src->quad1.slot1_p1;
494 break;
495 case 2:
496 dest->quad1.slot2 = src->quad1.slot2;
497 break;
498 }
478 flush_icache_range(arm_addr, arm_addr + sizeof(kprobe_opcode_t)); 499 flush_icache_range(arm_addr, arm_addr + sizeof(kprobe_opcode_t));
479} 500}
480 501
@@ -807,7 +828,9 @@ int __kprobes kprobe_exceptions_notify(struct notifier_block *self,
807 switch(val) { 828 switch(val) {
808 case DIE_BREAK: 829 case DIE_BREAK:
809 /* err is break number from ia64_bad_break() */ 830 /* err is break number from ia64_bad_break() */
810 if (args->err == 0x80200 || args->err == 0x80300 || args->err == 0) 831 if ((args->err >> 12) == (__IA64_BREAK_KPROBE >> 12)
832 || args->err == __IA64_BREAK_JPROBE
833 || args->err == 0)
811 if (pre_kprobes_handler(args)) 834 if (pre_kprobes_handler(args))
812 ret = NOTIFY_STOP; 835 ret = NOTIFY_STOP;
813 break; 836 break;