Skip to contentSkip to conversation

PCI Passthrough Problems/Questions

DISCUSSION Nick Couchman 3 participants 11 messages Oct 25, 2010 – Oct 28, 2010

lore
Share & tools
lore
#0 lore raw

This is a message I posted to xen-users without getting any good leads...I'm hoping someone on the devel list has some ideas as to what might be going on here.

I've asked a couple of these questions, already, but haven't really had any response, so I thought I'd try, again, and try to provide a little more detail. I need to pass through a PCIe 4-port Serial card. I've done this successfully multiple times with different serial cards, but the current one, a PCIe Perle quad-port RJ45, is causing some problems. I believe the problem stems from the fact that the card is a PCI card and that Perle just built a PCIe-PCI bridge so that they could reuse an existing PCI design. The following three PCI devices are all on the same card:

# lspci
...
01:00.0 PCI bridge: PLX Technology, Inc. PEX8112 x1 Lane PCI
Express-to-PCI Bridge (rev aa)
02:00.0 Serial controller: Perle Systems Ltd Device 0331
02:00.1 Bridge: Perle Systems Ltd Device 0331

I've tried various combinations of hiding 01:00.0, 02:00.0, and/or 02:00.1 from dom0 and passing those through. First, if I try all three, I put the following in my dom0 kernel arguments:

pciback.hide=(01:00.0)(02:00.0)(02:00.1)

Before someone suggests that maybe I have my kernel arguments wrong, this is a SuSE kernel, so it is not pvops, and that is the correct syntax - I can add other PCI(e) devices on the same exact host (like a graphics card) and pass those through without any problem at all. So syntax is correct. After I boot with these arguments, I check the dmesg output for pciback messages:

# dmesg|grep pciback

[    0.000000] Command line: root=/dev/local/dom0 resume=/dev/local/swap
pciback.hide=(01:00.0)(02:00.0)(02:00.1) splash=silent quiet showopts
[    0.000000] Kernel command line: root=/dev/local/dom0
resume=/dev/local/swap pciback.hide=(01:00.0)(02:00.0)(02:00.1)
splash=silent quiet showopts
[    3.646529] pciback 0000:01:00.0: seizing device
[    3.646536] pciback 0000:02:00.0: seizing device
[    3.646540] pciback 0000:02:00.1: seizing device
[    3.646594] pciback 0000:02:00.1: PCI INT A -> GSI 16 (level, low) ->
IRQ 16
[    3.646599] pciback 0000:02:00.1: PCI INT A disabled
[    3.646637] pciback 0000:02:00.0: PCI INT A -> GSI 16 (level, low) ->
IRQ 16
[    3.646642] pciback 0000:02:00.0: PCI INT A disabled

So, everything points to the devices having been removed from dom0's visibility and placed under the control of pciback. A check with "xm" confirms this:

# xm pci-list-assignable-devices
0000:02:00.0
0000:02:00.1
0000:01:00.0

Next, I set up the pci pass through in my HVM domU configuration. By the way, VTd is enabled and working fine - xm dmesg shows it as enabled, and, as already mentioned, I can forward through other PCI(e) devices without problem. I set the following in my domU configuration:

pci=['01:00.0','02:00.0','02:00.1']

and then I try to start the domU:

# xm start XP
Error: pci: PCI Backend and pci-stub don't own device 0000:01:00.0
Usage: xm start <DomainName>

??? Ummm, actually, the device is owned by pciback, so why is Xen telling me it's not?? I can confirm via lspci -v:

# lspci -v
...
01:00.0 PCI bridge: PLX Technology, Inc. PEX8112 x1 Lane PCI
Express-to-PCI Bridge (rev aa) (prog-if 00 [Normal decode])
	Flags: bus master, fast devsel, latency 0
	Memory at d0000000 (64-bit, prefetchable) [size=64K]
	Bus: primary=01, secondary=02, subordinate=02, sec-latency=64
	I/O behind bridge: 0000d000-0000dfff
	Memory behind bridge: fe500000-fe5fffff
	Capabilities: [40] Power Management version 2
	Capabilities: [50] MSI: Enable- Count=1/1 Maskable- 64bit+
	Capabilities: [60] Express PCI/PCI-X Bridge, MSI 00
	Capabilities: [100] Power Budgeting <?>
	Kernel driver in use: pciback

Any hints on this particular part of the problem would be appreciated. My next step was to leave this one out and just try forwarding through 02:00.0 and 02:00.1. However, when I modify the domU configuration and remove the 01:00.0 device and try to start the domU:

# xm start XP
Error: Failed to assign device to IOMMU
(0000:02:00.0@100,msitranslate=1,power_mgmt=0)
Usage: xm start <DomainName>

