logo资料库

vfio-pci-passthrough.pdf

第1页 / 共33页
第2页 / 共33页
第3页 / 共33页
第4页 / 共33页
第5页 / 共33页
第6页 / 共33页
第7页 / 共33页
第8页 / 共33页
资料共33页,剩余部分请下载后查看
Slide 1
Slide 2
Slide 3
Slide 4
Slide 5
Slide 6
Slide 7
Slide 8
Slide 9
Slide 10
Slide 11
Slide 12
Slide 13
Slide 14
Slide 15
Slide 16
Slide 17
Slide 18
Slide 19
Slide 20
Slide 21
Slide 22
Slide 23
Slide 24
Slide 25
Slide 26
Slide 27
Slide 28
Slide 29
Slide 30
Slide 31
Slide 32
Slide 33
vfio-pci passthrough Fei Li fli@suse.com
Summary ➢ What is VFIO/IOMMU? Why want them? ➢ VFIO – qemu part ➢ VFIO – kernel part ➢ VFIO usage: how to passthrough a pci device 2
- What is VFIO/IOMMU? Why want them?
What is VFIO/IOMMU? ➢ The VFIO (Virtual Function I/O) driver is an IOMMU/device agnostic framework for exposing direct device access to userspace, in a secure, IOMMU protected environment. ➢ For x86, it needs the I/O MMU hardware support. ➢ VFIO consists of ➢ - kernel device driver: vfio_pci_driver, vfio_iommu_driver, vfio_dma ➢ - QEMU device class: VFIODevice, VFIOPCIDevice ➢ The guest can operate the pass-throughed PCI device by: - accessing the mapped PCI config space and memory space - ioctl() on a fd of the VFIO kernel device for control operations 4
What is VFIO/IOMMU? (Continue.) ➢ In qemu, use VFIO to configure IOMMU: e.g. ioctl(VFIO_SET_IOMMU) && ioctl(VFIO_IOMMU_MAP_DMA) 5
VFIO: device, group, container ➢ A group is a set of devices which is isolatable from all other devices, specialized in IOMMU. It is the minimum granularity. ➢ Within one container, different groups can share a set of page tables to reduce the duplication. The container provides little functionality: version check and extension query. ➢ The user needs to add a group into the container. ➢ The VFIO device API includes ioctls for describing the device, the I/O regions and their read/write/mmap offsets on the device descriptor, && mechanisms for describing and registering interrupt notifications. 6
Why want them? ➢ In short, for higher I/O performance by lessening the times of VM-EXIT/VM-ENTRY when accessing PCI BAR and doing DMA. 7
Why want them? (literal) ➢ - when accessing PCI BAR. The emulated guest BIOS emulate the BAR address for the guest (On the contrary, if expose the host real BAR to the guest, there may be conflicts between host real PCI BAR and the other emulated PCI device’s BAR in the guest). For the first time when BAR is accessed and can not be visited, the VM exists and does the address mapping between GPA and HPA using EPT, and records the mapping. When later access, no VM-exit is needed. ➢ - when PCI device communicates with GPA via DMA. When initializing the vfio: vfio_realize() in qemu, a memory mapping is established via vfio_region_mmap(). Then a (ioctl(s->container, VFIO_IOMMU_MAP_DMA, &dma_map) in qemu_vfio_do_mapping will do the real mapping between VFIO iova and HPA. 8
分享到:
收藏