indicogniBuild a VMM

Lab

System call stepper

Used in chapter 00, the os-basics primer.

Single-step an app's svc from user mode into the kernel and back, then compare it with a page fault, predicting which of mode, PC, saved return address and reason change at each step.

Runs in browser
A system call, step by step The app in user mode runs mov x16, #20 then svc #0x80. The hardware switches to kernel mode, masks interrupts, saves the return address 0x1008 (the instruction after the svc) and the reason "svc #0x80", and jumps to the vector table slot at base 0x8000 plus 0x400. The kernel reads the reason (an svc), reads the request in x16 (20, getpid), puts the answer 42 in x0 and runs eret, which restores user mode and jumps to the saved address 0x1008. A page fault differs in one way: the saved address is the faulting instruction itself, so it runs again. app (user mode, EL0) kernel (kernel mode, EL1) 0x1000 mov x16, #20 0x1004 svc #0x80 0x1008 mov x1, x0 0x8400 b sync_from_user 0x9000 mrs x9, esr_el1 ... is it svc? yes 0x9010 cmp x16, #20 getpid? 0x9018 mov x0, #42 0x901c eret saved return address = 0x1008 reason = svc #0x80 restore user mode, PC = 0x1008 Page fault: the saved address is the faulting instruction, so it runs again.

All labs