Logical Address
The address included in the machine language instruction is used to specify an operand or a command. Each logical address consists of a segment and an offset, and the offset indicates the distance between the start of the segment to the actual address.
Linear Address
It is a 32-bit unsigned integer that can be used to represent up to 4GB of addresses.
Physical Address
Used to address the memory chip-level memory unit. The physical address is represented by a 32-bit unsigned integer.
The CPU control unit converts a logical address into a linear address by a hardware circuit called a segment unit (segmentation unit); then, the second hardware circuit called a paging unit converts a linear address into a physical address.
Segmentation in hardware
Starting from the 80386 model, the Intel microprocessor performs address transition in two different ways, which are respectively referred to as real mode and protection mode, respectively.
Segment register
A logical address consists of two parts: a segment identifier and an offset of the relative address within a command segment. The segment identifier is a 16-bit long field called a Segment Selector, while the offset is a 32-bit field. The CPU provides 6 segment registers CS, SS, DS, ES, FS, and GS to store the segment selector to quickly and easily find the segment selector. The three sections of registers have specialized purposes: CS is the code segment register, pointing to the segment containing the program instruction; SS is a stack register, pointing to the segment containing the current program; DS is a data segment register, pointing to the contained static data or external data The segment, and the remaining ES, FS, and GS can only be used as a data segment register. That is, at a moment, the programmer consists of up to six segments, 1 code segment, 1 stack segment, and up to 4 data segments.
Segment descriptor
Each segment is represented by a 8-byte segment descriptor (Segment Descriptor), which describes the feature of the segment. Segment Descriptors are placed in the Global Descriptor Table, GDT or Local Descriptor Table, LDT. Usually only one GDT is defined, and each process is stored in addition to segments in GDT, if you need to create additional segments, you can have your own LDT. GDT stores in the main memory in the GDTR register, and the address of the LDT that is currently being used is stored in the LDTR register. Only the segment selector is stored in the segment register, each segment selector contains a field: 13 bit index, used to select one of the 8192 (213) global descriptor or partial descriptor; TI flag indicating the segment descriptor is GDT (Ti = 0) or in the LDT (Ti = 1); 2-bit RPL field, used to represent the privileged level of the requester.
references:
1. In-depth understanding of the second edition of Linux kernel
2. Linux kernel complete notes
3. Intel 80386 Programmer's Reference Manual 1986