mbox series

[v4,00/10] vfio/igd: Enable legacy mode on more devices

Message ID 20241206122749.9893-1-tomitamoeko@gmail.com (mailing list archive)
Headers show
Series vfio/igd: Enable legacy mode on more devices | expand

Message

Tomita Moeko Dec. 6, 2024, 12:27 p.m. UTC
This patchset extends the support of legacy mode igd passthrough to
all Intel Gen 11 and 12 devices (including Ice Lake, Jasper Lake,
Rocket Lake, Alder Lake and Raptor Lake), and emulates GGC register
in MMIO BAR0 for better compatibiltiy (It is tested Windows and GOP
driver will read this MMIO register).

It also replaces magic numbers with macros to improve readability,
and aligns behavior (BDSM registor mirroring and GGMS calculation for
gen7) with i915 driver to avoid possible issues.

The x-igd-gms option removed in 971ca22f041b ("vfio/igd: don't set
stolen memory size to zero") is also added back so that data stolen
memory size can be specified for guest. It is tested that GMS may
related to framebuffer size, a small GMS value may cause display issues
like blackscreen. It can be changed by DVMT Pre-allocated option in
host BIOS, but not all BIOS comes with this option. Having it in QEMU
helps resolves such issues.

This patchset was verified on Intel i9-12900K CPU(UHD 770, 8086:4680)
with custom OVMF firmware [1] and IntelGopDriver extracted from host
bios. IGD device works well in both Windows and Linux guests, and
scored 726 in 3DMark Time Spy Graphics on Windows guest.

[1] https://github.com/tomitamoeko/edk2/commits/igd-pt-adl/

Btw, IO BAR4 seems never be used by guest, and it the IO BAR itself
is not working on Gen11+ devices in my experiments. There is no hints
about that in old commit message and mailing list. It would be greatly
appreciated if someone shares the background.

Changelog:
v4:
* Move "vfio/igd: fix GTT stolen memory size calculation for gen 8+" to
  the first.
Link: https://lore.kernel.org/qemu-devel/20241205105535.30498-1-tomitamoeko@gmail.com/

v3:
* Added new patch to fix GTT stolen memory size calculation for gen 8+
  devicess.
* Fixed quirk index in "vfio/igd: add macro for declaring mirrored
  registers"
* Fixed condition in "vfio/igd: add x-igd-gms option back to set DSM
  region size for guest"
* Updated comments and commit message.
Link: https://lore.kernel.org/qemu-devel/20241203133548.38252-1-tomitamoeko@gmail.com/

v2:
* Droped "vfio/igd: fix GTT stolen memory size calculation for gen 7".
* Fixed conditions when calculating GGMS size.
* Added Gemini Lake and Comet Lake device ids.
* Splited mirroring register declaration macro into a new patch.
* Minor fixes.
Link: https://lore.kernel.org/qemu-devel/20241201160938.44355-1-tomitamoeko@gmail.com/

Tomita Moeko (10):
  vfio/igd: fix GTT stolen memory size calculation for gen 8+
  vfio/igd: remove unsupported device ids
  vfio/igd: align generation with i915 kernel driver
  vfio/igd: canonicalize memory size calculations
  vfio/igd: add Gemini Lake and Comet Lake device ids
  vfio/igd: add Alder/Raptor/Rocket/Ice/Jasper Lake device ids
  vfio/igd: add macro for declaring mirrored registers
  vfio/igd: emulate GGC register in mmio bar0
  vfio/igd: emulate BDSM in mmio bar0 for gen 6-10 devices
  vfio/igd: add x-igd-gms option back to set DSM region size for guest

 hw/vfio/igd.c | 262 +++++++++++++++++++++++++++++++-------------------
 1 file changed, 165 insertions(+), 97 deletions(-)

Comments

Cédric Le Goater Dec. 6, 2024, 1:18 p.m. UTC | #1
On 12/6/24 13:27, Tomita Moeko wrote:
> This patchset extends the support of legacy mode igd passthrough to
> all Intel Gen 11 and 12 devices (including Ice Lake, Jasper Lake,
> Rocket Lake, Alder Lake and Raptor Lake), and emulates GGC register
> in MMIO BAR0 for better compatibiltiy (It is tested Windows and GOP
> driver will read this MMIO register).
> 
> It also replaces magic numbers with macros to improve readability,
> and aligns behavior (BDSM registor mirroring and GGMS calculation for
> gen7) with i915 driver to avoid possible issues.
> 
> The x-igd-gms option removed in 971ca22f041b ("vfio/igd: don't set
> stolen memory size to zero") is also added back so that data stolen
> memory size can be specified for guest. It is tested that GMS may
> related to framebuffer size, a small GMS value may cause display issues
> like blackscreen. It can be changed by DVMT Pre-allocated option in
> host BIOS, but not all BIOS comes with this option. Having it in QEMU
> helps resolves such issues.
> 
> This patchset was verified on Intel i9-12900K CPU(UHD 770, 8086:4680)
> with custom OVMF firmware [1] and IntelGopDriver extracted from host
> bios. IGD device works well in both Windows and Linux guests, and
> scored 726 in 3DMark Time Spy Graphics on Windows guest.
> 
> [1] https://github.com/tomitamoeko/edk2/commits/igd-pt-adl/
> 
> Btw, IO BAR4 seems never be used by guest, and it the IO BAR itself
> is not working on Gen11+ devices in my experiments. There is no hints
> about that in old commit message and mailing list. It would be greatly
> appreciated if someone shares the background.
> 
> Changelog:
> v4:
> * Move "vfio/igd: fix GTT stolen memory size calculation for gen 8+" to
>    the first.
> Link: https://lore.kernel.org/qemu-devel/20241205105535.30498-1-tomitamoeko@gmail.com/

A v4 was not necessary for just this change. Anyhow, It seems the
series is ready and an overall 'Acked-by' from Alex or Corvin would
be appreciated before applying to vfio-next.


Thanks,

C.




> 
> v3:
> * Added new patch to fix GTT stolen memory size calculation for gen 8+
>    devicess.
> * Fixed quirk index in "vfio/igd: add macro for declaring mirrored
>    registers"
> * Fixed condition in "vfio/igd: add x-igd-gms option back to set DSM
>    region size for guest"
> * Updated comments and commit message.
> Link: https://lore.kernel.org/qemu-devel/20241203133548.38252-1-tomitamoeko@gmail.com/
> 
> v2:
> * Droped "vfio/igd: fix GTT stolen memory size calculation for gen 7".
> * Fixed conditions when calculating GGMS size.
> * Added Gemini Lake and Comet Lake device ids.
> * Splited mirroring register declaration macro into a new patch.
> * Minor fixes.
> Link: https://lore.kernel.org/qemu-devel/20241201160938.44355-1-tomitamoeko@gmail.com/
> 
> Tomita Moeko (10):
>    vfio/igd: fix GTT stolen memory size calculation for gen 8+
>    vfio/igd: remove unsupported device ids
>    vfio/igd: align generation with i915 kernel driver
>    vfio/igd: canonicalize memory size calculations
>    vfio/igd: add Gemini Lake and Comet Lake device ids
>    vfio/igd: add Alder/Raptor/Rocket/Ice/Jasper Lake device ids
>    vfio/igd: add macro for declaring mirrored registers
>    vfio/igd: emulate GGC register in mmio bar0
>    vfio/igd: emulate BDSM in mmio bar0 for gen 6-10 devices
>    vfio/igd: add x-igd-gms option back to set DSM region size for guest
> 
>   hw/vfio/igd.c | 262 +++++++++++++++++++++++++++++++-------------------
>   1 file changed, 165 insertions(+), 97 deletions(-)
>
Alex Williamson Dec. 6, 2024, 4:07 p.m. UTC | #2
On Fri,  6 Dec 2024 20:27:38 +0800
Tomita Moeko <tomitamoeko@gmail.com> wrote:

> This patchset extends the support of legacy mode igd passthrough to
> all Intel Gen 11 and 12 devices (including Ice Lake, Jasper Lake,
> Rocket Lake, Alder Lake and Raptor Lake), and emulates GGC register
> in MMIO BAR0 for better compatibiltiy (It is tested Windows and GOP
> driver will read this MMIO register).
> 
> It also replaces magic numbers with macros to improve readability,
> and aligns behavior (BDSM registor mirroring and GGMS calculation for
> gen7) with i915 driver to avoid possible issues.
> 
> The x-igd-gms option removed in 971ca22f041b ("vfio/igd: don't set
> stolen memory size to zero") is also added back so that data stolen
> memory size can be specified for guest. It is tested that GMS may
> related to framebuffer size, a small GMS value may cause display issues
> like blackscreen. It can be changed by DVMT Pre-allocated option in
> host BIOS, but not all BIOS comes with this option. Having it in QEMU
> helps resolves such issues.
> 
> This patchset was verified on Intel i9-12900K CPU(UHD 770, 8086:4680)
> with custom OVMF firmware [1] and IntelGopDriver extracted from host
> bios. IGD device works well in both Windows and Linux guests, and
> scored 726 in 3DMark Time Spy Graphics on Windows guest.
> 
> [1] https://github.com/tomitamoeko/edk2/commits/igd-pt-adl/
> 
> Btw, IO BAR4 seems never be used by guest, and it the IO BAR itself
> is not working on Gen11+ devices in my experiments. There is no hints
> about that in old commit message and mailing list. It would be greatly
> appreciated if someone shares the background.
> 
> Changelog:
> v4:
> * Move "vfio/igd: fix GTT stolen memory size calculation for gen 8+" to
>   the first.
> Link: https://lore.kernel.org/qemu-devel/20241205105535.30498-1-tomitamoeko@gmail.com/

Series:

Reviewed-by: Alex Williamson <alex.williamson@redhat.com>
Cédric Le Goater Dec. 6, 2024, 4:25 p.m. UTC | #3
On 12/6/24 13:27, Tomita Moeko wrote:
> This patchset extends the support of legacy mode igd passthrough to
> all Intel Gen 11 and 12 devices (including Ice Lake, Jasper Lake,
> Rocket Lake, Alder Lake and Raptor Lake), and emulates GGC register
> in MMIO BAR0 for better compatibiltiy (It is tested Windows and GOP
> driver will read this MMIO register).
> 
> It also replaces magic numbers with macros to improve readability,
> and aligns behavior (BDSM registor mirroring and GGMS calculation for
> gen7) with i915 driver to avoid possible issues.
> 
> The x-igd-gms option removed in 971ca22f041b ("vfio/igd: don't set
> stolen memory size to zero") is also added back so that data stolen
> memory size can be specified for guest. It is tested that GMS may
> related to framebuffer size, a small GMS value may cause display issues
> like blackscreen. It can be changed by DVMT Pre-allocated option in
> host BIOS, but not all BIOS comes with this option. Having it in QEMU
> helps resolves such issues.
> 
> This patchset was verified on Intel i9-12900K CPU(UHD 770, 8086:4680)
> with custom OVMF firmware [1] and IntelGopDriver extracted from host
> bios. IGD device works well in both Windows and Linux guests, and
> scored 726 in 3DMark Time Spy Graphics on Windows guest.
> 
> [1] https://github.com/tomitamoeko/edk2/commits/igd-pt-adl/
> 
> Btw, IO BAR4 seems never be used by guest, and it the IO BAR itself
> is not working on Gen11+ devices in my experiments. There is no hints
> about that in old commit message and mailing list. It would be greatly
> appreciated if someone shares the background.
> 
> Changelog:
> v4:
> * Move "vfio/igd: fix GTT stolen memory size calculation for gen 8+" to
>    the first.
> Link: https://lore.kernel.org/qemu-devel/20241205105535.30498-1-tomitamoeko@gmail.com/
> 
> v3:
> * Added new patch to fix GTT stolen memory size calculation for gen 8+
>    devicess.
> * Fixed quirk index in "vfio/igd: add macro for declaring mirrored
>    registers"
> * Fixed condition in "vfio/igd: add x-igd-gms option back to set DSM
>    region size for guest"
> * Updated comments and commit message.
> Link: https://lore.kernel.org/qemu-devel/20241203133548.38252-1-tomitamoeko@gmail.com/
> 
> v2:
> * Droped "vfio/igd: fix GTT stolen memory size calculation for gen 7".
> * Fixed conditions when calculating GGMS size.
> * Added Gemini Lake and Comet Lake device ids.
> * Splited mirroring register declaration macro into a new patch.
> * Minor fixes.
> Link: https://lore.kernel.org/qemu-devel/20241201160938.44355-1-tomitamoeko@gmail.com/
> 
> Tomita Moeko (10):
>    vfio/igd: fix GTT stolen memory size calculation for gen 8+
>    vfio/igd: remove unsupported device ids
>    vfio/igd: align generation with i915 kernel driver
>    vfio/igd: canonicalize memory size calculations
>    vfio/igd: add Gemini Lake and Comet Lake device ids
>    vfio/igd: add Alder/Raptor/Rocket/Ice/Jasper Lake device ids
>    vfio/igd: add macro for declaring mirrored registers
>    vfio/igd: emulate GGC register in mmio bar0
>    vfio/igd: emulate BDSM in mmio bar0 for gen 6-10 devices
>    vfio/igd: add x-igd-gms option back to set DSM region size for guest
> 
>   hw/vfio/igd.c | 262 +++++++++++++++++++++++++++++++-------------------
>   1 file changed, 165 insertions(+), 97 deletions(-)
> 


Applied to vfio-next.

Thanks,

C.