vfio-pci: Fix GTT wrap-around for Skylake+ IGD
commitac2a9862b761f6ccabc35ac5d38c948dec97777d
authorAlex Williamson <alex.williamson@redhat.com>
Fri, 10 Feb 2017 20:12:03 +0000 (10 13:12 -0700)
committerAlex Williamson <alex.williamson@redhat.com>
Fri, 10 Feb 2017 20:12:03 +0000 (10 13:12 -0700)
tree3f49aefec13b3722ae02ae43356fc11533d0ab65
parent98b2faeaee96ab084d0b1669918688d8895c155f
vfio-pci: Fix GTT wrap-around for Skylake+ IGD

Previous IGD, up through Broadwell, only seem to write GTT values into
the first 1MB of space allocated for the BDSM, but clearly the GTT
can be multiple MB in size.  Our test in vfio_igd_quirk_data_write()
correctly filters out indexes beyond 1MB, but given the 1MB mask we're
using, we re-apply writes only to the first 1MB of the guest allocated
BDSM.

We can't assume either the host or guest BDSM is naturally aligned, so
we can't simply apply a different mask.  Instead, save the host BDSM
and do the arithmetic to subtract the host value to get the BDSM
offset and add it to the guest allocated BDSM.

Reported-by: Alexander Indenbaum <alexander.indenbaum@gmail.com>
Tested-by: Alexander Indenbaum <alexander.indenbaum@gmail.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
hw/vfio/pci-quirks.c