Saturday, August 29, 2009

Windows XP Home DomU Test Results after applying Intel's VGA Passthrough Patchset to Xen 3.5-unstable

Dear All,

I have applied the following patches to xen 3.5-unstable

1) intel-gfx-passthru-patch01.patch
2) intel-gfx-passthru-patch02.patch
3) intel-gfx-passthru-patch03.patch
4) enming-patch04.patch

and compiled xen 3.5-unstable successfully (both hypervisor and tools).

i rebooted into this newly compiled Xen hypervisor which supports loading vga bios from firmware file of nVidia Geforce 8400 GS PCI Express x16.

After dom0 has booted up, I executed the following script to hide nVidia Geforce 8400 GS from dom0.

[enming@fedora11-x86-64-host scripts]$ cat bind-devices-pci-stub.sh
#!/bin/sh
echo "10de 06e4" > /sys/bus/pci/drivers/pci-stub/new_id
echo "0000:01:00.0" > /sys/bus/pci/devices/0000:01:00.0/driver/unbind
echo "0000:01:00.0" > /sys/bus/pci/drivers/pci-stub/bind

I also assigned the nVidia Geforce 8400 GS to my Windows XP Home HVM domU.

pci = [ '01:00.0' ]

I also specified gfx_passthru=2.

Do note that I booted up with onboard Intel GMA4500 as the primary video adapter. Hence dom 0 has onboard graphics and Windows XP HVM domU has nvidia graphics.

Then I started Windows XP Home HVM DomU.

Very soon, my Dom 0's display was garbaged and X server on Dom 0 totally froze and became unresponsive. I cannot switch to any ttys.

However, I was still able to vnc into my Windows XP Home HVM Dom U. I had earlier installed a VNC server into my Windows XP guest. After remoting in to my Windows XP DomU through vnc, I found that NVIDIA Geforce 8400 GS cannot be initialized and no resources are available for this graphics card.






It shows that the emulated virtual VGA card is now disabled (not appearing in Windows XP Home DomU's device manager) and only the nVidia Geforce 8400 GS VGA BIOS gets loaded.

Intel's VGA Passthrough Patchset to xen 3.5-unstable
====================================================

1) intel-gfx-passthru-patch01.patch

diff -r 5d7e7a250267 tools/firmware/hvmloader/config.h
--- a/tools/firmware/hvmloader/config.h Wed Aug 26 18:28:44 2009 +0800
+++ b/tools/firmware/hvmloader/config.h Thu Aug 27 16:54:24 2009 +0800
@@ -15,7 +15,7 @@
#define PCI_ISA_IRQ_MASK 0x0c20U /* ISA IRQs 5,10,11 are PCI connected */

/* MMIO hole: Hardcoded defaults, which can be dynamically expanded. */
-#define PCI_MEM_START 0xf0000000
+#define PCI_MEM_START 0xe0000000
#define PCI_MEM_END 0xfc000000
extern unsigned long pci_mem_start, pci_mem_end;

diff -r 5d7e7a250267 tools/firmware/hvmloader/hvmloader.c
--- a/tools/firmware/hvmloader/hvmloader.c Wed Aug 26 18:28:44 2009 +0800
+++ b/tools/firmware/hvmloader/hvmloader.c Fri Aug 28 14:41:22 2009 +0800
@@ -113,7 +113,7 @@ unsigned long pci_mem_start = PCI_MEM_ST
unsigned long pci_mem_start = PCI_MEM_START;
unsigned long pci_mem_end = PCI_MEM_END;

-static enum { VGA_none, VGA_std, VGA_cirrus } virtual_vga = VGA_none;
+static enum { VGA_none, VGA_std, VGA_cirrus, VGA_pt } virtual_vga = VGA_none;

