110 likes | 206 Views
Segmentation. Segmentation provides the basis of protection which encapsulates regions of memory which have common attributes. All information about a segment is stored in an 8-byte data structure called a descriptor . All descriptors are contained in tables recognized by hardware. 1.
E N D
Segmentation • Segmentation provides the basis of protection which encapsulates regions of memory which have common attributes. • All information about a segment is stored in an 8-byte data structure called a descriptor. • All descriptors are contained in tables recognized by hardware. 1
Selector (Segment Register) • A selector in protected mode has 3 fields: • TI (Table Indicator): Local or Global Descriptor Table Indicator • Index(Descriptor Entry Index ): Selects one of 8K descriptors • RPL (Requestor Privilege Level): allows testing of selector’s privilege attributes • Level 0: Most Privilege Level • Level 3: Least Privilege Level 2
Selector 3
Descriptor Tables • It defines all the segments used in x86 system • There are 3 types of table: • Global Descriptor Table(GDT) • Local Descriptor Table(LDT) • Interrupt Descriptor Table(IDT) • All tables are variable length memory arrays • They can range in size from 8 bytes to 64KB (213 x 23) (3 bits are implied as descriptor size is fixed)
Descriptor Tables • Each table can hold up to 8192(213) 8-byte descriptors. • The table has registers associated with them named GDTR, LDTR and IDTR which hold the 32-bit linear base address and 16-bit limit of each table. • These tables are manipulated by the OS using privileged instructions.
Global Descriptor Table • It contains descriptors which are possibly available to all of the tasks in a system. • Every Intel386 DX system contains a GDT. • It contains code and data segments used by the operating systems and task state segments and descriptors for the LDTs in a system. • The first slot of GDT corresponds to the null selector and is not used.
Local Descriptor Table • LDTs contain descriptors which are Task Specific. • LDT may contain only code, data, stack, task gate and call gate descriptors. • LDTs isolates a given task's code and data segments from the rest of the OS. • Unlike the 6 byte GDT or IDT registers, the visible portion of LDT register contains only a 16-bit selector. • This selector refers to a Local Descriptor Table Descriptor in the GDT.
Interrupt Descriptor Table • IDT contains descriptors to point to the location of up to 256 interrupt service routines. • IDT should be atleast256 bytes to hold 32 Intel Reserved Interrupts(32*8) • Every interrupt used must have an entry in IDT. • IDT entries are referenced via INT instructions, external interrupt vectors and exceptions. • Interrupts handle asynchronous external events(eg.pressing a key) and exceptions handle instruction faults (e.g. page permission fault)