Lecture: address spaces
Preparation
- read OSPP §8, Address Translation
- read
kern/entrypgdir.c
again in your JOS (and compare it with
xv6’s entrypgdir
in main.c
)
Overview
- last lecture
- isolation and sharing
- kernel, user space, system calls
- kernel organization: monolithic kernel, microkernel, exokernel
- virtual addresses
- popular in modern OSes: not just for isolation; more examples next week
- both kernel and user space are virtual addresses
- again, even pointers in kernel are not using physical addresses
- MMU (memory management unit)
- hardware support: VA → PA translation [ draw the workflow ]
- cache: TLB (translation lookaside buffer)
- segmentation vs. paging
- paging
- page: fixed-size memory chunk (e.g., 4KB/2MB/4MB on x86)
- page table: address translation map
- entry: physical address, plus flags
- P/W/U: present/writable/user
- A/D: accessed/dirty
- see xv6’s
mmu.h
- isolation
- per-process page table: switch with process
- kernel (un)sets W, etc.
- x86 control registers
- CR0: turn on paging
- CR3: pointer to page table
- CR2: will use it later for page faults
Two-level paging
- x86
- let’s start with the 4K two-level paging
- read through JOS’s
kern/entrypgdir.c
- there are many other plans
- VA → PA translation
- linear address
- bits 31-22: page directory index
- bits 21-12: page table index
- bits 11-0: offset into 4K page
- page directory entry (PDE)
- bits 31-12: page table address
- bits 11-0: flags
- page table entry (PTE)
- bits 31-12: physical 4K page address
- bits 11-0: flags