Intel IA32 OS Support -Refresh

Slides:



Advertisements
Similar presentations
More on Processes Chapter 3. Process image _the physical representation of a process in the OS _an address space consisting of code, data and stack segments.
Advertisements

Exceptional Control Flow Processes Today. Control Flow Processors do only one thing: From startup to shutdown, a CPU simply reads and executes (interprets)
Interrupts Chapter 8 – pp Chapter 10 – pp Appendix A – pp 537 &
Memory Management Paging &Segmentation CS311, CS350 & CS550.
Unit 4 Chapter-1 Multitasking. The Task State Segment.
Intel MP.
Microprocessors system architectures – IA32 real and virtual-8086 mode Jakub Yaghob.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 2: Computer-System Structures Computer System Operation I/O Structure Storage.
Interrupts What is an interrupt? What does an interrupt do to the “flow of control” Interrupts used to overlap computation & I/O – Examples would be console.
OS2-1 Chapter 2 Computer System Structures. OS2-2 Outlines Computer System Operation I/O Structure Storage Structure Storage Hierarchy Hardware Protection.
Architectural Support for OS March 29, 2000 Instructor: Gary Kimura Slides courtesy of Hank Levy.
X86 segmentation, page tables, and interrupts 3/17/08 Frans Kaashoek MIT
OS Fall ’ 02 Introduction Operating Systems Fall 2002.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 2: Computer-System Structures Computer System Operation I/O Structure Storage.
Architectural Support for Operating Systems. Announcements Most office hours are finalized Assignments up every Wednesday, due next week CS 415 section.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 2: Computer-System Structures Computer System Operation I/O Structure Storage.
OS Spring’03 Introduction Operating Systems Spring 2003.
Abhinav Kamra Computer Science, Columbia University 2.1 Operating System Concepts Silberschatz, Galvin and Gagne  2002 Chapter 2: Computer-System Structures.
Linux Operating System
1 Last Class: Introduction Operating system = interface between user & architecture Importance of OS OS history: Change is only constant User-level Applications.
Introduction to Interrupts
1 OS & Computer Architecture Modern OS Functionality (brief review) Architecture Basics Hardware Support for OS Features.
UNIT 2 Memory Management Unit and Segment Description and Paging
General System Architecture and I/O.  I/O devices and the CPU can execute concurrently.  Each device controller is in charge of a particular device.
Interrupts. What Are Interrupts? Interrupts alter a program’s flow of control  Behavior is similar to a procedure call »Some significant differences.
80386DX.
CHAPTER 2: COMPUTER-SYSTEM STRUCTURES Computer system operation Computer system operation I/O structure I/O structure Storage structure Storage structure.
Chapter 2: Computer-System Structures
Khaled A. Al-Utaibi  Interrupt-Driven I/O  Hardware Interrupts  Responding to Hardware Interrupts  INTR and NMI  Computing the.
Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.
1 Chapter 2: Computer-System Structures  Computer System Operation  I/O Structure  Storage Structure  Storage Hierarchy  Hardware Protection  General.
CSC 2405 Computer Systems II Exceptions Mini-Lecture Traps & Interrupts.
Interrupt driven I/O. MIPS RISC Exception Mechanism The processor operates in The processor operates in user mode user mode kernel mode kernel mode Access.
Virtual 8086 Mode  The supports execution of one or more 8086, 8088, 80186, or programs in an protected-mode environment.  An 8086.
Exceptional Control Flow Topics Exceptions except1.ppt CS 105 “Tour of the Black Holes of Computing”
Operating Systems 1 K. Salah Module 1.2: Fundamental Concepts Interrupts System Calls.
1 CS.217 Operating System By Ajarn..Sutapart Sappajak,METC,MSIT Chapter 2 Computer-System Structures Slide 1 Chapter 2 Computer-System Structures.
Silberschatz, Galvin and Gagne  Applied Operating System Concepts Chapter 2: Computer-System Structures Computer System Architecture and Operation.
EFLAG Register of The The only new flag bit is the AC alignment check, used to indicate that the microprocessor has accessed a word at an odd.
Microprocessor system architectures – IA32 tasks Jakub Yaghob.
Interrupt driven I/O Computer Organization and Assembly Language: Module 12.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 2: Computer-System Structures Computer System Operation I/O Structure Storage.
Chapter 2: Computer-System Structures(Hardware) or Architecture or Organization Computer System Operation I/O Structure Storage Structure Storage Hierarchy.
Lecture 5 Rootkits Hoglund/Butler (Chapters 1-3).
Introduction to Operating Systems
An Interrupt is either a Hardware generated CALL (externally derived from a hardware signal) OR A Software-generated CALL (internally derived from.
Chapter 2: Computer-System Structures(Hardware)
Chapter 2: Computer-System Structures
Memory Management Paging (continued) Segmentation
MICROPROCESSOR BASED SYSTEM DESIGN
Microprocessor and Assembly Language
Microprocessor Systems Design I
Anton Burtsev February, 2017
Exceptional Control Flow
Interrupts – (Chapter 12)
x86 segmentation, page tables, and interrupts
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 2: Computer-System Structures Computer System Operation I/O Structure Storage.
Memory Management Paging (continued) Segmentation
Computer-System Architecture
Module 2: Computer-System Structures
Exceptions Control Flow
Architectural Support for OS
Module 2: Computer-System Structures
Architectural Support for OS
Chapter 2: Computer-System Structures
Chapter 2: Computer-System Structures
Module 2: Computer-System Structures
Module 2: Computer-System Structures
Memory Management Paging (continued) Segmentation
Interrupts and System Calls
Presentation transcript:

Intel IA32 OS Support -Refresh Tore Larsen

We need to … Allow OS to control system Allow OS to interact with I/O Allow other parts to request OS services Protect OS from other parts of system Protect user processes from each other Protect I/O devices from access by other parts Key resources CPU, Memory, I/O devices 7.10.09 INF3151 - Tore Larsen

Areas of OS Support Memory management Protection of SW modules Multitasking Exception & interrupt handling Multiprocessing Cache management Hardware resource & power management Debugging, performance monitoring 7.10.09 INF3151 - Tore Larsen

Fundamental Concepts Privilege levels HW-level exceptional control flow Interrupts Traps 7.10.09 INF3151 - Tore Larsen

Privilege Levels An fundamental concept for protection Intel offers four levels of privilege (0—3), at any instant in time, the processor is logically at exactly one level Many OS’es use only the highest (0), and the lowest (3) levels Classic UNIX position. Portability reasons High privilege You can do anything Used for the OS kernel Low privilege You can do less Used for application programs Used to protect other modules and the kernel from the application programs Privilege levels are applied by other system mechanisms How about privilege levels when executing more than one instruction at any time? 7.10.09 INF3151 - Tore Larsen

Protecting Instructions Privileged instructions are legal only when processor is the corresponding privilege level If the processor is not at a sufficiently high privilege level, the instruction faults, and the OS is invoked and notified that an illegal instruction was issued 7.10.09 INF3151 - Tore Larsen

7.10.09 INF3151 - Tore Larsen

7.10.09 INF3151 - Tore Larsen

System Level Registers & Data Structures (ii) 7.10.09 INF3151 - Tore Larsen

Example Privileged Registers Flag register, EFLAG Processor state indicator bits Control registers CR0 System control flags CR2 Page fault linear address CR3 Page directory base CR4 Extensions Instruction pointer register, EIP 7.10.09 INF3151 - Tore Larsen

Example System Instructions 7.10.09 INF3151 - Tore Larsen

Tasks 7.10.09 INF3151 - Tore Larsen

Transferring Control Across Privilege Levels Gates Call gates Trap gates Interrupt gates Task gates Sysenter/sysexit 7.10.09 INF3151 - Tore Larsen

HW Level Exceptional Control Flow (Intel Terminology) Interrupt Asynchronous event, typically triggered by an I/O device Pending interrupts checked (and handled) before each instruction fetch Eventually resumes at next instruction Exception Synchronous event, triggered by the processing of an instruction Three classes of exceptions Trap Intentional. Resumes at next instruction Fault Error conditions that may be handled by handler. Re-executes faulting instruction if doable, otherwise makes sure faulting process is aborted Abort Unrecoverable, fatal error. Terminates process, …possibly also system IA-32 supports precise interrupts Interrupts and exceptions are conceptually similar, Interrupts happen at any time, asynchronous to the execution of instructions The occurrence of an interrupt is registered as a “pending interrupt” Before fetching the next instruction, the processor control section checks for pending interrupts In effect, pending interrupts are ignored until the processor is ready to fetch a new instruction Exceptions may occur at most phases of the instruction cycle; i.e.. Fetch, Decode, Execute, Memory, Write Back Faults must be handled in ways that allow re-executing the faulting instruction when appropiate 7.10.09 INF3151 - Tore Larsen

Actions taken on interrupt/exception Processor pushes status information (SS, EFLAGS register, CS (code segment register), and return address (EIP) onto stack Pushes error code (if appropriate) onto stack Service routine executed Return from interrupt instruction restores state of interrupted process 7.10.09 INF3151 - Tore Larsen

Interrupt Description Table (IDT) Used to locate appropriate service routine for each interrupt type Used similarly for interrupts and exceptions IDTR register specifies base address & length of IDT Intel uses vectored interrupts. The vector is a number provided by the interrupting unit that identifies the interrupt type. The vector (scaled by eight) is used to index into the IDT Each entry in IDT is an eight-byte descriptor which contains a segment selector for the handler’s code segment, an offset within the code segment, and access rights information 7.10.09 INF3151 - Tore Larsen

IDT entries Max 256 entries 0—31: Architecture-defined, or reserved by Intel for future use 32—255: ”User defined,” i.e. OS-defined 7.10.09 INF3151 - Tore Larsen

Interrupt priorities Simultaneous exceptions and interrupts are prioritized in eight classes Highest class (1) Hardware reset, machine check Lowest class (8) Faults on executing an instruction 7.10.09 INF3151 - Tore Larsen

Masking IF- and RF-flags in the EFLAGS register may be used to inhibit the generation of some interrupts 7.10.09 INF3151 - Tore Larsen

Some interrupt handling instructions LIDT Load IDTR register (32 bit) from memory. Privileged instruction (CPL = 0) SIDT Store IDTR register (32 bit) to memory. Non-privileged instruction INT Explicit call to any specific exception INTO, INT 3, BOUND Allow SW exception checking. Respectively Overflow, Breakpoint, and Range CLI, STI Clear/Set Interrupt Enable Flag PUSHF, POPF Push/pop Flags on/off stack IRET Return from interrupt 7.10.09 INF3151 - Tore Larsen

Virtual memory support (Providing and Protecting Memory) Segmentation and paging Basic flat memory model Contiguous unsegmented address space Set up (at least) one code and one data segment that both map entire address space Protected flat memory model As above except segment limits set to match physical memory present Multi segment model Each process is given its own table of segment descriptors and its own segments Works intimately with privilege level and access control Let’s skip the grimy details for now 7.10.09 INF3151 - Tore Larsen

Virtual memory support ii Segment registers contain segment selectors (14 bit) Segment selectors index into one of two (GDT/LDT) descriptor tables, containing segment descriptors Segment descriptors contain page directory base address and limit, ++ 7.10.09 INF3151 - Tore Larsen

System Level Registers & Data Structures (ii) 7.10.09 INF3151 - Tore Larsen

Cache support Cache policy set through CD and NW bits in CR3 (bits 4 and 3) Write back Write through Cache disabled INVD, Invalidate internal caches WBINVD, Write back, and invalidate internal caches 7.10.09 INF3151 - Tore Larsen

I/O support See foils on I/O Special instructions Memory mapped I/O Interrupts Polling 7.10.09 INF3151 - Tore Larsen

Virtual Machine Extensions Support for running several virtual machines concurrently on single physical processor Virtual Machine Monitors (VMM) Guest software Important resurface of technology similar to IBM/VM However, not a core issue on this course now 7.10.09 INF3151 - Tore Larsen

Multiprocessor support Multiple processors Single “hyperthreaded” processor Single “multi-core” processor chip Combinations of above Some issues Distribution of tasks among processors Distribution of interrupts among processors Ensuring memory consistency and cache coherence 7.10.09 INF3151 - Tore Larsen

Literature Randal E. Bryant and David O’Hallaron, Computer Systems: A Programmer’s Perspective, Prentice-Hall, 2003. Chapter Eight, pp. 585-648. http://csapp.cs.cmu.edu/ Intel® 64 and IA-32 Architectures Software Developer’s Manual, Volume 1: Basic Architecture http://www.intel.com/design/processor/manuals/253665.pdf Intel® 64 and IA-32 Architectures Software Developer’s Manual Volume 3A: System Programming Guide, Part 1 http://www.intel.com/design/processor/manuals/253668.pdf Intel® 64 and IA-32 Architectures Software Developer’s Manual Volume 3B: System Programming Guide, Part 2 http://www.intel.com/design/processor/manuals/253669.pdf 7.10.09 INF3151 - Tore Larsen