A Comparison of Software and Hardware Techniques For x86 Virtualization

Download as pdf or txt
Download as pdf or txt
You are on page 1of 18

A Comparison of Software and

Hardware Techniques for x86


Virtualization

Keith Adams, Ole Agesen


VMware

Presented by Keith Rutkowski


Overview
● Introduction
● Classical Virtualization
● Software Virtualization
● Hardware Virtualization
● Comparisons / Experiments
● Conclusion
Introduction
● Historically x86 has lacked HW virtualization
● Paravirtualization and guest OS modding
produces great results, but not always possible
● Currently best VMMs use binary translation
● Now with AMD and Intel providing virtualization
extensions, we can evaluate performance
between hardware and software virtualization
Classical Virtualization
● What is “virtualization”?
– Popek & Goldberg in 1974
– Fidelity
● Software on VMM executes identically to on hardware
allowing for some timing effects
– Performance
● Majority of guest instructions executed directly by
hardware
– Safety
● The VMM manages all hardware resources
Methods of Classical Virtualization
● De-privileging
– Run guest OS at reduced privilege level so that
privileged instructions trap to the VMM
– VMM then emulates the HW performing the
instruction
● Primary and shadow structures
– Privileged state of HW is different than guest OS's
expectation
– Fake the privileged HW register values in a shadow
structure
Methods of Classical Virtualization
● Memory traces
– Needed to keep coherency of shadow structures
– Guest OS page table entries are write-protected so
shadow copies can be modified when trap occurs
– DMA devices must be protected from reads and
writes to trigger a trap for VMM to keep shadow
copy of memory region
● Traps are expensive, so what else can we try?
– Improve the guest OS / VMM interface
– Improve the VMM / hardware interface
Software Virtualization
● Interpreter
– Literally pretends to be an x86 processor executing
instructions
– BAD!!! One interpreted instruction requires
hundreds of real instructions to execute
● Binary translation
– Instructions are “interpreted” on demand in chunks
– Translated instructions are a safe instruction subset
– Most instructions are 1:1 translation
– Re-addressing concerns for accessing memory
Software Virtualization
● Binary translation
(source)
Software Virtualization
● Binary translation (translated)
Software Virtualization
● Adaptive binary translation
– Detect frequently trapping code, retranslate to avoid
traps, patch new code into execution chain
– Group load/stores in “batch” calls to trap only once
Hardware Virtualization
● Provide virtual registers to fool guest OS
● Introduce a guest privilege mode
– “vmrun” instruction switches to guest mode for
guest OS execution
– traps return back to normal kernel mode for VMM
execution
● Still no MMU virtualization though... =(
Comparisons / Experiments
● Software vs. hardware
– Trap elimination – adaptive BT replaces most traps
which hardware must encounter
– Emulation speed – adaptive BT predecoded
instructions beats hardware “accelerated” traps
– Callout avoidance – BT avoids callout costs, but
hardware performs them faster still
– Code density is preserved among the two
● Hardware and software suffer different
overheads and causes for the overheads
Comparisons / Experiments
● Mature SW vs. first generation HW
Comparisons / Experiments
● Mature SW vs. first generation HW
Comparisons / Experiments
● Mature SW vs. first generation HW
Conclusion
● New hardware extensions allow x86 direct
guest OS execution
● Hardware vs. software
– Both execute computational bound code at near
native speed
– Software VMM is preferable for I/O bound code
– Hardware VMM is preferable for system call bound
code
● Adding MMU virtualization benefits to HW will
help
Conclusion
● Hybrid solutions could offer the best of both
worlds
● Despite the maturity of the software solutions
and the recent appearance of the hardware
solutions, both perform equally
● Most practical scenarios benefit from software
virtualization though
Questions?

You might also like