Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'vfio-v5.10-rc3' of git://github.com/awilliam/linux-vfio

Pull VFIO fixes from Alex Williamson:

- Remove code by using existing helper (Zenghui Yu)

- fsl-mc copy-user return and underflow fixes (Dan Carpenter)

- fsl-mc static function declaration (Diana Craciun)

- Fix ioeventfd sleeping under spinlock (Alex Williamson)

- Fix pm reference count leak in vfio-platform (Zhang Qilong)

- Allow opening IGD device w/o OpRegion support (Fred Gao)

* tag 'vfio-v5.10-rc3' of git://github.com/awilliam/linux-vfio:
vfio/pci: Bypass IGD init in case of -ENODEV
vfio: platform: fix reference leak in vfio_platform_open
vfio/pci: Implement ioeventfd thread handler for contended memory lock
vfio/fsl-mc: Make vfio_fsl_mc_irqs_allocate static
vfio/fsl-mc: prevent underflow in vfio_fsl_mc_mmap()
vfio/fsl-mc: return -EFAULT if copy_to_user() fails
vfio/type1: Use the new helper to find vfio_group

+50 -27
+7 -3
drivers/vfio/fsl-mc/vfio_fsl_mc.c
··· 248 248 info.size = vdev->regions[info.index].size; 249 249 info.flags = vdev->regions[info.index].flags; 250 250 251 - return copy_to_user((void __user *)arg, &info, minsz); 251 + if (copy_to_user((void __user *)arg, &info, minsz)) 252 + return -EFAULT; 253 + return 0; 252 254 } 253 255 case VFIO_DEVICE_GET_IRQ_INFO: 254 256 { ··· 269 267 info.flags = VFIO_IRQ_INFO_EVENTFD; 270 268 info.count = 1; 271 269 272 - return copy_to_user((void __user *)arg, &info, minsz); 270 + if (copy_to_user((void __user *)arg, &info, minsz)) 271 + return -EFAULT; 272 + return 0; 273 273 } 274 274 case VFIO_DEVICE_SET_IRQS: 275 275 { ··· 472 468 { 473 469 struct vfio_fsl_mc_device *vdev = device_data; 474 470 struct fsl_mc_device *mc_dev = vdev->mc_dev; 475 - int index; 471 + unsigned int index; 476 472 477 473 index = vma->vm_pgoff >> (VFIO_FSL_MC_OFFSET_SHIFT - PAGE_SHIFT); 478 474
+1 -1
drivers/vfio/fsl-mc/vfio_fsl_mc_intr.c
··· 13 13 #include "linux/fsl/mc.h" 14 14 #include "vfio_fsl_mc_private.h" 15 15 16 - int vfio_fsl_mc_irqs_allocate(struct vfio_fsl_mc_device *vdev) 16 + static int vfio_fsl_mc_irqs_allocate(struct vfio_fsl_mc_device *vdev) 17 17 { 18 18 struct fsl_mc_device *mc_dev = vdev->mc_dev; 19 19 struct vfio_fsl_mc_irq *mc_irq;
+1 -1
drivers/vfio/pci/vfio_pci.c
··· 385 385 pdev->vendor == PCI_VENDOR_ID_INTEL && 386 386 IS_ENABLED(CONFIG_VFIO_PCI_IGD)) { 387 387 ret = vfio_pci_igd_init(vdev); 388 - if (ret) { 388 + if (ret && ret != -ENODEV) { 389 389 pci_warn(pdev, "Failed to setup Intel IGD regions\n"); 390 390 goto disable_exit; 391 391 }
+35 -8
drivers/vfio/pci/vfio_pci_rdwr.c
··· 356 356 return done; 357 357 } 358 358 359 - static int vfio_pci_ioeventfd_handler(void *opaque, void *unused) 359 + static void vfio_pci_ioeventfd_do_write(struct vfio_pci_ioeventfd *ioeventfd, 360 + bool test_mem) 360 361 { 361 - struct vfio_pci_ioeventfd *ioeventfd = opaque; 362 - 363 362 switch (ioeventfd->count) { 364 363 case 1: 365 - vfio_pci_iowrite8(ioeventfd->vdev, ioeventfd->test_mem, 364 + vfio_pci_iowrite8(ioeventfd->vdev, test_mem, 366 365 ioeventfd->data, ioeventfd->addr); 367 366 break; 368 367 case 2: 369 - vfio_pci_iowrite16(ioeventfd->vdev, ioeventfd->test_mem, 368 + vfio_pci_iowrite16(ioeventfd->vdev, test_mem, 370 369 ioeventfd->data, ioeventfd->addr); 371 370 break; 372 371 case 4: 373 - vfio_pci_iowrite32(ioeventfd->vdev, ioeventfd->test_mem, 372 + vfio_pci_iowrite32(ioeventfd->vdev, test_mem, 374 373 ioeventfd->data, ioeventfd->addr); 375 374 break; 376 375 #ifdef iowrite64 377 376 case 8: 378 - vfio_pci_iowrite64(ioeventfd->vdev, ioeventfd->test_mem, 377 + vfio_pci_iowrite64(ioeventfd->vdev, test_mem, 379 378 ioeventfd->data, ioeventfd->addr); 380 379 break; 381 380 #endif 382 381 } 382 + } 383 + 384 + static int vfio_pci_ioeventfd_handler(void *opaque, void *unused) 385 + { 386 + struct vfio_pci_ioeventfd *ioeventfd = opaque; 387 + struct vfio_pci_device *vdev = ioeventfd->vdev; 388 + 389 + if (ioeventfd->test_mem) { 390 + if (!down_read_trylock(&vdev->memory_lock)) 391 + return 1; /* Lock contended, use thread */ 392 + if (!__vfio_pci_memory_enabled(vdev)) { 393 + up_read(&vdev->memory_lock); 394 + return 0; 395 + } 396 + } 397 + 398 + vfio_pci_ioeventfd_do_write(ioeventfd, false); 399 + 400 + if (ioeventfd->test_mem) 401 + up_read(&vdev->memory_lock); 383 402 384 403 return 0; 404 + } 405 + 406 + static void vfio_pci_ioeventfd_thread(void *opaque, void *unused) 407 + { 408 + struct vfio_pci_ioeventfd *ioeventfd = opaque; 409 + 410 + vfio_pci_ioeventfd_do_write(ioeventfd, ioeventfd->test_mem); 385 411 } 386 412 387 413 long vfio_pci_ioeventfd(struct vfio_pci_device *vdev, loff_t offset, ··· 483 457 ioeventfd->test_mem = vdev->pdev->resource[bar].flags & IORESOURCE_MEM; 484 458 485 459 ret = vfio_virqfd_enable(ioeventfd, vfio_pci_ioeventfd_handler, 486 - NULL, NULL, &ioeventfd->virqfd, fd); 460 + vfio_pci_ioeventfd_thread, NULL, 461 + &ioeventfd->virqfd, fd); 487 462 if (ret) { 488 463 kfree(ioeventfd); 489 464 goto out_unlock;
+1 -2
drivers/vfio/platform/vfio_platform_common.c
··· 267 267 268 268 ret = pm_runtime_get_sync(vdev->device); 269 269 if (ret < 0) 270 - goto err_pm; 270 + goto err_rst; 271 271 272 272 ret = vfio_platform_call_reset(vdev, &extra_dbg); 273 273 if (ret && vdev->reset_required) { ··· 284 284 285 285 err_rst: 286 286 pm_runtime_put(vdev->device); 287 - err_pm: 288 287 vfio_platform_irq_cleanup(vdev); 289 288 err_irq: 290 289 vfio_platform_regions_cleanup(vdev);
+5 -12
drivers/vfio/vfio_iommu_type1.c
··· 1993 1993 1994 1994 list_splice_tail(iova_copy, iova); 1995 1995 } 1996 + 1996 1997 static int vfio_iommu_type1_attach_group(void *iommu_data, 1997 1998 struct iommu_group *iommu_group) 1998 1999 { ··· 2010 2009 2011 2010 mutex_lock(&iommu->lock); 2012 2011 2013 - list_for_each_entry(d, &iommu->domain_list, next) { 2014 - if (find_iommu_group(d, iommu_group)) { 2015 - mutex_unlock(&iommu->lock); 2016 - return -EINVAL; 2017 - } 2018 - } 2019 - 2020 - if (iommu->external_domain) { 2021 - if (find_iommu_group(iommu->external_domain, iommu_group)) { 2022 - mutex_unlock(&iommu->lock); 2023 - return -EINVAL; 2024 - } 2012 + /* Check for duplicates */ 2013 + if (vfio_iommu_find_iommu_group(iommu, iommu_group)) { 2014 + mutex_unlock(&iommu->lock); 2015 + return -EINVAL; 2025 2016 } 2026 2017 2027 2018 group = kzalloc(sizeof(*group), GFP_KERNEL);