Check the vendor and device ID on GVT-g mdev to ensure it is a supported
device [1]. This extra check is required for automatically enabling
OpRegion access later.

Note that Cherryview and Gemini Lake are marked as supported here since
current code cannot distinguish them with other Gen8 and Gen9 devices.
Since mdev cannot be created on these devices, this has no functional
impact.

[1] 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/gpu/drm/i915/intel_gvt.c?h=v6.14#n52

Signed-off-by: Tomita Moeko <tomitamo...@gmail.com>
---
 hw/vfio/igd.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/hw/vfio/igd.c b/hw/vfio/igd.c
index cc397f8829..e94ed7029a 100644
--- a/hw/vfio/igd.c
+++ b/hw/vfio/igd.c
@@ -654,6 +654,19 @@ error:
  */
 static bool vfio_pci_kvmgt_config_quirk(VFIOPCIDevice *vdev, Error **errp)
 {
+    int gen;
+
+    if (!vfio_pci_is(vdev, PCI_VENDOR_ID_INTEL, PCI_ANY_ID) ||
+        !vfio_is_vga(vdev)) {
+        return true;
+    }
+
+    /* FIXME: Cherryview is Gen8, but don't support GVT-g */
+    gen = igd_gen(vdev);
+    if (gen != 8 && gen != 9) {
+        return true;
+    }
+
     /* Hotplugging is not supported for opregion access */
     if (vdev->pdev.qdev.hotplugged) {
         error_setg(errp, "Hotplugging Intel GVT-g vGPU is not supported.");
-- 
2.47.2


Reply via email to