On Tue, 2025-04-22 at 00:31 +0800, Tomita Moeko wrote: > CAUTION: External Email!! > Starting from Intel Core Ultra Series (Meteor Lake), Data Stolen Memory > has became a part of LMEMBAR (MMIO BAR2) [1][2], meaning that BDSM and > GGC register quirks are no longer needed on these platforms. > > To support Meteor/Arrow/Lunar Lake and future IGD devices, remove the > generation limitation in IGD passthrough, and apply BDSM and GGC quirks > only to known Gen6-12 devices. > > [1] > https://nospamproxywebp.beckhoff.com/enQsig/link?id=BAgAAABHhgBhwX01GO0AAACNi-GgHiUI4sV0qRTHkaBvP5PrY5DqqTz9YhuTNO_iXQUZlCVu442aEFUtFJIN9H4QuJJwNJh5ry3XO19WptfEahlpGX9F7Nq8Xpv-GQ9_LZd6niU0I-kMcs9DxxlKk8E802ILvUeF86QyZP4D7A7AEaoUDo15UvzlwHlTOoUj4fzKJYvykniL_MlVr8H8FS2ySMcVqfE6IFb5Aiwhkq7hrpL53XHUYCVoK_y89PCzSWC-Y0fS5-Xo-SxRDOtI140aTd7KpmA39tf447LtBR1YQP8ccM8PjukqvroMpZtV3cDQcgya3EsmP0Fgrmc1 > > [2] > https://nospamproxywebp.beckhoff.com/enQsig/link?id=BAgAAABHhgBhwX01GNYAAAAtMYPOda9hw4SLBezXYKaYHKRl05pN8tzXcVl9njzCJlE1HkXUG-mljVszTJQKhcQYQTJNcuCekCys_GWgxsVTyOaS_NHFmHSUCZG_K4lK67xtRF6gmeuH6VTzSH0evGV976t_N2r5ADGfofxEA3bNt0iJmL1IzjhRilkRiNe-EmvdQ7DLMn1nAV9ZQCkPM5bCjIyd7MIjXMAlwhK4CraFMv1xw33w-ZnR0YrP4VIGHwKE7vUKp7-BjGZzyrgtwQ5m2SKD0zkEOs3dls5l351dSvNfqp740 > > > Signed-off-by: Tomita Moeko <tomitamo...@gmail.com> > --- > hw/vfio/igd.c | 58 +++++++++++++++++++-------------------------------- > 1 file changed, 21 insertions(+), 37 deletions(-) > > diff --git a/hw/vfio/igd.c b/hw/vfio/igd.c > index bc4c79837d..5b888616f0 100644 > --- a/hw/vfio/igd.c > +++ b/hw/vfio/igd.c > @@ -103,6 +103,7 @@ static int igd_gen(VFIOPCIDevice *vdev) > /* > * Unfortunately, Intel changes it's specification quite often. This > makes > * it impossible to use a suitable default value for unknown devices. > + * Return -1 for not applying any generation-specific quirks. > */ > return -1; > } > @@ -434,20 +435,12 @@ void vfio_probe_igd_bar0_quirk(VFIOPCIDevice *vdev, int > nr) > VFIOConfigMirrorQuirk *ggc_mirror, *bdsm_mirror; > int gen; > > - /* > - * This must be an Intel VGA device at address 00:02.0 for us to even > - * consider enabling legacy mode. Some driver have dependencies on the > PCI > - * bus address. > - */
Same goes for this comment. It's not really correct as UEFI GOP and OS driver depend on address 0:2.0 too but I'd keep and improve it to make it more clear for future reader. > if (!vfio_pci_is(vdev, PCI_VENDOR_ID_INTEL, PCI_ANY_ID) || > !vfio_is_vga(vdev) || nr != 0) { > return; > } > > - /* > - * Only on IGD devices of gen 11 and above, the BDSM register is mirrored > - * into MMIO space and read from MMIO space by the Windows driver. > - */ > + /* Only on IGD Gen6-12 device needs quirks in BAR 0 */ > gen = igd_gen(vdev); > if (gen < 6) { > return; > @@ -494,7 +487,7 @@ static bool vfio_pci_igd_config_quirk(VFIOPCIDevice *vdev, > Error **errp) > { > g_autofree struct vfio_region_info *opregion = NULL; > int ret, gen; > - uint64_t gms_size; > + uint64_t gms_size = 0; > uint64_t *bdsm_size; > uint32_t gmch; > bool legacy_mode_enabled = false; > @@ -514,18 +507,7 @@ static bool vfio_pci_igd_config_quirk(VFIOPCIDevice > *vdev, Error **errp) > } > info_report("OpRegion detected on Intel display %x.", vdev->device_id); > > - /* > - * IGD is not a standard, they like to change their specs often. We > - * only attempt to support back to SandBridge and we hope that newer > - * devices maintain compatibility with generation 8. > - */ > gen = igd_gen(vdev); > - if (gen == -1) { > - error_report("IGD device %s is unsupported in legacy mode, " > - "try SandyBridge or newer", vdev- > >https://nospamproxywebp.beckhoff.com/enQsig/link?id=BAgAAABHhgBhwX01GGwAAADNE > nn7fAHvEAN3EJV6Ng4dOzKc7MR7f3e317FXOTfRW-ZxuzGFRyquEjUjSeP- > 6ByDI2TtwvI3jwlJBjQdXL-V9t40AFbX3wSV_K- > M0j4dDCcdYxjOhLKhEroDvVJ0XE20BM2QEteRk67iEFo1 ); > - return true; > - } > - > gmch = vfio_pci_read_config(&vdev->pdev, IGD_GMCH, 4); > > /* > @@ -624,32 +606,34 @@ static bool vfio_pci_igd_config_quirk(VFIOPCIDevice > *vdev, Error **errp) > } > } > > - gms_size = igd_stolen_memory_size(gen, gmch); > + if (gen > 0) { > + gms_size = igd_stolen_memory_size(gen, gmch); > + > + /* BDSM is read-write, emulated. BIOS needs to be able to write it */ > + if (gen < 11) { > + pci_set_long(vdev->pdev.config + IGD_BDSM, 0); > + pci_set_long(vdev->pdev.wmask + IGD_BDSM, ~0); > + pci_set_long(vdev->emulated_config_bits + IGD_BDSM, ~0); > + } else { > + pci_set_quad(vdev->pdev.config + IGD_BDSM_GEN11, 0); > + pci_set_quad(vdev->pdev.wmask + IGD_BDSM_GEN11, ~0); > + pci_set_quad(vdev->emulated_config_bits + IGD_BDSM_GEN11, ~0); > + } > + } > > /* > * Request reserved memory for stolen memory via fw_cfg. VM firmware > * must allocate a 1MB aligned reserved memory region below 4GB with > - * the requested size (in bytes) for use by the Intel PCI class VGA > - * device at VM address 00:02.0. The base address of this reserved > - * memory region must be written to the device BDSM register at PCI > - * config offset 0x5C. > + * the requested size (in bytes) for use by the IGD device. The base > + * address of this reserved memory region must be written to the > + * device BDSM register. > + * For newer device without BDSM register, this fw_cfg item is 0. > */ > bdsm_size = g_malloc(sizeof(*bdsm_size)); > *bdsm_size = cpu_to_le64(gms_size); > fw_cfg_add_file(fw_cfg_find(), "etc/igd-bdsm-size", > bdsm_size, sizeof(*bdsm_size)); > > - /* BDSM is read-write, emulated. The BIOS needs to be able to write it > */ > - if (gen < 11) { > - pci_set_long(vdev->pdev.config + IGD_BDSM, 0); > - pci_set_long(vdev->pdev.wmask + IGD_BDSM, ~0); > - pci_set_long(vdev->emulated_config_bits + IGD_BDSM, ~0); > - } else { > - pci_set_quad(vdev->pdev.config + IGD_BDSM_GEN11, 0); > - pci_set_quad(vdev->pdev.wmask + IGD_BDSM_GEN11, ~0); > - pci_set_quad(vdev->emulated_config_bits + IGD_BDSM_GEN11, ~0); > - } > - > trace_vfio_pci_igd_bdsm_enabled(vdev- > >https://nospamproxywebp.beckhoff.com/enQsig/link?id=BAgAAABHhgBhwX01GGwAAADNE > nn7fAHvEAN3EJV6Ng4dOzKc7MR7f3e317FXOTfRW-ZxuzGFRyquEjUjSeP- > 6ByDI2TtwvI3jwlJBjQdXL-V9t40AFbX3wSV_K- > M0j4dDCcdYxjOhLKhEroDvVJ0XE20BM2QEteRk67iEFo1 , (gms_size / MiB)); > > return true; -- Kind regards, Corvin
signature.asc
Description: This is a digitally signed message part