[PATCH 7/9] uprobes: add arch write opcode hook
From: Rabin Vincent
Date: Sun Oct 14 2012 - 15:23:42 EST
Allow arches to write the opcode with a custom function. ARM needs to
customize the swbp instruction depending on the condition code of the
instruction it replaces.
Signed-off-by: Rabin Vincent <rabin@xxxxxx>
---
include/linux/uprobes.h | 3 +++
kernel/events/uprobes.c | 8 +++++++-
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/include/linux/uprobes.h b/include/linux/uprobes.h
index c3dc5de..35b9490 100644
--- a/include/linux/uprobes.h
+++ b/include/linux/uprobes.h
@@ -131,6 +131,9 @@ extern void arch_uprobe_abort_xol(struct arch_uprobe *aup, struct pt_regs *regs)
extern bool __weak arch_uprobe_ignore(struct arch_uprobe *aup, struct pt_regs *regs);
extern void __weak arch_uprobe_xol_copy(struct arch_uprobe *auprobe, void *vaddr);
extern int __weak arch_uprobes_init(void);
+extern void __weak arch_uprobe_write_opcode(struct arch_uprobe *auprobe,
+ void *vaddr,
+ uprobe_opcode_t opcode);
#else /* !CONFIG_UPROBES */
struct uprobes_state {
};
diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
index 8c52f93..95ea618 100644
--- a/kernel/events/uprobes.c
+++ b/kernel/events/uprobes.c
@@ -203,6 +203,12 @@ bool __weak is_swbp_insn(uprobe_opcode_t *insn)
* have fixed length instructions.
*/
+void __weak arch_uprobe_write_opcode(struct arch_uprobe *auprobe, void *vaddr,
+ uprobe_opcode_t opcode)
+{
+ memcpy(vaddr, &opcode, UPROBE_SWBP_INSN_SIZE);
+}
+
/*
* write_opcode - write the opcode at a given virtual address.
* @auprobe: arch breakpointing information.
@@ -242,7 +248,7 @@ retry:
vaddr_new = kmap_atomic(new_page);
memcpy(vaddr_new, vaddr_old, PAGE_SIZE);
- memcpy(vaddr_new + (vaddr & ~PAGE_MASK), &opcode, UPROBE_SWBP_INSN_SIZE);
+ arch_uprobe_write_opcode(auprobe, vaddr_new + (vaddr & ~PAGE_MASK), opcode);
kunmap_atomic(vaddr_new);
kunmap_atomic(vaddr_old);
--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/