Re: Is the Linux memory 'flat' ?

H. Peter Anvin (hpa@freya.yggdrasil.com)
26 Jun 1996 08:41:15 GMT


Followup to: <199606251923.MAA00206@redshirt.tholian.web>
By author: Tom May <ftom@netcom.com>
In newsgroup: linux.dev.kernel
>
> Alan Cox says:
>=20
> >> Beeing Linux a 32 bits OS, does it means _necessary_ that the memo=
ry
> >> space of a process is 'flat' ? That is continuous, with no need
> >> of far/near stuff.
>=20
> >It is flat in Linux but if you are warped enough you can run segment=
ed mode
> >32bit segments in 32bit mode. Nobody is quite that sad however
>=20
> The linux kernel code is :-) I was glad to see that Linus plans to
> drop the segmented stuff in the kernel in the near future.
>=20

The Linux kernel just uses two set of segments for address space
separation. There is nothing funny about it; it was mostly a "it's
there, we might as well use the bloody thing for something." Of
course, some of us remember when Linux only had one linear address
space for all processes, and actually used segmentation for isolating
processes; this also limited these early Linux systems to 63 64MB
processes. Back then we were much more worried about the 16MB RAM and
64MB partition size limitations; the former which still lives in the
form of a Config.in question, since long obsolete...

I think what Alan was referring to was the possibility of running
Multics-style segmentation (the i386 segmentation and ring mechanisms
were basically Multics rip-offs, and Intel still managed to get a
patent on it!) complete with 48-bit pointers (16-bit selector+32-bit
offset). The advantage is that most fandango on core and array
overruns are automatically caught, the disadvantage is that lugging
around those 48-bit pointers and reloading segment registers all the
time is a bloody waste of time.

I still, however, believe we should use %gs for the glocal storage
pointer on the i386 (for multithreaded apps.) On machines with a real
register file this would of course be kept in a normal register, but
on the i386 there are only five registers left once %ebp is made frame
pointer and %ebx PIC pointer.

I would personally have been much happier had base-index addressing
been implemented from %esp (this is a flaw in the i386 instruction
set, not a Linux flaw) and left %ebp a general-purpose
register... *sigh*.

-hpa
--=20
PGP public key available - finger hpa@zytor.com
I don't work for Yggdrasil, but they sponsor the linux.* hierarchy.
"The earth is but one country, and mankind its citizens." -- Bah=E1'u=
'll=E1h
Just Say No to Morden * Save Babylon 5: http://www.babylon5.com/cmp/sup=
port/