Interrupts in the guest VM A look at the steps needed to “reflect” hardware interrupts back into the ROM-BIOS for servicing.

Slides:



Advertisements
Similar presentations
The Microprocessor and its Architecture
Advertisements

Unit 4 Chapter-1 Multitasking. The Task State Segment.
Intel MP.
Microprocessors system architectures – IA32 real and virtual-8086 mode Jakub Yaghob.
IA32 Paging Scheme Introduction to the Pentium’s support for “virtual” memory.
Introduction to 8086 emulation Using ‘Virtual-8086’ mode to execute real-mode procedures in a protected-mode environment.
Task-Switching How the x86 processor assists with context-switching among multiple program-threads.
Interrupts in Protected-Mode Writing a protected-mode interrupt-service routine for the timer-tick interrupt.
Interrupts in Protected-Mode Writing a protected-mode interrupt-service routine for the timer-tick interrupt.
Prelude to Multiprocessing Detecting cpu and system-board capabilities with CPUID and the MP Configuration Table.
Operating Systems: Segments 1 Segmentation Hardware Support single user program system: – wish somehow to relocate address 0 to after operating system.
Processor Exceptions A survey of the x86 exceptions and mechanism for handling faults, traps, and aborts.
8086 emulation Using Virtual-8086 mode to execute real-mode procedures in a protected-mode environment.
Page-Faults in Linux How can we study the handling of page-fault exceptions?
Exceptions and Interrupts How does Linux handle service- requests from the cpu and from the peripheral devices?
Interrupts in Protected-Mode Writing a protected-mode interrupt-service routine for the timer-tick interrupt.
Deferred segment-loading An exercise on implementing the concept of ‘load-on-demand’ for the program-segments in an ELF executable file.
1 Hardware and Software Architecture Chapter 2 n The Intel Processor Architecture n History of PC Memory Usage (Real Mode)
X86 segmentation, page tables, and interrupts 3/17/08 Frans Kaashoek MIT
Using VM controls Examples of ‘event-injection’ by our ‘host’ VMM into its ‘guest’ VM.
What about ‘interrupts’? An introduction to the basic issues affecting the design of code that performs servicing of interrupts.
Resolving interrupt conflicts An introduction to reprogramming of the 8259A Interrupt Controllers.
Processor Exceptions A survey of the x86 exceptions and mechanism for handling faults, traps, and aborts.
Prelude to Multiprocessing Detecting cpu and system-board capabilities with CPUID and the MP Configuration Table.
Task-Switching How the x86 processor assists with context-switching among multiple program-threads.
The i/o-sensitive instructions An introduction to the software emulation of i/o-sensitive instructions in Virtual-8086 mode.
Setup for VM launch Using ‘vmxwrite’ and ‘vmxread’ for access to state-information in a Virtual Machine Control Structure.
Linux Operating System
VGA System Services How to use Linux’s ‘vm86()’ system-call to access the video ROM-BIOS functions.
Introduction to Interrupts
GNU/Linux assembly language Reviewing the basics of assembly language programming for Intel x86-based Linux systems.
On handling interrupts An introduction to the basic issues affecting the design of code that performs servicing of interrupts.
Prelude to Multiprocessing Detecting cpu and system-board capabilities with CPUID and the MP Configuration Table.
Microprocessor Systems Design I Instructor: Dr. Michael Geiger Spring 2012 Lecture 2: 80386DX Internal Architecture & Data Organization.
Our planned VMX demo Implementation-code for our ‘Guest’ VM and ‘Host’ VMM.
8086 emulation Using Virtual-8086 mode to execute real-mode procedures in a protected-mode environment.
Interrupts in Protected-Mode Writing a protected-mode interrupt-service routine for the timer-tick interrupt.
UNIT 2 Memory Management Unit and Segment Description and Paging
Intel IA32 OS Support -Refresh
An Introduction to 8086 Microprocessor.
Interrupts. What Are Interrupts? Interrupts alter a program’s flow of control  Behavior is similar to a procedure call »Some significant differences.
Windows Kernel Internals Traps, Interrupts, Exceptions
Computer architecture Lecture 6: Processor’s structure Piotr Bilski.
The Intel Microprocessors. Real Mode Memory Addressing Real mode, also called real address mode, is an operating mode of and later x86-compatible.
Multitasking Mr. Mahendra B. Salunke Asst. Prof. Dept. of Computer Engg., STES SITS, Narhe, Pune-41 STES Sinhgad Institute of Tech. & Science Dept. of.
CS 6560 Operating System Design Lecture 8: Memory Management.
Virtual 8086 Mode  The supports execution of one or more 8086, 8088, 80186, or programs in an protected-mode environment.  An 8086.
(-133)*33+44* *33+44*14 Input device memory calculator Output device controller Control bus data bus memory.
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.
80386DX. Programming Model The basic programming model consists of the following aspects: – Registers – Instruction Set – Addressing Modes – Data Types.
6. HAL and IDT ENGI 3655 Lab Sessions. Richard Khoury2 Textbook Readings  Interrupts ◦ Section  Hardware Abstraction Layer ◦ Section
Page Replacement Implementation Issues Text: –Tanenbaum ch. 4.7.
Microprocessor system architectures – IA32 security
Information Security - 2. Task Switching Every process has an associated Task State Segment, whose starting point is stored in the Task register. A task.
BIOS and DOS Interrupts Basic Input /Outpu System Disk Operating System.
Lecture 2. General-Purpose Computer Systems Prof. Taeweon Suh Computer Science Education Korea University ECM586 Special Topics in Embedded Systems.
The Microprocessor & Its Architecture A Course in Microprocessor Electrical Engineering Department Universitas 17 Agustus 1945 Jakarta.
1 Interrupts A Course in Microprocessor Electrical Engineering Dept. University of Indonesia.
Microprocessor Architecture
Homework / Exam Return and Review Exam #1 Reading Machine Projects
MICROPROCESSOR BASED SYSTEM DESIGN
Microprocessor and Assembly Language
Operating Systems Engineering
Anton Burtsev February, 2017
Basic Microprocessor Architecture
x86 segmentation, page tables, and interrupts
CS 301 Fall 2002 Computer Organization
CNET 315 Microprocessor & Assembly Language
REGISTER ORGANIZATION OF 80386
Presentation transcript:

