1. How to convert a logical address to a linear address:
Logical address = segment Selector (16bit) + offset (32bit)
The segment selector is made up of three parts: index (index number), T1 (table indicator), RPL (Request privilege level requester privilege)
Index number: Refers to the segment descriptor in the GDT (Global descriptor table) or the LDT (Local descriptor table).
Table indicator: Marks point to GDT or LDT
RPL: Divided into User State (3), or kernel state (0)
Segment Descriptor: 64bit, primary field Base (linear address 32bit of the first byte of the segment), Limit (length of segment), DPL (description privilege level), etc.
Address of Segment descriptor = GDT (LDT) address (stored in GDTR, LDTR Register) + Index * 8 (because of a segment descriptor of 8 bytes)
Logical address = base + offset in segment descriptor
Note: 1, rarely use fragmentation in Linux, it is biased to whether paging
2. The main 4 segments are user code segment, user data segment, kernel code snippet, kernel data segment, respectively.
3, and their base value is 0, that is, all the linear address to the segment starting from 0
4, that is, the low cost of the logical address of Linux and the corresponding linear address of the value is always consistent
2. How to convert a linear address to a physical address?
Page: 4,096 bytes, including in-page addresses, data
Page box: physical page, 4096 bytes, without in-page data
Paging: For efficiency, the linear address is divided into fixed-length pages, the continuous linear address of the page is mapped to a contiguous physical address, and the advantage is that the kernel can specify access rights to the page without having to specify all the linear addresses in the page
Linear address = Directory (directory 10bit) + table (page table 10bit) + offset (offset 12bit)
The offset of the offset:12bit is the size of a page, indicating that 4,096 consecutive linear addresses are one page
Extended Paging: Page catalog (10bit) + offset (offset 22bit); The middle page table is removed, and the size of each page is 4MB
Deep understanding of the Linux kernel-memory addressing