ioemu: add libpci fixup to handle recent change in PCIUtils
PATCH 2/3 ioemu: add libpci fixup to handle recent change in PCIUtils
Hi Yu,
What were the changes in libutils that triggered this patch?
I've been trying to get a domu guest to correctly use a passed through VGA card, and noticed that some IO mappings are not as what the driver in the guest expects to see. For example, one of the I/O range starts from C000h. After the fixup, it was changed to C200h. I'm suspecting this causes the guest driver not to work correctly, although there may be other reasons. What do you think?
Thanks. :)
-Alex
Date: Sat, 24 Jan 2009 12:47:09 +0800
From: Yu Zhao <[email protected]>
Subject: [Xen-devel] [PATCH 2/3] ioemu: add libpci fixup to handle
recent change in PCIUtils
To: [email protected]
Cc: Yu Zhao <[email protected]>
Message-ID: <[email protected]>
The following commit of PCIUtils changes what 'base_addr' contains. Add a fixup to make sure the pass-through works when building against different versions of PCIUtils.
commit 6d143c3283855c474445a3cf27c65280ed7ab1b7
Author: Yu Zhao <[email protected]>
Date: Fri Dec 26 09:59:28 2008 +0800
Fix base address flags when using sysfs method
The base address flags are ignored when using sysfs method, while the proc and generic methods combined the flags into 'base_addr'. This inconsistency may fail some applications using libpci.
---
=== deprecated ===
Quoted 10 lines · Alexia Benington
Hi Yu,
What were the changes in libutils that triggered this patch?
I've been trying to get a domu guest to correctly use a passed through VGA card, and noticed that some IO mappings are not as what the driver in the guest expects to see. For example, one of the I/O range starts from C000h. After the fixup, it was changed to C200h. I'm suspecting this causes the guest driver not to work correctly, although there may be other reasons. What do you think?
The old libpci doesn't provide BAR flags in pci_dev->base_addr' when using sysfs method. This is inconsistent with what it does when using proc or direct I/O access method. The fix of libpci makes the BAR flags combined into base_addr', which impacts applications (like Xen Qemu) using `base_addr' without masking the flags. That's why the fix triggered the patch you mentioned.
Can you please grab some logs?
cat /sys/bus/pci/devices/xx:xx.x/resource
lspci -s xx:xx.x -vvv
Qemu log under /var/log/xen/qemu-dm-xxx
I'll try to figure out what happened to your I/O mapping.
Thanks,
Yu
Hi,
Apologies for the delay. I was trying to trace through the mappings myself. It seems the incorrect mappings are not necessarily due to this patch, but I'm still unable to figure out why there's a misalignment in the port mapping.
I've attached the lspci outputs for the 2 devices I was tinkering with, although it was mostly 01:00.0. There's also an lspci-like output in the Windows guest for reference.
I also noticed that some of the registers are being emulated rather than passed through. I'm wondering if this will affect the functionality of the device in the guest.
By the way, is there any good way to step through qemu-dm instead of looking at the log? The log helps experienced Xen developers understand what's wrong with the system, but its quite challenging for a beginner, like myself, in understanding Xen implementation. If anyone prefers, I can start another thread on this.
Thanks. :)
-Alex
Quoted 21 lines · Yu Zhao
Quoted 10 lines · Alexia Benington
Hi Yu,
What were the changes in libutils that triggered this patch?
I've been trying to get a domu guest to correctly use a passed through VGA card, and noticed that some IO mappings are not as what the driver in the guest expects to see. For example, one of the I/O range starts from C000h. After the fixup, it was changed to C200h. I'm suspecting this causes the guest driver not to work correctly, although there may be other reasons. What do you think?
The old libpci doesn't provide BAR flags in
pci_dev->base_addr' when using sysfs method. This is inconsistent with what it does when using proc or direct I/O access method. The fix of libpci makes the BAR flags combined intobase_addr', which impacts applications (like Xen Qemu) using `base_addr' without masking the flags. That's why the fix triggered the patch you mentioned.Can you please grab some logs?
Quoted 9 lines
cat /sys/bus/pci/devices/xx:xx.x/resource
lspci -s xx:xx.x -vvv
Qemu log under/var/log/xen/qemu-dm-xxxI'll try to figure out what happened to your I/O mapping.
Thanks,
Yu
domid: 79
qemu: the number of cpus is 1
config qemu network with xen bridge for tap79.0 eth0
Watching /local/domain/0/device-model/79/logdirty/next-active
Watching /local/domain/0/device-model/79/command
char device redirected to /dev/pts/2qemu_map_cache_init nr_buckets = 10000 size 3145728
shared page at pfn feffd
buffered io page at pfn feffb
Guest uuid = 2e3977ad-da71-2a89-3156-88407f25b679
Time offset set 0register_real_device: <pid 16793> Assigning real physical device 01:00.0 ...register_real_device: Disable MSI translation via per device optionpt_register_regions: IO region registered (size=0x10000000 base_addr=0xc000000c)pt_register_regions: IO region registered (size=0x00010000 base_addr=0xd0020004)pt_register_regions: IO region registered (size=0x00000100 base_addr=0x0000c001)pt_register_regions: Expansion ROM registered (size=0x00020000 base_addr=0xd0000000)register_real_device: Real physical device 01:00.0 registered successfuly!
IRQ type = INTxregister_real_device: <pid 16793> Assigning real physical device 01:00.1 ...register_real_device: Disable MSI translation via per device optionpt_register_regions: IO region registered (size=0x00004000 base_addr=0xd0030004)register_real_device: Real physical device 01:00.1 registered successfuly!
IRQ type = INTx
Register xen platform.
Done register platform.xs_read(/local/domain/0/device-model/79/xen_extended_power_mgmt): read error
I/O request not ready: 0, ptr: 0, port: 0, data: 0, count: 0, size: 0
(qemu) pt_iomem_map: e_phys=e0000000 maddr=c000000c type=8 len=268435456 index=0 first_map=1pt_iomem_map: e_phys=f1000000 maddr=d0000000 type=8 len=131072 index=6 first_map=1pt_iomem_map: e_phys=f1020000 maddr=d0020004 type=0 len=65536 index=2 first_map=1pt_iomem_map: e_phys=f1030000 maddr=d0030004 type=0 len=16384 index=0 first_map=1pt_ioport_map: e_phys=c200 pio_base=c001 len=256 index=4 first_map=1gpe_sts_write: addr=0x1f68, val=0x0.gpe_sts_write: addr=0x1f69, val=0x0.gpe_sts_write: addr=0x1f6a, val=0x0.gpe_sts_write: addr=0x1f6b, val=0x0.gpe_en_write: addr=0x1f6c, val=0x0.gpe_en_write: addr=0x1f6d, val=0x0.gpe_en_write: addr=0x1f6e, val=0x0.gpe_en_write: addr=0x1f6f, val=0x0.gpe_en_write: addr=0x1f6c, val=0x0.gpe_en_write: addr=0x1f6d, val=0x0.gpe_en_write: addr=0x1f6e, val=0x0.gpe_en_write: addr=0x1f6f, val=0x0.gpe_sts_write: addr=0x1f68, val=0x0.gpe_sts_write: addr=0x1f69, val=0x0.gpe_sts_write: addr=0x1f6a, val=0x0.gpe_sts_write: addr=0x1f6b, val=0x0.gpe_en_write: addr=0x1f6c, val=0x8.gpe_en_write: addr=0x1f6d, val=0x0.gpe_en_write: addr=0x1f6e, val=0x0.gpe_en_write: addr=0x1f6f, val=0x0.
ACPI PCI hotplug: read addr=0x10c1, val=0xf.
ACPI PCI hotplug: read addr=0x10c2, val=0xf.
ACPI PCI hotplug: read addr=0x10c1, val=0xf.
ACPI PCI hotplug: read addr=0x10c2, val=0xf.
ACPI PCI hotplug: read addr=0x10c1, val=0xf.
ACPI PCI hotplug: read addr=0x10c2, val=0xf.pt_iomem_map: e_phys=ffffffff maddr=c000000c type=8 len=268435456 index=0 first_map=0pt_iomem_map: e_phys=ffffffff maddr=d0020004 type=0 len=65536 index=2 first_map=0pt_ioport_map: e_phys=ffff pio_base=c001 len=256 index=4 first_map=0pt_iomem_map: e_phys=ffffffff maddr=d0000000 type=8 len=131072 index=6 first_map=0pt_iomem_map: e_phys=e0000000 maddr=c000000c type=8 len=268435456 index=0 first_map=0pt_iomem_map: e_phys=f1020000 maddr=d0020004 type=0 len=65536 index=2 first_map=0pt_ioport_map: e_phys=c200 pio_base=c001 len=256 index=4 first_map=0pt_iomem_map: e_phys=f1000000 maddr=d0000000 type=8 len=131072 index=6 first_map=0pt_iomem_map: e_phys=ffffffff maddr=d0030004 type=0 len=16384 index=0 first_map=0pt_pci_write_config: Warning: Guest attempt to set address to unused Base Address Register. [00:07.0][Offset:30h][Length:4]pt_iomem_map: e_phys=f1030000 maddr=d0030004 type=0 len=16384 index=0 first_map=0
ACPI PCI hotplug: read addr=0x10c1, val=0xf.
ACPI PCI hotplug: read addr=0x10c2, val=0xf.
ACPI PCI hotplug: read addr=0x10c1, val=0xf.
ACPI PCI hotplug: read addr=0x10c2, val=0xf.
ACPI PCI hotplug: read addr=0x10c1, val=0xf.
ACPI PCI hotplug: read addr=0x10c1, val=0xf.
ACPI PCI hotplug: read addr=0x10c2, val=0xf.
ACPI PCI hotplug: read addr=0x10c1, val=0xf.
ACPI PCI hotplug: read addr=0x10c2, val=0xf.
ACPI PCI hotplug: read addr=0x10c1, val=0xf.
ACPI PCI hotplug: read addr=0x10c2, val=0xf.
ACPI PCI hotplug: read addr=0x10c1, val=0xf.
ACPI PCI hotplug: read addr=0x10c2, val=0xf.
ACPI PCI hotplug: read addr=0x10c2, val=0xf.
ACPI PCI hotplug: read addr=0x10c2, val=0xf.pt_iomem_map: e_phys=ffffffff maddr=d0030004 type=0 len=16384 index=0 first_map=0pt_iomem_map: e_phys=f1030000 maddr=d0030004 type=0 len=16384 index=0 first_map=0
ACPI PCI hotplug: read addr=0x10c2, val=0xf.
ACPI PCI hotplug: read addr=0x10c2, val=0xf.
ACPI PCI hotplug: read addr=0x10c2, val=0xf.
ACPI PCI hotplug: read addr=0x10c1, val=0xf.
ACPI PCI hotplug: read addr=0x10c1, val=0xf.pt_iomem_map: e_phys=ffffffff maddr=c000000c type=8 len=268435456 index=0 first_map=0pt_iomem_map: e_phys=ffffffff maddr=d0020004 type=0 len=65536 index=2 first_map=0pt_ioport_map: e_phys=ffff pio_base=c001 len=256 index=4 first_map=0pt_iomem_map: e_phys=ffffffff maddr=d0000000 type=8 len=131072 index=6 first_map=0pt_iomem_map: e_phys=e0000000 maddr=c000000c type=8 len=268435456 index=0 first_map=0pt_iomem_map: e_phys=f1020000 maddr=d0020004 type=0 len=65536 index=2 first_map=0pt_ioport_map: e_phys=c200 pio_base=c001 len=256 index=4 first_map=0pt_iomem_map: e_phys=f1000000 maddr=d0000000 type=8 len=131072 index=6 first_map=0
ACPI PCI hotplug: read addr=0x10c1, val=0xf.gpe_en_write: addr=0x1f6c, val=0x8.gpe_en_write: addr=0x1f6d, val=0x0.gpe_en_write: addr=0x1f6e, val=0x0.gpe_en_write: addr=0x1f6f, val=0x0.
ACPI PCI hotplug: read addr=0x10c1, val=0xf.
ACPI PCI hotplug: read addr=0x10c1, val=0xf.
Send fake arp for domain 79, MAC: [00:16:3E:73:A8:D7]
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 6 lines · Alexia Benington
Hi,
Apologies for the delay. I was trying to trace through the mappings myself. It seems the incorrect mappings are not necessarily due to this patch, but I'm still unable to figure out why there's a misalignment in the port mapping.
According to the Qemu log, the I/O region of 01:00.0 has PIO address 0xc000 in the dom0, which is the host physical address (i.e. the value in the device BAR). And the 0xc200 is guest physical address emulated by Qemu by creating P2M mapping via hypercall. The `passthrough' doesn't mean guest really can change PCI config space of device. Actually Qemu emulates most of CSRs :-)
HPA of a BAR is not changed during device passthrough while GPA can be any value programmed by guest firmware and OS. The 0xc200 was allocated by guest BIOS and is size aligned (256 byte aligned). So there is nothing wrong with it.
Quoted 7 lines
I've attached the lspci outputs for the 2 devices I was tinkering with, although it was mostly 01:00.0. There's also an lspci-like output in the Windows guest for reference.
I also noticed that some of the registers are being emulated rather than passed through. I'm wondering if this will affect the functionality of the device in the guest.
Yes, we can't let guest directly access some CSRs due to architectural and security reasons. Some devices aren't able to work due to this. For example, legacy IDE controller using fixed PIO address won't work if PIO address seen by guest is not equal to that fixed address. But I'm not sure if it is the case of your VGA card. IIRC, someone did successfully assign VGA card to guest. Maybe you could find some clue by digging archive of this mailing list.
And I'll try to find a some VGA card same as yours and do some debug. I'll keep you posted if I get some luck.
Quoted 5 lines
By the way, is there any good way to step through qemu-dm instead of looking at the log? The log helps experienced Xen developers understand what's wrong with the system, but its quite challenging for a beginner, like myself, in understanding Xen implementation. If anyone prefers, I can start another thread on this.
Yes, the log is not so friendly. Any effort on improving it is appreciated!
Thanks,
Yu