Skip to content

Commit c322f53

Browse files
committed
Merge tag 'vfio-v5.8-rc3' of git://github.com/awilliam/linux-vfio
Pull VFIO fixes from Alex Williamson: - Fix double free of eventfd ctx (Alex Williamson) - Fix duplicate use of capability ID (Alex Williamson) - Fix SR-IOV VF memory enable handling (Alex Williamson) * tag 'vfio-v5.8-rc3' of git://github.com/awilliam/linux-vfio: vfio/pci: Fix SR-IOV VF handling with MMIO blocking vfio/type1: Fix migration info capability ID vfio/pci: Clear error and request eventfd ctx after releasing
2 parents 8bf9865 + ebfa440 commit c322f53

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

drivers/vfio/pci/vfio_pci.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -521,10 +521,14 @@ static void vfio_pci_release(void *device_data)
521521
vfio_pci_vf_token_user_add(vdev, -1);
522522
vfio_spapr_pci_eeh_release(vdev->pdev);
523523
vfio_pci_disable(vdev);
524-
if (vdev->err_trigger)
524+
if (vdev->err_trigger) {
525525
eventfd_ctx_put(vdev->err_trigger);
526-
if (vdev->req_trigger)
526+
vdev->err_trigger = NULL;
527+
}
528+
if (vdev->req_trigger) {
527529
eventfd_ctx_put(vdev->req_trigger);
530+
vdev->req_trigger = NULL;
531+
}
528532
}
529533

530534
mutex_unlock(&vdev->reflck->lock);

drivers/vfio/pci/vfio_pci_config.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,9 +398,15 @@ static inline void p_setd(struct perm_bits *p, int off, u32 virt, u32 write)
398398
/* Caller should hold memory_lock semaphore */
399399
bool __vfio_pci_memory_enabled(struct vfio_pci_device *vdev)
400400
{
401+
struct pci_dev *pdev = vdev->pdev;
401402
u16 cmd = le16_to_cpu(*(__le16 *)&vdev->vconfig[PCI_COMMAND]);
402403

403-
return cmd & PCI_COMMAND_MEMORY;
404+
/*
405+
* SR-IOV VF memory enable is handled by the MSE bit in the
406+
* PF SR-IOV capability, there's therefore no need to trigger
407+
* faults based on the virtual value.
408+
*/
409+
return pdev->is_virtfn || (cmd & PCI_COMMAND_MEMORY);
404410
}
405411

406412
/*
@@ -1728,6 +1734,15 @@ int vfio_config_init(struct vfio_pci_device *vdev)
17281734
vconfig[PCI_INTERRUPT_PIN]);
17291735

17301736
vconfig[PCI_INTERRUPT_PIN] = 0; /* Gratuitous for good VFs */
1737+
1738+
/*
1739+
* VFs do no implement the memory enable bit of the COMMAND
1740+
* register therefore we'll not have it set in our initial
1741+
* copy of config space after pci_enable_device(). For
1742+
* consistency with PFs, set the virtual enable bit here.
1743+
*/
1744+
*(__le16 *)&vconfig[PCI_COMMAND] |=
1745+
cpu_to_le16(PCI_COMMAND_MEMORY);
17311746
}
17321747

17331748
if (!IS_ENABLED(CONFIG_VFIO_PCI_INTX) || vdev->nointx)

include/uapi/linux/vfio.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1030,7 +1030,7 @@ struct vfio_iommu_type1_info_cap_iova_range {
10301030
* size in bytes that can be used by user applications when getting the dirty
10311031
* bitmap.
10321032
*/
1033-
#define VFIO_IOMMU_TYPE1_INFO_CAP_MIGRATION 1
1033+
#define VFIO_IOMMU_TYPE1_INFO_CAP_MIGRATION 2
10341034

10351035
struct vfio_iommu_type1_info_cap_migration {
10361036
struct vfio_info_cap_header header;

0 commit comments

Comments
 (0)