System Virtual Machines Introduction Key concepts Resource - - PowerPoint PPT Presentation

system virtual machines
SMART_READER_LITE
LIVE PREVIEW

System Virtual Machines Introduction Key concepts Resource - - PowerPoint PPT Presentation

System Virtual Machines Introduction Key concepts Resource virtualization processors memory I/O devices Performance issues Applications EECS 768 Virtual Machines 1 Introduction System virtual machine


slide-1
SLIDE 1

1 EECS 768 Virtual Machines

System Virtual Machines

  • Introduction
  • Key concepts
  • Resource virtualization

– processors – memory – I/O devices

  • Performance issues
  • Applications
slide-2
SLIDE 2

2 EECS 768 Virtual Machines

Introduction

  • System virtual machine

– capable of supporting multiple system images – each guest OS manages a set of virtualized hardware resources – VMM owns the real system resources – VMM allocates resources to guest OS by partitioning or time-sharing – guest OS allocates resources to its user programs – each virtual resource may not have physical resource – see Figure 8.1

slide-3
SLIDE 3

3 EECS 768 Virtual Machines

Introduction (2)

L i n u x A p p l i c a t i o n L i n u x O S W i n d o w s A p p l i c a t i o n W i n d o w s O S O S / 2 A p p l i c a t i o n O S / 2 O S I n t e l x 8 6 H a r d w a r e V i r t u a l I n t e l x 8 6 V i r t u a l I n t e l x 8 6 V i r t u a l I n t e l x 8 6

slide-4
SLIDE 4

4 EECS 768 Virtual Machines

Key Concepts

  • Outward appearance
  • State management
  • Resource control
  • Native and hosted virtual machines
  • Several concepts are simplifjed

– same guest and host ISA – uniprocessor systems

slide-5
SLIDE 5

5 EECS 768 Virtual Machines

Outward Appearance

  • Create an illusion of multiple machines.
  • Illusion in software

– no replication of hardware resources – switch to move devices from one VM to the

  • ther
  • Replication of hardware resources

– devices used directly by each user are replicated – rest of the hardware is shared

  • Hosted VM

– one OS more important than the other – UI of host OS provides way to display UI of the second

slide-6
SLIDE 6

6 EECS 768 Virtual Machines

State Management

  • Refers to how each individual guest state

is managed by the SVM

– each guest OS has an architected state – host resources may not be adequate

  • Fixed location for all guest state in host

– VMM manages pointer and switching – indirection can be very ineffjcient (Figure 8.3a)

  • Copy approach

– more effjcient (Figure 8.3b) – essential to allow direct execution of native code

slide-7
SLIDE 7

7 EECS 768 Virtual Machines

State Management (2)

P r o c e s s o r V M M M e m o r y R e g is t e r v a lu e s f o r V M 1 R e g i s t e r v a l u e s f o r V M 2 R e g i s t e r v a l u e s f o r V M 3 R e g is t e r B lo c k P o i n t e r V M M M e m o r y P r o c e s s o r P r o c e s s o r R e g is t e r s R e g is t e r v a lu e s f o r V M 1 R e g is t e r v a lu e s f o r V M 2 R e g is t e r v a lu e s f o r V M 3

slide-8
SLIDE 8

8 EECS 768 Virtual Machines

Resource Control

  • Refers to how the VMM maintains overall

control of all hardware resources.

  • Scheme similar to time-sharing OS

– VMM intercept accesses to privileged resources – get control on all privileged instructions – VMM handles the timer interrupt (Figure 8.4) – similar tradeofgs between fair scheduling and large switching overhead

slide-9
SLIDE 9

9 EECS 768 Virtual Machines

VMM Timesharing

  • VMM timeshares resources among

guests

– similar to OS timesharing

V M M s a v e s a r c h i t e c t e d s t a t e

  • f r u n n i n g V M

V M M r e s t o r e s a r c h i t e c t e d s t a t e f o r n e x t V M V M M s e t s P C t o t i m e r i n t e r r u p t h a n d l e r o f O S i n n e x t V M V M M s e t s t i m e r i n t e r v a l a n d e n a b l e s i n t e r r u p t s T i m e r i n t e r r u p t

  • c c u r s

