invlpg va
Is TLB write through? Is it write back? If not, what is it?
uint
translate (uint la, bool user, bool write)
{
uint pde;
pde = read_mem (%CR3 + 4*(la >> 22));
access (pde, user, write);
pte = read_mem ( (pde & 0xfffff000) + 4*((la >> 12) & 0x3ff));
access (pte, user, write);
return (pte & 0xfffff000) + (la & 0xfff);
}
// check protection. pxe is a pte or pde.
// user is true if CPL==3
void
access (uint pxe, bool user, bool write)
{
if (!(pxe & PG_P)
=> page fault -- page not present
if (!(pxe & PG_U) && user)
=> page fault -- not access for user
if (write && !(pxe & PG_W)) {
if (user)
=> page fault -- not writable
if (%CR0 & CR0_WP)
=> page fault -- not writable
}
}
Can we use paging to limit what memory an app can read/write?
Who stores what?
Page tables vs. Segmentation