mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Felipe Alfaro Solana <felipe_alfaro@linuxmail.org>
To: Ben Johnson <ben@blarg.net>
Cc: "Martin J. Bligh" <mbligh@aracnet.com>,
	William Lee Irwin III <wli@holomorphy.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: linear vs. logical addresses?  how does cpu interpret kernel addrs?
Date: Wed, 17 Sep 2003 04:10:03 +0200	[thread overview]
Message-ID: <1063764603.19730.8.camel@teapot.felipe-alfaro.com> (raw)
In-Reply-To: <20030916184421.A25733@blarg.net>

On Wed, 2003-09-17 at 03:44, Ben Johnson wrote:
> On Tue, Sep 16, 2003 at 05:58:08PM -0700, Martin J. Bligh wrote:
> > 
> > BTW, to the original question ... chapter 2 of "Understanding the Linux Kernel"
> > had a good explanation of all this.
> 
> Thank you.  I've been reading the first addition.  is there a second?
> the second chapter has a very good explanation of paging and how linear
> addresses are used.  logical addresses on the other hand are barely
> mentioned.  Segmentation is described well, but the translation of
> logical into linear addresses is not described.
> 
> I've read elsewhere that logical addresses are comprised of a 16-bit
> segment selector and a 32-bit offset.  I thought pointers were always
> exactly 32-bits (on 32-bit intel).  where is the 16-bit selector?

It was a long time ago since I read about i386 addressing mechanisms,
but if my memory serves me well:

The selector is a 16-bit number which points to a segment descriptor in
either the GDT or the LDT.

The LDT is a Local Descriptor Table which is particular to a given task.
There is a task register on the CPU which contains a region of memory
used to store CPU registers when a context switch is performed and where
the LDT for that task is stored. The GDT is global to the system and
shared by all tasks.

Basically, the segment descriptor tells what kind of segment it is
(code, data, stack), defines its priority (the ring, being 0 the most
privileged and 3 the least), if it's present in memory, and defines it's
base linear address and it's size (either in bytes or in 4KB pages,
depending on it's granularity).

A selector is stored in any of the CPU segment registers (CS, DS, ES,
FS, GS and SS).

Thus from the <selector:offset> pair, you get the base address from the 
segment descriptor pointed to by the selector, and then add it up the
offset. The resulting linear address is then converted by the MMU to a
physical address using the page tables. Note that even selector+offset
is a 48-bit number, the resulting address is always a 32-bit address.
Modern processors can address 36 bit addresses using PAE extensions, but
those remember me of the times when we mapped Expanded Memory into 64KB
frames below 1MB of RAM.

I recommend you reading the Intel manuals, they are worth reading :-)


  parent reply	other threads:[~2003-09-17  2:10 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-09-16 22:47 Ben Johnson
2003-09-17  0:48 ` Martin J. Bligh
2003-09-17  0:54   ` William Lee Irwin III
2003-09-17  0:58     ` Martin J. Bligh
2003-09-17  1:44       ` Ben Johnson
2003-09-17  1:55         ` William Lee Irwin III
2003-09-17  2:07           ` Ben Johnson
2003-09-17  2:10             ` William Lee Irwin III
2003-09-17  2:32               ` Ben Johnson
2003-09-17  2:10         ` Felipe Alfaro Solana [this message]
2003-09-17 11:39 ` Richard B. Johnson
2003-09-17 19:42   ` Ben Johnson
2003-09-17 20:05     ` Richard B. Johnson
2003-09-17 20:44       ` Jamie Lokier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1063764603.19730.8.camel@teapot.felipe-alfaro.com \
    --to=felipe_alfaro@linuxmail.org \
    --cc=ben@blarg.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mbligh@aracnet.com \
    --cc=wli@holomorphy.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®