Tutorial Week 9
What is the difference between the different MIPS address space segments? What is the use of each segment?
What functions exist to help you manage the TLB? Describe their use. (Hint: look in kern/arch/mips/include/tlb.h)
What macros are used to convert from a physical address to a kernel virtual address?
What address should the initial user stack pointer be?
What are the entryhi and entrylo co-processor registers? Describe their contents.
What do the as_* functions do? Why do we need as_prepare_load() and as_complete_load()?
What does vm_fault() do? When is it called?
Assuming a 2-level hierarchical page table (4k pages), show for the following virtual addresses:
- The page number and offset;
- the translated address (after any page allocation); and
- the contents of the page table after the TLB miss.
The page table is initially empty, with no L2 pages. You may assume that the allocator returns frames in order, so that the first frame allocated is frame 1, then frames 2, 3, 4, etc.
- What C expressions would you use to set or reset the valid bit in a page table entry?
- What C expression would you use to test if the valid bit is set?
- How would you extract the 12-bit offset (bits 0 - 11) from the virtual address?
- How would you convert the 10 most significant bits (22-31) of a virtual address into an index?
- How would you convert the next 10 most significant bits (12-21) into an index?
- How would you round down a virtual address to the base of the page?
Assignment 3 Exercises
By now you should be familiar enough with navigating the kernel source that you can find the answers to the questions below by yourself (Hint: use a source code browser or the grep utility). You may also find the MIPS r3000 reference useful.
C bitwise operations refresher
Given the following constants from the source code:
#define TLBHI_VPAGE 0xfffff000 #define TLBLO_PPAGE 0xfffff000 #define TLBLO_NOCACHE 0x00000800 #define TLBLO_DIRTY 0x00000400 #define TLBLO_VALID 0x00000200And a 32-bit page table entry and 32-bit virtual address is defined as
uint32_t pte; vaddr_t vaddr;