Skip to contentSkip to conversation

Getting VGA Passthrough to work on Xen Unstable

PATCH Beng Heng, Ng 2 participants 4 messages May 14, 2009 – May 18, 2009

lore
Share & tools
lore
#0 lore raw

Hi all,

I've tried to filter out parts of XCI that are relevant to VGA passthrough (most, if not all, are Jean Guyader's work) and apply them to Xen unstable. The patch doesn't work with changeset 19597. I'm not sure why. But I've gotten DomU to boot up showing only the physical gfx on previous changesets. I didn't have a chance to test the gfx functionalities though. I made a lot of simplifications, such as excluding user options, and ignoring HID passthrough for now. The patch is hardcoded for VGA passthrough on HVM guests. The reason is really to study which are the parts really affect VGA passthrough, and of course ultimately getting VGA passthrough to work.

This may seem like taking a step backwards, but I think there are many people out there who are new, like me, and are really interested to understand and get VGA passthrough to work correctly. I'm hoping that experts out there can provide constructive criticism on this patch, and of course provide suggestions on how to make this patch work for the latest changeset.

- Beng Heng

tools/firmware/hvmloader/hvmloader.c +3 -1
diff -rupN -X diffignore --ignore-all-space a/tools/firmware/hvmloader/hvmloader.c b/tools/firmware/hvmloader/hvmloader.c
@@ -187,7 +187,9 @@ static void pci_setup(void)
         class     = pci_readw(devfn, PCI_CLASS_DEVICE);
         vendor_id = pci_readw(devfn, PCI_VENDOR_ID);
         device_id = pci_readw(devfn, PCI_DEVICE_ID);
