Paginazione X86 1 Schemi di paginazione nell architettura 86 (32 e 64 bit) Questo documento mette insieme figure dai manuali Intel che illustrano gli aspetti salienti della gestione della memoria nell architettura IA-32 Intel, con particolare riferimento ai differenti formati di paginazione. Tutte le figure qui contenute, come pure il testo in lingua inglese sono tratti dai manuali Intel. Essi vengono riportati ai soli fini didattici. Alcune didascalie sono originali, in tal caso non si faccia caso alla numerazione. Segmentazione e paginazione Figura 1: Segmentazione e paginazione. Il riferimento è alla GDT, ma può essere anche alla LDT. Paginazione Modalità di paginazione La paginazione in tre modalità (si veda la parte sui registri di controllo). Se CR0.PG = 1 e CR4.PAE = 0 32-bit paging. Se CR0.PG = 1, CR4.PAE = 1, e IA32 EFER.LME = 0 PAE paging. Se CR0.PG = 1, CR4.PAE = 1, e IA32 EFER.LME = 1 32e paging.
Paginazione X86 2 Paginazione a 32 bit Le pagine possono essere di 4KB o 4MB. Lo standard è la misura di 4 KB. Figura 2: Traduzione dell indirizzo lineare con pagine da 4KB. Figura 3: Traduzione dell indirizzo lineare con pagine da 4MB.
Paginazione X86 3
Paginazione X86 4 Paginazione con PAE (32 bit) A partire dal Pentium-Pro è stata introdotta (su alcuni modelli) la cosiddetta Phyical Address Extension (PAE). A tale scopo il bus degli indirizzi è stato portato a 36 bit. In tal modo lo spazio fisico indirizzabile arriva a 2 36 = 2 4 2 32 = 64GB. Le pagine ora sono di 4KB o di 2MB. Viene introdotta una ulteriore tabella (PDPTE) puntata da CR3. Gli elementi nelle tabelle diventano di 64 bit (anziché di 32 bit come in precedenza). Ovviamente un programma in un dato momento può al massimo indirizzare 4GB. Figura 4: Traduzione dell indirizzo lineare (pagine da 4K e PAE). In questa figura e nelle successiva non compare CR3. In realtà CR3 entra ancora in gioco come puntatore tabella di registri PDPT.
Paginazione X86 5 Figura 5: Traduzione dell indirizzo lineare (pagine da 2M e PAE). Anche qui non viene rappresentato CR3.
Paginazione X86 6 Paginazione a 64 bit I livelli crescono. Le pagine sono di 4KB o 2MB.
Paginazione X86 7
Paginazione X86 8 Registri di controllo CR0 - Contains system control flags that control operating mode and states of the processor. CR1 - Reserved. CR2 - Contains the page-fault linear address (the linear address that caused a page fault). CR3 - Contains the physical address of the base of the paging-structure hierarchy and two flags (PCD and PWT). Only the most-significant bits (less the lower 12 bits) of the base address are specified; the lower 12 bits of the address are assumed to be 0. The first paging structure must thus be aligned to a page (4-KByte) boundary. The PCD and PWT flags control caching of that paging structure in the processor s internal data caches (they do not control TLB caching of page-directory information). When using the physical address extension, the CR3 register contains the base address of the page-directory-pointer table In IA-32e mode, the CR3 register contains the base address of the PML4 table. CR4 - Contains a group of flags that enable several architectural extensions, and indicate operating system or executive support for specific processor capabilities. The control registers can be read and loaded (or modified) using the moveto- or-from-control-registers forms of the MOV instruction. In protected mode, the MOV instructions allow the control registers to be read or loaded (at privilege level 0 only). This restriction means that application programs or operatingsystem procedures (running at privilege levels 1, 2, or 3) are prevented from reading or loading the control registers. Significato di alcuni bit dei registri di controllo PG - Paging (bit 31 of CR0) Enables paging when set; disables paging when clear. WP - Write Protect (bit 16 of CR0) When set, inhibits supervisor-level procedures from writing into read-only pages; when clear, allows supervisor-level procedures to write into read-only pages (regardless of the U/S bit setting). PE - Protection Enable (bit 0 of CR0) Enables protected mode when set. PAE - Physical Address Extension (bit 5 of CR4) When set, enables paging to produce physical addresses with more than 32 bits. PSE - Page Size Extensions (bit 4 of CR4) Enables 4-MByte pages with 32-bit paging when set. EM - Emulation (bit 2 of CR0) Indicates that the processor does not have an internal or external x87 FPU when set; indicates an x87 FPU is present when clear. It also affects the execution of MMX/SSE/SSE2/SSE3/SSSE3/SSE4 instructions.
Paginazione X86 9 Organizzazione dell architettura IA-32
Paginazione X86 10 Organizzazione dell architettura IA-32e
Paginazione X86 11 G. Bucci Aprile 2012