From 7122ec8158b0f88befd94f4da8feae2c8d08d1b4 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Wed, 30 Jan 2008 13:30:50 +0100 Subject: 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 Signed-off-by: Ingo Molnar Signed-off-by: Thomas Gleixner --- arch/x86/kernel/step.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'arch/x86/kernel/step.c') diff --git a/arch/x86/kernel/step.c b/arch/x86/kernel/step.c index 6a93b93f91f..6732272e347 100644 --- a/arch/x86/kernel/step.c +++ b/arch/x86/kernel/step.c @@ -5,12 +5,24 @@ #include #include +#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 @@ static int is_setting_trap_flag(struct task_struct *child, struct pt_regs *regs) 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 */ -- cgit v1.2.3