Re: gpf in do_exit

Richard B. Johnson (root@chaos.analogic.com)
Tue, 15 Sep 1998 13:01:48 -0400 (EDT)


On Tue, 15 Sep 1998, Gabriel Paubert wrote:

>
>
> On Mon, 14 Sep 1998, Linus Torvalds wrote:
>
> >
> >
> > On Mon, 14 Sep 1998, Richard B. Johnson wrote:
> > > >
> > > > pushl %ss;\
> > > > popl %ds;\
> > > > pushl %ss;\
> > > > popl %es;\
> > > > pushl $11;\
> > > > call do_exit
> > > >
> > > [SNIPPED]
> > >
> > > The segment registers are 16-bit registers!
> >
> > Yes. However, you should still use "pushl" and "popl", because they are
> > smaller and faster. The upper bits are just ignored and/or push undefined
> > values.
> >
> > Go figure, the x86 is a strange and wonderful beast.
>
> However, the main reason to use 4 byte pushes and pops is to preserve
> stack alignment. An interrupt handler executed on a misaligned stack would
> have horrible performance.
>
> >
> > However, in this particular case the right thing to do is to just reset
> > the segment register values in the trap handler rather than in entry.S.
> > I'm doing that in my current kernel, I'll make a pre-2.1.122-3 shortly.
> >
>
> I did not want to speculate about this before seeing the code because
> nobody should argue with God^H^H^HLinus without a good reason :-).
>
[SNIPPED]

I forgot that the gcc compiler doesn't 'know' about ix86 with its
pseudo-assembly. In neither protected-mode nor real-mode, the
0x66 override prefix is never used with segment operations.

Therefore a real assembler would, in fact push a 32-bit word onto
the stack if it pushed es, ds, ss, cs, fs, or gs. It would pop a
long-word for the reverse operation because it would not generate
the 0x66 prefix in any case.

Since gcc doesn't know this, one has to 'pushl', 'popl' to fool
the pseudo-assembler into not generating a 0x66 prefix.

Cheers,
Dick Johnson
***** FILE SYSTEM WAS MODIFIED *****
Penguin : Linux version 2.1.118 on an i586 machine (66.15 BogoMips).
Warning : It's hard to remain at the trailing edge of technology.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/