background image

Vol. 3A 3-13

PROTECTED-MODE MEMORY MANAGEMENT

the stack. If the size of a stack segment is intended to remain static, the stack segment may be either an expand-
up or expand-down type.
The accessed bit indicates whether the segment has been accessed since the last time the operating-system or 
executive cleared the bit. The processor sets this bit whenever it loads a segment selector for the segment into a 
segment register, assuming that the type of memory that contains the segment descriptor supports processor 
writes. The bit remains set until explicitly cleared. This bit can be used both for virtual memory management and 
for debugging. 
For code segments, the three low-order bits of the type field are interpreted as accessed (A), read enable (R), and 
conforming (C). Code segments can be execute-only or execute/read, depending on the setting of the read-enable 
bit. An execute/read segment might be used when constants or other static data have been placed with instruction 
code in a ROM. Here, data can be read from the code segment either by using an instruction with a CS override 
prefix or by loading a segment selector for the code segment in a data-segment register (the DS, ES, FS, or GS 
registers). In protected mode, code segments are not writable.
Code segments can be either conforming or nonconforming. A transfer of execution into a more-privileged 
conforming segment allows execution to continue at the current privilege level. A transfer into a nonconforming 
segment at a different privilege level results in a general-protection exception (#GP), unless a call gate or task 
gate is used (see Section 5.8.1, “Direct Calls or Jumps to Code Segments”, for more information on conforming and 
nonconforming code segments). System utilities that do not access protected facilities and handlers for some types 
of exceptions (such as, divide error or overflow) may be loaded in conforming code segments. Utilities that need to 
be protected from less privileged programs and procedures should be placed in nonconforming code segments. 

NOTE

Execution cannot be transferred by a call or a jump to a less-privileged (numerically higher 
privilege level) code segment, regardless of whether the target segment is a conforming or 
nonconforming code segment. Attempting such an execution transfer will result in a general-
protection exception.

All data segments are nonconforming, meaning that they cannot be accessed by less privileged programs or proce-
dures (code executing at numerically higher privilege levels). Unlike code segments, however, data segments can 
be accessed by more privileged programs or procedures (code executing at numerically lower privilege levels) 
without using a special access gate.
If the segment descriptors in the GDT or an LDT are placed in ROM, the processor can enter an indefinite loop if 
software or the processor attempts to update (write to) the ROM-based segment descriptors. To prevent this 
problem, set the accessed bits for all segment descriptors placed in a ROM. Also, remove operating-system or 
executive code that attempts to modify segment descriptors located in ROM.

3.5 

SYSTEM DESCRIPTOR TYPES

When the S (descriptor type) flag in a segment descriptor is clear, the descriptor type is a system descriptor. The 
processor recognizes the following types of system descriptors:

Local descriptor-table (LDT) segment descriptor.

Task-state segment (TSS) descriptor.

Call-gate descriptor.

Interrupt-gate descriptor.

Trap-gate descriptor.

Task-gate descriptor.

These descriptor types fall into two categories: system-segment descriptors and gate descriptors. System-
segment descriptors point to system segments (LDT and TSS segments). Gate descriptors are in themselves 
“gates,” which hold pointers to procedure entry points in code segments (call, interrupt, and trap gates) or which 
hold segment selectors for TSS’s (task gates).