Skip to content

Commit e46b7af

Browse files
tomitamoekolegoater
authored andcommitted
vfio/igd: Fix broken KVMGT OpRegion support
The KVMGT/GVT-g vGPU also exposes OpRegion. But unlike IGD passthrough, it only needs the OpRegion quirk. A previous change moved x-igd-opregion handling to config quirk breaks KVMGT functionality as it brings extra checks and applied other quirks. Here we check if the device is mdev (KVMGT) or not (passthrough), and then applies corresponding quirks. As before, users must manually specify x-igd-opregion=on to enable it on KVMGT devices. In the future, we may check the VID/DID and enable OpRegion automatically. Signed-off-by: Tomita Moeko <[email protected]> Reviewed-by: Alex Williamson <[email protected]> Tested-by: Alex Williamson <[email protected]> Reviewed-by: Corvin Köhne <[email protected]> Link: https://lore.kernel.org/qemu-devel/[email protected] Signed-off-by: Cédric Le Goater <[email protected]>
1 parent 674f611 commit e46b7af

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

hw/vfio/igd.c

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ void vfio_probe_igd_bar0_quirk(VFIOPCIDevice *vdev, int nr)
481481
QLIST_INSERT_HEAD(&vdev->bars[nr].quirks, bdsm_quirk, next);
482482
}
483483

484-
bool vfio_probe_igd_config_quirk(VFIOPCIDevice *vdev, Error **errp)
484+
static bool vfio_pci_igd_config_quirk(VFIOPCIDevice *vdev, Error **errp)
485485
{
486486
int ret, gen;
487487
uint64_t gms_size;
@@ -655,3 +655,28 @@ bool vfio_probe_igd_config_quirk(VFIOPCIDevice *vdev, Error **errp)
655655
error_propagate(errp, err);
656656
return false;
657657
}
658+
659+
/*
660+
* KVMGT/GVT-g vGPU exposes an emulated OpRegion. So far, users have to specify
661+
* x-igd-opregion=on to enable the access.
662+
* TODO: Check VID/DID and enable opregion access automatically
663+
*/
664+
static bool vfio_pci_kvmgt_config_quirk(VFIOPCIDevice *vdev, Error **errp)
665+
{
666+
if ((vdev->features & VFIO_FEATURE_ENABLE_IGD_OPREGION) &&
667+
!vfio_pci_igd_setup_opregion(vdev, errp)) {
668+
return false;
669+
}
670+
671+
return true;
672+
}
673+
674+
bool vfio_probe_igd_config_quirk(VFIOPCIDevice *vdev, Error **errp)
675+
{
676+
/* KVMGT/GVT-g vGPU is exposed as mdev */
677+
if (vdev->vbasedev.mdev) {
678+
return vfio_pci_kvmgt_config_quirk(vdev, errp);
679+
}
680+
681+
return vfio_pci_igd_config_quirk(vdev, errp);
682+
}

0 commit comments

Comments
 (0)