aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel
diff options
context:
space:
mode:
authorHarvey Harrison <harvey.harrison@gmail.com>2008-01-30 07:32:14 -0500
committerIngo Molnar <mingo@elte.hu>2008-01-30 07:32:14 -0500
commit9930927f36ac3e39ffa674dc23ef06f13c39cef7 (patch)
tree23c92c361ba87fca19e7d9ffd741b1343b89dcf9 /arch/x86/kernel
parente419190683cdeeda9be69af1dbc77031478559af (diff)
x86: introduce REX prefix helper for kprobes
Fold some small ifdefs into a helper function. Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com> Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'arch/x86/kernel')
-rw-r--r--arch/x86/kernel/kprobes.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/arch/x86/kernel/kprobes.c b/arch/x86/kernel/kprobes.c
index 4e33329ce8a3..b1804e40235d 100644
--- a/arch/x86/kernel/kprobes.c
+++ b/arch/x86/kernel/kprobes.c
@@ -171,6 +171,19 @@ static void __kprobes set_jmp_op(void *from, void *to)
171} 171}
172 172
173/* 173/*
174 * Check for the REX prefix which can only exist on X86_64
175 * X86_32 always returns 0
176 */
177static int __kprobes is_REX_prefix(kprobe_opcode_t *insn)
178{
179#ifdef CONFIG_X86_64
180 if ((*insn & 0xf0) == 0x40)
181 return 1;
182#endif
183 return 0;
184}
185
186/*
174 * Returns non-zero if opcode is boostable. 187 * Returns non-zero if opcode is boostable.
175 * RIP relative instructions are adjusted at copying time in 64 bits mode 188 * RIP relative instructions are adjusted at copying time in 64 bits mode
176 */ 189 */
@@ -239,14 +252,14 @@ static int __kprobes is_IF_modifier(kprobe_opcode_t *insn)
239 case 0x9d: /* popf/popfd */ 252 case 0x9d: /* popf/popfd */
240 return 1; 253 return 1;
241 } 254 }
242#ifdef CONFIG_X86_64 255
243 /* 256 /*
244 * on 64 bit x86, 0x40-0x4f are prefixes so we need to look 257 * on X86_64, 0x40-0x4f are REX prefixes so we need to look
245 * at the next byte instead.. but of course not recurse infinitely 258 * at the next byte instead.. but of course not recurse infinitely
246 */ 259 */
247 if (*insn >= 0x40 && *insn <= 0x4f) 260 if (is_REX_prefix(insn))
248 return is_IF_modifier(++insn); 261 return is_IF_modifier(++insn);
249#endif 262
250 return 0; 263 return 0;
251} 264}
252 265
@@ -284,7 +297,7 @@ static void __kprobes fix_riprel(struct kprobe *p)
284 } 297 }
285 298
286 /* Skip REX instruction prefix. */ 299 /* Skip REX instruction prefix. */
287 if ((*insn & 0xf0) == 0x40) 300 if (is_REX_prefix(insn))
288 ++insn; 301 ++insn;
289 302
290 if (*insn == 0x0f) { 303 if (*insn == 0x0f) {
@@ -748,11 +761,9 @@ static void __kprobes resume_execution(struct kprobe *p,
748 unsigned long orig_ip = (unsigned long)p->addr; 761 unsigned long orig_ip = (unsigned long)p->addr;
749 kprobe_opcode_t *insn = p->ainsn.insn; 762 kprobe_opcode_t *insn = p->ainsn.insn;
750 763
751#ifdef CONFIG_X86_64
752 /*skip the REX prefix*/ 764 /*skip the REX prefix*/
753 if (*insn >= 0x40 && *insn <= 0x4f) 765 if (is_REX_prefix(insn))
754 insn++; 766 insn++;
755#endif
756 767
757 regs->flags &= ~X86_EFLAGS_TF; 768 regs->flags &= ~X86_EFLAGS_TF;
758 switch (*insn) { 769 switch (*insn) {