Полезная информация

next up previous contents
Next: Selectors in the 80386 Up: 80386 Memory Mangament Previous: Page Fault handling Information

Segments in the 80386

Segment registers are used in address translation to generate a linear address from a logical (virtual) address.

screen2183

The linear address is then translated into a physical address by the paging hardware.

Each segment in the system is described by a 8 byte segment descriptor which contains all pertinent information (base, limit, type, privilege).

The segments are:

Regular segments

System segments

Characteristics of system segments:

To keep track of all these segments, the 386 uses a global descriptor table (GDT) that is setup in memory by the system (located by the GDT register). The GDT contains a segment descriptors for each task state segment, each local descriptor tablet and also regular segments. The Linux GDT contains just two normal segment entries:

The rest of the GDT is filled with TSS and LDT system descriptors:

Note LDT[n] != LDTn

At present the GDT has a total of 256 entries or room for as many as 126 tasks. The kernel segments have base 0xc0000000 which is where the kernel lives in the linear view. Before a segment can be used, the contents of the descriptor for that segment must be loaded into the segment register. The 386 has a complex set of criteria regarding access to segments so you can't simply load a descriptor into a segment register. Also these segment registers have programmer invisible portions. The visible portion is what is usually called a segment register: cs, ds, es, fs, gs, and ss.

The programmer loads one of these registers with a 16-bit value called a selector. The selector uniquely identifies a segment descriptor in one of the tables. Access is validated and the corresponding descriptor loaded by the hardware.

Currently largely ignores the (overly?) complex segment level protection afforded by the 386. It is biased towards the paging hardware and the associated page level protection. The segment level rules that apply to user processes are

  1. A process cannot directly access the kernel data or code segments
  2. There is always limit checking but given that every user segment goes from 0x00 to 0xc0000000 it is unlikely to apply. [This has changed, and needs updating, please.]

next up previous contents
Next: Selectors in the 80386 Up: 80386 Memory Mangament Previous: Page Fault handling Information

Converted on:
Mon Apr 1 10:20:16 EST 1996