当前位置:网站首页>IOMMU (VII) -vfio and mdev
IOMMU (VII) -vfio and mdev
2022-06-24 12:35:00 【Huiwei】
Have a look first vifo and mdev What modules does the kernel have , Then analyze the relationship between modules .
vfio It is an interface between user mode and kernel mode , Be similar to vhost and vhost-user, The specific usage is vfio.ko adopt /dev/vfio In the kernel, the user mode is provided with api,qemu perhaps dpdk use api Interact with kernel modules .
vfio-pci Is a kernel driver , Network card and NVME Disk and other devices can use this driver , Use vfio-pci Will be called to vfio-pci Of probe.vfio-pci For standard pci equipment , If multiple virtual machines want to use this pci The device is turned on pci The equipment sr-iov function , This pci The device becomes multiple standard pci equipment , One for each virtual machine .sr-iov It is a segmentation method of hardware resources , Not only DMA queue Such data slicing ,pci config space And so on , The hardware implementation is too complex ,GPU and NVME It is difficult for these devices to realize the segmentation of the control surface , But there are other ways to segment the data plane , Different virtual machines can share data plane functions and ensure isolation , Call this device mdev equipment , It's strict mediated Devices that can be virtualized .mdev.ko Provide users with interfaces to create virtual mdev equipment , Make virtual mdev And reality mdev relation , Put the real mdev It is called the parent device , At the same time, the virtual mdev And drive vfio-mdev matching ,vfio-mdev Begin probe.
vfio-pci and mdev-vfio Of probe All call vfio_add_group_dev Add your own ops, Generate a dev,qemu adopt /dev/vfio Access to this dev, Operate this again dev Is called to vfio-pci and vfio-mdev Of ops function ,vfio-pci work ,vfio-mdev Basically nothing , Call the parent device as soon as you change hands ops work , It is equivalent to calling GPU perhaps NVME The driver .sr-iov yes pci Standard device virtualization solutions ,mdev For the device virtualization solution privately owned by the manufacturer , The driver is implemented by the manufacturer , Hardware is also made by manufacturers , The combination of driver and hardware can achieve the effect of virtualization .
[[email protected] 81]# ll /sys/class/vfio/81/dev -r--r--r--. 1 root root 4096 May 28 10:31 /sys/class/vfio/81/dev
vfio group Not a concept created out of thin air ,vfio group and IOMMU The hardware group Closely related , therefore vfio Another important function is vfio_register_iommu_driver,vfio_iommu_type1.ko Just call this function to vfio Action registered IOMMU Of ops, One device DMA Use of pagetable You can go through this ops Configuration to IOMMU in .
qemu call memory_region_init_io register vfio-pci The equipment config space, Drive write in virtual machine config space,qemu Intercept and simulate .
pci_host_data_write->pci_data_write->pci_host_config_write_common->vfio_pci_write_config->vfio_msi_enable
qemu Call kernel vfio,irqbypass Used for holding vfio and kvm Connect .
vfio_msi_enable->vfio_enable_vectors(qemu Code )->vfio_pci_set_irqs_ioctl( kernel vfio Code )->vfio_pci_set_msi_trigger->vfio_msi_set_block->vfio_msi_set_vector_signal->irq_bypass_register_producer->pi_update_irte
qemu Call to the kernel at the same time kvm.
vfio_msi_enable->vfio_add_kvm_msi_virq->kvm_irqchip_add_irqfd_notifier_gsi->kvm_irqchip_assign_irqfd(qemu Code )->kvm_vm_ioctl(kvm Code )->kvm_irqfd->kvm_irqfd_assign->irq_bypass_register_consumer
The peripheral interrupt is coming ,vfio Handle ,signal kvm,kvm Then inject the virtual interrupt into the virtual machine .
vfio_msihandler->eventfd_signal wakeup 了 irqfd_wakeup->schedule_work
irqfd_inject->kvm_set_irq Interrupt to register
边栏推荐
- [mysql_16] variables, process control and cursors
- The pod is evicted due to insufficient disk space of tke node
- Hardware enterprise website ranking, 8 commonly used processes
- What are the low threshold financial products in 2022? Not much money
- How does the video networking / network penetration tool easynts permanently delete one of the devices?
- LS-DYNA beginner's experience
- Kubernetes practical skills: use cert manager to issue free certificates for DNSPod domain names
- Conceptual analysis of DDD Domain Driven Design
- Install MySQL in docker and modify my CNF profile
- How to check the situation that the national standard platform easygbs equipment video cannot be accessed by grabbing packets?
猜你喜欢

How stupid of me to hire a bunch of programmers who can only "Google"!

Opencv learning notes -- Separation of color channels and multi-channel mixing

Installation and operation of libuv

How is the e-commerce red envelope realized? For interview (typical high concurrency)

微医CodeReview工具链

巴比特 | 元宇宙每日必读:618成绩已然揭晓,在这份还算满意的答卷背后,数字藏品做出了多少贡献?...
Cloud native database: the outlet of the database, you can also take off

《回归故里》阅读笔记

MySQL 外键影响

使用开源工具 k8tz 优雅设置 Kubernetes Pod 时区
随机推荐
不用做实验的6分+基因家族纯生信思路~
Essential key steps in the construction of e-commerce live broadcast source code
怎样购买打新债 开户是安全的吗
Group planning - General Review
Install MySQL in docker and modify my CNF profile
How to purchase new bonds is it safe to open an account
Practice of dynamic load balancing based on open source tars
I'm in Shenzhen. Where can I open an account? Is it safe to open an account online now?
深度学习~11+高分疾病相关miRNA研究新视角
Hardware enterprise website ranking, 8 commonly used processes
Discussion on redis communication protocol
Cryptography series: collision defense and collision attack
As one of the bat, what open source projects does Tencent have?
Kubernetes best practice: graceful termination
Argo 全家桶如何让 DevOps 变的更容易?
Kubernetes practical technique: setting kernel parameters for pod
VaR in PHP_ export、print_ r、var_ Differences in dump debugging
[redisson] analysis of semaphore lock source code
Based on am335x development board arm cortex-a8 -- acontis EtherCAT master station development case
11+的基于甲基化组和转录组综合分析识别葡萄膜黑色素瘤中新的预后 DNA 甲基化特征~