Interrupts in the guest VM A look at the steps needed to “reflect” hardware interrupts back into the ROM-BIOS for servicing

The VME-bit in CR4 Our VMX demo-program set the VME-bit (bit #0) in Guest’s Control Register CR4 VMXEVMXE PAEPAE PSEPSE VMEVME Legend: VME (Virtual-8086 Extensions): 1=on, 0=off PSE (Page-Size Extensions): 1=on, 0=off PAE (Page-Address Extensions): 1=on, 0=off VMXE (Virtual Machine eXtensions Enabled): 1=yes, 0=no

Virtual-8086 Mode Extensions Software interrupt instructions (int $nn) will selectively be directed either to IDT-gates or to IVT-vectors, depending on a ‘bitmap’ located within the Task-State Descriptor This ‘interrupt redirection bitmap’ has 256 bits (one for each 8-bit interrupt-number) Its location within the TSS is immediately ahead of the I/O Permission Bitmap

Interrupt-redirection Bitmap 256 bits bits Task-State Segment = interrupt-redirection bitmap = I/O-permission bitmap = ‘IOMAP’ field (at offset 0x66) Interrupt-redirection Bitmap 256-bits ( = 32 longwords) I/O-Permission Bitmap bits ( = 8192 bytes) TSS base 25 longwords Legend: 1 = interrupt is directed to IDT 0 = interrupt is directed to IVT

Software INTs Only! The interrupt-redirection bitmap does NOT affect any ‘hardware’ interrupts – they are serviced by the interrupt-handlers whose entry-points are specified within the gate- descriptors that comprise the IDT How can the Guest VM in our VMX demo- program handle the ‘hardware’ interrupts generated by the peripheral devices?

We’ll modify our VMX demo One change to ‘vmxstep3.s’: guest_RFLAGS: 0x # IF=1, IOPL=3 One change to ‘vmxdemo.s’: in $0x21, %al# get master-PIC’s mask or $0x10, %al# mask UART interrupt out %al, $0x21# set master-PIC’s mask

Modify ‘guest_isrGPF’ We introduce a major modification into the guest’s General Protection Fault-handler, to “reflect” external device-interrupts back to ‘real-mode’ code in the ROM-BIOS that will be executed in ‘Virtual-8086 mode’ The steps needed to do this are based on ‘emulating’ the CPU’s usual response to an external interrupt in 8086 real-mode

CPU’s interrupt-response Push FLAGS register onto the stack Clear IF and TF bits in FLAGS register Push CS and IP registers onto the stack Acquire the device’s interrupt-ID number Lookup that ID-number’s interrupt-vector Put that vector’s ‘loword’ into IP register Put that vector’s ‘hiword’ into CS register Then resume CPU’s fetch-execute cycle

EFLAGS IDID VIPVIP VIFVIF ACAC VMVM RFRF 0 NTNT I/O PL OFOF DFDF IFIF TFTF SFSF ZFZF 0 AFAF 0 PFPF 1 CFCF IF (Interrupt-Flag): 1=on, 0=off VM (Virtual-8086 Mode): 1=on, 0=off IOPL (Input/Output Permission-Level): =00 (only ring0 can execute ‘in’ and ’out’) =01 (ring0 and ring1 can execute ‘in’ and ‘out’) =10 (ring0, ring1, ring2 can execute ‘in’ and ‘out’) =11 (ring0, ring1, ring2, ring3 can execute ‘in’ and ‘out’) NOTE: Virtual-8086 mode operates at the ‘ring3’ privilege-level

PIC masks Each Programmable Interrupt Controller has a ‘mask register’ that allows blocking of the interrupts from specific devices IRQ7IRQ7 IRQ6IRQ6 IRQ5IRQ5 IRQ4IRQ4 IRQ3IRQ3 IRQ2IRQ2 IRQ1IRQ1 IRQ0IRQ0 IRQFIRQF IRQEIRQE IRQDIRQD IRQCIRQC IRQBIRQB IRQAIRQA IRQ9IRQ9 IRQ8IRQ8 I/O Port 0x21 I/O Port 0xA1 Master-PIC mask-register Slave-PIC mask-register

GPF stack-frame GS FS DS ES SS SP EFLAGS CS IP error SS0:ESP0 ring0 stack ? ? ? ? ? FLAGS CS IP SS:SP (before) SS:SP (after) ring3 stack

GPF error-code selector-index EXTEXT INTINT TITI 15 \ Legend: EXT (External-event): 1=yes, 0=no INT (Interrupt-table): 1=yes, 0=no TI (Table-Indicator): 1=LDT, 0=GDT Index = Table’s element-number

GPF stack-frame GS FS DS ES SS SP EFLAGS CS IP error SS0:ESP0 ring0 stack hiwordloword Interrupt Vector Table hiwordloword hiwordloword hiwordloword hiwordloword hiwordloword hiwordloword hiwordloword hiwordloword hiwordloword hiwordloword hiwordloword hiwordloword hiwordloword hiwordloword