Intel 64 and IA-32 Architectures Software Developers Manual Volume 3B, System Programming Guide Part 2

Table Of Contents
28-4 Vol. 3
HANDLING BOUNDARY CONDITIONS IN A VIRTUAL MACHINE MONITOR
With host control of external interrupts, the VMM (or the host OS in a hosted VMM
model) manages the physical interrupt controllers in the platform and the interrupts
generated through them. The VMM exposes software-emulated virtual interrupt
controller devices (such as PIC and APIC) to each guest virtual machine instance.
28.3.1 Virtualization of Interrupt Vector Space
The Intel 64 and IA-32 architectures use 8-bit vectors of which 244 (20H - FFH) are
available for external interrupts. Vectors are used to select the appropriate entry in
the interrupt descriptor table (IDT). VMX operation allows each guest to control its
own IDT. Host vectors refer to vectors delivered by the platform to the processor
during the interrupt acknowledgement cycle. Guest vectors refer to vectors
programmed by a guest to select an entry in its guest IDT. Depending on the I/O
resource management models supported by the VMM design, the guest vector space
may or may not overlap with the underlying host vector space.
Interrupts from virtual devices: Guest vector numbers for virtual interrupts
delivered to guests on behalf of emulated virtual devices have no direct relation
to the host vector numbers of interrupts from physical devices on which they are
emulated. A guest-vector assigned for a virtual device by the guest operating
environment is saved by the VMM and utilized when injecting virtual interrupts on
behalf of the virtual device.
Interrupts from assigned physical devices: Hardware support for I/O device
assignment allows physical I/O devices in the host platform to be assigned
(direct-mapped) to VMs. Guest vectors for interrupts from direct-mapped
physical devices take up equivalent space from the host vector space, and
require the VMM to perform host-vector to guest-vector mapping for interrupts.
Figure 28-1 illustrates the functional relationship between host external interrupts
and guest virtual external interrupts. Device A is owned by the host and generates
external interrupts with host vector X. The host IDT is set up such that the interrupt
service routine (ISR) for device driver A is hooked to host vector X as normal. VMM
emulates (over device A) virtual device C in software which generates virtual inter-
rupts to the VM with guest expected vector P. Device B is assigned to a VM and gener-
ates external interrupts with host vector Y. The host IDT is programmed to hook the
VMM interrupt service routine (ISR) for assigned devices for vector Y, and the VMM
handler injects virtual interrupt with guest vector Q to the VM. The guest operating
system programs the guest to hook appropriate guest driver’s ISR to vectors P
and Q.