I've been able to find very, very little useful information on this particular error - most of the issues are with trying to forward through one or two of the devices on a card to one domU and the others to another or not at all - splitting the devices on a card between domains. I'm not really trying to do this, but I suspect that there's some sort of tie between the PCIe-PCI bridge device (01:00.0) and the actual serial card (02:00.0) that is causing Xen to need to have both those devices present in the same domain. Of course, because of the problems I'm having forwarding the bridge through, that's not really working for me.

Environment:
Xen: 4.0.0 (4.0.0_21091_06-0.1)
Kernel: 2.6.34.7 (2.6.34.7-0.4-xen, not pvops)
Hardware: Dell Optiplex 780

Any help, hints, information, would be greatly appreciated!

-Nick

--------
This e-mail may contain confidential and privileged material for the sole use of the intended recipient. If this email is not intended for you, or you are not responsible for the delivery of this message to the intended recipient, please note that this message may contain SEAKR Engineering (SEAKR) Privileged/Proprietary Information. In such a case, you are strictly prohibited from downloading, photocopying, distributing or otherwise using this message, its contents or attachments in any way. If you have received this message in error, please notify us immediately by replying to this e-mail and delete the message from your mailbox. Information contained in this message that does not relate to the business of SEAKR is neither endorsed by nor attributable to SEAKR.

#1 lore raw
Quoted 98 lines · Nick Couchman

This is a message I posted to xen-users without getting any good leads...I'm hoping someone on the devel list has some ideas as to what might be going on here.

I've asked a couple of these questions, already, but haven't really had any response, so I thought I'd try, again, and try to provide a little more detail. I need to pass through a PCIe 4-port Serial card. I've done this successfully multiple times with different serial cards, but the current one, a PCIe Perle quad-port RJ45, is causing some problems. I believe the problem stems from the fact that the card is a PCI card and that Perle just built a PCIe-PCI bridge so that they could reuse an existing PCI design. The following three PCI devices are all on the same card:

# lspci
...
01:00.0 PCI bridge: PLX Technology, Inc. PEX8112 x1 Lane PCI
Express-to-PCI Bridge (rev aa)
02:00.0 Serial controller: Perle Systems Ltd Device 0331
02:00.1 Bridge: Perle Systems Ltd Device 0331

I've tried various combinations of hiding 01:00.0, 02:00.0, and/or 02:00.1 from dom0 and passing those through. First, if I try all three, I put the following in my dom0 kernel arguments:

pciback.hide=(01:00.0)(02:00.0)(02:00.1)

Before someone suggests that maybe I have my kernel arguments wrong, this is a SuSE kernel, so it is not pvops, and that is the correct syntax - I can add other PCI(e) devices on the same exact host (like a graphics card) and pass those through without any problem at all. So syntax is correct. After I boot with these arguments, I check the dmesg output for pciback messages:

# dmesg|grep pciback

[    0.000000] Command line: root=/dev/local/dom0 resume=/dev/local/swap
pciback.hide=(01:00.0)(02:00.0)(02:00.1) splash=silent quiet showopts
[    0.000000] Kernel command line: root=/dev/local/dom0
resume=/dev/local/swap pciback.hide=(01:00.0)(02:00.0)(02:00.1)
splash=silent quiet showopts
[    3.646529] pciback 0000:01:00.0: seizing device
[    3.646536] pciback 0000:02:00.0: seizing device
[    3.646540] pciback 0000:02:00.1: seizing device
[    3.646594] pciback 0000:02:00.1: PCI INT A -> GSI 16 (level, low) ->
IRQ 16
[    3.646599] pciback 0000:02:00.1: PCI INT A disabled
[    3.646637] pciback 0000:02:00.0: PCI INT A -> GSI 16 (level, low) ->
IRQ 16
[    3.646642] pciback 0000:02:00.0: PCI INT A disabled

So, everything points to the devices having been removed from dom0's visibility and placed under the control of pciback. A check with "xm" confirms this:

# xm pci-list-assignable-devices
0000:02:00.0
0000:02:00.1
0000:01:00.0

Next, I set up the pci pass through in my HVM domU configuration. By the way, VTd is enabled and working fine - xm dmesg shows it as enabled, and, as already mentioned, I can forward through other PCI(e) devices without problem. I set the following in my domU configuration:

pci=['01:00.0','02:00.0','02:00.1']

and then I try to start the domU:

# xm start XP
Error: pci: PCI Backend and pci-stub don't own device 0000:01:00.0
Usage: xm start <DomainName>

??? Ummm, actually, the device is owned by pciback, so why is Xen telling me it's not?? I can confirm via lspci -v:

