《深入理解Linux内核》阅读笔记 --- Chapter 2 Memory Addressing

1、logical address = segment identifier (16bits) + offset (32bits)

segment selector其实就是GDT或者LDT的索引,其中的TI字段用来确定是选择GDT还是IDT

2、segment identifier is called segment selector, and in order to retrieve it quickly,  the process provides segmentation registers whose only purpose is to hold segment selectors,like cs, ss, ds, es, fs and gs.

3、The cs register has another import function: it includes a 2-bit field that specifies the Current Privilege Level (CPL) of the CPU.

4、Each segment is represented by an 8-byte Segment Descriptor that describes the segment characteristics.

Global Descriptor Table(GDT) or Local Descriptor Table(LDT) is used to store them.

5、There are several types of segments and thus several types of Segment Descriptors:

Code Segment Descriptor, Data Segment Descriptor, Task State Segment Descriptor(TSSD), Local Descriptor Table Descriptor(LDTD)

6、TSSD is a segment used to save contents of the processor registers, it can appear only in the GDT

7、The first entry of the GDT is always 0. This ensures that logical addresses with a null segment selector will be considered invalid, thus causing a processor exception.

8、Whenever the CPL is changed, some segmentation registers must be correspondingly updated.For instance, when the CPL is equal to 3(User Mode), the ds register must contain the segment selector of the user data segment, but when the CPL is equal to 0, the ds register must contain the segment selector of the kernel data segment

9、In uniprocessor systems there is only one GDT, while in multiprocessor systems there is one GDT for every CPU in the system.All GDTs are stored in the cpu_gdt_table array, while the addresses and sizes of the GDTs are stored in the cpu_gdt_descr

10、A Task State Segment (TSS), different for each processor in the system.The linear address space corresponding to a TSS is a small subset of the linear address space corresponding to the kernel data segment.

Process in user mode are not allowed to access TSS segments.

11、When a processor starts executing a process having a custom LDT, the LDT entry in the CPU-specified copy of the GDT is changed accordingly.

 

posted on 2017-01-19 13:34  姚灯灯!  阅读(282)  评论(0编辑  收藏  举报

导航