Skip to content

Commit

Permalink
uprobes/core: Remove uprobe_opcode_sz
Browse files Browse the repository at this point in the history
uprobe_opcode_sz refers to the smallest instruction size for
that architecture. UPROBES_BKPT_INSN_SIZE refers to the size of
the breakpoint instruction for that architecture.

For now we are assuming that both uprobe_opcode_sz and
UPROBES_BKPT_INSN_SIZE are the same for all archs and hence
removing uprobe_opcode_sz in favour of UPROBES_BKPT_INSN_SIZE.

However if we have to support architectures where the smallest
instruction size is different from the size of breakpoint
instruction, we may have to re-introduce uprobe_opcode_sz.

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/20120222091549.15880.67020.sendpatchset@srdronam.in.ibm.com
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Srikar Dronamraju authored and Ingo Molnar committed Feb 22, 2012
1 parent 04a3d98 commit 96379f6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
2 changes: 0 additions & 2 deletions include/linux/uprobes.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ struct uprobe_arch_info {};
#define MAX_UINSN_BYTES 4
#endif

#define uprobe_opcode_sz sizeof(uprobe_opcode_t)

/* flags that denote/change uprobes behaviour */

/* Have a copy of original instruction */
Expand Down
6 changes: 3 additions & 3 deletions kernel/events/uprobes.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,8 @@ static int write_opcode(struct mm_struct *mm, struct uprobe *uprobe,

/* poke the new insn in, ASSUMES we don't cross page boundary */
vaddr &= ~PAGE_MASK;
BUG_ON(vaddr + uprobe_opcode_sz > PAGE_SIZE);
memcpy(vaddr_new + vaddr, &opcode, uprobe_opcode_sz);
BUG_ON(vaddr + UPROBES_BKPT_INSN_SIZE > PAGE_SIZE);
memcpy(vaddr_new + vaddr, &opcode, UPROBES_BKPT_INSN_SIZE);

kunmap_atomic(vaddr_new);
kunmap_atomic(vaddr_old);
Expand Down Expand Up @@ -293,7 +293,7 @@ static int read_opcode(struct mm_struct *mm, unsigned long vaddr, uprobe_opcode_
lock_page(page);
vaddr_new = kmap_atomic(page);
vaddr &= ~PAGE_MASK;
memcpy(opcode, vaddr_new + vaddr, uprobe_opcode_sz);
memcpy(opcode, vaddr_new + vaddr, UPROBES_BKPT_INSN_SIZE);
kunmap_atomic(vaddr_new);
unlock_page(page);

Expand Down

0 comments on commit 96379f6

Please sign in to comment.