Full lecture notes on kernel — Textbook readings
Review
vmiter
- The
vmiterclass examines and modifies the page table structure that implements virtual memory on x86-64 vmiter(PAGETABLE, VA)constructs avmiterpointing at virtual addressVAin pagetablePAGETABLEit.va()returns thevmiter’s current virtual address (i.e., the key)it.pa()andit.perm()retrieve \mathscr{P}(\texttt{it.va()}, \textit{priv})it.pa()is the physical address result (if there is one)it.perm()determines which accesses fault- If
(it.perm() & PTE_P) == 0, all accesses fault - If
(it.perm() & PTE_W) == 0, write accesses fault - If
(it.perm() & PTE_U) == 0, unprivileged accesses fault
- If
it.find(va)andit += Nredirectvmiterto point to a different virtual address
vmiter mappings
it.try_map(pa, perm)changes the mapping forit.va()- You may only call
it.try_map(pa, perm)ifit.va()is page-aligned (a multiple ofPAGESIZE) - If
it.try_map(pa, perm)succeeds, then afterwards,it.pa() == paandit.perm() == perm it.try_map(pa, perm)can fail (return -1)- Because
it.try_mapmight require allocating kernel memory usingkalloc!
- Because
Tries and x86-64 page tables
- How are page tables designed and why?