static void init_hypercalls(void)
{
@@ -212,8 +212,10 @@ static void pci_setup(void)
case 0x0300:
if ( (vendor_id == 0x1234) && (device_id == 0x1111) )
virtual_vga = VGA_std;
- if ( (vendor_id == 0x1013) && (device_id == 0xb8) )
+ else if ( (vendor_id == 0x1013) && (device_id == 0xb8) )
virtual_vga = VGA_cirrus;
+ else
+ virtual_vga = VGA_pt;
break;
case 0x0680:
/* PIIX4 ACPI PM. Special device with special PCI config space. */
@@ -684,6 +686,11 @@ int main(void)
memcpy((void *)VGABIOS_PHYSICAL_ADDRESS,
vgabios_stdvga, sizeof(vgabios_stdvga));
vgabios_sz = round_option_rom(sizeof(vgabios_stdvga));
+ break;
+ case VGA_pt:
+ printf("Loading VGABIOS of passthroughed gfx ...\n");
+ vgabios_sz =
+ round_option_rom((*(uint8_t *)(VGABIOS_PHYSICAL_ADDRESS+2)) * 512);
break;
default:
printf("No emulated VGA adaptor ...\n");
diff -r 5d7e7a250267 tools/libxc/ia64/xc_ia64_hvm_build.c
--- a/tools/libxc/ia64/xc_ia64_hvm_build.c Wed Aug 26 18:28:44 2009 +0800
+++ b/tools/libxc/ia64/xc_ia64_hvm_build.c Thu Aug 27 16:54:24 2009 +0800
@@ -1109,7 +1109,9 @@ int xc_hvm_build_target_mem(int xc_handl
uint32_t domid,
int memsize,
int target,
- const char *image_name)
+ const char *image_name,
+ int gfx_passthru)
+
{
/* XXX:PoD isn't supported yet */
return xc_hvm_build(xc_handle, domid, target, image_name);
diff -r 5d7e7a250267 tools/libxc/xc_hvm_build.c
--- a/tools/libxc/xc_hvm_build.c Wed Aug 26 18:28:44 2009 +0800
+++ b/tools/libxc/xc_hvm_build.c Thu Aug 27 16:54:24 2009 +0800
@@ -64,6 +64,67 @@ static void build_hvm_info(void *hvm_inf
for ( i = 0, sum = 0; i < hvm_info->length; i++ )
sum += ((uint8_t *)hvm_info)[i];
hvm_info->checksum = -sum;
+}
+
+static int init_vgabios(int xc_handle, uint32_t dom,
+ unsigned char *buffer, uint32_t bios_size)
+{
+ char *va_bios = NULL;
+ uint32_t va_size = 0;
+
+ va_size = bios_size + bios_size % XC_PAGE_SIZE;
+ va_bios = xc_map_foreign_range(xc_handle, dom, va_size,
+ PROT_READ | PROT_WRITE, 0xC0);
+ if ( !va_bios )
+ {
+ IPRINTF("Unable to map vga bios!\n");
+ return -1;
+ }
+
+ if ( buffer != NULL )
+ memcpy(va_bios, buffer, bios_size);
+ else
+ memset(va_bios, 0, bios_size);
+
+ munmap(va_bios, va_size);
+ return 0;
+}
+
+static int setup_vga_pt(int xc_handle, uint32_t dom)
+{
+ int rc = 0;
+ unsigned char *bios = NULL;
+ int bios_size = 0;
+ char *c = NULL;
+ char checksum = 0;
+
+ /* Allocated 64K for the vga bios */
+ if (!(bios = malloc(64 * 1024)))
+ return -1;
+
+#ifdef __linux__
+ bios_size = xc_get_vgabios(bios, 64 * 1024);
+#else
+ bios_size = 0;
+#endif /* __linux__ */
+
+ if (bios_size == 0)
+ {
+ IPRINTF("vga bios size is 0!\n");
+ rc = -1;
+ goto error;
+ }
+
+ /* Adjust the bios checksum */
+ for ( c = (char*)bios; c < ((char*)bios + bios_size); c++ )
+ checksum += *c;
+ if (checksum)
+ bios[bios_size - 1] -= checksum;
+
+ init_vgabios(xc_handle, dom, bios, bios_size);
+error:
+ free(bios);
+ return rc;
}

static int loadelfimage(
@@ -381,7 +442,8 @@ int xc_hvm_build_target_mem(int xc_handl
uint32_t domid,
int memsize,
int target,
- const char *image_name)
+ const char *image_name,
+ int gfx_passthru)
{
char *image;
int sts;
@@ -392,6 +454,11 @@ int xc_hvm_build_target_mem(int xc_handl
return -1;

sts = xc_hvm_build_internal(xc_handle, domid, memsize, target, image, image_size);
+
+ if ( gfx_passthru )
+ sts |= setup_vga_pt(xc_handle, domid);
+ else
+ sts |= init_vgabios(xc_handle, domid, NULL, 0x800);

free(image);

diff -r 5d7e7a250267 tools/libxc/xc_linux.c
--- a/tools/libxc/xc_linux.c Wed Aug 26 18:28:44 2009 +0800
+++ b/tools/libxc/xc_linux.c Thu Aug 27 16:54:24 2009 +0800
@@ -638,6 +638,56 @@ err:
return gnt;
}

+int xc_get_vgabios(unsigned char *buf,
+ int len)
+{
+ int mem;
+ uint32_t start, size = 0;
+ uint16_t magic = 0;
+
+ start = 0xC0000;
+ if (len < size)
+ return 0;
+ if ((mem = open("/dev/mem", O_RDONLY)) < 0)
+ return 0;
+
+ /*
+ ** Check if it a real bios extension.
+ ** The magic number is 0xAA55.
+ */
+ if (start != lseek(mem, start, SEEK_SET))
+ goto out;
+ if (read(mem, &magic, 2) != 2)
+ goto out;
+ if (magic != 0xAA55)
+ goto out;
+ /* Find the size of the rom extension */
+ if (start != lseek(mem, start, SEEK_SET))
+ goto out;
+ if (lseek(mem, 2, SEEK_CUR) != (start + 2))
+ goto out;
+ if (read(mem, &size, 1) != 1)
+ goto out;
+ /* This size is in 512K */
+ size *= 512;
+
+ /*
+ ** Set the file to the begining of the rombios,
+ ** to start the copy.
+ */
+ if (start != lseek(mem, start, SEEK_SET))
+ {
+ size = 0;
+ goto out;
+ }
+ if (size != read(mem, buf, size))
+ size = 0;
+
+out:
+ close(mem);
+ return size;
+}
+
/*
* Local variables:
* mode: C
diff -r 5d7e7a250267 tools/libxc/xenctrl.h
--- a/tools/libxc/xenctrl.h Wed Aug 26 18:28:44 2009 +0800
+++ b/tools/libxc/xenctrl.h Thu Aug 27 16:54:24 2009 +0800
@@ -1285,4 +1285,6 @@ int xc_tmem_restore(int xc_handle, int d
int xc_tmem_restore(int xc_handle, int dom, int fd);
int xc_tmem_restore_extra(int xc_handle, int dom, int fd);

+int xc_get_vgabios(unsigned char *bios, int len);
+
#endif /* XENCTRL_H */
diff -r 5d7e7a250267 tools/libxc/xenguest.h
--- a/tools/libxc/xenguest.h Wed Aug 26 18:28:44 2009 +0800
+++ b/tools/libxc/xenguest.h Thu Aug 27 16:54:24 2009 +0800
@@ -135,7 +135,8 @@ int xc_hvm_build_target_mem(int xc_handl
uint32_t domid,
int memsize,
int target,
- const char *image_name);
+ const char *image_name,
+ int gfx_passthru);

int xc_hvm_build_mem(int xc_handle,
uint32_t domid,
diff -r 5d7e7a250267 tools/python/xen/lowlevel/xc/xc.c
--- a/tools/python/xen/lowlevel/xc/xc.c Wed Aug 26 18:28:44 2009 +0800
+++ b/tools/python/xen/lowlevel/xc/xc.c Thu Aug 27 16:54:24 2009 +0800
@@ -894,21 +894,21 @@ static PyObject *pyxc_hvm_build(XcObject
int i;
#endif
char *image;
- int memsize, target=-1, vcpus = 1, acpi = 0, apic = 1;
+ int memsize, target=-1, vcpus = 1, acpi = 0, apic = 1, gfx_passthru = 0;

static char *kwd_list[] = { "domid",
"memsize", "image", "target", "vcpus", "acpi",
- "apic", NULL };
- if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iis|iiii", kwd_list,
+ "apic", "gfx_passthru", NULL };
+ if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iis|iiiii", kwd_list,
&dom, &memsize, &image, &target, &vcpus,
- &acpi, &apic) )
+ &acpi, &apic, &gfx_passthru) )
return NULL;

