Lecture: virtual memory Q&A
lab 2 questions
- be careful: think twice whether an address is virtual or physical
- addresses from e820 - virtual or physical?
- if you are directly casting between integers and pointers, it’s often wrong!
%cr2
value
- try to read an invalid virtual address (say
0x0
or 0xdead
)
- QEMU prints
0x40
as the %cr2
value upon triple fault, not the invalid virtual address - why?
- try
make qemu-nox QEMUEXTRA="-d int"
and guess based on the last few entries in the file qemu.log
- virtual linear page tables:
uvpt[n]
gives the PTE of page n
- self mapping: set one PDE to point to the page directory
- CPU walks the tree as usual, but ends up in one level up
- see UVPT for detail
single-level paging
- x86 (32-bit): 4M single-level paging
- turn on the
PSE
bit on CR4
- add the
PS
bit to page entries
- VA → PA translation
- linear address
- bits 31-22: page directory index
- bits 21-0: offset into 4M page
- page directory entry
- bits 31-22: physical 4M page address
- bits 21-12: reserved
- bits 11-0: flags
- example
- xv6: used during booting - see
entrypgdir
in main.c
- demo: turn your JOS into using 4M pages
- general concept: superpages (also known as huge pages or large pages)
four-level paging