Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 306639
b: refs/heads/master
c: 5cb4ac3
h: refs/heads/master
i:
  306637: 3111301
  306635: c18f532
  306631: 2a467f2
  306623: cabd638
v: v3
  • Loading branch information
Srikar Dronamraju authored and Ingo Molnar committed Mar 13, 2012
1 parent d4193f7 commit ddd7fc3
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: e3343e6a2819ff5d0dfc4bb5c9fb7f9a4d04da73
refs/heads/master: 5cb4ac3a583d4ee18c8682ab857e093c4a0d0895
4 changes: 2 additions & 2 deletions trunk/arch/x86/include/asm/uprobes.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ typedef u8 uprobe_opcode_t;
#define MAX_UINSN_BYTES 16
#define UPROBE_XOL_SLOT_BYTES 128 /* to keep it cache aligned */

#define UPROBE_BKPT_INSN 0xcc
#define UPROBE_BKPT_INSN_SIZE 1
#define UPROBE_SWBP_INSN 0xcc
#define UPROBE_SWBP_INSN_SIZE 1

struct arch_uprobe {
u16 fixups;
Expand Down
4 changes: 2 additions & 2 deletions trunk/include/linux/uprobes.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ struct uprobe_consumer {
};

#ifdef CONFIG_UPROBES
extern int __weak set_bkpt(struct arch_uprobe *aup, struct mm_struct *mm, unsigned long vaddr);
extern int __weak set_swbp(struct arch_uprobe *aup, struct mm_struct *mm, unsigned long vaddr);
extern int __weak set_orig_insn(struct arch_uprobe *aup, struct mm_struct *mm, unsigned long vaddr, bool verify);
extern bool __weak is_bkpt_insn(uprobe_opcode_t *insn);
extern bool __weak is_swbp_insn(uprobe_opcode_t *insn);
extern int uprobe_register(struct inode *inode, loff_t offset, struct uprobe_consumer *uc);
extern void uprobe_unregister(struct inode *inode, loff_t offset, struct uprobe_consumer *uc);
extern int uprobe_mmap(struct vm_area_struct *vma);
Expand Down
34 changes: 17 additions & 17 deletions trunk/kernel/events/uprobes.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,14 @@ static int __replace_page(struct vm_area_struct *vma, struct page *page, struct
}

/**
* is_bkpt_insn - check if instruction is breakpoint instruction.
* is_swbp_insn - check if instruction is breakpoint instruction.
* @insn: instruction to be checked.
* Default implementation of is_bkpt_insn
* Default implementation of is_swbp_insn
* Returns true if @insn is a breakpoint instruction.
*/
bool __weak is_bkpt_insn(uprobe_opcode_t *insn)
bool __weak is_swbp_insn(uprobe_opcode_t *insn)
{
return *insn == UPROBE_BKPT_INSN;
return *insn == UPROBE_SWBP_INSN;
}

/*
Expand Down Expand Up @@ -227,7 +227,7 @@ static int write_opcode(struct arch_uprobe *auprobe, struct mm_struct *mm,
* adding probes in write mapped pages since the breakpoints
* might end up in the file copy.
*/
if (!valid_vma(vma, is_bkpt_insn(&opcode)))
if (!valid_vma(vma, is_swbp_insn(&opcode)))
goto put_out;

uprobe = container_of(auprobe, struct uprobe, arch);
Expand Down Expand Up @@ -259,8 +259,8 @@ static int write_opcode(struct arch_uprobe *auprobe, struct mm_struct *mm,

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

kunmap_atomic(vaddr_new);
kunmap_atomic(vaddr_old);
Expand Down Expand Up @@ -308,7 +308,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_BKPT_INSN_SIZE);
memcpy(opcode, vaddr_new + vaddr, UPROBE_SWBP_INSN_SIZE);
kunmap_atomic(vaddr_new);
unlock_page(page);

Expand All @@ -317,7 +317,7 @@ static int read_opcode(struct mm_struct *mm, unsigned long vaddr, uprobe_opcode_
return 0;
}

static int is_bkpt_at_addr(struct mm_struct *mm, unsigned long vaddr)
static int is_swbp_at_addr(struct mm_struct *mm, unsigned long vaddr)
{
uprobe_opcode_t opcode;
int result;
Expand All @@ -326,33 +326,33 @@ static int is_bkpt_at_addr(struct mm_struct *mm, unsigned long vaddr)
if (result)
return result;

if (is_bkpt_insn(&opcode))
if (is_swbp_insn(&opcode))
return 1;

return 0;
}

/**
* set_bkpt - store breakpoint at a given address.
* set_swbp - store breakpoint at a given address.
* @auprobe: arch specific probepoint information.
* @mm: the probed process address space.
* @vaddr: the virtual address to insert the opcode.
*
* For mm @mm, store the breakpoint instruction at @vaddr.
* Return 0 (success) or a negative errno.
*/
int __weak set_bkpt(struct arch_uprobe *auprobe, struct mm_struct *mm, unsigned long vaddr)
int __weak set_swbp(struct arch_uprobe *auprobe, struct mm_struct *mm, unsigned long vaddr)
{
int result;

result = is_bkpt_at_addr(mm, vaddr);
result = is_swbp_at_addr(mm, vaddr);
if (result == 1)
return -EEXIST;

if (result)
return result;

return write_opcode(auprobe, mm, vaddr, UPROBE_BKPT_INSN);
return write_opcode(auprobe, mm, vaddr, UPROBE_SWBP_INSN);
}

/**
Expand All @@ -371,7 +371,7 @@ set_orig_insn(struct arch_uprobe *auprobe, struct mm_struct *mm, unsigned long v
if (verify) {
int result;

result = is_bkpt_at_addr(mm, vaddr);
result = is_swbp_at_addr(mm, vaddr);
if (!result)
return -EINVAL;

Expand Down Expand Up @@ -642,7 +642,7 @@ install_breakpoint(struct uprobe *uprobe, struct mm_struct *mm,
if (ret)
return ret;

if (is_bkpt_insn((uprobe_opcode_t *)uprobe->arch.insn))
if (is_swbp_insn((uprobe_opcode_t *)uprobe->arch.insn))
return -EEXIST;

ret = arch_uprobes_analyze_insn(&uprobe->arch, mm);
Expand All @@ -651,7 +651,7 @@ install_breakpoint(struct uprobe *uprobe, struct mm_struct *mm,

uprobe->flags |= UPROBE_COPY_INSN;
}
ret = set_bkpt(&uprobe->arch, mm, addr);
ret = set_swbp(&uprobe->arch, mm, addr);

return ret;
}
Expand Down

0 comments on commit ddd7fc3

Please sign in to comment.