Commit a9ad965e authored by bibo, mao's avatar bibo, mao Committed by Linus Torvalds

[PATCH] IA64: kprobe invalidate icache of jump buffer

Kprobe inserts breakpoint instruction in probepoint and then jumps to
instruction slot when breakpoint is hit, the instruction slot icache must
be consistent with dcache.  Here is the patch which invalidates instruction
slot icache area.

Without this patch, in some machines there will be fault when executing
instruction slot where icache content is inconsistent with dcache.
Signed-off-by: default avatarbibo,mao <bibo.mao@intel.com>
Acked-by: default avatar"Luck, Tony" <tony.luck@intel.com>
Acked-by: default avatarKeshavamurthy Anil S <anil.s.keshavamurthy@intel.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 25c8716c
...@@ -448,11 +448,20 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p) ...@@ -448,11 +448,20 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p)
return 0; return 0;
} }
void __kprobes flush_insn_slot(struct kprobe *p)
{
unsigned long arm_addr;
arm_addr = ((unsigned long)&p->opcode.bundle) & ~0xFULL;
flush_icache_range(arm_addr, arm_addr + sizeof(bundle_t));
}
void __kprobes arch_arm_kprobe(struct kprobe *p) void __kprobes arch_arm_kprobe(struct kprobe *p)
{ {
unsigned long addr = (unsigned long)p->addr; unsigned long addr = (unsigned long)p->addr;
unsigned long arm_addr = addr & ~0xFULL; unsigned long arm_addr = addr & ~0xFULL;
flush_insn_slot(p);
memcpy((char *)arm_addr, &p->ainsn.insn.bundle, sizeof(bundle_t)); memcpy((char *)arm_addr, &p->ainsn.insn.bundle, sizeof(bundle_t));
flush_icache_range(arm_addr, arm_addr + sizeof(bundle_t)); flush_icache_range(arm_addr, arm_addr + sizeof(bundle_t));
} }
......
...@@ -45,6 +45,7 @@ typedef u8 kprobe_opcode_t; ...@@ -45,6 +45,7 @@ typedef u8 kprobe_opcode_t;
#define JPROBE_ENTRY(pentry) (kprobe_opcode_t *)pentry #define JPROBE_ENTRY(pentry) (kprobe_opcode_t *)pentry
#define ARCH_SUPPORTS_KRETPROBES #define ARCH_SUPPORTS_KRETPROBES
#define ARCH_INACTIVE_KPROBE_COUNT 0 #define ARCH_INACTIVE_KPROBE_COUNT 0
#define flush_insn_slot(p) do { } while (0)
void arch_remove_kprobe(struct kprobe *p); void arch_remove_kprobe(struct kprobe *p);
void kretprobe_trampoline(void); void kretprobe_trampoline(void);
......
...@@ -125,5 +125,6 @@ static inline void jprobe_return(void) ...@@ -125,5 +125,6 @@ static inline void jprobe_return(void)
} }
extern void invalidate_stacked_regs(void); extern void invalidate_stacked_regs(void);
extern void flush_register_stack(void); extern void flush_register_stack(void);
extern void flush_insn_slot(struct kprobe *p);
#endif /* _ASM_KPROBES_H */ #endif /* _ASM_KPROBES_H */
...@@ -51,6 +51,7 @@ typedef unsigned int kprobe_opcode_t; ...@@ -51,6 +51,7 @@ typedef unsigned int kprobe_opcode_t;
#define ARCH_SUPPORTS_KRETPROBES #define ARCH_SUPPORTS_KRETPROBES
#define ARCH_INACTIVE_KPROBE_COUNT 1 #define ARCH_INACTIVE_KPROBE_COUNT 1
#define flush_insn_slot(p) do { } while (0)
void kretprobe_trampoline(void); void kretprobe_trampoline(void);
extern void arch_remove_kprobe(struct kprobe *p); extern void arch_remove_kprobe(struct kprobe *p);
......
...@@ -13,6 +13,7 @@ typedef u32 kprobe_opcode_t; ...@@ -13,6 +13,7 @@ typedef u32 kprobe_opcode_t;
#define JPROBE_ENTRY(pentry) (kprobe_opcode_t *)pentry #define JPROBE_ENTRY(pentry) (kprobe_opcode_t *)pentry
#define arch_remove_kprobe(p) do {} while (0) #define arch_remove_kprobe(p) do {} while (0)
#define ARCH_INACTIVE_KPROBE_COUNT 0 #define ARCH_INACTIVE_KPROBE_COUNT 0
#define flush_insn_slot(p) do { } while (0)
/* Architecture specific copy of original instruction*/ /* Architecture specific copy of original instruction*/
struct arch_specific_insn { struct arch_specific_insn {
......
...@@ -47,6 +47,7 @@ typedef u8 kprobe_opcode_t; ...@@ -47,6 +47,7 @@ typedef u8 kprobe_opcode_t;
void kretprobe_trampoline(void); void kretprobe_trampoline(void);
extern void arch_remove_kprobe(struct kprobe *p); extern void arch_remove_kprobe(struct kprobe *p);
#define flush_insn_slot(p) do { } while (0)
/* Architecture specific copy of original instruction*/ /* Architecture specific copy of original instruction*/
struct arch_specific_insn { struct arch_specific_insn {
......
...@@ -393,6 +393,7 @@ static int __kprobes add_new_kprobe(struct kprobe *old_p, struct kprobe *p) ...@@ -393,6 +393,7 @@ static int __kprobes add_new_kprobe(struct kprobe *old_p, struct kprobe *p)
static inline void add_aggr_kprobe(struct kprobe *ap, struct kprobe *p) static inline void add_aggr_kprobe(struct kprobe *ap, struct kprobe *p)
{ {
copy_kprobe(p, ap); copy_kprobe(p, ap);
flush_insn_slot(ap);
ap->addr = p->addr; ap->addr = p->addr;
ap->pre_handler = aggr_pre_handler; ap->pre_handler = aggr_pre_handler;
ap->fault_handler = aggr_fault_handler; ap->fault_handler = aggr_fault_handler;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment