600 likes | 613 Views
CompSci 510: Graduate OS. Landon Cox January 10, 2018. About me. Background BS in Math, CS: Duke ‘99 PhD in CSE: Michigan ‘05 Research interests OS and distributed systems Mobile computing Privacy and security. About CompSci 510. CompSci 510 is about operating-systems research
E N D
CompSci 510: Graduate OS Landon Cox January 10, 2018
About me • Background • BS in Math, CS: Duke ‘99 • PhD in CSE: Michigan ‘05 • Research interests • OS and distributed systems • Mobile computing • Privacy and security
About CompSci 510 • CompSci 510 is about operating-systems research • You will read a lot of old and new papers • You will perform a semester-long research project • What CompSci 510 is not about • Learning basic operating systems concepts • Will do some review, but you should already know this material • Who should take it? • Graduate students and undergrads who enjoyed CompSci 310
Abstractions, hardware reality Applications Programs Files, web Virtual Memory Threads Disk , NIC Page Tables Atomic Test/Set OS Hardware Hardware
Main government functions • Resource manager (who gets what and when) • Lock acquisition • Processes • Disk requests • Page eviction • Isolation and security (law and order) • Access control • Kernel bit • Authentication
Two roles of the OS Abstractions Government Modularity Simplicity Hide messy reality Law and order Fair, efficient allocation Source of trust Goals for each role?
Two roles of the OS Abstractions Government Modularity Simplicity Hide messy reality Law and order Fair, efficient allocation Source of trust How does OS enforce modularity?
Two roles of the OS Abstractions Government Modularity Simplicity Hide messy reality Law and order Fair, efficient allocation Source of trust How does OS ensure fair allocation?
Two roles of the OS Abstractions Government Modularity Simplicity Hide messy reality Law and order Fair, efficient allocation Source of trust What is the basis for trust? Why do we trust the government?
Key questions for semester • What are the right abstractions? • How should we enforce modularity? • How do we ensure fair, efficient resource allocation? • Is there a reasonable basis for trust? • We will read a lot of papers this semester • Useful to think about them in terms of these questions • Sometimes goals are in tension (e.g., modularity vs. efficiency) • Good papers help us understand the trade-offs
Course administration • Syllabus is online • Reading list/schedule is subject to change • In general, one or two papers per lecture • Grade composition • Paper summaries (5%) • Programming projects (20%) • Research project (25%) • In-class midterm (25%) • In-class final exam (25%)
Paper summaries • Post summaries to Piazza • Summaries will be available to all • Due before class • Summaries must include • Two positives • Two negatives • Two questions
Programming Projects • Done in groups of two or three • Email me your groups by January 18 • Two small programming projects • Virtual memory (50%) • Building a shell (50%)
Research Projects • Done in groups of two or three • Four phases • Form groups (due after first prog project) • Project proposal (5% of project grade) • Status report (20% of pg) • Final report and demo (75% of pg)
Exams • Both will be closed-note and in-class • Will cover topics covered to that point • Often will ask about composing systems • “How would SimOS run on top of LFS?” • Requires a clear understanding of both
Syllabus: project collaboration • Okay between groups • Programming syntax, course concepts • “What does this part of the project specification mean?” • Not okay between groups • Design/writing of another’s program • Includes prior class solutions and Piazza • “How do I do this part of the handout?” • Don’t post details of your solution to Piazza • If in doubt, ask me
https://www.wired.com/story/meltdown-spectre-bug-collision-intel-chip-flaw-discovery/https://www.wired.com/story/meltdown-spectre-bug-collision-intel-chip-flaw-discovery/
Understanding these attacks • Building blocks • Address spaces • Speculative execution • Side channels • Attack targets • Kernel memory • Web browser sandboxes (e.g., javascript)
Understanding these attacks • Building blocks • Address spaces • Speculative execution • Side channels • Attack targets • Kernel memory • Web browser sandboxes (e.g., javascript)
Hardware, OS interfaces Applications Job 1 Job 2 Job 3 CPU, Mem CPU, Mem CPU, Mem OS Memory CPU Hardware
Illusions of the address space • Address independence • Can use same numeric address in two processes • Each process has its own version of “address 4” • Each “address 4” refers to different data items • Protection • One process cannot corrupt another’s data • Virtual memory • Address space can be larger than physical memory
Dynamic address translation User process Translator (MMU) Physical memory Physical address Virtual address Base and bounds Segmentation Paging
Multi-level page table 0 1 … ? 1023 Level 1 NULL NULL Level 2 0: PhysPage, Res, Prot 0: PhysPage, Res, Prot 1: PhysPage, Res, Prot 1: PhysPage, Res, Prot … … 1023: PhysPage, Res, Prot ? ? 1023: PhysPage, Res, Prot
Accessing virtual memory User process Physical memory CPU Page table PTBR Page table base register (PTBR) OS
Accessing virtual memory User process Physical memory Access virtual address Physical pages CPU Page table PTBR OS
Accessing virtual memory User process Physical memory Access virtual address Determine if access is allowed Physical pages CPU Page table PTBR OS
Accessing virtual memory User process Physical memory Access virtual address Physical pages CPU Page table PTBR If OK, retrieve data, execute instruction OS
Accessing virtual memory User process Physical memory Access virtual address Physical pages CPU Page table PTBR If not OK, trap to OS OS
Accessing virtual memory User process Physical memory Access virtual address Physical pages CPU Page table PTBR If not OK, trap to OS Determine if access is valid OS
Accessing virtual memory User process If not valid, kill process Physical memory Access virtual address Physical pages CPU Page table PTBR If not OK, trap to OS OS
Accessing virtual memory User process Physical memory Access virtual address Physical pages CPU Page table PTBR If not OK, trap to OS If valid, determine if resident OS
Accessing virtual memory User process Physical memory Access virtual address Physical pages CPU Page table PTBR If not OK, trap to OS If resident, update protections OS
Accessing virtual memory User process Physical memory Access virtual address Physical pages CPU Page table PTBR If not OK, trap to OS If resident, update protections, retry faulting instruction OS
Accessing virtual memory User process Physical memory Access virtual address Physical pages CPU Page table PTBR If not OK, trap to OS OS If not resident, load non-resident page
Accessing virtual memory User process Physical memory Access virtual address Physical pages CPU Page table PTBR If not OK, trap to OS OS If not resident, load non-resident page, update page table
Accessing virtual memory User process Retry faulting instruction Physical memory Access virtual address Physical pages CPU Page table PTBR If not OK, trap to OS OS If not resident, load non-resident page, update page table
Multi-level page table 0 1 … ? 1023 Level 1 NULL NULL Level 2 0: PhysPage, Res, Prot 0: PhysPage, Res, Prot 1: PhysPage, Res, Prot 1: PhysPage, Res, Prot … … 1023: PhysPage, Res, Prot ? ? 1023: PhysPage, Res, Prot
User/kernel translation data 4GB Kernel data (same for all page tables) 3GB (0xc0000000) User data (different for every process) 0GB Virtual memory
Where to store translation data? • Point MMU to physical address where it resides • On x86, PTBR (aka CR3 register) refers to physical memory • To change page table, update PTBR • Data structure maintained in kernel virtual address space • Kernel instructions still reference virtual addresses • How does kernel manipulate translation data that is itself translated? • Page tables reside in kernel’s virtual memory • Kernel’s translation data always in physical memory (pinned) • Does anything else need to be pinned (and why)? • Kernel’s page fault handler code also has to be pinned. • Fault handling instructions cannot page themselves in
Where to store translation data? • How does kernel access data in user’s address space? • If for currently loaded process, access using current page table • If for another process, have to change page table
Kernel vs. user mode • Who sets up the data used by the MMU? • Can’t be the user process • Otherwise could access anything • Only kernel is allowed to modify any memory • Processor must know to allow kernel • To update the translator (e.g., set PTBR) • To execute privileged instructions (halt, do I/O)
Kernel vs. user mode • How does machine know kernel is running? • This requires hardware support • CPU supports different modes, kernel and user • Mode is indicated by a hardware register • Mode bit
Protection recap GBs of protected data • All memory accesses go through a translator • Who can modify translator’s data? • Only kernel can modify translator’s data • How do we know if kernel is running? • Mode bit indicates if kernel is running • Who can modify the mode bit? One bit of protected data Making progress: the amount of protected data is down to a bit
Protecting the mode bit • Can kernel change the mode bit? • Yes. Kernel is completely trusted. • Can user process change the mode bit? • Not directly • User programs need to invoke the kernel • Must be able to initiate a change
When to transition from user to kernel? • Exceptions (interrupts, traps) • Access something out of your valid address space • (e.g., segmentation fault) • Disk I/O finishes, causes interrupt • Timer pre-emption, causes interrupt • Page faults • System calls • Similar in purpose to a function call • Kernel as software library
Example system calls • Process management • Fork/exec (start a new process), exit, getpid • Signals • Kill (send a signal), sigaction (set up handler) • Memory management • Brk (extend the valid address space), mmap • File I/O • Open, close, read, write • Network I/O • Accept, send, receive • System management • Reboot