提交 b6f29e4d 编写于 作者: E Eric Auger 提交者: Zheng Zengkai

vfio/pci: Register and allow DMA FAULT IRQ signaling

virt inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I401IF
CVE: NA

------------------------------

Register the VFIO_IRQ_TYPE_NESTED/VFIO_IRQ_SUBTYPE_DMA_FAULT
IRQ that allows to signal a nested mode DMA fault.
Signed-off-by: NEric Auger <eric.auger@redhat.com>
Signed-off-by: Kunkun Jiang<jiangkunkun@huawei.com>
Reviewed-by: NKeqian Zhu <zhukeqian1@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 31ed6dc2
......@@ -396,6 +396,7 @@ vfio_pci_iommu_dev_fault_handler(struct iommu_fault *fault, void *data)
(struct vfio_region_dma_fault *)vdev->fault_pages;
struct iommu_fault *new;
u32 head, tail, size;
int ext_irq_index;
int ret = -EINVAL;
if (WARN_ON(!reg))
......@@ -420,7 +421,19 @@ vfio_pci_iommu_dev_fault_handler(struct iommu_fault *fault, void *data)
ret = 0;
unlock:
mutex_unlock(&vdev->fault_queue_lock);
if (ret)
return ret;
ext_irq_index = vfio_pci_get_ext_irq_index(vdev, VFIO_IRQ_TYPE_NESTED,
VFIO_IRQ_SUBTYPE_DMA_FAULT);
if (ext_irq_index < 0)
return -EINVAL;
mutex_lock(&vdev->igate);
if (vdev->ext_irqs[ext_irq_index].trigger)
eventfd_signal(vdev->ext_irqs[ext_irq_index].trigger, 1);
mutex_unlock(&vdev->igate);
return 0;
}
#define DMA_FAULT_RING_LENGTH 512
......@@ -475,6 +488,12 @@ static int vfio_pci_dma_fault_init(struct vfio_pci_device *vdev)
if (ret) /* the dma fault region is freed in vfio_pci_disable() */
goto out;
ret = vfio_pci_register_irq(vdev, VFIO_IRQ_TYPE_NESTED,
VFIO_IRQ_SUBTYPE_DMA_FAULT,
VFIO_IRQ_INFO_EVENTFD);
if (ret) /* the fault handler is also freed in vfio_pci_disable() */
goto out;
return 0;
out:
kfree(vdev->fault_pages);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册