提交 c2c23550 编写于 作者: K Kunkun Jiang 提交者: Zheng Zengkai

Revert "vfio/pci: Register an iommu fault handler"

virt inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I61SPO
CVE: NA

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

This reverts commit f7c0c57b.
Signed-off-by: NKunkun Jiang <jiangkunkun@huawei.com>
Reviewed-by: NKeqian Zhu <zhukeqian1@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 8d0cfd4d
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
#include <linux/vgaarb.h> #include <linux/vgaarb.h>
#include <linux/nospec.h> #include <linux/nospec.h>
#include <linux/sched/mm.h> #include <linux/sched/mm.h>
#include <linux/circ_buf.h>
#include "vfio_pci_private.h" #include "vfio_pci_private.h"
...@@ -389,41 +388,6 @@ static const struct vfio_pci_regops vfio_pci_dma_fault_regops = { ...@@ -389,41 +388,6 @@ static const struct vfio_pci_regops vfio_pci_dma_fault_regops = {
.add_capability = vfio_pci_dma_fault_add_capability, .add_capability = vfio_pci_dma_fault_add_capability,
}; };
static int
vfio_pci_iommu_dev_fault_handler(struct iommu_fault *fault, void *data)
{
struct vfio_pci_device *vdev = (struct vfio_pci_device *)data;
struct vfio_region_dma_fault *reg =
(struct vfio_region_dma_fault *)vdev->fault_pages;
struct iommu_fault *new;
u32 head, tail, size;
int ret = -EINVAL;
if (WARN_ON(!reg))
return ret;
mutex_lock(&vdev->fault_queue_lock);
head = reg->head;
tail = reg->tail;
size = reg->nb_entries;
new = (struct iommu_fault *)(vdev->fault_pages + reg->offset +
head * reg->entry_size);
if (CIRC_SPACE(head, tail, size) < 1) {
ret = -ENOSPC;
goto unlock;
}
*new = *fault;
reg->head = (head + 1) % size;
ret = 0;
unlock:
mutex_unlock(&vdev->fault_queue_lock);
return ret;
}
#define DMA_FAULT_RING_LENGTH 512 #define DMA_FAULT_RING_LENGTH 512
static int vfio_pci_dma_fault_init(struct vfio_pci_device *vdev) static int vfio_pci_dma_fault_init(struct vfio_pci_device *vdev)
...@@ -468,13 +432,6 @@ static int vfio_pci_dma_fault_init(struct vfio_pci_device *vdev) ...@@ -468,13 +432,6 @@ static int vfio_pci_dma_fault_init(struct vfio_pci_device *vdev)
header->entry_size = sizeof(struct iommu_fault); header->entry_size = sizeof(struct iommu_fault);
header->nb_entries = DMA_FAULT_RING_LENGTH; header->nb_entries = DMA_FAULT_RING_LENGTH;
header->offset = sizeof(struct vfio_region_dma_fault); header->offset = sizeof(struct vfio_region_dma_fault);
ret = iommu_register_device_fault_handler(&vdev->pdev->dev,
vfio_pci_iommu_dev_fault_handler,
vdev);
if (ret) /* the dma fault region is freed in vfio_pci_disable() */
goto out;
return 0; return 0;
out: out:
kfree(vdev->fault_pages); kfree(vdev->fault_pages);
...@@ -598,7 +555,7 @@ static void vfio_pci_disable(struct vfio_pci_device *vdev) ...@@ -598,7 +555,7 @@ static void vfio_pci_disable(struct vfio_pci_device *vdev)
struct pci_dev *pdev = vdev->pdev; struct pci_dev *pdev = vdev->pdev;
struct vfio_pci_dummy_resource *dummy_res, *tmp; struct vfio_pci_dummy_resource *dummy_res, *tmp;
struct vfio_pci_ioeventfd *ioeventfd, *ioeventfd_tmp; struct vfio_pci_ioeventfd *ioeventfd, *ioeventfd_tmp;
int i, bar, ret; int i, bar;
/* Stop the device from further DMA */ /* Stop the device from further DMA */
pci_clear_master(pdev); pci_clear_master(pdev);
...@@ -607,9 +564,6 @@ static void vfio_pci_disable(struct vfio_pci_device *vdev) ...@@ -607,9 +564,6 @@ static void vfio_pci_disable(struct vfio_pci_device *vdev)
VFIO_IRQ_SET_ACTION_TRIGGER, VFIO_IRQ_SET_ACTION_TRIGGER,
vdev->irq_type, 0, 0, NULL); vdev->irq_type, 0, 0, NULL);
ret = iommu_unregister_device_fault_handler(&vdev->pdev->dev);
WARN_ON(ret == -EBUSY);
/* Device closed, don't need mutex here */ /* Device closed, don't need mutex here */
list_for_each_entry_safe(ioeventfd, ioeventfd_tmp, list_for_each_entry_safe(ioeventfd, ioeventfd_tmp,
&vdev->ioeventfds_list, next) { &vdev->ioeventfds_list, next) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册