VGA device assignment: Difference between revisions
From KVM
No edit summary |
m (→Open issues) |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
= Assigning physical VGA adapters = | = Assigning physical VGA adapters = | ||
It would appear that assigning modern PCI/PCIe VGA adapters should not be any different from [[How_to_assign_devices_with_VT-d_in_KVM|passing through normal PCI devices]]. But there are additional challenges to solve, specifically related to legacy VGA requirements and proprietary mechanisms to relocate I/O regions of the adapters. Moreover, some QEMU and SeaBIOS deficits contribute to the current situation that things rarely work out of the box. | |||
== Open issues == | == Open issues == | ||
* '''Insufficient PCI window size'''<br>This is a fixable SeaBIOS | * '''Insufficient PCI window size'''<br>This is a fixable SeaBIOS limitation. Patches are currently under development by [http://www.kraxel.org/cgit/seabios/log/?h=kraxel.q35&id=99ff4d141d5a460eaf20fe2d4d13117c888eae15 Gerd Hoffmann]. | ||
* '''Non-standard I/O region remapping'''<br> | * '''Non-standard I/O region remapping'''<br>Some NVIDIA Quadro adapters are known to be affected by this, but probably only during early boot. A workaround could be identity mapping, i.e. locating the memory BARs in the guest at the same locations as on the host. Of course, this breaks if the guest OS or guest drivers decide to remap them. | ||
* '''Legacy VGA support'''<br>In order to get boot messages of the guest BIOS, boot loader, or early OS stages, access to the legacy VGA PIO and MMIO regions need to be forwarded to the passed-through adapter. Moreover, the VBIOS of the adapter must be bootable inside the guest. | * '''Legacy VGA support'''<br>In order to get boot messages of the guest BIOS, boot loader, or early OS stages, access to the legacy VGA PIO and MMIO regions need to be forwarded to the passed-through adapter. Moreover, the VBIOS of the adapter must be bootable inside the guest. As a result, the following aspects will need to be addressed: | ||
** '''Legacy VGA pass-through'''<br>QEMU requires patches to forward guest access to legacy VGA | ** '''Legacy VGA pass-through'''<br>QEMU requires patches to forward guest access to legacy VGA via the assigned adapter. | ||
** '''PAM/SRAM QEMU breakage'''<br>Current QEMU contains broken code that prevents access to legacy VGA even if the adapter is emulated but differently initialized (test case: -vga none -device VGA) | ** '''PAM/SRAM QEMU breakage'''<br>Current QEMU contains broken code that prevents access to legacy VGA even if the adapter is emulated but differently initialized (test case: -vga none -device VGA) | ||
** '''Legacy VGA arbitration'''<br>As the legacy IO resources cannot be remapped, access | ** '''Legacy VGA arbitration'''<br>As the legacy IO resources cannot be remapped, access needs to be switched between guests and the host on demand. The Linux kernel provides a VGA arbiter for this purpose, but it is not used consistently by all involved parties. Moreover, QEMU also requires additional patches to support this. | ||
** '''VBIOS ROM access'''<br>To re-run the POST procedures of the assigned adapter inside the guest, the proper VBIOS ROM image has to be used. However, when passing through the primary adapter of the host, Linux provides only access to the shadowed version of the VBIOS which may differ from the pre-POST version (due to | ** '''VBIOS ROM access'''<br>To re-run the POST procedures of the assigned adapter inside the guest, the proper VBIOS ROM image has to be used. However, when passing through the primary adapter of the host, Linux provides only access to the shadowed version of the VBIOS which may differ from the pre-POST version (due to modifications applied during POST). This has been observed with NVIDIA Quadro adapters. A workaround is to retrieve the VBIOS from the adapter while it is in secondary mode and use this saved image (-device pci-assign,...,romfile=...). But even that may fail, either due to problems of the host chipset or BIOS (e.g. host kernel complains about an unmappable ROM BAR). | ||
== Potential tweaks & tricks == | == Potential tweaks & tricks == | ||
Line 19: | Line 19: | ||
== Success stories == | == Success stories == | ||
Despite all existing problems, some users already succeeded | Despite all existing problems, some users have already succeeded in utilizing pass-through functionality for various VGA adapters: | ||
* [http://thread.gmane.org/gmane.comp.emulators.kvm.devel/94524 Radeon HD 7870] | * [http://thread.gmane.org/gmane.comp.emulators.kvm.devel/94524 Radeon HD 7870] | ||
* [http://thread.gmane.org/gmane.comp.emulators.kvm.devel/104760 Radeon HD 7750] | |||
* [http://thread.gmane.org/gmane.comp.emulators.kvm.devel/72987 Radeon HD 6950 with patched SeaBIOS] | * [http://thread.gmane.org/gmane.comp.emulators.kvm.devel/72987 Radeon HD 6950 with patched SeaBIOS] | ||
* [http://tavi-tech.blogspot.com.au/2012/05/vga-passthrough-kvm-fedora-17-and.html Radeon HD 6770] | |||
* [http://thread.gmane.org/gmane.comp.emulators.kvm.devel/71981 Radeon HD 5850] | * [http://thread.gmane.org/gmane.comp.emulators.kvm.devel/71981 Radeon HD 5850] |
Latest revision as of 21:44, 19 January 2017
Assigning physical VGA adapters
It would appear that assigning modern PCI/PCIe VGA adapters should not be any different from passing through normal PCI devices. But there are additional challenges to solve, specifically related to legacy VGA requirements and proprietary mechanisms to relocate I/O regions of the adapters. Moreover, some QEMU and SeaBIOS deficits contribute to the current situation that things rarely work out of the box.
Open issues
- Insufficient PCI window size
This is a fixable SeaBIOS limitation. Patches are currently under development by Gerd Hoffmann. - Non-standard I/O region remapping
Some NVIDIA Quadro adapters are known to be affected by this, but probably only during early boot. A workaround could be identity mapping, i.e. locating the memory BARs in the guest at the same locations as on the host. Of course, this breaks if the guest OS or guest drivers decide to remap them. - Legacy VGA support
In order to get boot messages of the guest BIOS, boot loader, or early OS stages, access to the legacy VGA PIO and MMIO regions need to be forwarded to the passed-through adapter. Moreover, the VBIOS of the adapter must be bootable inside the guest. As a result, the following aspects will need to be addressed:- Legacy VGA pass-through
QEMU requires patches to forward guest access to legacy VGA via the assigned adapter. - PAM/SRAM QEMU breakage
Current QEMU contains broken code that prevents access to legacy VGA even if the adapter is emulated but differently initialized (test case: -vga none -device VGA) - Legacy VGA arbitration
As the legacy IO resources cannot be remapped, access needs to be switched between guests and the host on demand. The Linux kernel provides a VGA arbiter for this purpose, but it is not used consistently by all involved parties. Moreover, QEMU also requires additional patches to support this. - VBIOS ROM access
To re-run the POST procedures of the assigned adapter inside the guest, the proper VBIOS ROM image has to be used. However, when passing through the primary adapter of the host, Linux provides only access to the shadowed version of the VBIOS which may differ from the pre-POST version (due to modifications applied during POST). This has been observed with NVIDIA Quadro adapters. A workaround is to retrieve the VBIOS from the adapter while it is in secondary mode and use this saved image (-device pci-assign,...,romfile=...). But even that may fail, either due to problems of the host chipset or BIOS (e.g. host kernel complains about an unmappable ROM BAR).
- Legacy VGA pass-through
Potential tweaks & tricks
- Some adapters may advertise MSI support even if that feature does not work properly. In that case, KVM will use MSI on the host side unconditionally unless instructed to follow the guest driver usage via -device pci-assign,...,prefer_msi=off.
Success stories
Despite all existing problems, some users have already succeeded in utilizing pass-through functionality for various VGA adapters: