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>
This commit is contained in:
Roland McGrath
2008-01-30 13:30:50 +01:00
committed by Ingo Molnar
parent 5f76cb1f6c
commit 7122ec8158
3 changed files with 15 additions and 125 deletions

View File

@@ -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 @@ 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 */