xen: add Intel IGD passthrough support
cover xen: add Intel IGD passthrough support
From: Yang Zhang <[email protected]>
The following patches are ported from Xen Qemu-traditional branch which are adding Intel IGD passthrough supporting to Qemu upstream.
To pass through IGD to guest, user need to add following lines in Xen config file:
gfx_passthru=1
pci=['00:02.0@2']
Besides, since Xen + Qemu upstream is requiring seabios, user also need to recompile seabios with CONFIG_OPTIONROMS_DEPLOYED=y to allow IGD pass through successfully:
1. change CONFIG_OPTIONROMS_DEPLOYED=y in file: xen/tools/firmware/seabios-config
2. recompile the tools
I have successfully boot Win 7 and RHEL6u4 guests with IGD assigned in Haswell desktop with Latest Xen + Qemu upstream.
Yang Zhang (5):
xen, gfx passthrough: basic graphics passthrough support xen, gfx passthrough: reserve 00:02.0 for INTEL IGD xen, gfx passthrough: create intel isa bridge
xen, gfx passthrough: support Intel IGD passthrough with VT-D xen, gfx passthrough: add opregion mapping
configure | 2 +- hw/pci-host/piix.c | 15 ++ hw/pci/pci.c | 19 ++ hw/xen/Makefile.objs | 2 +- hw/xen/xen-host-pci-device.c | 5 + hw/xen/xen-host-pci-device.h | 1 + hw/xen/xen_pt.c | 10 + hw/xen/xen_pt.h | 13 ++- hw/xen/xen_pt_config_init.c | 45 +++++- hw/xen/xen_pt_graphics.c | 407 ++++++++++++++++++++++++++++++++++++++++++ qemu-options.hx | 9 + vl.c | 8 + 12 files changed, 532 insertions(+), 4 deletions(-) create mode 100644 hw/xen/xen_pt_graphics.c
PATCH 1/5 xen, gfx passthrough: basic graphics passthrough support
From: Yang Zhang <[email protected]>
basic gfx passthrough support:
- add a vga type for gfx passthrough
- retrieve VGA bios from host 0xC0000, then load it to guest 0xC0000
- register/unregister legacy VGA I/O ports and MMIOs for passthroughed gfx
The original patch is from Weidong Han <[email protected]>
--- configure | 2 +- hw/xen/Makefile.objs | 2 +- hw/xen/xen-host-pci-device.c | 5 ++ hw/xen/xen-host-pci-device.h | 1 + hw/xen/xen_pt.c | 10 +++ hw/xen/xen_pt.h | 4 + hw/xen/xen_pt_graphics.c | 164 ++++++++++++++++++++++++++++++++++++++++++ qemu-options.hx | 9 +++ vl.c | 8 ++ 9 files changed, 203 insertions(+), 2 deletions(-) create mode 100644 hw/xen/xen_pt_graphics.c
configure +1 -1
@@ -4608,7 +4608,7 @@ case "$target_name" in if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then echo "CONFIG_XEN=y" >> $config_target_mak if test "$xen_pci_passthrough" = yes; then - echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak" + echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_host_mak" fi fi ;;
hw/xen/Makefile.objs +1 -1
@@ -3,4 +3,4 @@ common-obj-$(CONFIG_XEN_BACKEND) += xen_backend.o xen_devconfig.o obj-$(CONFIG_XEN_I386) += xen_platform.o xen_apic.o xen_pvdevice.o obj-$(CONFIG_XEN_PCI_PASSTHROUGH) += xen-host-pci-device.o -obj-$(CONFIG_XEN_PCI_PASSTHROUGH) += xen_pt.o xen_pt_config_init.o xen_pt_msi.o +obj-$(CONFIG_XEN_PCI_PASSTHROUGH) += xen_pt.o xen_pt_config_init.o xen_pt_msi.o xen_pt_graphics.o
hw/xen/xen-host-pci-device.c +5 -0
@@ -376,6 +376,11 @@ int xen_host_pci_device_get(XenHostPCIDevice *d, uint16_t domain, goto error; } d->irq = v; + rc =xen_host_pci_get_hex_value (d,"class" , &v); +if (rc) { + goto error; + } + d->class_code = v; d->is_virtfn =xen_host_pci_dev_is_virtfn (d);return 0 ;
hw/xen/xen-host-pci-device.h +1 -0
@@ -25,6 +25,7 @@ typedef struct XenHostPCIDevice {uint16_t vendor_id;uint16_t device_id; +uint32_t class_code;int irq;XenHostPCIIORegion io_regions[PCI_NUM_REGIONS -1 ];
hw/xen/xen_pt.c +10 -0
@@ -450,6 +450,7 @@ static int xen_pt_register_regions(XenPCIPassthroughState *s) d->rom.size, d->rom.base_addr); } +register_vga_regions (d);return 0 ; }
@@ -470,6 +471,8 @@ static void xen_pt_unregister_regions(XenPCIPassthroughState *s)if (d->rom.base_addr && d->rom.size) {memory_region_destroy (&s->rom); } + +unregister_vga_regions (d); }/* region mapping */
@@ -693,6 +696,13 @@ static int xen_pt_initfn(PCIDevice *d)/* Handle real device's MMIO/PIO BARs */ xen_pt_register_regions (s); +/* Setup VGA bios for passthroughed gfx */ +if (setup_vga_pt (&s->real_device) <0 ) { +XEN_PT_ERR (d,"Setup VGA BIOS of passthroughed gfx failed!\n" ); +xen_host_pci_device_put (&s->real_device); +return -1 ; + } +/* reinitialize each config register to be emulated */ if (xen_pt_config_init (s)) {XEN_PT_ERR (d,"PCI Config space initialisation failed.\n" );
hw/xen/xen_pt.h +4 -0
@@ -298,5 +298,9 @@ static inline bool xen_pt_has_msix_mapping(XenPCIPassthroughState *s, int bar) return s->msix && s->msix->bar_index == bar; } +extern int gfx_passthru; +int register_vga_regions (XenHostPCIDevice *dev); +int unregister_vga_regions (XenHostPCIDevice *dev); +int setup_vga_pt (XenHostPCIDevice *dev);#endif /* !XEN_PT_H */
hw/xen/xen_pt_graphics.c new file +164 -0
164 lines not on this page · raw message
qemu-options.hx +9 -0
@@ -1034,6 +1034,15 @@ STEXI Rotate graphical output some deg left (only PXA LCD). ETEXI +DEF("gfx_passthru", 0, QEMU_OPTION_gfx_passthru, + "-gfx_passthru enable Intel IGD passthrough by XEN\n", + QEMU_ARCH_ALL) +STEXI +@item -gfx_passthru +@findex -gfx_passthru +Enable Intel IGD passthrough by XEN +ETEXI + DEF("vga", HAS_ARG, QEMU_OPTION_vga, "-vga [std|cirrus|vmware|qxl|xenfb|none]\n" " select video card type\n", QEMU_ARCH_ALL)
vl.c +8 -0
@@ -215,6 +215,9 @@ static bool tcg_allowed = true;bool xen_allowed;uint32_t xen_domid;enum xen_mode xen_mode =XEN_EMULATE ; +#if defined(CONFIG_XEN_PCI_PASSTHROUGH ) +int gfx_passthru =0 ; +#endif static int tcg_tb_size;static int default_serial =1 ;
@@ -3775,6 +3778,11 @@ int main(int argc, char **argv, char **envp) }configure_msg (opts);break ; +#if defined(CONFIG_XEN_PCI_PASSTHROUGH ) +case QEMU_OPTION_gfx_passthru: + gfx_passthru =1 ; +break ; +#endif default :os_parse_cmd_args (popt->index, optarg); }
Signature · 1 line
1.7.1
Re: [Qemu-devel] [PATCH 1/5] xen, gfx passthrough: basic graphics passthrough support
Quoted 29 lines · Yang Zhang
From: Yang Zhang <[email protected]>
basic gfx passthrough support:
- add a vga type for gfx passthrough
- retrieve VGA bios from host0xC0000, then load it to guest0xC0000
- register/unregister legacy VGA I/O ports and MMIOs for passthroughed gfxThe original patch is from Weidong Han <[email protected]>
Signed-off-by Yang Zhang <[email protected]>Cc Weidong Han <[email protected]>--- configure | 2 +- hw/xen/Makefile.objs | 2 +- hw/xen/xen-host-pci-device.c | 5 ++ hw/xen/xen-host-pci-device.h | 1 + hw/xen/xen_pt.c | 10 +++ hw/xen/xen_pt.h | 4 + hw/xen/xen_pt_graphics.c | 164 ++++++++++++++++++++++++++++++++++++++++++ qemu-options.hx | 9 +++ vl.c | 8 ++ 9 files changed, 203 insertions(+), 2 deletions(-) create mode 100644 hw/xen/xen_pt_graphics.cconfigure +0
-0
configure case "$target_name" in · line 4611
Quoted 5 lines
configure +1
-1@@ -4608,7 +4608,7 @@ case "$target_name" in if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then echo "CONFIG_XEN=y" >> $config_target_mak if test "$xen_pci_passthrough" = yes; then - echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak" + echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_host_mak"
Why do you need to move this option from config_target to config_host?
Quoted 81 lines
configure +0
-0fi fi ;;hw/xen/Makefile.objs +1
-1@@ -3,4 +3,4 @@ common-obj-$(CONFIG_XEN_BACKEND) += xen_backend.o xen_devconfig.o obj-$(CONFIG_XEN_I386) += xen_platform.o xen_apic.o xen_pvdevice.o obj-$(CONFIG_XEN_PCI_PASSTHROUGH) += xen-host-pci-device.o -obj-$(CONFIG_XEN_PCI_PASSTHROUGH) += xen_pt.o xen_pt_config_init.o xen_pt_msi.o +obj-$(CONFIG_XEN_PCI_PASSTHROUGH) += xen_pt.o xen_pt_config_init.o xen_pt_msi.o xen_pt_graphics.ohw/xen/xen-host-pci-device.c +5
-0@@ -376,6 +376,11 @@ int xen_host_pci_device_get(XenHostPCIDevice *d, uint16_t domain, goto error; } d->irq = v; + rc =xen_host_pci_get_hex_value (d,"class" , &v); +if (rc) { + goto error; + } + d->class_code = v; d->is_virtfn =xen_host_pci_dev_is_virtfn (d);return 0 ;hw/xen/xen-host-pci-device.h +1
-0@@ -25,6 +25,7 @@ typedef struct XenHostPCIDevice {uint16_t vendor_id;uint16_t device_id; +uint32_t class_code;int irq;XenHostPCIIORegion io_regions[PCI_NUM_REGIONS -1 ];hw/xen/xen_pt.c +10
-0@@ -450,6 +450,7 @@ static int xen_pt_register_regions(XenPCIPassthroughState *s) d->rom.size, d->rom.base_addr); } +register_vga_regions (d);return 0 ; }@@ -470,6 +471,8 @@ static void xen_pt_unregister_regions(XenPCIPassthroughState *s)if (d->rom.base_addr && d->rom.size) {memory_region_destroy (&s->rom); } + +unregister_vga_regions (d); }/* region mapping */ @@ -693,6 +696,13 @@ static int xen_pt_initfn(PCIDevice *d)/* Handle real device's MMIO/PIO BARs */ xen_pt_register_regions (s); +/* Setup VGA bios for passthroughed gfx */ +if (setup_vga_pt (&s->real_device) <0 ) { +XEN_PT_ERR (d,"Setup VGA BIOS of passthroughed gfx failed!\n" ); +xen_host_pci_device_put (&s->real_device); +return -1 ; + } +/* reinitialize each config register to be emulated */ if (xen_pt_config_init (s)) {XEN_PT_ERR (d,"PCI Config space initialisation failed.\n" );hw/xen/xen_pt.h +0
-0
hw/xen/xen_pt.h static inline bool xen_pt_has_msix_mapping(XenPCIPassthroughState *s, int bar) · line 304
Quoted 7 lines
hw/xen/xen_pt.h +4
-0@@ -298,5 +298,9 @@ static inline bool xen_pt_has_msix_mapping(XenPCIPassthroughState *s, int bar)return s->msix && s->msix->bar_index == bar; } +extern int gfx_passthru; +int register_vga_regions (XenHostPCIDevice *dev); +int unregister_vga_regions (XenHostPCIDevice *dev); +int setup_vga_pt (XenHostPCIDevice *dev);
I believe those function names need to be prefix with xen_pt_ (e.g. xen_pt_register_vga_regions).
Quoted 12 lines
hw/xen/xen_pt.h +0
-0#endif /* !XEN_PT_H */ hw/xen/xen_pt_graphics.c new file +5
-0@@ -0,0 +1,164 @@ +/* +* graphics passthrough +*/ +#include "xen_pt.h" +#include "xen-host-pci-device.h"
hw/xen/xen_pt_graphics.c line 15
Quoted 10 lines
hw/xen/xen_pt_graphics.c new file +10
-0+#include "hw/xen/xen_backend.h" + +/* +* register VGA resources for the domain with assigned gfx +*/ +int register_vga_regions (XenHostPCIDevice *dev) +{ +int ret =0 ; + +if (!gfx_passthru || ((dev->class_code >>0x8 ) !=0x0300 )) {
Instead of 0x0300, you can use PCI_CLASS_DISPLAY_VGA. The same apply to the few other places.
Quoted 113 lines
hw/xen/xen_pt_graphics.c new file +113
-0+return ret; + } + + ret |=xc_domain_ioport_mapping (xen_xc, xen_domid,0x3B0 , +0x3B0 ,0xA ,DPCI_ADD_MAPPING ); + + ret |=xc_domain_ioport_mapping (xen_xc, xen_domid,0x3C0 , +0x3C0 ,0x20 ,DPCI_ADD_MAPPING ); + + ret |=xc_domain_memory_mapping (xen_xc, xen_domid, +0xa0000 >>XC_PAGE_SHIFT , +0xa0000 >>XC_PAGE_SHIFT , +0x20 , +DPCI_ADD_MAPPING ); + +if (ret !=0 ) { +XEN_PT_ERR (NULL ,"VGA region mapping failed\n" ); + } + +return ret; +} + +/* +* unregister VGA resources for the domain with assigned gfx +*/ +int unregister_vga_regions (XenHostPCIDevice *dev) +{ +int ret =0 ; + +if (!gfx_passthru || ((dev->class_code >>0x8 ) !=0x0300 )) { +return ret; + } + + ret |=xc_domain_ioport_mapping (xen_xc, xen_domid,0x3B0 , +0x3B0 ,0xC ,DPCI_REMOVE_MAPPING ); + + ret |=xc_domain_ioport_mapping (xen_xc, xen_domid,0x3C0 , +0x3C0 ,0x20 ,DPCI_REMOVE_MAPPING ); + + ret |=xc_domain_memory_mapping (xen_xc, xen_domid, +0xa0000 >>XC_PAGE_SHIFT , +0xa0000 >>XC_PAGE_SHIFT , +20 , +DPCI_REMOVE_MAPPING ); + +if (ret !=0 ) { +XEN_PT_ERR (NULL ,"VGA region unmapping failed\n" ); + } + +return ret; +} + +static int get_vgabios (unsigned char *buf) +{ +int fd; +uint32_t bios_size =0 ; +uint32_t start =0xC0000 ; +uint16_t magic =0 ; + + fd =open ("/dev/mem" ,O_RDONLY ); +if (fd <0 ) { +XEN_PT_ERR (NULL ,"Can't open /dev/mem: %s\n" ,strerror (errno)); +return 0 ; + } + +/* +* Check if it a real bios extension. +* The magic number is 0xAA55. +*/ +if (start !=lseek (fd, start,SEEK_SET )) { + goto out; + } +if (read (fd, &magic,2 ) !=2 ) { + goto out; + } +if (magic !=0xAA55 ) { + goto out; + } + +/* Find the size of the rom extension */ +if (start !=lseek (fd, start,SEEK_SET )) { + goto out; + } +if (lseek (fd,2 ,SEEK_CUR ) != (start +2 )) { + goto out; + } +if (read (fd, &bios_size,1 ) !=1 ) { + goto out; + } + +/* This size is in 512 bytes */ + bios_size *=512 ; + +/* +* Set the file to the begining of the rombios, +* to start the copy. +*/ +if (start !=lseek (fd, start,SEEK_SET )) { + goto out; + } + +if (bios_size !=read (fd, buf, bios_size)) { + bios_size =0 ; + } + +out: +close (fd); +return bios_size; +} + +int setup_vga_pt (XenHostPCIDevice *dev) +{ +unsigned char *bios =NULL ;
hw/xen/xen_pt_graphics.c line 138
Quoted 10 lines
hw/xen/xen_pt_graphics.c new file +10
-0+int bios_size =0 ; +char *c =NULL ; +char checksum =0 ; +int rc =0 ; + +if (!gfx_passthru || ((dev->class_code >>0x8 ) !=0x0300 )) { +return rc; + } + + bios =malloc (64 *1024 );
I think g_malloc should be used here, instead of malloc, and g_malloc always return an allocated buffer. (it never fail, or it don't return)
Quoted 33 lines
hw/xen/xen_pt_graphics.c new file +26
-0+/* Allocated 64K for the vga bios */ +if (!bios) { +return -1 ; + } + + bios_size =get_vgabios (bios); +if (bios_size ==0 || bios_size >64 *1024 ) { +XEN_PT_ERR (NULL ,"vga bios size (0x%x) is invalid!\n" , bios_size); + rc =-1 ; + goto out; + } + +/* Adjust the bios checksum */ +for (c = (char *)bios; c < ((char *)bios + bios_size); c++) { + checksum += *c; + } +if (checksum) { + bios[bios_size -1 ] -= checksum; +XEN_PT_LOG (NULL ,"vga bios checksum is adjusted!\n" ); + } + +cpu_physical_memory_rw (0xc0000 , bios, bios_size,1 ); +out: +free (bios); +return rc; +}qemu-options.hx +0
-0@@ -1034,6 +1034,15 @@ STEXI Rotate graphical output some deg left (only PXA LCD). ETEXI
qemu-options.hx STEXI · line 1045
Quoted 10 lines
qemu-options.hx +9
-0+DEF("gfx_passthru", 0, QEMU_OPTION_gfx_passthru, + "-gfx_passthru enable Intel IGD passthrough by XEN\n", + QEMU_ARCH_ALL) +STEXI +@item -gfx_passthru +@findex -gfx_passthru +Enable Intel IGD passthrough by XEN +ETEXI +
Is this options really necessary? If someone is passing-through a graphic card, he propably want to pass it through as a graphic card, without having to enable yet another option.
Quoted 29 lines
qemu-options.hx +0
-0DEF("vga", HAS_ARG, QEMU_OPTION_vga, "-vga [std|cirrus|vmware|qxl|xenfb|none]\n" " select video card type\n", QEMU_ARCH_ALL)vl.c +8
-0@@ -215,6 +215,9 @@ static bool tcg_allowed = true;bool xen_allowed;uint32_t xen_domid;enum xen_mode xen_mode =XEN_EMULATE ; +#if defined(CONFIG_XEN_PCI_PASSTHROUGH ) +int gfx_passthru =0 ; +#endif static int tcg_tb_size;static int default_serial =1 ;@@ -3775,6 +3778,11 @@ int main(int argc, char **argv, char **envp) }configure_msg (opts);break ; +#if defined(CONFIG_XEN_PCI_PASSTHROUGH ) +case QEMU_OPTION_gfx_passthru: + gfx_passthru =1 ; +break ; +#endif default :os_parse_cmd_args (popt->index, optarg); }
Signature · 1 line
Anthony PERARD
Re: [Qemu-devel] [PATCH 1/5] xen, gfx passthrough: basic graphics passthrough support
Anthony PERARD wrote on 2014-03-22:
Quoted 9 lines · Yang Zhang
Quoted 8 lines
From: Yang Zhang <[email protected]>
basic gfx passthrough support:
- add a vga type for gfx passthrough
- retrieve VGA bios from host0xC0000, then load it to guest0xC0000
- register/unregister legacy VGA I/O ports and MMIOs for passthroughed gfx
Quoted 4 lines
Quoted 4 lines
The original patch is from Weidong Han <[email protected]>
Signed-off-by Yang Zhang <[email protected]>Cc Weidong Han <[email protected]>
Hi all,
Thanks for your comments.
I am sorry for late reply. I have been busy working on other task so that I have no time to push this patch in the past two months. Now I and Tiejun will continue working on this and will send out the second version which is modified according your previous comments. Please help to review the second one again.
Quoted 246 lines
Quoted 15 lines
---
configure | 2 +- hw/xen/Makefile.objs |2 +- hw/xen/xen-host-pci-device.c | 5 ++
hw/xen/xen-host-pci-device.h| 1 +hw/xen/xen_pt.c|
10 +++hw/xen/xen_pt.h| 4 +hw/xen/xen_pt_graphics.c
| 164 ++++++++++++++++++++++++++++++++++++++++++ qemu-options.hx
| 9 +++vl.c| 8 ++ 9 files
changed, 203 insertions(+), 2 deletions(-) create mode
100644hw/xen/xen_pt_graphics.cconfigure +0
-0configure case "$target_name" in · line 4611
Quoted 5 lines
configure +0
-1@@ -4608,7 +4608,7 @@ case "$target_name" in if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then echo "CONFIG_XEN=y" >> $config_target_mak if test "$xen_pci_passthrough" = yes; then - echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak" + echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >>"$config_host_mak"
Why do you need to move this option from
config_targettoconfig_host?Quoted 19 lines
configure +0
-0fi fi ;;hw/xen/Makefile.objs index renamed from hw/xen/Makefile.objs +0
-0ce640c6..350d337 100644 --- a/hw/xen/Makefile.objs +++ b/hw/xen/Makefile.objs @@ -3,4 +3,4 @@ common-obj-$(CONFIG_XEN_BACKEND) += xen_backend.o xen_devconfig.o
obj-$(CONFIG_XEN_I386) += xen_platform.o xen_apic.o xen_pvdevice.o obj-$(CONFIG_XEN_PCI_PASSTHROUGH) += xen-host-pci-device.o
-obj-$(CONFIG_XEN_PCI_PASSTHROUGH) += xen_pt.o xen_pt_config_init.o xen_pt_msi.ohw/xen/Makefile.objs index renamed from hw/xen/Makefile.objs +2
-0+obj-$(CONFIG_XEN_PCI_PASSTHROUGH) += xen_pt.o xen_pt_config_init.o +xen_pt_msi.o xen_pt_graphics.o(quoted diff) +0
-0
b/hw/xen/xen-host-pci-device.cindex 743b37b..a54b7de 100644hw/xen/xen-host-pci-device.c int xen_host_pci_device_get(XenHostPCIDevice · line 376
Quoted 1 line
hw/xen/xen-host-pci-device.c +0
-0@@ -376,6 +376,11 @@ int xen_host_pci_device_get(XenHostPCIDevice *d,
uint16_tdomain,hw/xen/xen_pt.c static int
Quoted 25 lines
hw/xen/xen-host-pci-device.c +5
-0goto error; } d->irq = v; + rc =xen_host_pci_get_hex_value (d,"class" , &v); +if (rc) { + goto error; + } + d->class_code = v; d->is_virtfn =xen_host_pci_dev_is_virtfn (d);return 0;(quoted diff) +0
-0
b/hw/xen/xen-host-pci-device.hindex c2486f0..f1e1c30 100644hw/xen/xen-host-pci-device.h +0
-0@@ -25,6 +25,7 @@ typedef struct XenHostPCIDevice { uint16_t vendor_id; uint16_t device_id; + uint32_t class_code;int irq; XenHostPCIIORegion io_regions[PCI_NUM_REGIONS - 1]; diff --git
a/hw/xen/xen_pt.cb/hw/xen/xen_pt.cindex be4220b..5a36902 100644hw/xen/xen_pt.c +0
-0@@ -450,6 +450,7 @@ static int
xen_pt_register_regions(XenPCIPassthroughState *s)hw/xen/xen_pt.c static void
Quoted 6 lines
hw/xen/xen_pt.c +1
-0d->rom.size, d->rom.base_addr); } +register_vga_regions (d);return 0 ; }@@ -470,6 +471,8 @@ static void
xen_pt_unregister_regions(XenPCIPassthroughState *s)hw/xen/xen_pt.h static inline bool
Quoted 27 lines
hw/xen/xen_pt.c +9
-0if (d->rom.base_addr && d->rom.size) {memory_region_destroy (&s->rom); } + +unregister_vga_regions (d); }/* region mapping */ @@ -693,6 +696,13 @@ static int xen_pt_initfn(PCIDevice *d)/* Handle real device's MMIO/PIO BARs */ xen_pt_register_regions (s); +/* Setup VGA bios for passthroughed gfx */ +if (setup_vga_pt (&s->real_device) <0 ) { +XEN_PT_ERR (d,"Setup VGA BIOS of passthroughed gfx failed!\n" ); +xen_host_pci_device_put (&s->real_device); +return -1 ; + } +/* reinitialize each config register to be emulated */ if (xen_pt_config_init (s)) {XEN_PT_ERR (d,"PCI Config space initialisation failed.\n" );hw/xen/xen_pt.h index renamed from hw/xen/xen_pt.h +0
-0942dc60..c04bbfd
100644hw/xen/xen_pt.h +0
-0@@ -298,5 +298,9 @@ static inline bool
xen_pt_has_msix_mapping(XenPCIPassthroughState *s, int bar)hw/xen/xen_pt.h static inline bool · line 302
Quoted 5 lines
hw/xen/xen_pt.h +4
-0return s->msix && s->msix->bar_index == bar; } +extern int gfx_passthru; +int register_vga_regions (XenHostPCIDevice *dev);int +unregister_vga_regions (XenHostPCIDevice *dev);int +setup_vga_pt (XenHostPCIDevice *dev);I believe those function names need to be prefix with
xen_pt_(e.g.xen_pt_register_vga_regions).Quoted 9 lines
hw/xen/xen_pt.h +0
-0#endif /* !XEN_PT_H */ hw/xen/xen_pt_graphics.c new renamed from hw/xen/xen_pt_graphics.c +0
-0file mode 100644 index 0000000..9ad8a74
hw/xen/xen_pt_graphics.c new file +3
-0@@ -0,0 +1,164 @@ +/* +* graphics passthrough +*/ hw/xen/xen_pt_graphics.c line 13
Quoted 10 lines
hw/xen/xen_pt_graphics.c new file +10
-0+#include "xen_pt.h" +#include "xen-host-pci-device.h" +#include "hw/xen/xen_backend.h" + +/* +* register VGA resources for the domain with assigned gfx */ int +register_vga_regions (XenHostPCIDevice *dev) { +int ret =0 ; + +if (!gfx_passthru || ((dev->class_code >>0x8 ) !=0x0300 )) {Instead of
0x0300, you can usePCI_CLASS_DISPLAY_VGA. The same apply to the few other places.Quoted 32 lines
hw/xen/xen_pt_graphics.c new file +1
-0+ return ret; + } + + ret |=xc_domain_ioport_mapping(xen_xc,
xen_domid,0x3B0, +0x3B0,0xA,DPCI_ADD_MAPPING); + + ret |= xc_domain_ioport_mapping(xen_xc,xen_domid,0x3C0, +0x3C0,0x20,DPCI_ADD_MAPPING); + +
ret |= xc_domain_memory_mapping(xen_xc,xen_domid, +0xa0000Quoted 1 line
Quoted 1 line
XC_PAGE_SHIFT, +0xa0000>>XC_PAGE_SHIFT, +
0x20, +DPCI_ADD_MAPPING); + + if (ret != 0) { +XEN_PT_ERR(NULL, "VGA region mapping failed\n"); + } + + return
ret; +} + +/* + * unregister VGA resources for the domain with assigned
gfx */ +intunregister_vga_regions(XenHostPCIDevice *dev){ + int
ret = 0; + + if (!gfx_passthru || ((dev->class_code>>0x8) !=0x0300)) { + return ret; + } + + ret |=
xc_domain_ioport_mapping(xen_xc,xen_domid,0x3B0, +0x3B0,0xC,DPCI_REMOVE_MAPPING); + + ret |=
xc_domain_ioport_mapping(xen_xc,xen_domid,0x3C0, +0x3C0,0x20,DPCI_REMOVE_MAPPING); + + ret |=
xc_domain_memory_mapping(xen_xc,xen_domid, +0xa0000>>XC_PAGE_SHIFT, +0xa0000>>XC_PAGE_SHIFT, + 20,
+DPCI_REMOVE_MAPPING); + + if (ret != 0) { +XEN_PT_ERR(NULL, "VGA region unmapping failed\n"); + } + + return
ret; +} + +static intget_vgabios(unsigned char *buf){ + int fd; +
uint32_tbios_size= 0; +uint32_tstart =0xC0000; +uint16_t
magic = 0; + + fd =open("/dev/mem", O_RDONLY); + if (fd < 0) { +XEN_PT_ERR(NULL, "Can't open /dev/mem: %s\n", strerror(errno));+ return 0; + } + + /* + * Check if it a real bios
extension. + * The magic number is0xAA55. + */ + if (start
!=lseek(fd, start, SEEK_SET)) { + goto out; + } + if
(read(fd, &magic, 2)!= 2) { + goto out; + } + if (magic
!=0xAA55) { + goto out; + } + + /* Find the size of the
rom extension */ + if (start !=lseek(fd, start, SEEK_SET)) { +
goto out; + } + if (lseek(fd, 2, SEEK_CUR)!= (start + 2)) { +goto out; + } + if (read(fd, &bios_size, 1) != 1) { +Quoted 10 lines
goto out; + } + + /* This size is in 512 bytes */ +
bios_size
*= 512; + + /* + * Set the file to the begining of the rombios,
+ * to start the copy. + */ + if (start != lseek(fd, start,SEEK_SET)) { + goto out; + } + + if (bios_size!= read(fd,
buf,bios_size)) { +bios_size= 0; + } + +out: +
close(fd); + returnbios_size; +} + +intsetup_vga_pt(XenHostPCIDevice *dev){ + unsigned char *bios = NULL;
+ intbios_size= 0; + char *c = NULL; + char checksum = 0; +
int rc = 0; + + if (!gfx_passthru || ((dev->class_code>>0x8) !=0x0300)) { + return rc; + } + + bios =malloc(64 * 1024);I think
g_mallocshould be used here, instead of malloc, andg_mallocalways return an allocated buffer. (it never fail, or it don't return)Quoted 32 lines
hw/xen/xen_pt_graphics.c new file +26
-0+/* Allocated 64K for the vga bios */ +if (!bios) { +return -1 ; + } + + bios_size =get_vgabios (bios); +if (bios_size ==0 || bios_size >64 *1024 ) { +XEN_PT_ERR (NULL ,"vga bios size (0x%x) is invalid!\n" , bios_size); + rc =-1 ; + goto out; + } + +/* Adjust the bios checksum */ +for (c = (char *)bios; c < ((char *)bios + bios_size); c++) { + checksum += *c; + } +if (checksum) { + bios[bios_size -1 ] -= checksum; +XEN_PT_LOG (NULL ,"vga bios checksum is adjusted!\n" ); + } + +cpu_physical_memory_rw (0xc0000 , bios, bios_size,1 ); +out: +free (bios); +return rc; +}qemu-options.hx index renamed from qemu-options.hx +0
-056e5fdf..95de002
100644qemu-options.hx STEXI · line 1043
Quoted 10 lines
qemu-options.hx +8
-0@@ -1034,6 +1034,15 @@ STEXI Rotate graphical output some deg left (only PXA LCD). ETEXI +DEF("gfx_passthru", 0, QEMU_OPTION_gfx_passthru, + "-gfx_passthru enable Intel IGD passthrough by XEN\n", + QEMU_ARCH_ALL) +STEXI +@item -gfx_passthru +@findex -gfx_passthru +Enable Intel IGD passthrough by XEN ETEXI +Is this options really necessary? If someone is passing-through a graphic card, he propably want to pass it through as a graphic card, without having to enable yet another option.
Quoted 15 lines
qemu-options.hx +0
-0DEF("vga", HAS_ARG, QEMU_OPTION_vga, "-vga [std|cirrus|vmware|qxl|xenfb|none]\n" " select video card type\n", QEMU_ARCH_ALL)vl.c +0
-0@@ -215,6 +215,9 @@ static bool tcg_allowed = true; bool
xen_allowed;uint32_txen_domid; enumxen_modexen_mode=XEN_EMULATE;vl.c +3
-0+#if defined(CONFIG_XEN_PCI_PASSTHROUGH ) +int gfx_passthru =0 ; +#endif static int tcg_tb_size;
Quoted 14 lines
vl.c int main(int argc, char **argv, char **envp) · line 3788
Quoted 13 lines
static int
default_serial= 1;vl.c +5
-0@@ -3775,6 +3778,11 @@ int main(int argc, char **argv, char **envp) }configure_msg (opts);break ; +#if defined(CONFIG_XEN_PCI_PASSTHROUGH ) +case QEMU_OPTION_gfx_passthru: + gfx_passthru =1 ; +break ; +#endif default :os_parse_cmd_args (popt->index, optarg); }
Best regards,
Yang
Re: [Qemu-devel] [Xen-devel] [PATCH 1/5] xen, gfx passthrough: basic graphics passthrough support
In reply to Yang ZhangQuoted 207 lines
-----Original Message-----
From: [email protected] [mailto:xen-devel- [email protected]] On Behalf Of Yang Zhang
Sent: Friday, February 21, 2014 1:44 AM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Yang Zhang; [email protected]; [email protected]
Subject: [Xen-devel] [PATCH 1/5] xen, gfx passthrough: basic graphics passthrough supportFrom: Yang Zhang <[email protected]>
basic gfx passthrough support:
- add a vga type for gfx passthrough
- retrieve VGA bios from host0xC0000, then load it to guest0xC0000
- register/unregister legacy VGA I/O ports and MMIOs for passthroughed gfxThe original patch is from Weidong Han <[email protected]>
Signed-off-by Yang Zhang <[email protected]>Cc Weidong Han <[email protected]>--- configure | 2 +- hw/xen/Makefile.objs | 2 +- hw/xen/xen-host-pci-device.c | 5 ++ hw/xen/xen-host-pci-device.h | 1 + hw/xen/xen_pt.c | 10 +++ hw/xen/xen_pt.h | 4 + hw/xen/xen_pt_graphics.c | 164 ++++++++++++++++++++++++++++++++++++++++++ qemu-options.hx | 9 +++ vl.c | 8 ++ 9 files changed, 203 insertions(+), 2 deletions(-) create mode 100644
hw/xen/xen_pt_graphics.cconfigure +1
-1@@ -4608,7 +4608,7 @@ case "$target_name" in if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then echo "CONFIG_XEN=y" >> $config_target_mak if test "$xen_pci_passthrough" = yes; then - echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak" + echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_host_mak" fi fi ;;hw/xen/Makefile.objs index renamed from hw/xen/Makefile.objs +0
-0ce640c6..350d337 100644
hw/xen/Makefile.objs +0
-0@@ -3,4 +3,4 @@ common-obj-$(CONFIG_XEN_BACKEND) += xen_backend.oxen_devconfig.o
obj-$(CONFIG_XEN_I386) += xen_platform.o xen_apic.o xen_pvdevice.o obj-$(CONFIG_XEN_PCI_PASSTHROUGH) += xen-host-pci-device.o
-obj-$(CONFIG_XEN_PCI_PASSTHROUGH) += xen_pt.o xen_pt_config_init.o xen_pt_msi.ohw/xen/Makefile.objs +2
-0+obj-$(CONFIG_XEN_PCI_PASSTHROUGH) += xen_pt.o xen_pt_config_init.o +xen_pt_msi.o xen_pt_graphics.ohw/xen/xen-host-pci-device.c index renamed from hw/xen/xen-host-pci-device.c +0
-0743b37b..a54b7de 100644
hw/xen/xen-host-pci-device.c +5
-0@@ -376,6 +376,11 @@ int xen_host_pci_device_get(XenHostPCIDevice *d,uint16_t domain, goto error; } d->irq = v; + rc =xen_host_pci_get_hex_value (d,"class" , &v); +if (rc) { + goto error; + } + d->class_code = v; d->is_virtfn =xen_host_pci_dev_is_virtfn (d);return 0;hw/xen/xen-host-pci-device.h index renamed from hw/xen/xen-host-pci-device.h +0
-0c2486f0..f1e1c30 100644
hw/xen/xen-host-pci-device.h +1
-0@@ -25,6 +25,7 @@ typedef struct XenHostPCIDevice {uint16_t vendor_id;uint16_t device_id; +uint32_t class_code;int irq; XenHostPCIIORegion io_regions[PCI_NUM_REGIONS - 1]; diff --git
a/hw/xen/xen_pt.cb/hw/xen/xen_pt.cindex be4220b..5a36902 100644hw/xen/xen_pt.c +3
-0@@ -450,6 +450,7 @@ static intxen_pt_register_regions (XenPCIPassthroughState *s) d->rom.size, d->rom.base_addr); } +register_vga_regions (d);return 0 ; }@@ -470,6 +471,8 @@ static void xen_pt_unregister_regions(XenPCIPassthroughState *s)if (d->rom.base_addr && d->rom.size) {memory_region_destroy (&s->rom); } + +unregister_vga_regions (d); }/* region mapping */
hw/xen/xen_pt.c +7
-0@@ -693,6 +696,13 @@ static int xen_pt_initfn(PCIDevice *d)/* Handle real device's MMIO/PIO BARs */ xen_pt_register_regions (s); +/* Setup VGA bios for passthroughed gfx */ +if (setup_vga_pt (&s->real_device) <0 ) { +XEN_PT_ERR (d,"Setup VGA BIOS of passthroughed gfx failed!\n" ); +xen_host_pci_device_put (&s->real_device); +return -1 ; + } +/* reinitialize each config register to be emulated */ if (xen_pt_config_init (s)) { XEN_PT_ERR(d, "PCI Config space initialisation failed.\n"); diff --git
a/hw/xen/xen_pt.hb/hw/xen/xen_pt.hindex 942dc60..c04bbfd 100644hw/xen/xen_pt.h +4
-0@@ -298,5 +298,9 @@ static inline bool xen_pt_has_msix_mapping(XenPCIPassthroughState *s, int bar) return s->msix && s->msix->bar_index == bar; } +extern int gfx_passthru; +int register_vga_regions (XenHostPCIDevice *dev);int +unregister_vga_regions (XenHostPCIDevice *dev);int +setup_vga_pt (XenHostPCIDevice *dev);#endif /* !XEN_PT_H */ hw/xen/xen_pt_graphics.c new file renamed from hw/xen/xen_pt_graphics.c +0
-0mode 100644 index 0000000..9ad8a74
hw/xen/xen_pt_graphics.c new file +59
-0@@ -0,0 +1,164 @@ +/* +* graphics passthrough +*/ +#include "xen_pt.h" +#include "xen-host-pci-device.h" +#include "hw/xen/xen_backend.h" + +/* +* register VGA resources for the domain with assigned gfx */ int +register_vga_regions (XenHostPCIDevice *dev) { +int ret =0 ; + +if (!gfx_passthru || ((dev->class_code >>0x8 ) !=0x0300 )) { +return ret; + } + + ret |=xc_domain_ioport_mapping (xen_xc, xen_domid,0x3B0 , +0x3B0 ,0xA ,DPCI_ADD_MAPPING ); + + ret |=xc_domain_ioport_mapping (xen_xc, xen_domid,0x3C0 , +0x3C0 ,0x20 ,DPCI_ADD_MAPPING ); + + ret |=xc_domain_memory_mapping (xen_xc, xen_domid, +0xa0000 >>XC_PAGE_SHIFT , +0xa0000 >>XC_PAGE_SHIFT , +0x20 , +DPCI_ADD_MAPPING ); + +if (ret !=0 ) { +XEN_PT_ERR (NULL ,"VGA region mapping failed\n" ); + } + +return ret; +} + +/* +* unregister VGA resources for the domain with assigned gfx */ int +unregister_vga_regions (XenHostPCIDevice *dev) { +int ret =0 ; + +if (!gfx_passthru || ((dev->class_code >>0x8 ) !=0x0300 )) { +return ret; + } + + ret |=xc_domain_ioport_mapping (xen_xc, xen_domid,0x3B0 , +0x3B0 ,0xC ,DPCI_REMOVE_MAPPING ); + + ret |=xc_domain_ioport_mapping (xen_xc, xen_domid,0x3C0 , +0x3C0 ,0x20 ,DPCI_REMOVE_MAPPING ); + + ret |=xc_domain_memory_mapping (xen_xc, xen_domid, +0xa0000 >>XC_PAGE_SHIFT , +0xa0000 >>XC_PAGE_SHIFT , +20 , +DPCI_REMOVE_MAPPING ); + +if (ret !=0 ) { +XEN_PT_ERR (NULL ,"VGA region unmapping failed\n" ); + }
hw/xen/xen_pt_graphics.c line 69
Quoted 10 lines
hw/xen/xen_pt_graphics.c new file +10
-0+ +return ret; +} + +static int get_vgabios (unsigned char *buf) { +int fd; +uint32_t bios_size =0 ; +uint32_t start =0xC0000 ; +uint16_t magic =0 ; +
There is an inherent logic problem with this function. This logic will not work if there are multiple graphics adapters in the system and you are passing the secondary graphics adapter to the guest as a primary. Chances are very good that the VBios image at 0xC0000 does not match with the VBios image in the secondary adapter (unless they are absolutely identical and have the same VBios versions).
The proper way to do a get_vgabios() is to extract the VBios from the OPTION_ROM of the graphics device that is being passed into the guest. You cannot assume that the image at 0xC0000 is a valid image for the device that is being passed into the guest when there are multiple adapters.
The logic that you present will work only if the primary graphics boot adapter is being passed into the guest but this is not always the case.
Quoted 136 lines
hw/xen/xen_pt_graphics.c new file +89
-0+ fd =open ("/dev/mem" ,O_RDONLY ); +if (fd <0 ) { +XEN_PT_ERR (NULL ,"Can't open /dev/mem: %s\n" ,strerror (errno)); +return 0 ; + } + +/* +* Check if it a real bios extension. +* The magic number is 0xAA55. +*/ +if (start !=lseek (fd, start,SEEK_SET )) { + goto out; + } +if (read (fd, &magic,2 ) !=2 ) { + goto out; + } +if (magic !=0xAA55 ) { + goto out; + } + +/* Find the size of the rom extension */ +if (start !=lseek (fd, start,SEEK_SET )) { + goto out; + } +if (lseek (fd,2 ,SEEK_CUR ) != (start +2 )) { + goto out; + } +if (read (fd, &bios_size,1 ) !=1 ) { + goto out; + } + +/* This size is in 512 bytes */ + bios_size *=512 ; + +/* +* Set the file to the begining of the rombios, +* to start the copy. +*/ +if (start !=lseek (fd, start,SEEK_SET )) { + goto out; + } + +if (bios_size !=read (fd, buf, bios_size)) { + bios_size =0 ; + } + +out: +close (fd); +return bios_size; +} + +int setup_vga_pt (XenHostPCIDevice *dev) { +unsigned char *bios =NULL ; +int bios_size =0 ; +char *c =NULL ; +char checksum =0 ; +int rc =0 ; + +if (!gfx_passthru || ((dev->class_code >>0x8 ) !=0x0300 )) { +return rc; + } + + bios =malloc (64 *1024 ); +/* Allocated 64K for the vga bios */ +if (!bios) { +return -1 ; + } + + bios_size =get_vgabios (bios); +if (bios_size ==0 || bios_size >64 *1024 ) { +XEN_PT_ERR (NULL ,"vga bios size (0x%x) is invalid!\n" , bios_size); + rc =-1 ; + goto out; + } + +/* Adjust the bios checksum */ +for (c = (char *)bios; c < ((char *)bios + bios_size); c++) { + checksum += *c; + } +if (checksum) { + bios[bios_size -1 ] -= checksum; +XEN_PT_LOG (NULL ,"vga bios checksum is adjusted!\n" ); + } + +cpu_physical_memory_rw (0xc0000 , bios, bios_size,1 ); +out: +free (bios); +return rc; +}qemu-options.hx +9
-0@@ -1034,6 +1034,15 @@ STEXI Rotate graphical output some deg left (only PXA LCD). ETEXI +DEF("gfx_passthru", 0, QEMU_OPTION_gfx_passthru, + "-gfx_passthru enable Intel IGD passthrough by XEN\n", + QEMU_ARCH_ALL) +STEXI +@item -gfx_passthru +@findex -gfx_passthru +Enable Intel IGD passthrough by XEN +ETEXI + DEF("vga", HAS_ARG, QEMU_OPTION_vga, "-vga [std|cirrus|vmware|qxl|xenfb|none]\n" " select video card type\n", QEMU_ARCH_ALL)vl.c +8
-1@@ -215,6 +215,9 @@ static bool tcg_allowed = true; bool xen_allowed;uint32_t xen_domid;enum xen_mode xen_mode =XEN_EMULATE ; +#if defined(CONFIG_XEN_PCI_PASSTHROUGH ) +int gfx_passthru =0 ; +#endif static int tcg_tb_size;static int default_serial =1 ;@@ -3775,6 +3778,11 @@ int main(int argc, char **argv, char **envp) }configure_msg (opts);break ; +#if defined(CONFIG_XEN_PCI_PASSTHROUGH ) +case QEMU_OPTION_gfx_passthru: + gfx_passthru =1 ; +break ; +#endif default :os_parse_cmd_args (popt->index, optarg); } --1.7.1
Quoted 4 lines
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Thanks,
Kelly
PATCH 2/5 xen, gfx passthrough: reserve 00:02.0 for INTEL IGD
In reply to Yang ZhangFrom: Yang Zhang <[email protected]>
Some VBIOSs and drivers assume the IGD BDF (bus:device:function) is always 00:02.0, so this patch reserves 00:02.0 for assigned IGD in guest.
The original patch is from Weidong Han <[email protected]>
--- hw/pci/pci.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
hw/pci/pci.c +6 -0
@@ -808,6 +808,12 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,if (devfn <0 ) {for (devfn = bus->devfn_min ; devfn <ARRAY_SIZE (bus->devices); devfn +=PCI_FUNC_MAX ) { +#if defined(CONFIG_XEN_PCI_PASSTHROUGH ) +/* If gfx_passthru is in use, reserve 00:02.* for the IGD */ +if (gfx_passthru && devfn ==0x10 ) { +continue ; + } +#endif if (!bus->devices[devfn]) goto found; }
Signature · 1 line
1.7.1
Re: [Qemu-devel] [PATCH 2/5] xen, gfx passthrough: reserve 00:02.0 for INTEL IGD
Quoted 21 lines · Yang Zhang
From: Yang Zhang <[email protected]>
Some VBIOSs and drivers assume the IGD BDF (bus:device:function) is always 00:02.0, so this patch reserves 00:02.0 for assigned IGD in guest.
The original patch is from Weidong Han <[email protected]>
Signed-off-by Yang Zhang <[email protected]>Cc Weidong Han <[email protected]>--- hw/pci/pci.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)hw/pci/pci.c +0
-0@@ -808,6 +808,12 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,if (devfn <0 ) { for(devfn = bus->devfn_min ; devfn < ARRAY_SIZE(bus->devices);
hw/pci/pci.c static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus, · line 819
Quoted 10 lines
hw/pci/pci.c +6
-0devfn += PCI_FUNC_MAX) { +#if defined(CONFIG_XEN_PCI_PASSTHROUGH ) +/* If gfx_passthru is in use, reserve 00:02.* for the IGD */ +if (gfx_passthru && devfn ==0x10 ) { +continue ; + } +#endif if (!bus->devices[devfn]) goto found; }
This does not look quite right, there is maybe another way to reserve a devfn.
Signature · 1 line
Anthony PERARD
PATCH 3/5 xen, gfx passthrough: create intel isa bridge
In reply to Yang ZhangFrom: Yang Zhang <[email protected]>
ISA bridge is needed since Intel gfx drive will probe it instead of Dev31:Fun0 to make graphics device passthrough work easy for VMM, that only need to expose ISA bridge to let driver know the real hardware underneath.
The original patch is from Allen Kay [[email protected]]
--- hw/xen/xen_pt_graphics.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 71 insertions(+), 0 deletions(-)
hw/xen/xen_pt_graphics.c +71 -0
@@ -162,3 +162,74 @@ out:free (bios);return rc; } + +static uint32_t isa_bridge_read_config (PCIDevice *d,uint32_t addr,int len) +{ +uint32_t v; + + v =pci_default_read_config (d, addr, len); + +return v; +} + +static void isa_bridge_write_config (PCIDevice *d,uint32_t addr,uint32_t v, +int len) +{ +pci_default_write_config (d, addr, v, len); + +return ; +} + +static void isa_bridge_class_init (ObjectClass *klass,void *data) +{ +PCIDeviceClass *k =PCI_DEVICE_CLASS (klass); + + k->config_read = isa_bridge_read_config; + k->config_write = isa_bridge_write_config; + +return ; +}; + +typedef struct { +PCIDevice dev; +}ISABridgeState ; + +static TypeInfo isa_bridge_info = { + .name ="inte-pch-isa-bridge" , + .parent =TYPE_PCI_DEVICE , + .instance_size =sizeof (ISABridgeState), + .class_init = isa_bridge_class_init, +}; + +static void xen_pt_graphics_register_types (void ) +{ +type_register_static (&isa_bridge_info); +} + +type_init (xen_pt_graphics_register_types) + +static int create_pch_isa_bridge(PCIBus *bus, XenHostPCIDevice *hdev) +{ +struct PCIDevice *dev; + +char rid; + + dev =pci_create (bus,PCI_DEVFN (0x1f ,0 ),"inte-pch-isa-bridge" ); +if (!dev) { +XEN_PT_LOG (dev,"fail to create PCH ISA bridge.\n" ); +return -1 ; + } + +qdev_init_nofail (&dev->qdev); + +pci_config_set_vendor_id (dev->config, hdev->vendor_id); +pci_config_set_device_id (dev->config, hdev->device_id); + +xen_host_pci_get_block (hdev,PCI_REVISION_ID , (uint8_t *)&rid,1 ); + +pci_config_set_revision (dev->config, rid); +pci_config_set_class (dev->config,PCI_CLASS_BRIDGE_ISA ); + +XEN_PT_LOG (dev,"Intel PCH ISA bridge is created.\n" ); +return 0 ; +}
Signature · 1 line
1.7.1
PATCH 4/5 xen, gfx passthrough: support Intel IGD passthrough with VT-D
In reply to Yang ZhangFrom: Yang Zhang <[email protected]>
Some registers of Intel IGD are mapped in host bridge, so it needs to passthrough these registers of physical host bridge to guest because emulated host bridge in guest doesn't have these mappings.
The original patch is from Weidong Han < weidong.han @ intel.com >
--- hw/pci-host/piix.c | 15 ++++++ hw/pci/pci.c | 13 +++++ hw/xen/xen_pt.h | 5 ++ hw/xen/xen_pt_graphics.c | 127 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 160 insertions(+), 0 deletions(-)
hw/pci-host/piix.c +15 -0
@@ -34,6 +34,9 @@#include "sysemu/sysemu.h" #include "hw/i386/ioapic.h" #include "qapi/visitor.h" +#if defined(CONFIG_XEN_PCI_PASSTHROUGH ) +#include "hw/xen/xen_pt.h" +#endif /* * I440FX chipset data sheet.
@@ -389,6 +392,18 @@ PCIBus *i440fx_init(PCII440FXState **pi440fx_state,i440fx_update_memory_mappings (f); +#if defined(CONFIG_XEN_PCI_PASSTHROUGH ) +/* +* Some registers of Intel IGD are mapped in host bridge, so it needs to +* passthrough these registers of physical host bridge to guest because +* emulated host bridge in guest doesn't have these mappings. +*/ +if (intel_pch_init (b) ==0 ) { + d->config_read = igd_pci_read; + d->config_write = igd_pci_write; + } +#endif +return b; }
hw/pci/pci.c +13 -0
@@ -36,6 +36,9 @@#include "hw/pci/msix.h" #include "exec/address-spaces.h" #include "hw/hotplug.h" +#if defined(CONFIG_XEN_PCI_PASSTHROUGH ) +#include "hw/xen/xen_pt.h" +#endif //#define DEBUG_PCI #ifdef DEBUG_PCI
@@ -805,6 +808,16 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,PCIConfigWriteFunc *config_write = pc->config_write;AddressSpace *dma_as; +#if defined(CONFIG_XEN_PCI_PASSTHROUGH ) +/* +* Some video bioses and gfx drivers will assume the bdf of IGD is 00:02.0. +* So user need to set it to 00:02.0 in Xen configure file explicitly, +* otherwise IGD will fail to work. +*/ +if (gfx_passthru && devfn ==0x10 ) + igd_passthru =1 ; + else +#endif if (devfn <0 ) {for (devfn = bus->devfn_min ; devfn <ARRAY_SIZE (bus->devices); devfn +=PCI_FUNC_MAX ) {
hw/xen/xen_pt.h +5 -0
@@ -299,8 +299,13 @@ static inline bool xen_pt_has_msix_mapping(XenPCIPassthroughState *s, int bar) }extern int gfx_passthru; +extern int igd_passthru;int register_vga_regions (XenHostPCIDevice *dev);int unregister_vga_regions (XenHostPCIDevice *dev);int setup_vga_pt (XenHostPCIDevice *dev); +int intel_pch_init (PCIBus *bus); +void igd_pci_write (PCIDevice *pci_dev,uint32_t config_addr, +uint32_t val,int len); +uint32_t igd_pci_read (PCIDevice *pci_dev,uint32_t config_addr,int len);#endif /* !XEN_PT_H */
hw/xen/xen_pt_graphics.c +127 -0
136 lines not on this page · raw message
Signature · 1 line
1.7.1
Re: [Qemu-devel] [PATCH 4/5] xen, gfx passthrough: support Intel IGD passthrough with VT-D
CC'ing Michael.
Quoted 36 lines · Yang Zhang
From: Yang Zhang <[email protected]>
Some registers of Intel IGD are mapped in host bridge, so it needs to passthrough these registers of physical host bridge to guest because emulated host bridge in guest doesn't have these mappings.
The original patch is from Weidong Han < weidong.han @ intel.com >
Signed-off-by Yang Zhang <[email protected]>Cc Weidong Han <[email protected]>--- hw/pci-host/piix.c | 15 ++++++ hw/pci/pci.c | 13 +++++ hw/xen/xen_pt.h | 5 ++ hw/xen/xen_pt_graphics.c | 127 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 160 insertions(+), 0 deletions(-)hw/pci-host/piix.c +4
-0@@ -34,6 +34,9 @@#include "sysemu/sysemu.h" #include "hw/i386/ioapic.h" #include "qapi/visitor.h" +#if defined(CONFIG_XEN_PCI_PASSTHROUGH ) +#include "hw/xen/xen_pt.h" +#endif /* * I440FX chipset data sheet. @@ -389,6 +392,18 @@ PCIBus *i440fx_init(PCII440FXState **pi440fx_state,i440fx_update_memory_mappings (f); +#if defined(CONFIG_XEN_PCI_PASSTHROUGH )
hw/pci-host/piix.c PCIBus *i440fx_init(PCII440FXState **pi440fx_state, · line 405
Quoted 10 lines
hw/pci-host/piix.c +10
-0+/* +* Some registers of Intel IGD are mapped in host bridge, so it needs to +* passthrough these registers of physical host bridge to guest because +* emulated host bridge in guest doesn't have these mappings. +*/ +if (intel_pch_init (b) ==0 ) { + d->config_read = igd_pci_read; + d->config_write = igd_pci_write; + } +#endif
I can't see the other QEMU maintainers being happy with these changes. Michael, do you have a suggestion on how to do this in a better way?
Quoted 24 lines
hw/pci-host/piix.c +0
-0return b; }hw/pci/pci.c +6
-0@@ -36,6 +36,9 @@#include "hw/pci/msix.h" #include "exec/address-spaces.h" #include "hw/hotplug.h" +#if defined(CONFIG_XEN_PCI_PASSTHROUGH ) +#include "hw/xen/xen_pt.h" +#endif //#define DEBUG_PCI #ifdef DEBUG_PCI @@ -805,6 +808,16 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,PCIConfigWriteFunc *config_write = pc->config_write;AddressSpace *dma_as; +#if defined(CONFIG_XEN_PCI_PASSTHROUGH ) +/* +* Some video bioses and gfx drivers will assume the bdf of IGD is 00:02.0.
hw/pci/pci.c static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus, · line 823
Quoted 10 lines
hw/pci/pci.c +7
-0+* So user need to set it to 00:02.0 in Xen configure file explicitly, +* otherwise IGD will fail to work. +*/ +if (gfx_passthru && devfn ==0x10 ) + igd_passthru =1 ; + else +#endif if (devfn <0 ) {for (devfn = bus->devfn_min ; devfn <ARRAY_SIZE (bus->devices); devfn +=PCI_FUNC_MAX ) {
Same here
Quoted 149 lines
hw/xen/xen_pt.h +5
-0@@ -299,8 +299,13 @@ static inline bool xen_pt_has_msix_mapping(XenPCIPassthroughState *s, int bar) }extern int gfx_passthru; +extern int igd_passthru;int register_vga_regions (XenHostPCIDevice *dev);int unregister_vga_regions (XenHostPCIDevice *dev);int setup_vga_pt (XenHostPCIDevice *dev); +int intel_pch_init (PCIBus *bus); +void igd_pci_write (PCIDevice *pci_dev,uint32_t config_addr, +uint32_t val,int len); +uint32_t igd_pci_read (PCIDevice *pci_dev,uint32_t config_addr,int len);#endif /* !XEN_PT_H */ hw/xen/xen_pt_graphics.c +116
-0@@ -5,6 +5,8 @@#include "xen-host-pci-device.h" #include "hw/xen/xen_backend.h" +int igd_passthru; +/* * register VGA resources for the domain with assigned gfx */ @@ -233,3 +235,128 @@ static int create_pch_isa_bridge(PCIBus *bus, XenHostPCIDevice *hdev)XEN_PT_LOG (dev,"Intel PCH ISA bridge is created.\n" );return 0 ; } + +int intel_pch_init (PCIBus *bus) +{ +XenHostPCIDevice hdev; +int r =0 ; + +if (!gfx_passthru) { +return -1 ; + } + + r =xen_host_pci_device_get (&hdev,0 ,0 ,0x1f ,0 ); +if (r) { +XEN_PT_ERR (NULL ,"Fail to find intel PCH in host\n" ); + goto err; + } + +if (hdev.vendor_id ==PCI_VENDOR_ID_INTEL ) { + r =create_pch_isa_bridge (bus, &hdev); +if (r) { +XEN_PT_ERR (NULL ,"Fail to create PCH ISA bridge.\n" ); + goto err; + } + } + +xen_host_pci_device_put (&hdev); + +return r; + +err: +return r; +} + +void igd_pci_write (PCIDevice *pci_dev,uint32_t config_addr, +uint32_t val,int len) +{ +XenHostPCIDevice dev; +int r; + +assert (pci_dev->devfn ==0x00 ); + +if (!igd_passthru) { + goto write_default; + } + +switch (config_addr) { +case 0x58 :/* PAVPC Offset */ +break ; +default : + goto write_default; + } + +/* Host write */ + r =xen_host_pci_device_get (&dev,0 ,0 ,0 ,0 ); +if (r) { +XEN_PT_ERR (pci_dev,"Can't get pci_dev_host_bridge\n" ); +abort (); + } + + r =xen_host_pci_set_block (&dev, config_addr, (uint8_t *)&val, len); +if (r) { +XEN_PT_ERR (pci_dev,"Can't get pci_dev_host_bridge\n" ); +abort (); + } + +xen_host_pci_device_put (&dev); + +return ; + +write_default: +pci_default_write_config (pci_dev, config_addr, val, len); +} + +uint32_t igd_pci_read (PCIDevice *pci_dev,uint32_t config_addr,int len) +{ +XenHostPCIDevice dev; +uint32_t val; +int r; + +assert (pci_dev->devfn ==0x00 ); + +if (!igd_passthru) { + goto read_default; + } + +switch (config_addr) { +case 0x00 :/* vendor id */ +case 0x02 :/* device id */ +case 0x08 :/* revision id */ +case 0x2c :/* sybsystem vendor id */ +case 0x2e :/* sybsystem id */ +case 0x50 :/* SNB: processor graphics control register */ +case 0x52 :/* processor graphics control register */ +case 0xa0 :/* top of memory */ +case 0xb0 :/* ILK: BSM: should read from dev 2 offset 0x5c */ +case 0x58 :/* SNB: PAVPC Offset */ +case 0xa4 :/* SNB: graphics base of stolen memory */ +case 0xa8 :/* SNB: base of GTT stolen memory */ +break ; +default : + goto read_default; + } + +/* Host read */ + r =xen_host_pci_device_get (&dev,0 ,0 ,0 ,0 ); +if (r) { + goto err_out; + } + + r =xen_host_pci_get_block (&dev, config_addr, (uint8_t *)&val, len); +if (r) { + goto err_out; + } + +xen_host_pci_device_put (&dev);
hw/xen/xen_pt_graphics.c static int create_pch_isa_bridge(PCIBus *bus, XenHostPCIDevice *hdev) · line 361
Quoted 10 lines
hw/xen/xen_pt_graphics.c +10
-0+ +return val; + +read_default: +return pci_default_read_config (pci_dev, config_addr, len); + +err_out: +XEN_PT_ERR (pci_dev,"Can't get pci_dev_host_bridge\n" ); +return -1 ; +}
The Xen specific part is OK.
Re: [Qemu-devel] [PATCH 4/5] xen, gfx passthrough: support Intel IGD passthrough with VT-D
Quoted 38 lines · Stefano Stabellini
CC'ing Michael.
Quoted 35 lines · Yang Zhang
From: Yang Zhang <[email protected]>
Some registers of Intel IGD are mapped in host bridge, so it needs to passthrough these registers of physical host bridge to guest because emulated host bridge in guest doesn't have these mappings.
The original patch is from Weidong Han < weidong.han @ intel.com >
Signed-off-by Yang Zhang <[email protected]>Cc Weidong Han <[email protected]>--- hw/pci-host/piix.c | 15 ++++++ hw/pci/pci.c | 13 +++++ hw/xen/xen_pt.h | 5 ++ hw/xen/xen_pt_graphics.c | 127 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 160 insertions(+), 0 deletions(-)hw/pci-host/piix.c +3
-0@@ -34,6 +34,9 @@#include "sysemu/sysemu.h" #include "hw/i386/ioapic.h" #include "qapi/visitor.h" +#if defined(CONFIG_XEN_PCI_PASSTHROUGH ) +#include "hw/xen/xen_pt.h" +#endif /* * I440FX chipset data sheet. @@ -389,6 +392,18 @@ PCIBus *i440fx_init(PCII440FXState **pi440fx_state,i440fx_update_memory_mappings (f);
Quoted 14 lines
hw/pci-host/piix.c PCIBus *i440fx_init(PCII440FXState **pi440fx_state, · line 405
Quoted 11 lines
hw/pci-host/piix.c +11
-0+#if defined(CONFIG_XEN_PCI_PASSTHROUGH ) +/* +* Some registers of Intel IGD are mapped in host bridge, so it needs to +* passthrough these registers of physical host bridge to guest because +* emulated host bridge in guest doesn't have these mappings. +*/ +if (intel_pch_init (b) ==0 ) { + d->config_read = igd_pci_read; + d->config_write = igd_pci_write; + } +#endif I can't see the other QEMU maintainers being happy with these changes. Michael, do you have a suggestion on how to do this in a better way?
Implement your own pci host bridge, inherit the standard one.
Quoted 22 lines
Quoted 22 lines
hw/pci-host/piix.c +0
-0return b; }hw/pci/pci.c +3
-0@@ -36,6 +36,9 @@#include "hw/pci/msix.h" #include "exec/address-spaces.h" #include "hw/hotplug.h" +#if defined(CONFIG_XEN_PCI_PASSTHROUGH ) +#include "hw/xen/xen_pt.h" +#endif //#define DEBUG_PCI #ifdef DEBUG_PCI @@ -805,6 +808,16 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,PCIConfigWriteFunc *config_write = pc->config_write;AddressSpace *dma_as;
Quoted 16 lines
hw/pci/pci.c static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus, · line 823
Quoted 13 lines
hw/pci/pci.c +10
-0+#if defined(CONFIG_XEN_PCI_PASSTHROUGH ) +/* +* Some video bioses and gfx drivers will assume the bdf of IGD is 00:02.0. +* So user need to set it to 00:02.0 in Xen configure file explicitly, +* otherwise IGD will fail to work. +*/ +if (gfx_passthru && devfn ==0x10 ) + igd_passthru =1 ; + else +#endif if (devfn <0 ) {for (devfn = bus->devfn_min ; devfn <ARRAY_SIZE (bus->devices); devfn +=PCI_FUNC_MAX ) {Same here
So just set the address property to 00:02.0.
Quoted 161 lines
Quoted 149 lines
hw/xen/xen_pt.h +5
-0@@ -299,8 +299,13 @@ static inline bool xen_pt_has_msix_mapping(XenPCIPassthroughState *s, int bar) }extern int gfx_passthru; +extern int igd_passthru;int register_vga_regions (XenHostPCIDevice *dev);int unregister_vga_regions (XenHostPCIDevice *dev);int setup_vga_pt (XenHostPCIDevice *dev); +int intel_pch_init (PCIBus *bus); +void igd_pci_write (PCIDevice *pci_dev,uint32_t config_addr, +uint32_t val,int len); +uint32_t igd_pci_read (PCIDevice *pci_dev,uint32_t config_addr,int len);#endif /* !XEN_PT_H */ hw/xen/xen_pt_graphics.c +116
-0@@ -5,6 +5,8 @@#include "xen-host-pci-device.h" #include "hw/xen/xen_backend.h" +int igd_passthru; +/* * register VGA resources for the domain with assigned gfx */ @@ -233,3 +235,128 @@ static int create_pch_isa_bridge(PCIBus *bus, XenHostPCIDevice *hdev)XEN_PT_LOG (dev,"Intel PCH ISA bridge is created.\n" );return 0 ; } + +int intel_pch_init (PCIBus *bus) +{ +XenHostPCIDevice hdev; +int r =0 ; + +if (!gfx_passthru) { +return -1 ; + } + + r =xen_host_pci_device_get (&hdev,0 ,0 ,0x1f ,0 ); +if (r) { +XEN_PT_ERR (NULL ,"Fail to find intel PCH in host\n" ); + goto err; + } + +if (hdev.vendor_id ==PCI_VENDOR_ID_INTEL ) { + r =create_pch_isa_bridge (bus, &hdev); +if (r) { +XEN_PT_ERR (NULL ,"Fail to create PCH ISA bridge.\n" ); + goto err; + } + } + +xen_host_pci_device_put (&hdev); + +return r; + +err: +return r; +} + +void igd_pci_write (PCIDevice *pci_dev,uint32_t config_addr, +uint32_t val,int len) +{ +XenHostPCIDevice dev; +int r; + +assert (pci_dev->devfn ==0x00 ); + +if (!igd_passthru) { + goto write_default; + } + +switch (config_addr) { +case 0x58 :/* PAVPC Offset */ +break ; +default : + goto write_default; + } + +/* Host write */ + r =xen_host_pci_device_get (&dev,0 ,0 ,0 ,0 ); +if (r) { +XEN_PT_ERR (pci_dev,"Can't get pci_dev_host_bridge\n" ); +abort (); + } + + r =xen_host_pci_set_block (&dev, config_addr, (uint8_t *)&val, len); +if (r) { +XEN_PT_ERR (pci_dev,"Can't get pci_dev_host_bridge\n" ); +abort (); + } + +xen_host_pci_device_put (&dev); + +return ; + +write_default: +pci_default_write_config (pci_dev, config_addr, val, len); +} + +uint32_t igd_pci_read (PCIDevice *pci_dev,uint32_t config_addr,int len) +{ +XenHostPCIDevice dev; +uint32_t val; +int r; + +assert (pci_dev->devfn ==0x00 ); + +if (!igd_passthru) { + goto read_default; + } + +switch (config_addr) { +case 0x00 :/* vendor id */ +case 0x02 :/* device id */ +case 0x08 :/* revision id */ +case 0x2c :/* sybsystem vendor id */ +case 0x2e :/* sybsystem id */ +case 0x50 :/* SNB: processor graphics control register */ +case 0x52 :/* processor graphics control register */ +case 0xa0 :/* top of memory */ +case 0xb0 :/* ILK: BSM: should read from dev 2 offset 0x5c */ +case 0x58 :/* SNB: PAVPC Offset */ +case 0xa4 :/* SNB: graphics base of stolen memory */ +case 0xa8 :/* SNB: base of GTT stolen memory */ +break ; +default : + goto read_default; + } + +/* Host read */ + r =xen_host_pci_device_get (&dev,0 ,0 ,0 ,0 ); +if (r) { + goto err_out; + } + + r =xen_host_pci_get_block (&dev, config_addr, (uint8_t *)&val, len); +if (r) { + goto err_out; + } + +xen_host_pci_device_put (&dev);hw/xen/xen_pt_graphics.c static int create_pch_isa_bridge(PCIBus *bus, XenHostPCIDevice *hdev) · line 361
Quoted 10 lines
hw/xen/xen_pt_graphics.c +10
-0+ +return val; + +read_default: +return pci_default_read_config (pci_dev, config_addr, len); + +err_out: +XEN_PT_ERR (pci_dev,"Can't get pci_dev_host_bridge\n" ); +return -1 ; +}The Xen specific part is OK.
PATCH 5/5 xen, gfx passthrough: add opregion mapping
In reply to Yang ZhangFrom: Yang Zhang <[email protected]>
The OpRegion shouldn't be mapped 1:1 because the address in the host can't be used in the guest directly.
This patch traps read and write access to the opregion of the Intel GPU config space (offset 0xfc).
The original patch is from Jean Guyader <[email protected]>
--- hw/xen/xen_pt.h | 4 ++- hw/xen/xen_pt_config_init.c | 45 ++++++++++++++++++++++++++++++++++++++++++- hw/xen/xen_pt_graphics.c | 45 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 92 insertions(+), 2 deletions(-)
hw/xen/xen_pt.h +3 -1
@@ -63,7 +63,7 @@ typedef int (*xen_pt_conf_byte_read)#define XEN_PT_BAR_UNMAPPED (-1)#define PCI_CAP_MAX 48 - +#define PCI_INTEL_OPREGION 0xfc typedef enum { XEN_PT_GRP_TYPE_HARDWIRED = 0, /* 0 Hardwired reg group */
@@ -307,5 +307,7 @@ int intel_pch_init(PCIBus *bus);void igd_pci_write (PCIDevice *pci_dev,uint32_t config_addr,uint32_t val,int len);uint32_t igd_pci_read (PCIDevice *pci_dev,uint32_t config_addr,int len); +uint32_t igd_read_opregion (XenPCIPassthroughState *s); +void igd_write_opregion (XenPCIPassthroughState *s,uint32_t val);#endif /* !XEN_PT_H */
hw/xen/xen_pt_config_init.c +44 -1
75 lines not on this page · raw message
hw/xen/xen_pt_graphics.c +45 -0
54 lines not on this page · raw message
Signature · 1 line
1.7.1
Zhang, Yang Z wrote on 2014-02-21:
Quoted 26 lines
From: Yang Zhang <[email protected]>
The following patches are ported from Xen Qemu-traditional branch which are adding Intel IGD passthrough supporting to Qemu upstream.
To pass through IGD to guest, user need to add following lines in Xen config file: gfx_passthru=1 pci=['00:02.0@2']
Besides, since Xen + Qemu upstream is requiring seabios, user also need to recompile seabios with
CONFIG_OPTIONROMS_DEPLOYED=yto allow IGD pass through
successfully:
1. changeCONFIG_OPTIONROMS_DEPLOYED=yin file:
xen/tools/firmware/seabios-config 2. recompile the toolsI have successfully boot Win 7 and RHEL6u4 guests with IGD assigned in Haswell desktop with Latest Xen + Qemu upstream.
Yang Zhang (5):
xen, gfx passthrough: basic graphics passthrough support xen, gfx passthrough: reserve 00:02.0 for INTEL IGD xen, gfx passthrough: create intel isa bridge
xen, gfx passthrough: support Intel IGD passthrough with VT-D xen, gfx passthrough: add opregion mapping
configure | 2 +-hw/pci-host/piix.c|
15 ++hw/pci/pci.c| 19 ++ hw/xen/Makefile.objs
Quoted 8 lines
| 2 +- hw/xen/xen-host-pci-device.c | 5 + hw/xen/xen-host-pci-device.h | 1 + hw/xen/xen_pt.c | 10 + hw/xen/xen_pt.h | 13 ++- hw/xen/xen_pt_config_init.c | 45 +++++- hw/xen/xen_pt_graphics.c | 407 ++++++++++++++++++++++++++++++++++++++++++ qemu-options.hx | 9 + vl.c | 8 + 12 files changed, 532 insertions(+), 4 deletions(-) create mode100644
hw/xen/xen_pt_graphics.c
Ping.
Best regards,
Yang
Quoted 36 lines · Yang Z
Zhang, Yang Z wrote on 2014-02-21:
Quoted 26 lines
From: Yang Zhang <[email protected]>
The following patches are ported from Xen Qemu-traditional branch which are adding Intel IGD passthrough supporting to Qemu upstream.
To pass through IGD to guest, user need to add following lines in Xen config file: gfx_passthru=1 pci=['00:02.0@2']
Besides, since Xen + Qemu upstream is requiring seabios, user also need to recompile seabios with
CONFIG_OPTIONROMS_DEPLOYED=yto allow IGD pass through
successfully:
1. changeCONFIG_OPTIONROMS_DEPLOYED=yin file:
xen/tools/firmware/seabios-config 2. recompile the toolsI have successfully boot Win 7 and RHEL6u4 guests with IGD assigned in Haswell desktop with Latest Xen + Qemu upstream.
Yang Zhang (5):
xen, gfx passthrough: basic graphics passthrough support xen, gfx passthrough: reserve 00:02.0 for INTEL IGD xen, gfx passthrough: create intel isa bridge
xen, gfx passthrough: support Intel IGD passthrough with VT-D xen, gfx passthrough: add opregion mapping
configure | 2 +-hw/pci-host/piix.c|
15 ++hw/pci/pci.c| 19 ++ hw/xen/Makefile.objsQuoted 8 lines
| 2 +- hw/xen/xen-host-pci-device.c | 5 + hw/xen/xen-host-pci-device.h | 1 + hw/xen/xen_pt.c | 10 + hw/xen/xen_pt.h | 13 ++- hw/xen/xen_pt_config_init.c | 45 +++++- hw/xen/xen_pt_graphics.c | 407 ++++++++++++++++++++++++++++++++++++++++++ qemu-options.hx | 9 + vl.c | 8 + 12 files changed, 532 insertions(+), 4 deletions(-) create mode100644
hw/xen/xen_pt_graphics.c
Quoted 1 line
Ping.
Sorry but with the Xen 4.4 release and travels I won't be able to review it for a while, but I'll get around to it at some point not too far.
Quoted 5 lines · Yang Zhang
From: Yang Zhang <[email protected]>
The following patches are ported from Xen Qemu-traditional branch which are adding Intel IGD passthrough supporting to Qemu upstream.
Quoted 8 lines
To pass through IGD to guest, user need to add following lines in Xen config file:
gfx_passthru=1
pci=['00:02.0@2']Besides, since Xen + Qemu upstream is requiring seabios, user also need to recompile seabios with
CONFIG_OPTIONROMS_DEPLOYED=yto allow IGD pass through successfully:
I'm not familiar with the Xen parts of your patch series. However, I don't think one should be compiling SeaBIOS with CONFIG_OPTIONROMS_DEPLOYED enabled. That option was for very old versions of Bochs and QEMU that did not support fetching of optionroms directly from PCI config space nor from fw_cfg.
That compile time option is no longer well supported and it may be removed in the future. I suggest looking at getting one of the other mechanisms working instead of using CONFIG_OPTIONROMS_DEPLOYED.
-Kevin
Quoted 11 lines · Kevin O'Connor
Quoted 10 lines · Yang Zhang
From: Yang Zhang <[email protected]>
The following patches are ported from Xen Qemu-traditional branch which are adding Intel IGD passthrough supporting to Qemu upstream.
To pass through IGD to guest, user need to add following lines in Xen config file:
gfx_passthru=1
pci=['00:02.0@2']
Quoted 7 lines
Quoted 3 lines
Besides, since Xen + Qemu upstream is requiring seabios, user also need to recompile seabios with
CONFIG_OPTIONROMS_DEPLOYED=yto allow IGD pass through successfully:I'm not familiar with the Xen parts of your patch series. However, I don't think one should be compiling SeaBIOS with
CONFIG_OPTIONROMS_DEPLOYEDenabled.
I agree, thanks for spotting this. I would nack any patch which tried to enable this option in the Xen build of SeaBIOS.
Quoted 7 lines
That option was for very old
versions of Bochs and QEMU that did not support fetching of optionroms directly from PCI config space nor fromfw_cfg.That compile time option is no longer well supported and it may be removed in the future. I suggest looking at getting one of the other mechanisms working instead of using
CONFIG_OPTIONROMS_DEPLOYED.
AFAIK the usual mechanisms already work for SeaBIOS under Xen, e.g. for the video BIOS of the emulated VGA it Just Works. I've no idea what makes Intel IGD passthrough special.
Ian.