# lspci -v
...
01:00.0 PCI bridge: PLX Technology, Inc. PEX8112 x1 Lane PCI
Express-to-PCI Bridge (rev aa) (prog-if 00 [Normal decode])
	Flags: bus master, fast devsel, latency 0
	Memory at d0000000 (64-bit, prefetchable) [size=64K]
	Bus: primary=01, secondary=02, subordinate=02, sec-latency=64
	I/O behind bridge: 0000d000-0000dfff
	Memory behind bridge: fe500000-fe5fffff
	Capabilities: [40] Power Management version 2
	Capabilities: [50] MSI: Enable- Count=1/1 Maskable- 64bit+
	Capabilities: [60] Express PCI/PCI-X Bridge, MSI 00
	Capabilities: [100] Power Budgeting <?>
	Kernel driver in use: pciback

Any hints on this particular part of the problem would be appreciated. My next step was to leave this one out and just try forwarding through 02:00.0 and 02:00.1. However, when I modify the domU configuration and remove the 01:00.0 device and try to start the domU:

# xm start XP
Error: Failed to assign device to IOMMU
(0000:02:00.0@100,msitranslate=1,power_mgmt=0)
Usage: xm start <DomainName>
Quoted 10 lines

I've been able to find very, very little useful information on this particular error - most of the issues are with trying to forward through one or two of the devices on a card to one domU and the others to another or not at all - splitting the devices on a card between domains. I'm not really trying to do this, but I suspect that there's some sort of tie between the PCIe-PCI bridge device (01:00.0) and the actual serial card (02:00.0) that is causing Xen to need to have both those devices present in the same domain. Of course, because of the problems I'm having forwarding the bridge through, that's not really working for me.

What do you see on your Xen serial output? I presume you cranked up logging:
loglevel=all guest_lvl=all iommu=verbose on your Xen command line.

Is there anything that shows up when you get the 'Failed to assign.." ?

#2 lore raw
Quoted 6 lines · Konrad Rzeszutek Wilk

What do you see on your Xen serial output? I presume you cranked up logging:
loglevel=all guest_lvl=all iommu=verbose on your Xen command line.

Is there anything that shows up when you get the 'Failed to assign.." ?

The only messages I get on the serial console after setting those parameters on the xen.gz kernel line in grub (and rebooting, of course) are the following:

(XEN) [VT-D]iommu.c:1496: d0:PCI: unmap bdf = 2:0.0
(XEN) [VT-D]iommu.c:1364: d1:PCI: map bdf = 2:0.0
(XEN) domctl.c:848:d0 XEN_DOMCTL_assign_device: assign device (2:0.0) failed
(XEN) event_channel.c:192:d0 EVTCHNOP failure: domain 1, error -22

-Nick

--------
This e-mail may contain confidential and privileged material for the sole use of the intended recipient. If this email is not intended for you, or you are not responsible for the delivery of this message to the intended recipient, please note that this message may contain SEAKR Engineering (SEAKR) Privileged/Proprietary Information. In such a case, you are strictly prohibited from downloading, photocopying, distributing or otherwise using this message, its contents or attachments in any way. If you have received this message in error, please notify us immediately by replying to this e-mail and delete the message from your mailbox. Information contained in this message that does not relate to the business of SEAKR is neither endorsed by nor attributable to SEAKR.

#3 lore raw
Quoted 13 lines · Nick Couchman
Quoted 6 lines · Konrad Rzeszutek Wilk

What do you see on your Xen serial output? I presume you cranked up logging:
loglevel=all guest_lvl=all iommu=verbose on your Xen command line.

Is there anything that shows up when you get the 'Failed to assign.." ?

The only messages I get on the serial console after setting those parameters on the xen.gz kernel line in grub (and rebooting, of course) are the following:

Quoted 5 lines

(XEN) [VT-D]iommu.c:1496: d0:PCI: unmap bdf = 2:0.0
(XEN) [VT-D]iommu.c:1364: d1:PCI: map bdf = 2:0.0
(XEN) domctl.c:848:d0 XEN_DOMCTL_assign_device: assign device (2:0.0) failed
(XEN) event_channel.c:192:d0 EVTCHNOP failure: domain 1, error -22