V M M d e t e r m i n e s n e x t V M t o b e a c t i v a t e d V M M A c t i v e F i r s t V M A c t i v e N e x t V M A c t i v e

slide-10
SLIDE 10

10 EECS 768 Virtual Machines

Native and Hosted VM

  • Refers to the runtime privilege level of

the VMM (and OS).

– for effjciency, some part of VMM should have higher privileges

  • Figure 8.5

– analogous relationship to OS and user programs – native VM system: only the VMM operates in privilege mode – hosted VM: VMM installed on top of existing OS

  • some or no part of VMM in privilege mode
slide-11
SLIDE 11

11 EECS 768 Virtual Machines

Native and Hosted VM (2)

N o n - p r i v i l e g e d m o d e s P r i v i l e g e d M o d e A p p l i c a t i o n s O S T r a d i t i o n a l u n i p r o c e s s o r s y s t e m H a r d w a r e V i r t u a l M a c h i n e V M M H a r d w a r e V i r t u a l M a c h i n e H o s t O S H a r d w a r e V M M V i r t u a l M a c h i n e H o s t O S H a r d w a r e V M M N a t i v e V M s y s t e m U s e r - m o d e H o s t e d V M s y s t e m D u a l - m o d e H o s t e d V M s y s t e m

slide-12
SLIDE 12

12 EECS 768 Virtual Machines

Resource Virtualization – Processors

  • T

echniques to execute guest instructions – emulation – direct native execution

  • Emulation

– interpretation or binary translation – necessary if difgerent host and guest ISAs

  • Direct native execution

– same host and guest ISAs required – may still require emulation of some instructions

slide-13
SLIDE 13

13 EECS 768 Virtual Machines

Conditions for ISA Virtualizability

  • Conditions laid out by Popek and Goldberg.
  • Assume native system VMs

– VMM runs in system mode – all other software runs in user mode

  • Other assumptions

– hardware consists of processor and uniformly addressable memory – processor can operate in two modes, user and system – some subset of instructions only available in system mode – relocation register available for memory addressing

slide-14
SLIDE 14

14 EECS 768 Virtual Machines

Privileged Instructions

  • Instructions that trap if the machine is

in user mode, and does not trap if the machine is in system mode.

  • LPSW (Load Processor Status Word)

– PSW can change the state of the CPU – can also change the instruction address (PC)

  • SPT (Set CPU Timer)

– can change the CPU interval timer

slide-15
SLIDE 15

15 EECS 768 Virtual Machines

Privileged Instructions (cont…)

  • LRW (Load Real Address)

– translate a virtual address, save corresponding real address in a specifjed GPR

  • POPF (Pop Stack into Flags Register)

– replace fmag register with top of memory stack – interrupt-enable fmag can only be modifjed in system mode – no trap in user mode

slide-16
SLIDE 16

16 EECS 768 Virtual Machines

Sensitive Instructions

  • These specify instructions that

interact with hardware.

  • Control-sensitive instructions

– can change the confjguration of system resources – e.g., physical memory assigned to a program – e.g., LPSW – change mode of operation – e.g., SPT – change CPU timer value

slide-17
SLIDE 17

17 EECS 768 Virtual Machines

Sensitive Instructions (cont…)

  • Behavior-sensitive instructions

– behavior or results depend on confjguration

  • f resources

– e.g., LRA – depends on mapping (state) of real memory resource – e.g., POPF – depends on mode of operation

  • Innocuous instructions

– neither context-sensitive nor behavior- sensitive

  • see Figure 8.6
slide-18
SLIDE 18

18 EECS 768 Virtual Machines

Instruction T ypes – Summary

P r i v i l e g e d N o n - P r i v i l e g e d S e n s i t i v e B e h a v i o r - s e n s i t i v e C o n t r o l - s e n s i t i v e I n n o c u o u s S e n s i t i v e

slide-19
SLIDE 19

19 EECS 768 Virtual Machines

Components of a VMM

I n s t r u c t i o n t r a p o c c u r s D i s p a t c h e r A l l o c a t o r I n t e r p r e t e r R o u t i n e 2 I n t e r p r e t e r R o u t i n e 1 I n t e r p r e t e r R o u t i n e n T h e s e i n s t r u c t i o n s d e s i r e t o c h a n g e m a c h i n e r e s o u r c e s , e . g . L o a d R e l o c a t i o n B o u n d s R e g i s t e r T h e s e i n s t r u c t i o n s d o n o t c h a n g e m a c h i n e r e s o u r c e s , b u t a c c e s s p r i v i l e g e d r e s o u r c e s , e . g . I N , O U T , W r i t e T L B

P r i v i l e g e d I n s t r u c t i o n P r i v i l e g e d I n s t r u c t i o n P r i v i l e g e d I n s t r u c t i o n P r i v i l e g e d I n s t r u c t i o n

slide-20
SLIDE 20

20 EECS 768 Virtual Machines

Components of a VMM (2)

  • Dispatcher

– control module, called on hardware traps – decides the next module to be invoked

  • Allocator

– decides allocation of system resources – invoked by dispatcher to change machine resource allocation for VMs

  • Interpreter routines

– emulates trap functionality for each user VM – all traps except resource re-assignment traps

slide-21
SLIDE 21

21 EECS 768 Virtual Machines

Properties for a True VMM

  • Effjciency

– All innocuous instructions must be natively executed

  • Resource control

– impossible for guest s/w to directly change system resource confjgurations

  • Equivalence

– guaranty of identical behavior – allowed exceptions

  • performance can be slower
  • available resources can be limited
  • difgerences in performance due to changed

timings

slide-22
SLIDE 22

22 EECS 768 Virtual Machines

Requirement for True VMM

  • For any third-generation computer, a

VMM may be constructed if the set of sensitive instructions for a computer is a subset of the set of privileged instructions

– sensitive instructions always trap in user mode – non-privileged instructions execute natively

slide-23
SLIDE 23

23 EECS 768 Virtual Machines

Handling Privileged Instruction

  • Privileged instruction traps in the guest OS

G u e s t O S c o d e i n V M

( u s e r m o d e ) P r i v i l e g e d i n s t r u c t i o n ( L P S W ) … . . . … . . . N e x t i n s t r u c t i o n ( t a r g e t o f L P S W )

V M M c o d e

( p r i v i l e g e d m o d e ) L P S W R o u t i n e: C h a n g e m o d e t o p r i v i l e g e d C h e c k p r i v i l e g e l e v e l i n V M E m u l a t e i n s t r u c t i o n C o m p u t e t a r g e t R e s t o r e m o d e t o u s e r J u m p t o t a r g e t D i s p a t c h e r

slide-24
SLIDE 24

24 EECS 768 Virtual Machines

Problem Instructions

  • Sensitive instructions that are not

privileged

– POPF instruction in the Intel IA-32 – IA-32 not virtualizable by Popek-Goldberg rules

  • Handling problem instructions

– interpret all guest software – scan and patch problem instructions before execution – see Figure 8.11

slide-25
SLIDE 25

25 EECS 768 Virtual Machines

Patching Problem Instructions

C o n t r o l t r a n s f e r , e . g . t r a p

S c a n n e r a n d P a t c h e r V M M

C o d e P a t c h f o r d i s c o v e r e d c r i t i c a l i n s t r u c t i o n

O r i g i n a l P r o g r a m P a t c h e d P r o g r a m

slide-26
SLIDE 26

26 EECS 768 Virtual Machines

Patching Problem Instructions (2)

  • VMM takes control at the head of each basic

block.

  • Scan to fjnd problem instructions.
  • Replace with trap to VMM.
  • Place another trap at end of basic block.
  • Patched basic blocks can be chained.
  • Mostly similar to binary translation.
slide-27
SLIDE 27

27 EECS 768 Virtual Machines

Caching Emulation Code

  • High frequency of sensitive instructions

requiring interpretation increases VMM

  • verhead

– cache interpreter actions in code cache – cache block containing the problem instruction

  • Each instance of the problem instruction

in the code associated with a distinct piece of cache code

– make code instance-specifjc and optimize

  • Simpler management of cached code

– cached code executed in system mode

slide-28
SLIDE 28

28 EECS 768 Virtual Machines

Resource Virtualization – Memory

  • Generalizes the concept of virtual memory
  • Virtual memory basics

– application provided a logical view of memory – OS manages actual real memory – page tables provide logical-physical mapping – TLBs cache most common mappings

  • VMM distinguishes between real memory and

