Homework: x86 paging

Read: Read chapters 5 and 6 of the Intel 80386 Reference Manual. These chapters explain the x86 Memory Management Unit (MMU), which we will cover in lecture today and which you need to understand in order to do lab 2.

Hand-In Procedure: You are to turn in this homework during lecture. Please write up your answers to the exercises below and hand them in to a 6.828 staff member at the beginning of lecture.

Assignment: Get the source code for lab 2, and read through the i386_vm_init() function in kern/pmap.c. Try to understand from the code what page mappings are being constructed. You may find the discussion in part 3 of the lab assignment helpful.

Turn in: Draw a diagram of the virtual address space constructed by i386_vm_init(), and identify any instances where multiple regions of virtual memory might be pointing to the same physical memory. Explain why the kernel might want to have different virtual addresses pointing to the same physical memory.

At the end of i386_vm_init(), the kernel finally enables paging, by setting the CR0_PG bit in the %cr0 register. This operation is surrounded by additional code that first installs and then removes a mapping for virtual addresses 0 through 4MB, as well as some assembly instructions that manipulate segmentation registers.

Turn in: Explain what would happen if paging was enabled without these additional mappings. How are the segmentation registers modified in the inline assembly in i386_vm_init() to allow these mappings to be removed?