-        if ( (vendor_id == 0xffff) && (device_id == 0xffff) )
+        if ( ((vendor_id == 0xffff) && (device_id == 0xffff)) ||
+             ((vendor_id == 0x1234) && (device_id == 0x1111)) ||
+             ((vendor_id == 0x1013) && (device_id == 0xb8)) )
             continue;
 
         ASSERT((devfn != PCI_ISA_DEVFN) ||
tools/ioemu-remote/hw/pc.c +5 -1
diff -rupN -X diffignore --ignore-all-space a/tools/ioemu-remote/hw/pc.c b/tools/ioemu-remote/hw/pc.c
@@ -805,6 +805,7 @@ static void pc_init1(ram_addr_t ram_size
     BlockDriverState *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
     BlockDriverState *fd[MAX_FD];
     int rc;
+    unsigned long vga_pt_enabled = 1;
 
     if (ram_size >= 0xe0000000 ) {
         above_4g_mem_size = ram_size - 0xe0000000;
@@ -890,8 +891,10 @@ static void pc_init1(ram_addr_t ram_size
         exit(1);
     }
 
-    if (cirrus_vga_enabled || std_vga_enabled || vmsvga_enabled) {
+    if ((cirrus_vga_enabled || std_vga_enabled || vmsvga_enabled) && !vga_pt_enabled) {
         /* VGA BIOS load */
         if (cirrus_vga_enabled) {
             snprintf(buf, sizeof(buf), "%s/%s", bios_dir, VGABIOS_CIRRUS_FILENAME);
@@ -984,6 +988,8 @@ vga_bios_error:
 
     register_ioport_write(0xf0, 1, 1, ioportF0_write, NULL);
 
+    if (!vga_pt_enabled)
+    {
     if (cirrus_vga_enabled) {
         if (pci_enabled) {
             pci_cirrus_vga_init(pci_bus,
@@ -1010,6 +1016,7 @@ vga_bios_error:
                          vga_ram_addr, vga_ram_size);
         }
     }
+    }
 
 #ifdef CONFIG_PASSTHROUGH
     /* Pass-through Initialization
xen/arch/x86/hvm/hvm.c +3 -0
diff -rupN -X diffignore --ignore-all-space a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
@@ -297,6 +297,7 @@ static int hvm_print_line(
 int hvm_domain_initialise(struct domain *d)
 {
     int rc;
+    unsigned long vga_pt_enabled = 1;
 
     if ( !hvm_enabled )
     {
@@ -328,6 +329,7 @@ int hvm_domain_initialise(struct domain 
     if ( rc != 0 )
         goto fail1;
 
+    if(!vga_pt_enabled)
     stdvga_init(d);
 
     rtc_init(d);
@@ -345,6 +347,7 @@ int hvm_domain_initialise(struct domain 
 
  fail2:
     rtc_deinit(d);
+    if(!vga_pt_enabled)
     stdvga_deinit(d);
     vioapic_deinit(d);
  fail1:
tools/libxc/xenctrl.h +4 -0
diff -rupN -X diffignore --ignore-all-space a/tools/libxc/xenctrl.h b/tools/libxc/xenctrl.h
@@ -145,6 +145,10 @@ int xc_waitdomain(
     int *status,
     int options);
 
+int xc_get_vgabios(
+    unsigned char       *bios,
+    int                 len);
+
 #endif /* __linux__ */
 
 /*
tools/libxc/xc_linux.c +51 -0

54 lines not on this page · raw message

tools/libxc/xc_hvm_build.c +54 -0

72 lines not on this page · raw message

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw

Hi,

Quoted 13 lines

Hi all,

I've tried to filter out parts of XCI that are relevant to VGA passthrough (most, if not all, are Jean Guyader's work) and apply them to Xen unstable. The patch doesn't work with changeset 19597. I'm not sure why. But I've gotten DomU to boot up showing only the physical gfx on previous changesets. I didn't have a chance to test the gfx functionalities though. I made a lot of simplifications, such as excluding user options, and ignoring HID passthrough for now. The patch is hardcoded for VGA passthrough on HVM guests. The reason is really to study which are the parts really affect VGA passthrough, and of course ultimately getting VGA passthrough to work.

Quoted 7 lines

This may seem like taking a step backwards, but I think there are many people out there who are new, like me, and are really interested to understand and get VGA passthrough to work correctly. I'm hoping that experts out there can provide constructive criticism on this patch, and of course provide suggestions on how to make this patch work for the latest changeset.

I suspect the VGA rom doesn't be loaded.
pci_load_option_roms() loads only mass stroage devices and serial bus controller. You need to remove the ckeck.

@tools/firmware/hvmloader/hvmloader.c
476 static int pci_load_option_roms(uint32_t rom_base_addr) 477 {

 478     uint32_t option_rom_addr, rom_phys_addr = rom_base_addr;
 479     uint16_t vendor_id, device_id;
 480     uint8_t devfn, class;
 481 
 482     for ( devfn = 0; devfn < 128; devfn++ )
 483     {
 484         class     = pci_readb(devfn, PCI_CLASS_DEVICE + 1);
 485         vendor_id = pci_readw(devfn, PCI_VENDOR_ID);
 486         device_id = pci_readw(devfn, PCI_DEVICE_ID);
 487 
 488         if ( (vendor_id == 0xffff) && (device_id == 0xffff) )
 489             continue;
 490 
 491         /*
 492          * Currently only scan options from mass storage devices and serial
 493          * bus controller (Fibre Channel included).
 494          */

495 if ( (class != 0x1) && (class != 0xc) )
496 continue;
497
498 option_rom_addr = pci_readl(devfn, PCI_ROM_ADDRESS);
499 if ( !option_rom_addr )
500 continue;
501
502 /* Ensure Expansion Bar is enabled before copying */
503 pci_writel(devfn, PCI_ROM_ADDRESS, option_rom_addr | 0x1);
504
505 rom_phys_addr += scan_option_rom(
506 devfn, vendor_id, device_id,
507 (void *)(option_rom_addr & ~2047), rom_phys_addr);
508
509 /* Restore the default original value of Expansion Bar */
510 pci_writel(devfn, PCI_ROM_ADDRESS, option_rom_addr);
511 }
512
513 return rom_phys_addr - rom_base_addr;
514 }

Best Regards,

Akio Takebe

#2 lore raw

Hi Akio,

Thanks for the reply. I didn't make any changes to pci_load_option_roms. Did you mean pci_setup? :)

- Beng Heng

Quoted 50 lines · Akio Takebe

Hi,

I suspect the VGA rom doesn't be loaded.
pci_load_option_roms() loads only mass stroage devices and serial bus controller. You need to remove the ckeck.

@tools/firmware/hvmloader/hvmloader.c
476 static int pci_load_option_roms(uint32_t rom_base_addr) 477 {

 478     uint32_t option_rom_addr, rom_phys_addr = rom_base_addr;
 479     uint16_t vendor_id, device_id;
 480     uint8_t devfn, class;
 481 
 482     for ( devfn = 0; devfn < 128; devfn++ )
 483     {
 484         class     = pci_readb(devfn, PCI_CLASS_DEVICE + 1);
 485         vendor_id = pci_readw(devfn, PCI_VENDOR_ID);
 486         device_id = pci_readw(devfn, PCI_DEVICE_ID);
 487 
 488         if ( (vendor_id == 0xffff) && (device_id == 0xffff) )
 489             continue;
 490 
 491         /*
 492          * Currently only scan options from mass storage devices and serial
 493          * bus controller (Fibre Channel included).
 494          */

495 if ( (class != 0x1) && (class != 0xc) )
496 continue;
497
498 option_rom_addr = pci_readl(devfn, PCI_ROM_ADDRESS);
499 if ( !option_rom_addr )
500 continue;
501
502 /* Ensure Expansion Bar is enabled before copying */
503 pci_writel(devfn, PCI_ROM_ADDRESS, option_rom_addr | 0x1);
504
505 rom_phys_addr += scan_option_rom(
506 devfn, vendor_id, device_id,
507 (void *)(option_rom_addr & ~2047), rom_phys_addr);
508
509 /* Restore the default original value of Expansion Bar */
510 pci_writel(devfn, PCI_ROM_ADDRESS, option_rom_addr);
511 }
512
513 return rom_phys_addr - rom_base_addr;
514 }

Best Regards,

Akio Takebe

#3 lore raw

Hi, Beng

Quoted 3 lines

Thanks for the reply. I didn't make any changes to pci_load_option_roms. Did you mean pci_setup? :)

No, your change of pci_setup is needed. But it's not enough. You need to change also pci_load_option_roms.

Best Regards,

Akio Takebe