Logical Address)
It is included in the machine language instruction to specify the address of an operand or an instruction. Each logical address consists of a segment and an offset, indicating the distance from the beginning of the segment to the actual address.
Linear address)
Is a 32-bit unsigned integer that can be used to represent a 4 GB address.
Physical address)
Memory chip-level memory unit addressing. The physical address is represented by a 32-bit unsigned integer.
The CPU control unit converts a logical address to a linear address through a hardware circuit called a segmentation unit. The second is called a paging unit) the hardware circuit converts a linear address to a physical address.
Segment in hardware
Starting from the 80386 model, Intel microprocessor performs address translation in two different ways, namely the real mode and the protection mode.
Segment register
A logical address consists of two parts: a segment identifier and the offset of the relative address in a command segment. The segment identifier is a 16-bit long field, called the segment selector, And the offset is a 32-bit long field. The CPU provides six segment registers, Cs, SS, DS, es, FS, and GS, to store segment Selection Characters for fast and convenient segment selection. Among them, three segment registers have special purposes: CS is the code segment register, pointing to the segment containing program instructions; SS is the stack segment register, pointing to the segment containing the current program stack; DS is a data segment register pointing to a segment that contains static or external data, and the rest of ES, FS, and GS can only be used as data segment registers. That is to say, at a certain time point, for programmers, the memory consists of a maximum of six segments, one segment, one stack segment, and a maximum of four data segments.
Segment descriptor
Each segment is represented by an 8-byte segment descriptor (segment descriptor), which describes the features of the segment. Segment descriptors are stored in the Global Descriptor Table (gdt) or Local Descriptor Table (LDT. Generally, only one gdt is defined. In addition to the segments in gdt, each process can have its own LDT if it needs to create additional segments. Gdt addresses in the primary memory are stored in the GDTR register, and the currently used LDT addresses are stored in the ldtr register. The segment register only stores the segment selection character. Each segment selection character contains the following field: 13-bit index, which is used to select one of the 8192 (213) global descriptors or local descriptors; the Ti flag indicates that the segment descriptor is in gdt (Ti = 0) or in LDT (Ti = 1); 2-bit RPL field, used to indicate the privilege level of the requester.
References:
1. deep understanding of the second version of Linux kernel
2. Complete Linux kernel Annotation
3. Intel 80386 programmer's reference manual 1986