So, -EINVAL. How comfortable are you sticking a bunch of dprintk(VTDPREFIX, " in the drivers/passthrough/vtd/iommu.c file? Basically you need to figure which of the functions that are past line 1364 are being called and return -EINVAL.

#4 lore raw
Quoted 20 lines · Konrad Rzeszutek Wilk
Quoted 13 lines · Nick Couchman
Quoted 6 lines · Konrad Rzeszutek Wilk

What do you see on your Xen serial output? I presume you cranked up logging:
loglevel=all guest_lvl=all iommu=verbose on your Xen command line.

Is there anything that shows up when you get the 'Failed to assign.." ?

The only messages I get on the serial console after setting those parameters on the xen.gz kernel line in grub (and rebooting, of course) are the following:

Quoted 5 lines

(XEN) [VT-D]iommu.c:1496: d0:PCI: unmap bdf = 2:0.0
(XEN) [VT-D]iommu.c:1364: d1:PCI: map bdf = 2:0.0
(XEN) domctl.c:848:d0 XEN_DOMCTL_assign_device: assign device (2:0.0) failed
(XEN) event_channel.c:192:d0 EVTCHNOP failure: domain 1, error -22

Quoted 4 lines

So, -EINVAL. How comfortable are you sticking a bunch of dprintk(VTDPREFIX, " in the drivers/passthrough/vtd/iommu.c file? Basically you need to figure which of the functions that are past line 1364 are being called and return -EINVAL.

I'm happy to give it a shot...it'll take a while to get the devel environment configured, as I'm using packages right now and I don't even think I have a compiler on this system. I'll report back once I get that done and give that a try.

-Nick

--------
This e-mail may contain confidential and privileged material for the sole use of the intended recipient. If this email is not intended for you, or you are not responsible for the delivery of this message to the intended recipient, please note that this message may contain SEAKR Engineering (SEAKR) Privileged/Proprietary Information. In such a case, you are strictly prohibited from downloading, photocopying, distributing or otherwise using this message, its contents or attachments in any way. If you have received this message in error, please notify us immediately by replying to this e-mail and delete the message from your mailbox. Information contained in this message that does not relate to the business of SEAKR is neither endorsed by nor attributable to SEAKR.

#5 lore raw
Quoted 26 lines · Nick Couchman
Quoted 20 lines · Konrad Rzeszutek Wilk
Quoted 13 lines · Nick Couchman
Quoted 6 lines · Konrad Rzeszutek Wilk

What do you see on your Xen serial output? I presume you cranked up logging:
loglevel=all guest_lvl=all iommu=verbose on your Xen command line.

Is there anything that shows up when you get the 'Failed to assign.." ?

The only messages I get on the serial console after setting those parameters on the xen.gz kernel line in grub (and rebooting, of course) are the following:

Quoted 5 lines

(XEN) [VT-D]iommu.c:1496: d0:PCI: unmap bdf = 2:0.0
(XEN) [VT-D]iommu.c:1364: d1:PCI: map bdf = 2:0.0
(XEN) domctl.c:848:d0 XEN_DOMCTL_assign_device: assign device (2:0.0) failed
(XEN) event_channel.c:192:d0 EVTCHNOP failure: domain 1, error -22

Quoted 4 lines

So, -EINVAL. How comfortable are you sticking a bunch of dprintk(VTDPREFIX, " in the drivers/passthrough/vtd/iommu.c file? Basically you need to figure which of the functions that are past line 1364 are being called and return -EINVAL.

Quoted 4 lines

I'm happy to give it a shot...it'll take a while to get the devel environment configured, as I'm using packages right now and I don't even think I have a compiler on this system. I'll report back once I get that done and give that a try.

Excellent. You might also want to CC Weidong ([email protected]) in the future who is right now on travel and he might have better suggestions. CC-ing him on this e-mail.

#6 lore raw
Quoted 27 lines · Konrad Rzeszutek Wilk
Quoted 26 lines · Nick Couchman
Quoted 24 lines · Konrad Rzeszutek Wilk
Quoted 13 lines · Nick Couchman
Quoted 6 lines · Konrad Rzeszutek Wilk

What do you see on your Xen serial output? I presume you cranked up logging:
loglevel=all guest_lvl=all iommu=verbose on your Xen command line.

Is there anything that shows up when you get the 'Failed to assign.." ?

The only messages I get on the serial console after setting those parameters on the xen.gz kernel line in grub (and rebooting, of course) are the following:

Quoted 5 lines

(XEN) [VT-D]iommu.c:1496: d0:PCI: unmap bdf = 2:0.0
(XEN) [VT-D]iommu.c:1364: d1:PCI: map bdf = 2:0.0
(XEN) domctl.c:848:d0 XEN_DOMCTL_assign_device: assign device (2:0.0) failed
(XEN) event_channel.c:192:d0 EVTCHNOP failure: domain 1, error -22

So, -EINVAL. How comfortable are you sticking a bunch of dprintk(VTDPREFIX, " in the drivers/passthrough/vtd/iommu.c file? Basically you need to figure which of the functions that are past line 1364 are being called and return -EINVAL.

Quoted 7 lines
Quoted 4 lines

I'm happy to give it a shot...it'll take a while to get the devel environment configured, as I'm using packages right now and I don't even think I have a compiler on this system. I'll report back once I get that done and give that a try.

Excellent. You might also want to CC Weidong ([email protected]) in the future who is right now on travel and he might have better suggestions. CC-ing him on this e-mail.

Okay, I've traced it down to this section of code in iommu.c:

/*
* Devices behind PCIe-to-PCI/PCIx bridge may generate
* different requester-id. It may originate from devfn=0
* on the secondary bus behind the bridge. Map that id
* as well.
*/
ret = domain_context_mapping_one(domain, drhd->iommu,
secbus, 0);
dprintk(XENLOG_ERR VTDPREFIX, "domain_conext_mapping_one
ret: %d\n", ret);

I guess that shouldn't surprise me, given this device is behind a PCIe-to-PCI bridge. On to the domain_context_mapping_one function.

-Nick

--------
This e-mail may contain confidential and privileged material for the sole use of the intended recipient. If this email is not intended for you, or you are not responsible for the delivery of this message to the intended recipient, please note that this message may contain SEAKR Engineering (SEAKR) Privileged/Proprietary Information. In such a case, you are strictly prohibited from downloading, photocopying, distributing or otherwise using this message, its contents or attachments in any way. If you have received this message in error, please notify us immediately by replying to this e-mail and delete the message from your mailbox. Information contained in this message that does not relate to the business of SEAKR is neither endorsed by nor attributable to SEAKR.

#7 lore raw
In reply to Konrad Rzeszutek Wilk
Quoted 27 lines · Konrad Rzeszutek Wilk
Quoted 26 lines · Nick Couchman
Quoted 24 lines · Konrad Rzeszutek Wilk
Quoted 13 lines · Nick Couchman
Quoted 6 lines · Konrad Rzeszutek Wilk

What do you see on your Xen serial output? I presume you cranked up logging:
loglevel=all guest_lvl=all iommu=verbose on your Xen command line.

Is there anything that shows up when you get the 'Failed to assign.." ?

The only messages I get on the serial console after setting those parameters on the xen.gz kernel line in grub (and rebooting, of course) are the following:

Quoted 5 lines

(XEN) [VT-D]iommu.c:1496: d0:PCI: unmap bdf = 2:0.0
(XEN) [VT-D]iommu.c:1364: d1:PCI: map bdf = 2:0.0
(XEN) domctl.c:848:d0 XEN_DOMCTL_assign_device: assign device (2:0.0) failed
(XEN) event_channel.c:192:d0 EVTCHNOP failure: domain 1, error -22

So, -EINVAL. How comfortable are you sticking a bunch of dprintk(VTDPREFIX, " in the drivers/passthrough/vtd/iommu.c file? Basically you need to figure which of the functions that are past line 1364 are being called and return -EINVAL.

Quoted 7 lines
Quoted 4 lines

I'm happy to give it a shot...it'll take a while to get the devel environment configured, as I'm using packages right now and I don't even think I have a compiler on this system. I'll report back once I get that done and give that a try.

Excellent. You might also want to CC Weidong ([email protected]) in the future who is right now on travel and he might have better suggestions. CC-ing him on this e-mail.

Okay, I'm fairly certain that the root cause is actually the issue Xen has trying to forward through the actual PCIe-to-PCI bridge. In my original e-mail, I stated that if I try to add that bridge to the domU, I get an error about it not being owned by PCI Backend or pci-stub. In the function domain_context_mapping, bus is the bus of the device you're actually trying to forward through to the new domain, and secbus is set with the function find_upstream_bridge, which appears to find the bus to which your device is attached. Here's the section of code in question from iommu.c:

        if ( pdev_type(bus, devfn) == DEV_TYPE_PCIe2PCI_BRIDGE )
        {
            ret = domain_context_mapping_one(domain, drhd->iommu, bus,

devfn);
dprintk(XENLOG_ERR VTDPREFIX, "domain_conext_mapping_one
ret: %d\n", ret);
if ( ret )
return ret;

/*
* Devices behind PCIe-to-PCI/PCIx bridge may generate
* different requester-id. It may originate from devfn=0
* on the secondary bus behind the bridge. Map that id
* as well.
*/
ret = domain_context_mapping_one(domain, drhd->iommu,
secbus, 0);
dprintk(XENLOG_ERR VTDPREFIX, "domain_conext_mapping_one

ret: %d\n", ret);
        }
        else /* Legacy PCI bridge */ {
            ret = domain_context_mapping_one(domain, drhd->iommu, bus,
devfn);
            dprintk(XENLOG_ERR VTDPREFIX, "domain_conext_mapping_one
ret: %d\n", ret);
        }

If I understand this code, if the device is a PCIe2PCI bridge, the first thing that's done is that the device itself is mapped, then the upstream bridge device is mapped (secbus with devfn=0). This is where the command is failing for the device that I'm trying to forward. So, the question is, why can't Xen seem to forward through the bridge itself? It doesn't seem to matter whether I have that particular bridge listed on the kernel line in the pciback.hide section - Xen still thinks that dom0 has a hold of that device and won't forward it on.

Where do I go from here?

-Nick

--------
This e-mail may contain confidential and privileged material for the sole use of the intended recipient. If this email is not intended for you, or you are not responsible for the delivery of this message to the intended recipient, please note that this message may contain SEAKR Engineering (SEAKR) Privileged/Proprietary Information. In such a case, you are strictly prohibited from downloading, photocopying, distributing or otherwise using this message, its contents or attachments in any way. If you have received this message in error, please notify us immediately by replying to this e-mail and delete the message from your mailbox. Information contained in this message that does not relate to the business of SEAKR is neither endorsed by nor attributable to SEAKR.

#8 lore raw
In reply to Konrad Rzeszutek Wilk
Quoted 19 lines · Konrad Rzeszutek Wilk
Quoted 17 lines · Nick Couchman
Quoted 15 lines · Konrad Rzeszutek Wilk
Quoted 13 lines · Nick Couchman
Quoted 6 lines · Konrad Rzeszutek Wilk

What do you see on your Xen serial output? I presume you cranked up logging:
loglevel=all guest_lvl=all iommu=verbose on your Xen command line.

Is there anything that shows up when you get the 'Failed to assign.." ?

The only messages I get on the serial console after setting those parameters on the xen.gz kernel line in grub (and rebooting, of course) are the following:

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

(XEN) [VT-D]iommu.c:1496: d0:PCI: unmap bdf = 2:0.0
(XEN) [VT-D]iommu.c:1364: d1:PCI: map bdf = 2:0.0
(XEN) domctl.c:848:d0 XEN_DOMCTL_assign_device: assign device (2:0.0) failed
(XEN) event_channel.c:192:d0 EVTCHNOP failure: domain 1, error -22

Nick,

I think the issue is 02:00.0 was mapped twice. Could you try with below patch? Then post the xen log. Pls post all output of 'lspci -v' on your system.

xen/drivers/passthrough/vtd/iommu.c Wed Oct 27 14:33:23 2010 +0800 renamed from xen/drivers/passthrough/vtd/iommu.c Wed Sep 01 11:23:49 2010 +0100 +7 -1
diff -r eff592364826 xen/drivers/passthrough/vtd/iommu.c
@@ -1225,7 +1225,11 @@ static int domain_context_mapping_one(
        if (!pdev)
            res = -ENODEV;
        else if (pdev->domain != domain)
-            res = -EINVAL;
+        {
+            dprintk(VTDPREFIX, "context_present: %x:%x.%x: pdev->domain=%d domain=%d\n",
+                    bus, PCI_SLOT(devfn), PCI_FUNC(devfn), pdev->domain, domain->domain_id);
+        //    res = -EINVAL;
+        }
        unmap_vtd_domain_page(context_entries);
        spin_unlock(&iommu->lock);
        return res;
@@ -1352,6 +1356,8 @@ static int domain_context_mapping(struct
        /* PCIe to PCI/PCIx bridge */
        if ( pdev_type(bus, devfn) == DEV_TYPE_PCIe2PCI_BRIDGE )
        {
+            dprintk(VTDPREFIX, "d%d:PCI: map PCIe2PCI bdf = %x:%x.%x\n",
+                    domain->domain_id, bus, PCI_SLOT(devfn), PCI_FUNC(devfn));
            ret = domain_context_mapping_one(domain, drhd->iommu, bus, 

devfn);
if ( ret )
return ret;
@@ -1362,6 +1368,8 @@ static int domain_context_mapping(struct
* on the secondary bus behind the bridge. Map that id
* as well.
*/
+ dprintk(VTDPREFIX, "d%d:PCI: map secbus (%d) with devfn 0\n",

+                    domain->domain_id, secbus);
            ret = domain_context_mapping_one(domain, drhd->iommu, 

secbus, 0);
}
else /* Legacy PCI bridge */

Quoted 14 lines
Quoted 10 lines
Quoted 5 lines

So, -EINVAL. How comfortable are you sticking a bunch of dprintk(VTDPREFIX, " in the drivers/passthrough/vtd/iommu.c file? Basically you need to figure which of the functions that are past line 1364 are being called and return -EINVAL.

I'm happy to give it a shot...it'll take a while to get the devel environment configured, as I'm using packages right now and I don't even think I have a compiler on this system. I'll report back once I get that done and give that a try.

Excellent. You might also want to CC Weidong ([email protected]) in the future who is right now on travel and he might have better suggestions. CC-ing him on this e-mail.

#9 lore raw
Quoted 6 lines

Nick,

I think the issue is 02:00.0 was mapped twice. Could you try with below patch? Then post the xen log. Pls post all output of 'lspci -v' on your system.

I applied the patch, with one minor change. The line:

dprintk(XENLOG_ERR VTDPREFIX, "context_present: %x:%x.%x:pdev->domain=%d domain=%d\n", bus, PCI_SLOT(devfn), PCI_FUNC(devfn), pdev->domain, domain->domain_id);

should be:

dprintk(XENLOG_ERR VTDPREFIX, "context_present: %x:%x.%x:pdev->domain=%d domain=%d\n", bus, PCI_SLOT(devfn), PCI_FUNC(devfn), pdev->domain->domain_id, domain->domain_id);

(notice the pdev->domain->domain_id instead of pdev->domain).

The domU no longer generates the error about failing to assign device to IOMMU, but now it just silently crashes. xm dmesg output:

(XEN) [VT-D]iommu.c:1511: d0:PCI: unmap bdf = 2:0.0
(XEN) [VT-D]iommu.c:1340: bus: 2, devfn: 0[VT-D]iommu.c:1368: d1:PCI:
map bdf = 2:0.0
(XEN) [VT-D]iommu.c:1371: domain_conext_mapping_one ret: 0 (XEN) [VT-D]iommu.c:1378: Upstream bridge for 1:0 is 2. (XEN) [VT-D]iommu.c:1383: d1:PCI: map PCIe2PCI bdf = 1:0.0 (XEN) [VT-D]iommu.c:1394: d1:PCI: map secbus (2) with devfn 0 (XEN) [VT-D]iommu.c:1249: context_present: 2:0.0:pdev->domain=0 domain=1 (XEN) [VT-D]iommu.c:1415: Return value: 0
(XEN) [VT-D]io.c:300: d1: bind: m_gsi=16 g_gsi=36 device=5 intx=0 (XEN) [VT-D]iommu.c:1511: d0:PCI: unmap bdf = 2:0.1
(XEN) [VT-D]iommu.c:1340: bus: 2, devfn: 1[VT-D]iommu.c:1368: d1:PCI:
map bdf = 2:0.1
(XEN) [VT-D]iommu.c:1371: domain_conext_mapping_one ret: 0 (XEN) [VT-D]iommu.c:1378: Upstream bridge for 1:0 is 2. (XEN) [VT-D]iommu.c:1383: d1:PCI: map PCIe2PCI bdf = 1:0.0 (XEN) [VT-D]iommu.c:1394: d1:PCI: map secbus (2) with devfn 0 (XEN) [VT-D]iommu.c:1415: Return value: 0
(XEN) [VT-D]io.c:300: d1: bind: m_gsi=16 g_gsi=40 device=6 intx=0 (XEN) [VT-D]iommu.c:1511: d1:PCI: unmap bdf = 2:0.1
(XEN) [VT-D]iommu.c:1340: bus: 2, devfn: 1[VT-D]iommu.c:1368: d0:PCI:
map bdf = 2:0.1
(XEN) [VT-D]iommu.c:1371: domain_conext_mapping_one ret: 0 (XEN) [VT-D]iommu.c:1378: Upstream bridge for 1:0 is 2. (XEN) [VT-D]iommu.c:1383: d0:PCI: map PCIe2PCI bdf = 1:0.0 (XEN) [VT-D]iommu.c:1394: d0:PCI: map secbus (2) with devfn 0 (XEN) [VT-D]iommu.c:1415: Return value: 0
(XEN) [VT-D]iommu.c:1511: d1:PCI: unmap bdf = 2:0.0
(XEN) [VT-D]iommu.c:1340: bus: 2, devfn: 0[VT-D]iommu.c:1368: d0:PCI:
map bdf = 2:0.0
(XEN) [VT-D]iommu.c:1371: domain_conext_mapping_one ret: 0 (XEN) [VT-D]iommu.c:1378: Upstream bridge for 1:0 is 2. (XEN) [VT-D]iommu.c:1383: d0:PCI: map PCIe2PCI bdf = 1:0.0 (XEN) [VT-D]iommu.c:1394: d0:PCI: map secbus (2) with devfn 0 (XEN) [VT-D]iommu.c:1249: context_present: 2:0.0:pdev->domain=1 domain=0 (XEN) [VT-D]iommu.c:1415: Return value: 0

And from xend.log I've pasted into this pastebin:

http://pastebin.com/b4bwdBPq

I have some extra dprintk calls that I threw in there, so there may be a little more output than with the patch you sent.

-Nick

--------
This e-mail may contain confidential and privileged material for the sole use of the intended recipient. If this email is not intended for you, or you are not responsible for the delivery of this message to the intended recipient, please note that this message may contain SEAKR Engineering (SEAKR) Privileged/Proprietary Information. In such a case, you are strictly prohibited from downloading, photocopying, distributing or otherwise using this message, its contents or attachments in any way. If you have received this message in error, please notify us immediately by replying to this e-mail and delete the message from your mailbox. Information contained in this message that does not relate to the business of SEAKR is neither endorsed by nor attributable to SEAKR.

#10 lore raw
Quoted 60 lines · Nick Couchman
Quoted 5 lines

Nick,

I think the issue is 02:00.0 was mapped twice. Could you try with below patch? Then post the xen log. Pls post all output of 'lspci -v' on your system.

I applied the patch, with one minor change. The line:

dprintk(XENLOG_ERR VTDPREFIX, "context_present: %x:%x.%x:pdev->domain=%d domain=%d\n", bus, PCI_SLOT(devfn), PCI_FUNC(devfn), pdev->domain, domain->domain_id);

should be:

dprintk(XENLOG_ERR VTDPREFIX, "context_present: %x:%x.%x:pdev->domain=%d domain=%d\n", bus, PCI_SLOT(devfn), PCI_FUNC(devfn), pdev->domain->domain_id, domain->domain_id);

(notice the pdev->domain->domain_id instead of pdev->domain).

The domU no longer generates the error about failing to assign device to IOMMU, but now it just silently crashes. xm dmesg output:

(XEN) [VT-D]iommu.c:1511: d0:PCI: unmap bdf = 2:0.0
(XEN) [VT-D]iommu.c:1340: bus: 2, devfn: 0[VT-D]iommu.c:1368: d1:PCI:
map bdf = 2:0.0
(XEN) [VT-D]iommu.c:1371: domain_conext_mapping_one ret: 0 (XEN) [VT-D]iommu.c:1378: Upstream bridge for 1:0 is 2. (XEN) [VT-D]iommu.c:1383: d1:PCI: map PCIe2PCI bdf = 1:0.0 (XEN) [VT-D]iommu.c:1394: d1:PCI: map secbus (2) with devfn 0 (XEN) [VT-D]iommu.c:1249: context_present: 2:0.0:pdev->domain=0 domain=1 (XEN) [VT-D]iommu.c:1415: Return value: 0
(XEN) [VT-D]io.c:300: d1: bind: m_gsi=16 g_gsi=36 device=5 intx=0 (XEN) [VT-D]iommu.c:1511: d0:PCI: unmap bdf = 2:0.1
(XEN) [VT-D]iommu.c:1340: bus: 2, devfn: 1[VT-D]iommu.c:1368: d1:PCI:
map bdf = 2:0.1
(XEN) [VT-D]iommu.c:1371: domain_conext_mapping_one ret: 0 (XEN) [VT-D]iommu.c:1378: Upstream bridge for 1:0 is 2. (XEN) [VT-D]iommu.c:1383: d1:PCI: map PCIe2PCI bdf = 1:0.0 (XEN) [VT-D]iommu.c:1394: d1:PCI: map secbus (2) with devfn 0 (XEN) [VT-D]iommu.c:1415: Return value: 0
(XEN) [VT-D]io.c:300: d1: bind: m_gsi=16 g_gsi=40 device=6 intx=0 (XEN) [VT-D]iommu.c:1511: d1:PCI: unmap bdf = 2:0.1
(XEN) [VT-D]iommu.c:1340: bus: 2, devfn: 1[VT-D]iommu.c:1368: d0:PCI:
map bdf = 2:0.1
(XEN) [VT-D]iommu.c:1371: domain_conext_mapping_one ret: 0 (XEN) [VT-D]iommu.c:1378: Upstream bridge for 1:0 is 2. (XEN) [VT-D]iommu.c:1383: d0:PCI: map PCIe2PCI bdf = 1:0.0 (XEN) [VT-D]iommu.c:1394: d0:PCI: map secbus (2) with devfn 0 (XEN) [VT-D]iommu.c:1415: Return value: 0
(XEN) [VT-D]iommu.c:1511: d1:PCI: unmap bdf = 2:0.0
(XEN) [VT-D]iommu.c:1340: bus: 2, devfn: 0[VT-D]iommu.c:1368: d0:PCI:
map bdf = 2:0.0
(XEN) [VT-D]iommu.c:1371: domain_conext_mapping_one ret: 0 (XEN) [VT-D]iommu.c:1378: Upstream bridge for 1:0 is 2. (XEN) [VT-D]iommu.c:1383: d0:PCI: map PCIe2PCI bdf = 1:0.0 (XEN) [VT-D]iommu.c:1394: d0:PCI: map secbus (2) with devfn 0 (XEN) [VT-D]iommu.c:1249: context_present: 2:0.0:pdev->domain=1 domain=0 (XEN) [VT-D]iommu.c:1415: Return value: 0

Quoted 9 lines

And from xend.log I've pasted into this pastebin:

http://pastebin.com/b4bwdBPq

I have some extra dprintk calls that I threw in there, so there may be a little more output than with the patch you sent.

the log of xm dmesg looks no problem. you'd better post complete log and lspci -v.

Regards,
Weidong