tools/hvmloader: implement Intel IGD extended VBT support
PATCH 1/1 tools/hvmloader: implement Intel IGD extended VBT support
In reply to a message not in the archiveModern Intel IGD devices do not work well with the current implementation of support for the Intel IGD in hvmloader because it lacks support for an extended video bios table (VBT).
Code 43 errors in Windows guests and failure of the guest screen to light up are some of the problems that occur with the current implementation.
To address this problem, this patch implements support for Intel IGD devices with an extended VBT and OpRegion version 2 and higher which is required for most modern Intel IGD devices.
This patch also depends on compatible support in the device model. If hvmloader detects the device model lacks such support, it will fall back to the currently implemented protocol for configuring the OpRegion to provide backward compatibiltiy for systems that lack a device model with support for an extended VBT.
Support for an extended VBT is implemented in the newly introduced function opregion_setup() which is implemented in the new file intel_opregion.c.
Major differences between this implementation and the current implemntation that only supports older devices without an extended VBT:
1. The current implemntation reserves a constant number of pages (3) in the E820 map for the OpRegion which is set by the IGD_OPREGION_PAGES macro in the current implementation. With OpRegion 2 and higher, the OpRegion can have an extended VBT that must be provided to the guest with the OpRegion. This means the size of the region is not fixed, so in this new implementation the IGD_OPREGION_PAGES constant is changed to a variable in e820.c, igd_opregion_e820_pages, that is set to its proper value based on the the size of the VBT. In this new implemntation, the size of the ACPI NVS region reserved for the OpRegion in the E820 map is equal to the value of the igd_opregion_e820_pages variable instead of being set to the constant value determined by IGD_OPREGION_PAGES.
2. The current implemntation provides the guest with access to the unmodified OpRegion on the host via memory mapping from the host to the guest. This is insufficient for OpRegion 2 and higher because some devices will require modifications to the OpRegion for proper operation in the guest. So this new implementation provides hvmloader with a copy of the host's OpRegion that hvmloader can modify as needed for proper operation. Mapping the OpRegion from the host to the guest is only used temporarily during setup of the OpRegion by hvmloader and once hvmloader has a copy of the OpRegion and the extended VBT, the device model removes the host mapping and hvmloader configures the guest to use the guest's possibly modified copy of the OpRegion instead.
3. The current implementation lacks useful debugging information for the more recent devices. This new implementation provides useful debugging output from hvmloader, such as the detected host OpRegion version and address, the values for rvda, rvds, and the guest OpRegion address when the guest_loglvl is set to all/all.
---
Later versions of this patch will provide a link to the compatible patch for extended VBT support in the device model which will be posted to the qemu-devel and xen-devel mailing lists and Cc'd to the appropriate maintainers and reviewers soon.
The compatible patch for the device model is part of a larger patchset that fixes many of the problems that currently affect the feature of Intel IGD passthrough to Xen HVM guests. This patch should be considered as a companion patch to that patchset for the device model. Do not try to test this patch with a real Intel IGD device without also applying the patchset for the device model because without those patches, the guest will most likely fail to start if an Intel IGD is passed through to the guest.
There are different requirements to support OpRegion version 2.0 and OpRegion version 2.1+, with support for OpRegion 2 the more difficult case because it always requires modifications to the OpRegion for proper operation in the guest. For some details about OpRegion 2 and higher and the extended VBT, see the links in the commit message.
tools/firmware/hvmloader/Makefile | 1 + tools/firmware/hvmloader/config.h | 15 +- tools/firmware/hvmloader/e820.c | 4 +- tools/firmware/hvmloader/intel_opregion.c | 297 ++++++++++++++++++++++ tools/firmware/hvmloader/pci.c | 10 +- 5 files changed, 313 insertions(+), 14 deletions(-) create mode 100644 tools/firmware/hvmloader/intel_opregion.c
tools/firmware/hvmloader/Makefile +1 -0
@@ -35,6 +35,7 @@ OBJS += smp.o cacheattr.o xenbus.o vnuma.o OBJS += e820.o pci.o pir.o ctype.o OBJS += hvm_param.o OBJS += ovmf.o seabios.o +OBJS += intel_opregion.o ifeq ($(debug),y) OBJS += tests.o endif
tools/firmware/hvmloader/config.h +12 -3
@@ -7,9 +7,6 @@enum virtual_vga { VGA_none, VGA_std, VGA_cirrus, VGA_pt };extern enum virtual_vga virtual_vga; -extern unsigned long igd_opregion_pgbase; -#define IGD_OPREGION_PAGES 3 -struct bios_config {const char *name;
@@ -43,6 +40,18 @@ extern struct bios_config ovmf_config;#define PAGE_SHIFT 12#define PAGE_SIZE (1ul << PAGE_SHIFT) +#define IGD_OPREGION_PAGES 3 +#define IGD_OPREGION_SIZE ((IGD_OPREGION_PAGES - 1) << PAGE_SHIFT) +#define IGD_OPREGION_RVDA 0x3ba +#define IGD_OPREGION_RVDS 0x3c2 +#define IGD_OPREGION_VERSION 0x16 +#define IGD_OPREGION_MASK 0xfff +#define IGD_OPREGION2_SUPPORT_MASK 0x1 +#define IGD_OPREGION_SIGNATURE "IntelGraphicsMem" +#define IGD_VBT_SIGNATURE "$VBT" +extern unsigned long igd_opregion_pgbase; +extern uint32_t igd_opregion_e820_pages; +void intel_opregion_setup (uint32_t vga_devfn);extern uint8_t ioapic_version;
tools/firmware/hvmloader/e820.c +2 -2
@@ -243,11 +243,11 @@ int build_e820_table(struct e820entry *e820, nr++; e820[nr].addr = igd_opregion_base; - e820[nr].size =IGD_OPREGION_PAGES *PAGE_SIZE ; + e820[nr].size = igd_opregion_e820_pages *PAGE_SIZE ; e820[nr].type =E820_NVS ; nr++; - e820[nr].addr = igd_opregion_base +IGD_OPREGION_PAGES *PAGE_SIZE ; + e820[nr].addr = igd_opregion_base + igd_opregion_e820_pages *PAGE_SIZE ; e820[nr].size = (uint32_t )-e820[nr].addr; e820[nr].type =E820_RESERVED ; nr++;
tools/firmware/hvmloader/intel_opregion.c new file +297 -0
297 lines not on this page · raw message
tools/firmware/hvmloader/pci.c +1 -9
@@ -43,7 +43,6 @@ uint64_t pci_hi_mem_start = 0, pci_hi_mem_end = 0;#define BAR_RELOC_THRESH GB(1)enum virtual_vga virtual_vga = VGA_none; -unsigned long igd_opregion_pgbase =0 ;/* Check if the specified range conflicts with any reserved device memory. */ static bool check_overlap_all (uint64_t start,uint64_t size)
@@ -190,14 +189,7 @@ void pci_setup(void) virtual_vga = VGA_pt;if ( vendor_id ==0x8086 ) { - igd_opregion_pgbase =mem_hole_alloc (IGD_OPREGION_PAGES ); -/* -* Write the the OpRegion offset to give the opregion -* address to the device model. The device model will trap -* and map the OpRegion at the give address. -*/ -pci_writel (vga_devfn,PCI_INTEL_OPREGION , - igd_opregion_pgbase <<PAGE_SHIFT ); +intel_opregion_setup (vga_devfn); } }break ;
Signature · 1 line
2.52.0
Quoted 61 lines · Chuck Zmudzinski
Modern Intel IGD devices do not work well with the current implementation of support for the Intel IGD in hvmloader because it lacks support for an extended video bios table (VBT).
Code 43 errors in Windows guests and failure of the guest screen to light up are some of the problems that occur with the current implementation.
To address this problem, this patch implements support for Intel IGD devices with an extended VBT and OpRegion version 2 and higher which is required for most modern Intel IGD devices.
This patch also depends on compatible support in the device model. If hvmloader detects the device model lacks such support, it will fall back to the currently implemented protocol for configuring the OpRegion to provide backward compatibiltiy for systems that lack a device model with support for an extended VBT.
Support for an extended VBT is implemented in the newly introduced function
opregion_setup()which is implemented in the new fileintel_opregion.c.Major differences between this implementation and the current implemntation that only supports older devices without an extended VBT:
1. The current implemntation reserves a constant number of pages (3) in the E820 map for the OpRegion which is set by the
IGD_OPREGION_PAGESmacro in the current implementation. With OpRegion 2 and higher, the OpRegion can have an extended VBT that must be provided to the guest with the OpRegion. This means the size of the region is not fixed, so in this new implementation theIGD_OPREGION_PAGESconstant is changed to a variable ine820.c,igd_opregion_e820_pages, that is set to its proper value based on the the size of the VBT. In this new implemntation, the size of the ACPI NVS region reserved for the OpRegion in the E820 map is equal to the value of theigd_opregion_e820_pagesvariable instead of being set to the constant value determined byIGD_OPREGION_PAGES.2. The current implemntation provides the guest with access to the unmodified OpRegion on the host via memory mapping from the host to the guest. This is insufficient for OpRegion 2 and higher because some devices will require modifications to the OpRegion for proper operation in the guest. So this new implementation provides hvmloader with a copy of the host's OpRegion that hvmloader can modify as needed for proper operation. Mapping the OpRegion from the host to the guest is only used temporarily during setup of the OpRegion by hvmloader and once hvmloader has a copy of the OpRegion and the extended VBT, the device model removes the host mapping and hvmloader configures the guest to use the guest's possibly modified copy of the OpRegion instead.
3. The current implementation lacks useful debugging information for the more recent devices. This new implementation provides useful debugging output from hvmloader, such as the detected host OpRegion version and address, the values for rvda, rvds, and the guest OpRegion address when the
guest_loglvlis set to all/all.
Quoted 8 lines
Signed-off-by Chuck Zmudzinski <[email protected]>---
Later versions of this patch will provide a link to the compatible patch for extended VBT support in the device model which will be posted to the qemu-devel and xen-devel mailing lists and Cc'd to the appropriate maintainers and reviewers soon.
I forgot to mention that there is an undocumented setting that works in the xl.cfg(5) domain configuration file, firmware_override, that makes it possible to use a patched version of hvmloader alongside an installation of unpatched upstream Xen or a version of Xen packaged by a distro. So one can download the source for one's installed version of Xen, apply this patch and build just hvmloader and then install the patched version of hvmloader with a different filename, such as hvmloader-igd-testing, into the same directory where hvmloader is installed (usually something like /usr/libexec/xen/boot) and then one can configure a guest to use the patched version of hvmloader with one's installed version of Xen by adding a line like this to the domain xl.cfg file:
firmware_override = 'hvmloader-igd-testing'
Quoted 16 lines
The compatible patch for the device model is part of a larger patchset that fixes many of the problems that currently affect the feature of Intel IGD passthrough to Xen HVM guests. This patch should be considered as a companion patch to that patchset for the device model. Do not try to test this patch with a real Intel IGD device without also applying the patchset for the device model because without those patches, the guest will most likely fail to start if an Intel IGD is passed through to the guest.
There are different requirements to support OpRegion version 2.0 and OpRegion version 2.1+, with support for OpRegion 2 the more difficult case because it always requires modifications to the OpRegion for proper operation in the guest. For some details about OpRegion 2 and higher and the extended VBT, see the links in the commit message.