if ( target == -1 )
target = memsize;

if ( xc_hvm_build_target_mem(self->xc_handle, dom, memsize,
- target, image) != 0 )
+ target, image, gfx_passthru) != 0 )
return pyxc_error_to_exception();

#if !defined(__ia64__)
diff -r 5d7e7a250267 tools/python/xen/xend/XendConfig.py
--- a/tools/python/xen/xend/XendConfig.py Wed Aug 26 18:28:44 2009 +0800
+++ b/tools/python/xen/xend/XendConfig.py Thu Aug 27 16:54:24 2009 +0800
@@ -175,6 +175,7 @@ XENAPI_PLATFORM_CFG_TYPES = {
'pci_msitranslate': int,
'pci_power_mgmt': int,
'xen_platform_pci': int,
+ "gfx_passthru": int,
}

# Xen API console 'other_config' keys.
diff -r 5d7e7a250267 tools/python/xen/xend/image.py
--- a/tools/python/xen/xend/image.py Wed Aug 26 18:28:44 2009 +0800
+++ b/tools/python/xen/xend/image.py Thu Aug 27 16:54:24 2009 +0800
@@ -786,7 +786,7 @@ class HVMImageHandler(ImageHandler):
self.apic = int(vmConfig['platform'].get('apic', 0))
self.acpi = int(vmConfig['platform'].get('acpi', 0))
self.guest_os_type = vmConfig['platform'].get('guest_os_type')
-
+ self.gfx_passthru = int(vmConfig['platform'].get('gfx_passthru', 0))

# Return a list of cmd line args to the device models based on the
# xm config file
@@ -807,7 +807,7 @@ class HVMImageHandler(ImageHandler):

dmargs = [ 'boot', 'fda', 'fdb', 'soundhw',
'localtime', 'serial', 'stdvga', 'isa',
- 'acpi', 'usb', 'usbdevice' ]
+ 'acpi', 'usb', 'usbdevice', 'gfx_passthru' ]

for a in dmargs:
v = vmConfig['platform'].get(a)
@@ -901,6 +901,7 @@ class HVMImageHandler(ImageHandler):
log.debug("vcpus = %d", self.vm.getVCpuCount())
log.debug("acpi = %d", self.acpi)
log.debug("apic = %d", self.apic)
+ log.debug("gfx_passthru = %d", self.gfx_passthru)

rc = xc.hvm_build(domid = self.vm.getDomid(),
image = self.loader,
@@ -908,7 +909,8 @@ class HVMImageHandler(ImageHandler):
target = mem_mb,
vcpus = self.vm.getVCpuCount(),
acpi = self.acpi,
- apic = self.apic)
+ apic = self.apic,
+ gfx_passthru = self.gfx_passthru)
rc['notes'] = { 'SUSPEND_CANCEL': 1 }

rc['store_mfn'] = xc.hvm_get_param(self.vm.getDomid(),
diff -r 5d7e7a250267 tools/python/xen/xm/create.py
--- a/tools/python/xen/xm/create.py Wed Aug 26 18:28:44 2009 +0800
+++ b/tools/python/xen/xm/create.py Thu Aug 27 16:54:24 2009 +0800
@@ -546,6 +546,10 @@ gopts.var('sdl', val='',
gopts.var('sdl', val='',
fn=set_value, default=None,
use="""Should the device model use SDL?""")
+
+gopts.var('gfx_passthru', val='',
+ fn=set_value, default=None,
+ use="""Passthrough graphics card?""")

gopts.var('opengl', val='',
fn=set_value, default=None,
@@ -957,7 +961,8 @@ def configure_hvm(config_image, vals):
'acpi', 'apic', 'usb', 'usbdevice', 'keymap', 'pci', 'hpet',
'guest_os_type', 'hap', 'opengl', 'cpuid', 'cpuid_check',
'viridian', 'xen_extended_power_mgmt', 'pci_msitranslate',
- 'vpt_align', 'pci_power_mgmt', 'xen_platform_pci' ]
+ 'vpt_align', 'pci_power_mgmt', 'xen_platform_pci',
+ 'gfx_passthru' ]

for a in args:
if a in vals.__dict__ and vals.__dict__[a] is not None:

2) intel-gfx-passthru-patch02.patch

