lkml.org 
[lkml]   [2023]   [Mar]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] vfio/pci/vfio_pci_core.c: add IORESOURCE_EXCLUSIVE flag
Date
While using a pci device (GPU) through the vfio-pci passthrough in QEMU
VM, host can mmap the PCI device which used by the guest through sysfs.

In this case, when the guest used the PCI device, the host could also
access the data stored in the PCI device memory.

Regarding this, there is a routine to check IORESOURCE_EXCLUSIVE through
iomem_is_exclusive() in pci_mmap_resource() of pci-sysfs.c, but vfio-pci
driver doesn't seem to set that flag.

Wouldn't it be better to use pci_request_selected_regions_exclusive() to
set the IORESOURCE_EXCLUSIVE flag rather than
pci_request_selected_regions() that was used previously?

Signed-off-by: Seunggyun Lee <sglee97@dankook.ac.kr>
---
drivers/vfio/pci/vfio_pci_core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/vfio/pci/vfio_pci_core.c b/drivers/vfio/pci/vfio_pci_core.c
index 26a541cc64d1..9731ac35b3ad 100644
--- a/drivers/vfio/pci/vfio_pci_core.c
+++ b/drivers/vfio/pci/vfio_pci_core.c
@@ -1779,7 +1779,7 @@ int vfio_pci_core_mmap(struct vfio_device *core_vdev, struct vm_area_struct *vma
* we need to request the region and the barmap tracks that.
*/
if (!vdev->barmap[index]) {
- ret = pci_request_selected_regions(pdev,
+ ret = pci_request_selected_regions_exclusive(pdev,
1 << index, "vfio-pci");
if (ret)
return ret;
--
2.25.1
\
 
 \ /
  Last update: 2023-03-27 00:46    [W:0.072 / U:0.440 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site