mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-12-18 13:38:36 -07:00
vfio/igd: Fix incorrect error propagation in vfio_pci_igd_opregion_detect()
In vfio_pci_igd_opregion_detect(), errp will be set when the device does
not have OpRegion or is hotplugged. This errp will be propagated to
pci_qdev_realize(), which interprets it as failure, causing unexpected
termination on devices without OpRegion like SR-IOV VFs or discrete
GPUs. Fix it by not setting errp in vfio_pci_igd_opregion_detect().
This patch also checks if the device has OpRegion before hotplug status
to prevent unwanted warning messages on non-IGD devices.
Fixes: c0273e77f2 ("vfio/igd: Detect IGD device by OpRegion")
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2968
Reported-by: Edmund Raile <edmund.raile@protonmail.com>
Link: https://lore.kernel.org/qemu-devel/30044d14-17ec-46e3-b9c3-63d27a5bde27@gmail.com
Tested-by: Edmund Raile <edmund.raile@protonmail.com>
Signed-off-by: Tomita Moeko <tomitamoeko@gmail.com>
Reviewed-by: Alex Williamson <alex.williamson@redhat.com>
Reviewed-by: Corvin Köhne <c.koehne@beckhoff.com>
Link: https://lore.kernel.org/qemu-devel/20250522151636.20001-1-tomitamoeko@gmail.com
Signed-off-by: Cédric Le Goater <clg@redhat.com>
This commit is contained in:
parent
1c729ca886
commit
0992ea07db
1 changed files with 10 additions and 12 deletions
|
|
@ -187,23 +187,21 @@ static bool vfio_pci_igd_opregion_init(VFIOPCIDevice *vdev,
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool vfio_pci_igd_opregion_detect(VFIOPCIDevice *vdev,
|
static bool vfio_pci_igd_opregion_detect(VFIOPCIDevice *vdev,
|
||||||
struct vfio_region_info **opregion,
|
struct vfio_region_info **opregion)
|
||||||
Error **errp)
|
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Hotplugging is not supported for opregion access */
|
|
||||||
if (vdev->pdev.qdev.hotplugged) {
|
|
||||||
error_setg(errp, "IGD OpRegion is not supported on hotplugged device");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = vfio_device_get_region_info_type(&vdev->vbasedev,
|
ret = vfio_device_get_region_info_type(&vdev->vbasedev,
|
||||||
VFIO_REGION_TYPE_PCI_VENDOR_TYPE | PCI_VENDOR_ID_INTEL,
|
VFIO_REGION_TYPE_PCI_VENDOR_TYPE | PCI_VENDOR_ID_INTEL,
|
||||||
VFIO_REGION_SUBTYPE_INTEL_IGD_OPREGION, opregion);
|
VFIO_REGION_SUBTYPE_INTEL_IGD_OPREGION, opregion);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
error_setg_errno(errp, -ret,
|
return false;
|
||||||
"Device does not support IGD OpRegion feature");
|
}
|
||||||
|
|
||||||
|
/* Hotplugging is not supported for opregion access */
|
||||||
|
if (vdev->pdev.qdev.hotplugged) {
|
||||||
|
warn_report("IGD device detected, but OpRegion is not supported "
|
||||||
|
"on hotplugged device.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -524,7 +522,7 @@ static bool vfio_pci_igd_config_quirk(VFIOPCIDevice *vdev, Error **errp)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* IGD device always comes with OpRegion */
|
/* IGD device always comes with OpRegion */
|
||||||
if (!vfio_pci_igd_opregion_detect(vdev, &opregion, errp)) {
|
if (!vfio_pci_igd_opregion_detect(vdev, &opregion)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
info_report("OpRegion detected on Intel display %x.", vdev->device_id);
|
info_report("OpRegion detected on Intel display %x.", vdev->device_id);
|
||||||
|
|
@ -695,7 +693,7 @@ static bool vfio_pci_kvmgt_config_quirk(VFIOPCIDevice *vdev, Error **errp)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!vfio_pci_igd_opregion_detect(vdev, &opregion, errp)) {
|
if (!vfio_pci_igd_opregion_detect(vdev, &opregion)) {
|
||||||
/* Should never reach here, KVMGT always emulates OpRegion */
|
/* Should never reach here, KVMGT always emulates OpRegion */
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue