summaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorSrikar Dronamraju <srikar@linux.vnet.ibm.com>2012-02-22 14:46:02 +0530
committerIngo Molnar <mingo@elte.hu>2012-02-22 11:26:09 +0100
commit3ff54efdfaace9e9b2b7c1959a865be6b91de96c (patch)
tree6218c7b40bd80704d059d5f3fa434974e675b070 /kernel
parent96379f60075c75b261328aa7830ef8aa158247ac (diff)
downloadop-kernel-dev-3ff54efdfaace9e9b2b7c1959a865be6b91de96c.zip
op-kernel-dev-3ff54efdfaace9e9b2b7c1959a865be6b91de96c.tar.gz
uprobes/core: Move insn to arch specific structure
Few cleanups suggested by Ingo Molnar. - Rename struct uprobe_arch_info to struct arch_uprobe. - Move insn from struct uprobe to struct arch_uprobe. - Make arch specific uprobe functions to accept struct arch_uprobe instead of struct uprobe. - Move struct uprobe to kernel/uprobes.c from include/linux/uprobes.h Signed-off-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Oleg Nesterov <oleg@redhat.com> Cc: Christoph Hellwig <hch@infradead.org> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Cc: Anton Arapov <anton@redhat.com> Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com> Cc: Jim Keniston <jkenisto@linux.vnet.ibm.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Josh Stone <jistone@redhat.com> Link: http://lkml.kernel.org/r/20120222091602.15880.40249.sendpatchset@srdronam.in.ibm.com [ Made various small improvements ] Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/events/uprobes.c38
1 files changed, 26 insertions, 12 deletions
diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
index ee496ad..13f1b59 100644
--- a/kernel/events/uprobes.c
+++ b/kernel/events/uprobes.c
@@ -65,6 +65,18 @@ struct vma_info {
loff_t vaddr;
};
+struct uprobe {
+ struct rb_node rb_node; /* node in the rb tree */
+ atomic_t ref;
+ struct rw_semaphore consumer_rwsem;
+ struct list_head pending_list;
+ struct uprobe_consumer *consumers;
+ struct inode *inode; /* Also hold a ref to inode */
+ loff_t offset;
+ int flags;
+ struct arch_uprobe arch;
+};
+
/*
* valid_vma: Verify if the specified vma is an executable vma
* Relax restrictions while unregistering: vm_flags might have
@@ -180,7 +192,7 @@ bool __weak is_bkpt_insn(uprobe_opcode_t *insn)
/*
* write_opcode - write the opcode at a given virtual address.
* @mm: the probed process address space.
- * @uprobe: the breakpointing information.
+ * @arch_uprobe: the breakpointing information.
* @vaddr: the virtual address to store the opcode.
* @opcode: opcode to be written at @vaddr.
*
@@ -190,13 +202,14 @@ bool __weak is_bkpt_insn(uprobe_opcode_t *insn)
* For mm @mm, write the opcode at @vaddr.
* Return 0 (success) or a negative errno.
*/
-static int write_opcode(struct mm_struct *mm, struct uprobe *uprobe,
+static int write_opcode(struct mm_struct *mm, struct arch_uprobe *auprobe,
unsigned long vaddr, uprobe_opcode_t opcode)
{
struct page *old_page, *new_page;
struct address_space *mapping;
void *vaddr_old, *vaddr_new;
struct vm_area_struct *vma;
+ struct uprobe *uprobe;
loff_t addr;
int ret;
@@ -216,6 +229,7 @@ static int write_opcode(struct mm_struct *mm, struct uprobe *uprobe,
if (!valid_vma(vma, is_bkpt_insn(&opcode)))
goto put_out;
+ uprobe = container_of(auprobe, struct uprobe, arch);
mapping = uprobe->inode->i_mapping;
if (mapping != vma->vm_file->f_mapping)
goto put_out;
@@ -326,7 +340,7 @@ static int is_bkpt_at_addr(struct mm_struct *mm, unsigned long vaddr)
* For mm @mm, store the breakpoint instruction at @vaddr.
* Return 0 (success) or a negative errno.
*/
-int __weak set_bkpt(struct mm_struct *mm, struct uprobe *uprobe, unsigned long vaddr)
+int __weak set_bkpt(struct mm_struct *mm, struct arch_uprobe *auprobe, unsigned long vaddr)
{
int result;
@@ -337,7 +351,7 @@ int __weak set_bkpt(struct mm_struct *mm, struct uprobe *uprobe, unsigned long v
if (result)
return result;
- return write_opcode(mm, uprobe, vaddr, UPROBES_BKPT_INSN);
+ return write_opcode(mm, auprobe, vaddr, UPROBES_BKPT_INSN);
}
/**
@@ -351,7 +365,7 @@ int __weak set_bkpt(struct mm_struct *mm, struct uprobe *uprobe, unsigned long v
* Return 0 (success) or a negative errno.
*/
int __weak
-set_orig_insn(struct mm_struct *mm, struct uprobe *uprobe, unsigned long vaddr, bool verify)
+set_orig_insn(struct mm_struct *mm, struct arch_uprobe *auprobe, unsigned long vaddr, bool verify)
{
if (verify) {
int result;
@@ -363,7 +377,7 @@ set_orig_insn(struct mm_struct *mm, struct uprobe *uprobe, unsigned long vaddr,
if (result != 1)
return result;
}
- return write_opcode(mm, uprobe, vaddr, *(uprobe_opcode_t *)uprobe->insn);
+ return write_opcode(mm, auprobe, vaddr, *(uprobe_opcode_t *)auprobe->insn);
}
static int match_uprobe(struct uprobe *l, struct uprobe *r)
@@ -593,13 +607,13 @@ static int copy_insn(struct uprobe *uprobe, struct vm_area_struct *vma, unsigned
/* Instruction at the page-boundary; copy bytes in second page */
if (nbytes < bytes) {
- if (__copy_insn(mapping, vma, uprobe->insn + nbytes,
+ if (__copy_insn(mapping, vma, uprobe->arch.insn + nbytes,
bytes - nbytes, uprobe->offset + nbytes))
return -ENOMEM;
bytes = nbytes;
}
- return __copy_insn(mapping, vma, uprobe->insn, bytes, uprobe->offset);
+ return __copy_insn(mapping, vma, uprobe->arch.insn, bytes, uprobe->offset);
}
static int install_breakpoint(struct mm_struct *mm, struct uprobe *uprobe,
@@ -625,23 +639,23 @@ static int install_breakpoint(struct mm_struct *mm, struct uprobe *uprobe,
if (ret)
return ret;
- if (is_bkpt_insn((uprobe_opcode_t *)uprobe->insn))
+ if (is_bkpt_insn((uprobe_opcode_t *)uprobe->arch.insn))
return -EEXIST;
- ret = arch_uprobes_analyze_insn(mm, uprobe);
+ ret = arch_uprobes_analyze_insn(mm, &uprobe->arch);
if (ret)
return ret;
uprobe->flags |= UPROBES_COPY_INSN;
}
- ret = set_bkpt(mm, uprobe, addr);
+ ret = set_bkpt(mm, &uprobe->arch, addr);
return ret;
}
static void remove_breakpoint(struct mm_struct *mm, struct uprobe *uprobe, loff_t vaddr)
{
- set_orig_insn(mm, uprobe, (unsigned long)vaddr, true);
+ set_orig_insn(mm, &uprobe->arch, (unsigned long)vaddr, true);
}
static void delete_uprobe(struct uprobe *uprobe)
OpenPOWER on IntegriCloud