07 Iovirt
07 Iovirt
Computing
I/O
VCPU-0
thread
1. Interrupt
QEMU (Userspace process) occurs, user
5. Guest OS process goes to
handles its kernel mode
3. Interrupts for host are handled by host OS interrupts
4. Interrupt for guest OS are normally
injected into guest via VMCS
KVM (kernel module)
Guest OS
Host OS 2. Guest OS configured in
VMCS to exit on interrupts
ring 0
Full virtualization VMM architecture
Host OS context VMM context
Guest application
Guest VM physical memory
ring 1 Guest OS
4. VMM kernel driver or
ring 0 userspace process handle 5. Interrupts handled by 2. Privileged action
I/O requests via emulation host and injected into guest traps to VMM
VMM
VMM kernel driver 3. VMM exits to host OS to handle I/O.
Some traps can handled by VMM (guest OS traps
(Host OS)
without world switch, e.g., exit only here)
once per batch of I/O requests
QEMU/KVM virtio optimization
ring 3 Root mode VMX mode
Guest
Guest VM physical memory application
PF VF VF VF
NIC
SR-IOV
• SR-IOV NIC communicates directly with device driver in guest OS
• Packets do not go to the host OS stack at all
• Packets switched at Layer-2 using VM virtual device’s MAC address
• Packets DMA’ed directly into guest VM memory, host OS not involved
• But, interrupts may still cause VM exit (interrupt can be for host too)
• Challenge: when guest device driver provides DMA buffers to VF, it
can only provide guest physical addresses (GPA) of the buffer
• NIC cannot access the DMA buffer memory using GPA alone
• SR-IOV capable NICs have an inbuilt MMU (IOMMU) to translate from
GPA to HPA
Summary
• Techniques for I/O virtualization
• Device emulation
• Virtio optimization
• Device passthrough or direct I/O (SR-IOV)