From fb818f1060e57dac6793187a70a79801a7c17e50 Mon Sep 17 00:00:00 2001
From: Weidong Han
Date: Thu, 27 Aug 2009 16:51:01 +0800
Subject: [PATCH] qemu gfx passthrough support

support basic gfx passthrough:
- disable emulated VGA adpater if there is passthroughed gfx
- register/unregister legacy VGA I/O ports and MMIOs for passthroughed gfx

Signed-off-by: Ben Lin
Signed-off-by: Weidong Han
---
hw/pass-through.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++
hw/pass-through.h | 6 +++++
hw/pc.c | 51 ++++++++++++++++++++++++------------------
vl.c | 32 +++++++++++++++++++++++---
4 files changed, 126 insertions(+), 26 deletions(-)

diff --git a/hw/pass-through.c b/hw/pass-through.c
index 8d80755..4a9e03a 100644
--- a/hw/pass-through.c
+++ b/hw/pass-through.c
@@ -93,6 +93,8 @@
#include
#include

+extern int gfx_passthru;
+
struct php_dev {
struct pt_dev *pt_dev;
uint8_t valid;
@@ -1781,12 +1783,57 @@ static int pt_dev_is_virtfn(struct pci_dev *dev)
return rc;
}

+/*
+ * register VGA resources for the domain with assigned gfx
+ */
+static int register_vga_regions(struct pt_dev *real_device)
+{
+ int ret = 0;
+
+ ret |= xc_domain_ioport_mapping(xc_handle, domid, 0x3B0,
+ 0x3B0, 0xC, DPCI_ADD_MAPPING);
+
+ ret |= xc_domain_ioport_mapping(xc_handle, domid, 0x3C0,
+ 0x3C0, 0x20, DPCI_ADD_MAPPING);
+
+ ret |= xc_domain_memory_mapping(xc_handle, domid,
+ 0xa0000 >> XC_PAGE_SHIFT,
+ 0xa0000 >> XC_PAGE_SHIFT,
+ 0x20,
+ DPCI_ADD_MAPPING);
+
+ return ret;
+}
+
+/*
+ * unregister VGA resources for the domain with assigned gfx
+ */
+static int unregister_vga_regions(struct pt_dev *real_device)
+{
+ int ret = 0;
+
+ ret |= xc_domain_ioport_mapping(xc_handle, domid, 0x3B0,
+ 0x3B0, 0xC, DPCI_REMOVE_MAPPING);
+
+ ret |= xc_domain_ioport_mapping(xc_handle, domid, 0x3C0,
+ 0x3C0, 0x20, DPCI_REMOVE_MAPPING);
+
+ ret |= xc_domain_memory_mapping(xc_handle, domid,
+ 0xa0000 >> XC_PAGE_SHIFT,
+ 0xa0000 >> XC_PAGE_SHIFT,
+ 0x20,
+ DPCI_REMOVE_MAPPING);
+
+ return ret;
+}
+
static int pt_register_regions(struct pt_dev *assigned_device)
{
int i = 0;
uint32_t bar_data = 0;
struct pci_dev *pci_dev = assigned_device->pci_dev;
PCIDevice *d = &assigned_device->dev;
+ int ret;

/* Register PIO/MMIO BARs */
for ( i = 0; i < PCI_BAR_ENTRIES; i++ )
@@ -1842,6 +1889,16 @@ static int pt_register_regions(struct pt_dev *assigned_device)
(uint32_t)(pci_dev->rom_size), (uint32_t)(pci_dev->rom_base_addr));
}

