[mkc2008] Kernel Entry and Kernel Exit - Segmentation

Udo A. Steinberg us15 at os.inf.tu-dresden.de
Sat Apr 4 03:00:31 CEST 2009


On Sat, 04 Apr 2009 01:36:58 +0200 Jan Bierbaum (JB) wrote:

JB> Since it's possible to have a segment cover the complete 4 GB address
JB> space (slide 9) the offset needs to be 32 bit long. When we add the
JB> segment selector that would necessarily produce a logical address longer
JB> then 32 bit.

I guess you mean that adding the offset to the segment base from the segment
descriptor referenced by the segment selector can produce an address larger
than 4GB. In reality the resulting address is truncated to 32bit, which
means that such addresses wrap around the 4GB border.

JB> All addresses specified by software are logical addresses because
JB> segmentation is a mandatory feature. Here is my problem:
JB> Addresses/Pointers in 32 bit code are 32 bit, not more. So how is the
JB> segment selector specified? And the other way around - what segment
JB> selector is used when none is explicitly specified?

The segment selectors are loaded into the segment registers: CS, DS, ES, FS,
GS, SS.

JB> To run any program we need at least a code segment and a stack/data
JB> segment (slide 9). So is the segment choosing done implicitly - code
JB> segment for fetching instructions, stack segment for stack operations,
JB> data segment for operant fetching?

Code fetches use CS, data operations use DS and stack operations use SS,
unless the programmer specified something else.

JB> Nevertheless there must be a way to
JB> explicitly specify a segment selector to use. Otherwise the extra data
JB> segments would not make any sense.

Indeed. Google for segment override.

JB> Another issue are the different privilege levels: current privilege
JB> level (CPL), requested privilege level (RPL), descriptor privilege level
JB>  (DPL).
JB> 
JB> CPL refers to the privilege level the CPU currently runs on. So this is
JB> used e.g. for checking the access right on page tables and instructions.
JB> DPLs are attached to various descriptors and function as a kind of guard
JB> - the descriptor or better the resource it "describes" may only be used
JB> if CPL <= DPL. RPLs are found inside segment selectors and can demote,
JB> but not promote, the CPL for access to the segment the selector
JB> references. Correct?

Yes.

	- Udo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://os.inf.tu-dresden.de/pipermail/mkc2008/attachments/20090404/3e01ee1b/attachment.asc>


More information about the mkc2008 mailing list