[PATCH 4/9] vfio/igd: Check vendor and device ID on GVT-g mdev

Tomita Moeko posted 9 patches 9 months, 2 weeks ago
There is a newer version of this series
[PATCH 4/9] vfio/igd: Check vendor and device ID on GVT-g mdev
Posted by Tomita Moeko 9 months, 2 weeks ago
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 <tomitamoeko@gmail.com>
---
 hw/vfio/igd.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/hw/vfio/igd.c b/hw/vfio/igd.c
index d6880cbff7..c6ecbefb35 100644
--- a/hw/vfio/igd.c
+++ b/hw/vfio/igd.c
@@ -671,6 +671,18 @@ error:
 static bool vfio_pci_kvmgt_config_quirk(VFIOPCIDevice *vdev, Error **errp)
 {
     g_autofree struct vfio_region_info *opregion = NULL;
+    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;
+    }
 
     if ((vdev->features & VFIO_FEATURE_ENABLE_IGD_OPREGION) &&
         (!vfio_pci_igd_opregion_detect(vdev, &opregion, errp) ||
-- 
2.47.2
Re: [PATCH 4/9] vfio/igd: Check vendor and device ID on GVT-g mdev
Posted by Corvin Köhne 9 months, 1 week ago
On Tue, 2025-04-29 at 00:09 +0800, Tomita Moeko wrote:
> CAUTION: External Email!!
> 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://nospamproxywebp.beckhoff.com/enQsig/link?id=BAgAAAC7d6njJfw46ssAAADF-nyovaDPsQJyKOV5T7sLGnzTfabj4BLcrjbmZT8baVh1nRPWc5X1Mlcgmchoiq4Ame7F9pv8Dm3p32EVUqXHVZUZ4ydwKGK8058NOSzZdk88Xvq87l3akIni9zsivM8SufPB80Ps4QQhkcFR2xjFsyp1doPFX7-vdSDEuv_KSFgq4SZ6UXxq6JDwaLRbsVEkIog7tW-TROEpexsHJm7QzPVbqSCuoHky-Rb7fvkEimsF6AGSvCpAEejUDe78EDkE1k4RSw53IT6Ohg2
>  
> 
> Signed-off-by: Tomita Moeko <tomitamoeko@gmail.com>
> ---
>  hw/vfio/igd.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/hw/vfio/igd.c b/hw/vfio/igd.c
> index d6880cbff7..c6ecbefb35 100644
> --- a/hw/vfio/igd.c
> +++ b/hw/vfio/igd.c
> @@ -671,6 +671,18 @@ error:
>  static bool vfio_pci_kvmgt_config_quirk(VFIOPCIDevice *vdev, Error **errp)
>  {
>      g_autofree struct vfio_region_info *opregion = NULL;
> +    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;
> +    }
>  
>      if ((vdev->features & VFIO_FEATURE_ENABLE_IGD_OPREGION) &&
>          (!vfio_pci_igd_opregion_detect(vdev, &opregion, errp) ||

Reviewed-by: Corvin Köhne <c.koehne@beckhoff.com>


-- 
Kind regards,
Corvin