+ if ( gfx_passthru && (pci_dev->device_class == 0x0300) )
+ {
+ ret = register_vga_regions(assigned_device);
+ if ( ret != 0 )
+ {
+ PT_LOG("VGA region mapping failed\n");
+ return ret;
+ }
+ }
+
return 0;
}

@@ -1891,6 +1948,12 @@ static void pt_unregister_regions(struct pt_dev *assigned_device)

}

+ if ( gfx_passthru && (assigned_device->pci_dev->device_class == 0x0300) )
+ {
+ ret = unregister_vga_regions(assigned_device);
+ if ( ret != 0 )
+ PT_LOG("VGA region unmapping failed\n");
+ }
}

static uint8_t find_cap_offset(struct pci_dev *pci_dev, uint8_t cap)
diff --git a/hw/pass-through.h b/hw/pass-through.h
index 028a03e..956e228 100644
--- a/hw/pass-through.h
+++ b/hw/pass-through.h
@@ -142,6 +142,12 @@ enum {
GRP_TYPE_EMU, /* emul reg group */
};

+enum {
+ GFX_NO_PASSTHRU = 0, /* No gfx pass-through */
+ GFX_IGD_PASSTHRU, /* IGD pass-through */
+ GFX_DISCRETE_PASSTHRU, /* Discrete gfx pass-through */
+};
+
#define PT_GET_EMUL_SIZE(flag, r_size) do { \
if (flag == PT_BAR_FLAG_MEM) {\
r_size = (((r_size) + XC_PAGE_SIZE - 1) & ~(XC_PAGE_SIZE - 1)); \
diff --git a/hw/pc.c b/hw/pc.c
index 129e9d9..53b59c0 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -41,6 +41,7 @@
#include "virtio-balloon.h"
#include "virtio-console.h"
#include "hpet_emul.h"
+#include "pass-through.h"

/* output Bochs bios info messages */
//#define DEBUG_BIOS
@@ -65,6 +66,8 @@ void tpm_tis_init(SetIRQFunc *set_irq, void *opaque, int irq);
extern uint8_t *acpi_tables;
extern size_t acpi_tables_len;

+extern int gfx_passthru;
+
static fdctrl_t *floppy_controller;
static RTCState *rtc_state;
static PITState *pit;
@@ -983,30 +986,34 @@ vga_bios_error:

register_ioport_write(0xf0, 1, 1, ioportF0_write, NULL);

- if (cirrus_vga_enabled) {
- if (pci_enabled) {
- pci_cirrus_vga_init(pci_bus,
- phys_ram_base + vga_ram_addr,
- vga_ram_addr, vga_ram_size);
- } else {
- isa_cirrus_vga_init(phys_ram_base + vga_ram_addr,
- vga_ram_addr, vga_ram_size);
- }
+ if (gfx_passthru == GFX_NO_PASSTHRU) {
+ if (cirrus_vga_enabled) {
+ fprintf(logfile,"cirrus_vga_enabled\n");
+ if (pci_enabled) {
+ pci_cirrus_vga_init(pci_bus,
+ phys_ram_base + vga_ram_addr,
+ vga_ram_addr, vga_ram_size);
+ } else {
+ isa_cirrus_vga_init(phys_ram_base + vga_ram_addr,
+ vga_ram_addr, vga_ram_size);
+ }
#ifndef CONFIG_DM
- } else if (vmsvga_enabled) {
- if (pci_enabled)
- pci_vmsvga_init(pci_bus, phys_ram_base + vga_ram_addr,
- vga_ram_addr, vga_ram_size);
- else
- fprintf(stderr, "%s: vmware_vga: no PCI bus\n", __FUNCTION__);
+ } else if (vmsvga_enabled) {
+ if (pci_enabled)
+ pci_vmsvga_init(pci_bus, phys_ram_base + vga_ram_addr,
+ vga_ram_addr, vga_ram_size);
+ else
+ fprintf(stderr, "%s: vmware_vga: no PCI bus\n", __FUNCTION__);
#endif
- } else if (std_vga_enabled) {
- if (pci_enabled) {
- pci_vga_init(pci_bus, phys_ram_base + vga_ram_addr,
- vga_ram_addr, vga_ram_size, 0, 0);
- } else {
- isa_vga_init(phys_ram_base + vga_ram_addr,
- vga_ram_addr, vga_ram_size);
+ } else if (std_vga_enabled) {
+ fprintf(logfile,"std_vga_enabled\n");
+ if (pci_enabled) {
+ pci_vga_init(pci_bus, phys_ram_base + vga_ram_addr,
+ vga_ram_addr, vga_ram_size, 0, 0);
+ } else {
+ isa_vga_init(phys_ram_base + vga_ram_addr,
+ vga_ram_addr, vga_ram_size);
+ }
}
}

diff --git a/vl.c b/vl.c
index 62bed05..72f3479 100644
--- a/vl.c
+++ b/vl.c
@@ -48,6 +48,7 @@
#include

#include "qemu-xen.h"
+#include "hw/pass-through.h"

#include
#include
@@ -213,6 +214,7 @@ static int rtc_date_offset = -1; /* -1 means no change */
int cirrus_vga_enabled = 1;
int std_vga_enabled = 0;
int vmsvga_enabled = 0;
+int gfx_passthru = 0;
#ifdef TARGET_SPARC
int graphic_width = 1024;
int graphic_height = 768;
@@ -4269,6 +4271,7 @@ enum {
/* Xen tree: */
QEMU_OPTION_disable_opengl,
QEMU_OPTION_direct_pci,
+ QEMU_OPTION_gfx_passthru,
QEMU_OPTION_pci_emulation,
QEMU_OPTION_vncunused,
QEMU_OPTION_videoram,
@@ -4447,6 +4450,7 @@ static const QEMUOption qemu_options[] = {
#endif
{ "acpi", 0, QEMU_OPTION_acpi }, /* deprecated, for xend compatibility */
{ "direct_pci", HAS_ARG, QEMU_OPTION_direct_pci },
+ { "gfx_passthru", HAS_ARG, QEMU_OPTION_gfx_passthru},
{ "pciemulation", HAS_ARG, QEMU_OPTION_pci_emulation },
{ "vncunused", 0, QEMU_OPTION_vncunused },
{ "vcpus", HAS_ARG, QEMU_OPTION_vcpus },
@@ -5484,6 +5488,22 @@ int main(int argc, char **argv, char **envp)
case QEMU_OPTION_runas:
run_as = optarg;
break;
+ case QEMU_OPTION_gfx_passthru:
+ gfx_passthru = atoi(optarg);
+ switch (gfx_passthru) {
+ case GFX_NO_PASSTHRU:
+ break;
+ case GFX_IGD_PASSTHRU:
+ fprintf(logfile, "IGD graphics card assignment\n");
+ break;
+ case GFX_DISCRETE_PASSTHRU:
+ fprintf(logfile, "Discrete graphics card assignment\n");
+ break;
+ default:
+ fprintf(stderr, "unsupported gfx_passthru option: %d\n",
+ gfx_passthru);
+ }
+ break;
}
}
}
@@ -5897,13 +5917,17 @@ int main(int argc, char **argv, char **envp)
exit(1);
xenstore_write_vncport(vnc_display_port);
}
+
+ if (gfx_passthru == GFX_NO_PASSTHRU)
+ {
#if defined(CONFIG_SDL)
- if (sdl || !vnc_display)
- sdl_display_init(ds, full_screen, no_frame, opengl_enabled);
+ if (sdl || !vnc_display)
+ sdl_display_init(ds, full_screen, no_frame, opengl_enabled);
#elif defined(CONFIG_COCOA)
- if (sdl || !vnc_display)
- cocoa_display_init(ds, full_screen);
+ if (sdl || !vnc_display)
+ cocoa_display_init(ds, full_screen);
#endif
+ }
}
}
dpy_resize(ds);
--
1.6.0.4

