Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 80115
b: refs/heads/master
c: 9930927
h: refs/heads/master
i:
  80113: 69acbad
  80111: 30909e3
v: v3
  • Loading branch information
Harvey Harrison authored and Ingo Molnar committed Jan 30, 2008
1 parent 3da0aae commit 5401bb7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 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: e419190683cdeeda9be69af1dbc77031478559af
refs/heads/master: 9930927f36ac3e39ffa674dc23ef06f13c39cef7
27 changes: 19 additions & 8 deletions trunk/arch/x86/kernel/kprobes.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,19 @@ static void __kprobes set_jmp_op(void *from, void *to)
jop->op = RELATIVEJUMP_INSTRUCTION;
}

/*
* Check for the REX prefix which can only exist on X86_64
* X86_32 always returns 0
*/
static int __kprobes is_REX_prefix(kprobe_opcode_t *insn)
{
#ifdef CONFIG_X86_64
if ((*insn & 0xf0) == 0x40)
return 1;
#endif
return 0;
}

/*
* Returns non-zero if opcode is boostable.
* RIP relative instructions are adjusted at copying time in 64 bits mode
Expand Down Expand Up @@ -239,14 +252,14 @@ static int __kprobes is_IF_modifier(kprobe_opcode_t *insn)
case 0x9d: /* popf/popfd */
return 1;
}
#ifdef CONFIG_X86_64

/*
* on 64 bit x86, 0x40-0x4f are prefixes so we need to look
* on X86_64, 0x40-0x4f are REX prefixes so we need to look
* at the next byte instead.. but of course not recurse infinitely
*/
if (*insn >= 0x40 && *insn <= 0x4f)
if (is_REX_prefix(insn))
return is_IF_modifier(++insn);
#endif

return 0;
}

Expand Down Expand Up @@ -284,7 +297,7 @@ static void __kprobes fix_riprel(struct kprobe *p)
}

/* Skip REX instruction prefix. */
if ((*insn & 0xf0) == 0x40)
if (is_REX_prefix(insn))
++insn;

if (*insn == 0x0f) {
Expand Down Expand Up @@ -748,11 +761,9 @@ static void __kprobes resume_execution(struct kprobe *p,
unsigned long orig_ip = (unsigned long)p->addr;
kprobe_opcode_t *insn = p->ainsn.insn;

#ifdef CONFIG_X86_64
/*skip the REX prefix*/
if (*insn >= 0x40 && *insn <= 0x4f)
if (is_REX_prefix(insn))
insn++;
#endif

regs->flags &= ~X86_EFLAGS_TF;
switch (*insn) {
Expand Down

0 comments on commit 5401bb7

Please sign in to comment.