How TLB misses are handled (part 2)
18 May, 2010 § 1 Comment
This blog post was co-authored by Brendan Grebur and Jared Wein.
As a follow up from the previous post on TLB misses, I’d like to cover a special case of TLB misses.
At boot time there is a “chicken-and-egg” dilemma where the TLB is empty yet TLB values are needed immediately.
How does a computer handle this? First to make some assumptions:
- Linux Kernel
- Hardware-managed TLB
The x86 chips boot up in Real Mode with a very limited memory space and the MMU disabled. The Linux kernel is uncompressed and loaded into low-memory by the boot loader. Assembly code initializes a page directory for the initial kernel process, sets the CR3 register, then enables the PG bit in CR0 to effectively enable the MMU and begin addressing in Protected Mode. Since this area is kernel memory, the virtual address will be identical to the physical address, as kernel memory is never swapped out. The init process begins running C code and making memory references to initialize the rest of the kernel. TLB misses occur, but resolve themselves as the MMU walks the page directory previously set up for the kernel process.
Hey; that’s pretty cool Jared!