3) intel-gfx-passthru-patch03.patch

Manually generated by Teo En Ming (Zhang Enming) on 29 August 2009 Saturday at 11:10 A.M. Singapore Time
Email #1: enming.teo@xxxxxxxxxxxxxxx
Email #2: space.time.universe@gmail.com
MSN: teoenming@hotmail.com

--- Makefile 2009-08-29 10:57:28.072084001 +0800
+++ Makefile 2009-08-29 11:03:30.650209241 +0800
@@ -50,6 +50,7 @@
roms.h: ../rombios/BIOS-bochs-latest ../vgabios/VGABIOS-lgpl-latest.bin \
../vgabios/VGABIOS-lgpl-latest.cirrus.bin ../etherboot/eb-roms.h
sh ./mkhex rombios ../rombios/BIOS-bochs-latest > roms.h
+ sh ./mkhex vgabios_pt ../vgabios/vgabios-pt.bin >> roms.h
sh ./mkhex vgabios_stdvga ../vgabios/VGABIOS-lgpl-latest.bin >> roms.h
sh ./mkhex vgabios_cirrusvga \
../vgabios/VGABIOS-lgpl-latest.cirrus.bin >> roms.h
--- hvmloader.c 2009-08-29 10:58:52.679084845 +0800
+++ hvmloader.c 2009-08-29 11:07:40.763119203 +0800
@@ -688,10 +688,10 @@
vgabios_sz = round_option_rom(sizeof(vgabios_stdvga));
break;
case VGA_pt:
- printf("Loading VGABIOS of passthroughed gfx ...\n");
- vgabios_sz =
- round_option_rom((*(uint8_t *)(VGABIOS_PHYSICAL_ADDRESS+2)) * 512);
- break;
+ printf("Loading Gfx Video BIOS from file ...\n");
+ memcpy((void *)VGABIOS_PHYSICAL_ADDRESS, vgabios_pt, sizeof(vgabios_pt));
+ vgabios_sz = round_option_rom(sizeof(vgabios_pt));
+ break;
default:
printf("No emulated VGA adaptor ...\n");
break;

