Full lecture notes on kernel — Textbook readings
Review
vmiter
- The
vmiter
class examines and modifies the page table structure that implements virtual memory on x86-64 vmiter(PAGETABLE, VA)
constructs avmiter
pointing at virtual addressVA
in pagetablePAGETABLE
it.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 += N
redirectvmiter
to 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() == pa
andit.perm() == perm
it.try_map(pa, perm)
can fail (return -1)- Because
it.try_map
might require allocating kernel memory usingkalloc
!
- Because
Tries and x86-64 page tables
- How are page tables designed and why?