x86: single_step: share code
This removes the single-step code from ptrace_32.c and uses the step.c code
shared with the 64-bit kernel. The two versions of the code were nearly
identical already, so the shared code has only a couple of simple #ifdef's.
Signed-off-by: Roland McGrath <roland@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
diff --git a/arch/x86/kernel/step.c b/arch/x86/kernel/step.c
index 6a93b93..6732272 100644
--- a/arch/x86/kernel/step.c
+++ b/arch/x86/kernel/step.c
@@ -5,12 +5,24 @@
#include <linux/mm.h>
#include <linux/ptrace.h>
+#ifdef CONFIG_X86_32
+static
+#endif
unsigned long convert_rip_to_linear(struct task_struct *child, struct pt_regs *regs)
{
unsigned long addr, seg;
+#ifdef CONFIG_X86_64
addr = regs->rip;
seg = regs->cs & 0xffff;
+#else
+ addr = regs->eip;
+ seg = regs->xcs & 0xffff;
+ if (regs->eflags & X86_EFLAGS_VM) {
+ addr = (addr & 0xffff) + (seg << 4);
+ return addr;
+ }
+#endif
/*
* We'll assume that the code segments in the GDT
@@ -69,12 +81,14 @@
case 0xf0: case 0xf2: case 0xf3:
continue;
+#ifdef CONFIG_X86_64
case 0x40 ... 0x4f:
if (regs->cs != __USER_CS)
/* 32-bit mode: register increment */
return 0;
/* 64-bit mode: REX prefix */
continue;
+#endif
/* CHECKME: f2, f3 */