Lab 3 tutorial
Instructor: Youngjin Kwon
1
Lab 3 tutorial Instructor: Youngjin Kwon 1 Lab 1 Lab 2 - - PowerPoint PPT Presentation
Lab 3 tutorial Instructor: Youngjin Kwon 1 Lab 1 Lab 2 Initialize page metadata (struct PageInfo) array kern/bootstrap.S Implement simple physical kern/entry.S memory allocator Kern/init.c Setup kernel virtual memory x64_vm_init() -
1
kern/entry.S Kern/init.c x64_vm_init() kern/bootstrap.S Initialize page metadata (struct PageInfo) array Implement simple physical memory allocator Setup kernel virtual memory
Key function: boot_map_region() Kernel Image
2
3
4
5
CPU registers Page table (root pointer)
6
7
9
10
Do you know what does the code mean?
11
called exception parameter
RIP CS EFLAGS RSP SS RSP When iret is executed, The instruction to continue execute The code segment selector to change to The value eflags register to load The stack pointer to load The stack segment selector to change to high address low address
12
RSP pointers after the instruction is executed High address Low address RIP CS EFLAGS RSP SS Exception parameter Low address High address
13
14
processer
Interrupt or exception? Page fault System call timer Control + C General protection error
15
16
Interrupt ReQuest (IRQ): Each hardware has a single output line connected to IRQ line All IRQ lines are connected to hardware circuit called Programmable Interrupt Controller (PIC)
number (0 to 255)
interrupt vector (or exception vector)
17
Each IDT entry looks like this:
CPU sets RIP to offset(16-31)||offset(0-15) to transfer control
18
Kernel User: OS stores processor states to a certain location User Kernel: OS restores the machine states from the location
19
RIP CS EFLAGS RSP SS Low address High address
20
[interrupt happens]
kernel function, trap()
21
22
23
24
25
from sys_getenvid syscall
26
Pointer from a user process
27
user/buggyhello.c user/buggyhello2.c user/evilhello.c
28
Now you can defeat buggyhello and evilhello!
29