pci-quirks.c (e692f9c6a681de1372a41999b14a947a553b6a1a) pci-quirks.c (d3c6a18bc7affd3b89903d98d8a3125a3e1c9861)
1/*
2 * device quirks for PCI devices
3 *
4 * Copyright Red Hat, Inc. 2012-2015
5 *
6 * Authors:
7 * Alex Williamson <alex.williamson@redhat.com>
8 *

--- 1155 unchanged lines hidden (view full) ---

1164/*
1165 * The OpRegion includes the Video BIOS Table, which seems important for
1166 * telling the driver what sort of outputs it has. Without this, the device
1167 * may work in the guest, but we may not get output. This also requires BIOS
1168 * support to reserve and populate a section of guest memory sufficient for
1169 * the table and to write the base address of that memory to the ASLS register
1170 * of the IGD device.
1171 */
1/*
2 * device quirks for PCI devices
3 *
4 * Copyright Red Hat, Inc. 2012-2015
5 *
6 * Authors:
7 * Alex Williamson <alex.williamson@redhat.com>
8 *

--- 1155 unchanged lines hidden (view full) ---

1164/*
1165 * The OpRegion includes the Video BIOS Table, which seems important for
1166 * telling the driver what sort of outputs it has. Without this, the device
1167 * may work in the guest, but we may not get output. This also requires BIOS
1168 * support to reserve and populate a section of guest memory sufficient for
1169 * the table and to write the base address of that memory to the ASLS register
1170 * of the IGD device.
1171 */
1172int vfio_pci_igd_opregion_init(VFIOPCIDevice *vdev,
1173 struct vfio_region_info *info, Error **errp)
1172bool vfio_pci_igd_opregion_init(VFIOPCIDevice *vdev,
1173 struct vfio_region_info *info, Error **errp)
1174{
1175 int ret;
1176
1177 vdev->igd_opregion = g_malloc0(info->size);
1178 ret = pread(vdev->vbasedev.fd, vdev->igd_opregion,
1179 info->size, info->offset);
1180 if (ret != info->size) {
1181 error_setg(errp, "failed to read IGD OpRegion");
1182 g_free(vdev->igd_opregion);
1183 vdev->igd_opregion = NULL;
1174{
1175 int ret;
1176
1177 vdev->igd_opregion = g_malloc0(info->size);
1178 ret = pread(vdev->vbasedev.fd, vdev->igd_opregion,
1179 info->size, info->offset);
1180 if (ret != info->size) {
1181 error_setg(errp, "failed to read IGD OpRegion");
1182 g_free(vdev->igd_opregion);
1183 vdev->igd_opregion = NULL;
1184 return -EINVAL;
1184 return false;
1185 }
1186
1187 /*
1188 * Provide fw_cfg with a copy of the OpRegion which the VM firmware is to
1189 * allocate 32bit reserved memory for, copy these contents into, and write
1190 * the reserved memory base address to the device ASLS register at 0xFC.
1191 * Alignment of this reserved region seems flexible, but using a 4k page
1192 * alignment seems to work well. This interface assumes a single IGD

--- 8 unchanged lines hidden (view full) ---

1201 vdev->igd_opregion, info->size);
1202
1203 trace_vfio_pci_igd_opregion_enabled(vdev->vbasedev.name);
1204
1205 pci_set_long(vdev->pdev.config + IGD_ASLS, 0);
1206 pci_set_long(vdev->pdev.wmask + IGD_ASLS, ~0);
1207 pci_set_long(vdev->emulated_config_bits + IGD_ASLS, ~0);
1208
1185 }
1186
1187 /*
1188 * Provide fw_cfg with a copy of the OpRegion which the VM firmware is to
1189 * allocate 32bit reserved memory for, copy these contents into, and write
1190 * the reserved memory base address to the device ASLS register at 0xFC.
1191 * Alignment of this reserved region seems flexible, but using a 4k page
1192 * alignment seems to work well. This interface assumes a single IGD

--- 8 unchanged lines hidden (view full) ---

1201 vdev->igd_opregion, info->size);
1202
1203 trace_vfio_pci_igd_opregion_enabled(vdev->vbasedev.name);
1204
1205 pci_set_long(vdev->pdev.config + IGD_ASLS, 0);
1206 pci_set_long(vdev->pdev.wmask + IGD_ASLS, ~0);
1207 pci_set_long(vdev->emulated_config_bits + IGD_ASLS, ~0);
1208
1209 return 0;
1209 return true;
1210}
1211
1212/*
1213 * Common quirk probe entry points.
1214 */
1215void vfio_vga_quirk_setup(VFIOPCIDevice *vdev)
1216{
1217 vfio_vga_probe_ati_3c3_quirk(vdev);

--- 468 unchanged lines hidden ---
1210}
1211
1212/*
1213 * Common quirk probe entry points.
1214 */
1215void vfio_vga_quirk_setup(VFIOPCIDevice *vdev)
1216{
1217 vfio_vga_probe_ati_3c3_quirk(vdev);

--- 468 unchanged lines hidden ---