2001-12-01 10:17:52

by Frank Cornelis

[permalink] [raw]
Subject: ptrace on i386

Hi,

In linux/arch/i386/kernel/ptrace.c next code is being used in the xxxreg
functions:
if (regno > GS*4)
regno -= 2*4;
Why this discontinuity? It doesn't prevent ORIG_EAX and EIP from being
written and makes the defines CS, EIF, ... from linux/include/asm/ptrace.h
useless. BTW: regno should really call reg_offset since it's no register
number but an offset.

Please CC me,

Frank.


2001-12-01 10:46:33

by Manfred Spraul

[permalink] [raw]
Subject: Re: ptrace on i386

>
> In linux/arch/i386/kernel/ptrace.c next code is being used in the xxxreg
> functions:
> if (regno > GS*4)
> regno -= 2*4;
> Why this discontinuity?

Backward compatibility. The syscall entry point changed between 2.0 and 2.2, but
that change must remain invisible to user space apps. the "-= 2*4" converts old offsets
to new offsets (or the other way around)

--
Manfred

2001-12-01 14:00:34

by Brian Gerst

[permalink] [raw]
Subject: Re: ptrace on i386

Frank Cornelis wrote:
>
> Hi,
>
> In linux/arch/i386/kernel/ptrace.c next code is being used in the xxxreg
> functions:
> if (regno > GS*4)
> regno -= 2*4;
> Why this discontinuity? It doesn't prevent ORIG_EAX and EIP from being
> written and makes the defines CS, EIF, ... from linux/include/asm/ptrace.h
> useless. BTW: regno should really call reg_offset since it's no register
> number but an offset.

It's because the %fs and %gs segment registers are not saved on the
stack upon kernel entry anymore. Thus, the following values have to be
shifted by 2 positions to maintain compatability with the ptrace
register structure.

--

Brian Gerst