physical memory – VMM does real-physical memory mapping

slide-29
SLIDE 29

29 EECS 768 Virtual Machines

VMM Memory Support

  • VMM mechanism to virtualize memory

– maintain a per-VM real-map table – maps real pages to physical pages – VMM maintains a distinct swap space

  • Additional indirection layer may be

ineffjcient

– virtualize architected page tables – virtualize architected TLB

slide-30
SLIDE 30

30 EECS 768 Virtual Machines

Resource Virtualization – I/O

  • Virtualization of I/O is diffjcult

– large number of I/O devices – each I/O device controlled in specifjc manner – OS have to deal with similar issues

  • Virtualization Scheme

– provide VMs with virtual version of a device – intercept VM requests made to virtual device – convert request, perform equivalent action

slide-31
SLIDE 31

31 EECS 768 Virtual Machines

Virtualizing Devices

  • Dedicated devices

– display, keyboard, mouse etc., for each user – no device virtualization necessary – device requests could bypass the VM

  • Partitioned devices

– smaller virtual disks for each user – VMM use map to translate parameters – status information from the device also needs translation and refmection in the map

slide-32
SLIDE 32

32 EECS 768 Virtual Machines

Virtualizing Devices (cont…)

  • Shared devices

– network adapter, virtual network address for a VM – maintain state information for each guest VM – translate device outgoing/incoming requests

  • Spooled devices

– shared at higher granularity, e.g., printer – two-level spool tables in OS and VMM – VMM schedules requests from multiple guest VMs

slide-33
SLIDE 33

33 EECS 768 Virtual Machines

Performance Degradation

  • Setup

– initialize the state of the machine

  • Emulation

– sensitive instructions, maybe others

  • Interrupt handling

– handling interrupts generated by the guest programs

  • State saving

– save/restore state of VM during switch to VMM

  • Book-keeping

– special operations to maintain equivalent behavior

  • Time elongation

– some instructions may require more processing time

slide-34
SLIDE 34

34 EECS 768 Virtual Machines

VM Assists

  • Piece of hardware that improves performance
  • f an application when running on a VM.
  • May not always improve performance

– improve user program-VMM system-mode switches – improve address translation performance

  • VM assists can help improve performance of

– instruction emulation – other aspects of VMM – the user-mode system running as the guest – specifjc types of guest systems

slide-35
SLIDE 35

35 EECS 768 Virtual Machines

Instruction Emulation Assists

  • Emulation of privileged instructions in the

guest VM is a cause of fundamental overhead

– causes interrupt that is handled by the VMM – VMM emulation depends on whether guest VM in user or system mode when instruction called

  • Assist for LPSW on system/370

– check state of guest VM – provides hardware-assisted instructions to modify physical resources

  • Depends on VM system implementation
  • The overhead of the trap still remains

– eliminates overhead of emulation and mode switching

slide-36
SLIDE 36

36 EECS 768 Virtual Machines

VMM Assists

  • Context switch

– hardware to save/restore registers, machine state

  • Decoding of privileged instructions

– helps certain critical parts of the emulation

  • Virtual interval timer

– precise timer for all guest VMs to schedule jobs

  • Adding to the instruction set

– to help commonly executed VMM parts

slide-37
SLIDE 37

37 EECS 768 Virtual Machines

Improve Guest VM Performance

  • Requires guest system to be VMM aware

– avoid duplication of functionality – provide VMM with additional information (handshaking), e.g., DIAGNOSE instruction

  • Example; non-paged mode

– disable dynamic address translation in guest VM – no translation from virtual to real address – translation from real to physical done by VMM

  • Paravirtualization

– modify guest OS to work around diffjcult to virtualize ISA features – Xen for the IA-32, eliminates code detection, patching, shadow page tables

slide-38
SLIDE 38

38 EECS 768 Virtual Machines

Applications

  • Implementing multiprogramming
  • Multiple single-application virtual machines
  • Multiple secure environments
  • Mixed-OS environments
  • Legacy applications
  • Multiplatform application development
  • Gradual migration to new system
  • New system software development
  • Operating system training
  • Help desk support
  • Operating system instrumentation
  • Event monitoring
  • System encapsulation and checkpointing