My Own Patch to Fix Xen 3.5-unstable ACPI Code Build Issue with Intel ACPI Component Architecture compiler version 20090730
=================================================================================================

4. enming-patch04.patch

Patch created by Teo En Ming (Zhang Enming) on 29 August 2009 Saturday at 8:00 P.M. Singapore Time
Email #1: enming.teo@xxxxxxxxxxxxxxx
Email #2: space.time.universe@gmail.com
MSN: teoenming@hotmail.com
Mobile Phone: +65-9648-9798

--- ssdt_pm.h 2009-08-29 19:54:52.653088000 +0800
+++ ssdt_pm.h 2009-08-29 19:56:51.813088550 +0800
@@ -10,7 +10,7 @@
* C source code output
*
*/
-unsigned char AmlCode[] =
+unsigned char AmlCode_PM[] =
{
0x53,0x53,0x44,0x54,0xD6,0x05,0x00,0x00, /* 00000000 "SSDT...." */
0x02,0xB9,0x58,0x65,0x6E,0x00,0x00,0x00, /* 00000008 "..Xen..." */
--- ssdt_tpm.h 2009-08-29 19:55:44.578738954 +0800
+++ ssdt_tpm.h 2009-08-29 19:57:27.896638884 +0800
@@ -10,7 +10,7 @@
* C source code output
*
*/
-unsigned char AmlCode[] =
+unsigned char AmlCode_TPM[] =
{
0x53,0x53,0x44,0x54,0x4C,0x00,0x00,0x00, /* 00000000 "SSDTL..." */
0x02,0x2A,0x58,0x65,0x6E,0x00,0x00,0x00, /* 00000008 ".*Xen..." */

Click here for technical discussions in the Xen developers mailing list (August 2009 entries)