Dealing with non-existent BDF devices in VT-d and in the hardware.
Hey,
I am one of those lucky folks who had purchased a motherboard that has bugs.
I figured I would post this email as way for a starting point for some discussion on this - and perhaps have a similar as 'pci-phantom' way of instructing the hypervisor what to do with them.
The problem I am seeing is that this device:
08:03.0 FireWire (IEEE 1394): Texas Instruments TSB43AB22A IEEE-1394a-2000 Controller (PHY/Link) [iOHCI-Lynx]
Can't be passed in the guest. Or rather it can - but everytime the guest (or domain0) tries to access I see:
(XEN) [VT-D]iommu.c:885: iommu_fault_status: Fault Overflow
(XEN) [VT-D]iommu.c:887: iommu_fault_status: Primary Pending Fault
(XEN) [VT-D]iommu.c:865: DMAR:[DMA Write] Request device [0000:08:00.0] fault addr 0, iommu reg = ffff82c3ffd53000 (XEN) DMAR:[fault reason 02h] Present bit in context entry is clear
(XEN) print_vtd_entries: iommu ffff83043dca99b0 dev 0000:08:00.0 gmfn 0
(XEN) root_entry = ffff83043dc6b000 (XEN) root_entry[8] = 3326b5001 (XEN) context = ffff8303326b5000 (XEN) context[0] = 0_0 (XEN) ctxt_entry[0] not present
Of course the '08:00.0' device does not exist. It is rather this chipset:
07:00.0 PCI bridge: Tundra Semiconductor Corp. Device 8113 (rev 01)
that is buggy and using the wrong BDF when forwarding DMA requests from devices underneath it (like this Firewire chip).
The hack I came up with was to create in the Xen code that deals with PCI passthrough a copy of the bridge (so 07:00.0) but with a new
BDF: 08:00.0. And link it to the PCI device that I am passing to the guest (so 08:03.0).
The end result is that when loading the driver (hack.c) one should see:
(XEN) 0000:08:00.0 linked with 08:03.0 (XEN) [VT-D]iommu.c:1456: d0:PCI: map 0000:08:00.0 (XEN) [VT-D]iommu.c:1476: d0:PCI: map 0000:08:03.0 (XEN) PCI add link 0000:08:00.0
And when launching a guest with the BDF:
pci = ["08:03.0"]
the hypervisor will automatically also create an VT-d context for the 08:00.0 device.
To use this hack, apply the 0001-xen-pci-Introduce-a-way-to-deal-with-buggy-hardware-.patch to your hypervisor, compile and install.
And also compile the 'hack.c' module. There is an attached 'Makefile' that will do it for you. Make sure you edit it to set the right BDF entries in it.
Once done install your new hypervisor, and insmod ./hack.ko and try passing in the device to your guest (or use it normally). The 'DMAR:[DMA Write]' error should go away.
This should be generic enough for most devices. It needn't be a bridge that is spewing out these DMAR errors.
Quoted 1 line
From
cb165429726978952f5b9e75bece1dcb5630667fMon Sep 17 00:00:00 2001
From: Konrad Rzeszutek Wilk <[email protected]>
Date: Wed, 19 Feb 2014 10:58:19 -0500
Subject: [PATCH] xen/pci: Introduce a way to deal with buggy hardware with
"hidden" PCI buses.
--- xen/arch/x86/physdev.c | 14 +++++- xen/drivers/passthrough/pci.c | 89 +++++++++++++++++++++++++++++++++---- xen/drivers/passthrough/vtd/iommu.c | 31 +++++++++++++ xen/include/public/physdev.h | 1 + xen/include/xen/pci.h | 3 ++ 5 files changed, 128 insertions(+), 10 deletions(-)
xen/arch/x86/physdev.c +13 -1
@@ -609,7 +609,11 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)if (copy_from_guest (&add, arg,1 ) !=0 )break ; - pdev_info.is_extfn = !!(add.flags &XEN_PCI_DEV_EXTFN ); +if ( add.flags &XEN_PCI_DEV_EXTFN ) + pdev_info.is_extfn =1 ; +else + pdev_info.is_extfn =0 ; +if ( add.flags &XEN_PCI_DEV_VIRTFN ) { pdev_info.is_virtfn =1 ;
@@ -618,6 +622,14 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) }else pdev_info.is_virtfn =0 ; + +if ( add.flags &XEN_PCI_DEV_LINK ) + { + pdev_info.is_link =1 ; + pdev_info.physfn.bus = add.physfn.bus; + pdev_info.physfn.devfn = add.physfn.devfn; + }else + pdev_info.is_link =0 ; ret =pci_add_device (add.seg, add.bus, add.devfn, &pdev_info);break ; }
xen/drivers/passthrough/pci.c +80 -9
170 lines not on this page · raw message
xen/drivers/passthrough/vtd/iommu.c +31 -0
@@ -1468,6 +1468,25 @@ static int domain_context_mapping(if ( ret )break ; +if ( pdev->link ) + { +u8 bus_link, devfn_link; +struct pci_dev *link_dev = pdev->link; + +ASSERT ( link_dev ); + + bus_link = link_dev->bus; + devfn_link = link_dev->devfn; + +if ( iommu_verbose ) +dprintk (VTDPREFIX ,"d%d:PCI: map %04x:%02x:%02x.%u\n" , + domain->domain_id, seg, bus_link, +PCI_SLOT (devfn_link),PCI_FUNC (devfn_link)); + + + ret =domain_context_mapping_one (domain, drhd->iommu, bus_link, devfn_link, +pci_get_pdev (seg, bus, devfn)); + }if (find_upstream_bridge (seg, &bus, &devfn, &secbus) <1 )break ;
@@ -1603,6 +1622,18 @@ static int domain_context_unmap(if ( ret )break ; +if ( pdev->link ) + { +struct pci_dev *link = pdev->link; + +ASSERT (link->link == pdev); + tmp_bus = link->bus; + tmp_devfn = link->devfn; +if ( iommu_verbose ) +dprintk (VTDPREFIX ,"d%d:PCI: unmap %04x:%02x:%02x.%u\n" , + domain->domain_id, seg, tmp_bus,PCI_SLOT (tmp_devfn),PCI_FUNC (tmp_devfn)); + ret =domain_context_unmap_one (domain, iommu, tmp_bus, tmp_devfn); + } tmp_bus = bus; tmp_devfn = devfn;if (find_upstream_bridge (seg, &tmp_bus, &tmp_devfn, &secbus) <1 )
xen/include/public/physdev.h +1 -0
@@ -281,6 +281,7 @@ DEFINE_XEN_GUEST_HANDLE(physdev_pci_mmcfg_reserved_t);#define XEN_PCI_DEV_EXTFN 0x1#define XEN_PCI_DEV_VIRTFN 0x2#define XEN_PCI_DEV_PXM 0x4 +#define XEN_PCI_DEV_LINK 0x8#define PHYSDEVOP_pci_device_add 25struct physdev_pci_device_add {
xen/include/xen/pci.h +3 -0
@@ -39,6 +39,7 @@ struct pci_dev_info {u8 bus;u8 devfn; } physfn; +bool_t is_link; };struct pci_dev {
@@ -75,6 +76,8 @@ struct pci_dev {#define PT_FAULT_THRESHOLD 10 } fault;u64 vf_rlen[6 ]; + +struct pci_dev *link; };#define for_each_pdev (domain, pdev) \
Signature · 1 line
1.8.5.3
#include <linux/module.h>
#include <linux/string.h>
#include <linux/types.h>
#include <linux/init.h>
#include <linux/stat.h>
#include <linux/err.h>
#include <linux/ctype.h>
#include <linux/slab.h>
#include <linux/limits.h>
#include <linux/device.h>
#include <linux/pci.h>
#include <linux/device.h>
#include <linux/pci.h>
#include <xen/interface/xen.h>
#include <xen/interface/physdev.h>
#include <asm/xen/hypervisor.h>
#include <asm/xen/hypercall.h>
#define LSI_HACK "0.1"
MODULE_AUTHOR("Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>"); MODULE_DESCRIPTION("lsi hack");MODULE_LICENSE("GPL");MODULE_VERSION(LSI_HACK);
/* Want to link to the device passed in the guest */ int bus = 8;module_param(bus, int, 0644); MODULE_PARM_DESC(bus, "bus");
int slot = 3;module_param(slot, int, 0644); MODULE_PARM_DESC(slot, "slot");
int func = 0;module_param(func, int, 0644); MODULE_PARM_DESC(func, "slot");
#define XEN_PCI_DEV_LINK 0x8
static int __init lsi_hack_init(void)
{
int r = 0;
struct physdev_pci_device_add add = {
.seg = 0,
.bus = 0x8, /* The phantom bridge */
.devfn = PCI_DEVFN(0,0), /* And its slot and function */
.physfn.bus = bus, /* The device we want to link too. */
.physfn.devfn = PCI_DEVFN(slot,func),
.flags = XEN_PCI_DEV_LINK,
};
printk("%s: %02x:%02x.%u, %02x:%02x.%u, %x\n",
__func__, add.bus, PCI_SLOT(add.devfn),
PCI_FUNC(add.devfn), add.physfn.bus,
PCI_SLOT(add.physfn.devfn), PCI_FUNC(add.physfn.devfn),
add.flags);
r = HYPERVISOR_physdev_op(PHYSDEVOP_pci_device_add, &add);
return r;
}static void __exit lsi_hack_exit(void)
{
int r = 0;
struct physdev_manage_pci manage_pci;
manage_pci.bus = 0x7;
manage_pci.devfn = PCI_DEVFN(0,0);
r = HYPERVISOR_physdev_op(PHYSDEVOP_manage_pci_remove,
&manage_pci);
if (r)
printk(KERN_ERR "%s: %d\n", __FUNCTION__, r);
}module_init(lsi_hack_init);module_exit(lsi_hack_exit);
# Comment/uncomment the following line to disable/enable debugging #DEBUG = y
# Add your debugging flag (or not) to CFLAGS ifeq ($(DEBUG),y)
DEBFLAGS = -O -g # "-O" is needed to expand inlines
else
DEBFLAGS = -O2
endif
EXTRA_CFLAGS += $(DEBFLAGS) -I$(LDDINCDIR)
ifneq ($(KERNELRELEASE),)
# call from kernel build system
obj-m := hack.o
else
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
default:
$(MAKE) -C $(KERNELDIR) M=$(PWD) LDDINCDIR=$(PWD)/../include modules
endif
clean:
rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions
depend .depend dep:
$(CC) $(CFLAGS) -M *.c > .depend
ifeq (.depend,$(wildcard .depend))
include .depend
endif
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 3 lines · Konrad Rzeszutek Wilk
Hey,
I am one of those lucky folks who had purchased a motherboard that has bugs.
You say this as if you expect someone has managed to find a bugfree motherboard :)
Quoted 56 lines
I figured I would post this email as way for a starting point for some discussion on this - and perhaps have a similar as 'pci-phantom' way of instructing the hypervisor what to do with them.
The problem I am seeing is that this device:
08:03.0 FireWire (IEEE 1394): Texas Instruments TSB43AB22A IEEE-1394a-2000 Controller (PHY/Link) [iOHCI-Lynx]
Can't be passed in the guest. Or rather it can - but everytime the guest (or domain0) tries to access I see:
(XEN) [VT-D]iommu.c:885:
iommu_fault_status: Fault Overflow
(XEN) [VT-D]iommu.c:887:iommu_fault_status: Primary Pending Fault
(XEN) [VT-D]iommu.c:865: DMAR:[DMA Write] Request device [0000:08:00.0] fault addr 0, iommu reg =ffff82c3ffd53000(XEN) DMAR:[fault reason 02h] Present bit in context entry is clear
(XEN)print_vtd_entries: iommuffff83043dca99b0dev 0000:08:00.0 gmfn 0(XEN) root_entry = ffff83043dc6b000 (XEN) root_entry[8] = 3326b5001 (XEN) context = ffff8303326b5000 (XEN) context[0] = 0_0 (XEN) ctxt_entry[0] not presentOf course the '08:00.0' device does not exist. It is rather this chipset:
07:00.0 PCI bridge: Tundra Semiconductor Corp. Device 8113 (rev 01)that is buggy and using the wrong BDF when forwarding DMA requests from devices underneath it (like this Firewire chip).
The hack I came up with was to create in the Xen code that deals with PCI passthrough a copy of the bridge (so 07:00.0) but with a new
BDF: 08:00.0. And link it to the PCI device that I am passing to the guest (so 08:03.0).The end result is that when loading the driver (
hack.c) one should see:(XEN) 0000:08:00.0 linked with 08:03.0 (XEN) [VT-D]iommu.c:1456: d0:PCI: map 0000:08:00.0 (XEN) [VT-D]iommu.c:1476: d0:PCI: map 0000:08:03.0 (XEN) PCI add link 0000:08:00.0
And when launching a guest with the BDF:
pci = ["08:03.0"]the hypervisor will automatically also create an VT-d context for the 08:00.0 device.
To use this hack, apply the 0001-xen-pci-Introduce-a-way-to-deal-with-buggy-hardware-.patch to your hypervisor, compile and install.
And also compile the '
hack.c' module. There is an attached 'Makefile' that will do it for you. Make sure you edit it to set the right BDF entries in it.
Quoted 6 lines
Once done install your new hypervisor, and insmod ./hack.ko and try passing in the device to your guest (or use it normally). The 'DMAR:[DMA Write]' error should go away.
This should be generic enough for most devices. It needn't be a bridge that is spewing out these DMAR errors.
Do you have an lspci -tv for the system?
It is genuinely the case that the bridge doesn't exist, or simply that it is not correctly attributed in the DMAR table?
If the latter, it Xen can probably gain some DMAR[$FOO]=$BAR command line workarounds similar to the IVRS ones for AMD systems.
~Andrew
Quoted 7 lines · Andrew Cooper
Quoted 3 lines · Konrad Rzeszutek Wilk
Hey,
I am one of those lucky folks who had purchased a motherboard that has bugs.
You say this as if you expect someone has managed to find a bugfree motherboard :)
One can dream :-)
Quoted 61 lines
Quoted 61 lines
I figured I would post this email as way for a starting point for some discussion on this - and perhaps have a similar as 'pci-phantom' way of instructing the hypervisor what to do with them.
The problem I am seeing is that this device:
08:03.0 FireWire (IEEE 1394): Texas Instruments TSB43AB22A IEEE-1394a-2000 Controller (PHY/Link) [iOHCI-Lynx]
Can't be passed in the guest. Or rather it can - but everytime the guest (or domain0) tries to access I see:
(XEN) [VT-D]iommu.c:885:
iommu_fault_status: Fault Overflow
(XEN) [VT-D]iommu.c:887:iommu_fault_status: Primary Pending Fault
(XEN) [VT-D]iommu.c:865: DMAR:[DMA Write] Request device [0000:08:00.0] fault addr 0, iommu reg =ffff82c3ffd53000(XEN) DMAR:[fault reason 02h] Present bit in context entry is clear
(XEN)print_vtd_entries: iommuffff83043dca99b0dev 0000:08:00.0 gmfn 0(XEN) root_entry = ffff83043dc6b000 (XEN) root_entry[8] = 3326b5001 (XEN) context = ffff8303326b5000 (XEN) context[0] = 0_0 (XEN) ctxt_entry[0] not presentOf course the '08:00.0' device does not exist. It is rather this chipset:
07:00.0 PCI bridge: Tundra Semiconductor Corp. Device 8113 (rev 01)that is buggy and using the wrong BDF when forwarding DMA requests from devices underneath it (like this Firewire chip).
The hack I came up with was to create in the Xen code that deals with PCI passthrough a copy of the bridge (so 07:00.0) but with a new
BDF: 08:00.0. And link it to the PCI device that I am passing to the guest (so 08:03.0).The end result is that when loading the driver (
hack.c) one should see:(XEN) 0000:08:00.0 linked with 08:03.0 (XEN) [VT-D]iommu.c:1456: d0:PCI: map 0000:08:00.0 (XEN) [VT-D]iommu.c:1476: d0:PCI: map 0000:08:03.0 (XEN) PCI add link 0000:08:00.0
And when launching a guest with the BDF:
pci = ["08:03.0"]the hypervisor will automatically also create an VT-d context for the 08:00.0 device.
To use this hack, apply the 0001-xen-pci-Introduce-a-way-to-deal-with-buggy-hardware-.patch to your hypervisor, compile and install.
And also compile the '
hack.c' module. There is an attached 'Makefile' that will do it for you. Make sure you edit it to set the right BDF entries in it.Once done install your new hypervisor, and insmod ./hack.ko and try passing in the device to your guest (or use it normally). The 'DMAR:[DMA Write]' error should go away.
Quoted 5 lines
Quoted 2 lines
This should be generic enough for most devices. It needn't be a bridge that is spewing out these DMAR errors.
Do you have an lspci -tv for the system?
Yes of course:
-[0000:00]-+-00.0 Intel Corporation Xeon E3-1200 v3 Processor DRAM Controller
+-01.0-[01]--+-00.0 Intel Corporation 82576 Gigabit Network Connection
| \-00.1 Intel Corporation 82576 Gigabit Network Connection
+-01.1-[02]----00.0 LSI Logic / Symbios Logic SAS2008 PCI-Express Fusion-MPT SAS-2 [Falcon]
+-02.0 Intel Corporation Xeon E3-1200 v3 Processor Integrated Graphics Controller
+-03.0 Intel Corporation Xeon E3-1200 v3/4th Gen Core Processor HD Audio Controller
+-14.0 Intel Corporation 8 Series/C220 Series Chipset Family USB xHCI
+-16.0 Intel Corporation 8 Series/C220 Series Chipset Family MEI Controller #1
+-19.0 Intel Corporation Ethernet Connection I217-LM
+-1a.0 Intel Corporation 8 Series/C220 Series Chipset Family USB EHCI #2
+-1b.0 Intel Corporation 8 Series/C220 Series Chipset High Definition Audio Controller
+-1c.0-[03]----00.0 Intel Corporation 82574L Gigabit Network Connection
+-1c.1-[04]----00.0 Intel Corporation 82574L Gigabit Network Connection
+-1c.3-[05]----00.0 Intel Corporation I210 Gigabit Network Connection
+-1c.4-[06]--+-00.0 Intel Corporation 82571EB Gigabit Ethernet Controller
| \-00.1 Intel Corporation 82571EB Gigabit Ethernet Controller
+-1c.5-[07-09]----00.0-[08-09]--+-01.0-[09]--+-08.0 Brooktree Corporation Bt878 Video Capture
| | +-08.1 Brooktree Corporation Bt878 Audio Capture
| | +-09.0 Brooktree Corporation Bt878 Video Capture
| | +-09.1 Brooktree Corporation Bt878 Audio Capture
| | +-0a.0 Brooktree Corporation Bt878 Video Capture
| | +-0a.1 Brooktree Corporation Bt878 Audio Capture
| | +-0b.0 Brooktree Corporation Bt878 Video Capture
| | \-0b.1 Brooktree Corporation Bt878 Audio Capture
| \-03.0 Texas Instruments TSB43AB22A IEEE-1394a-2000 Controller (PHY/Link) [iOHCI-Lynx]
+-1c.6-[0a]----00.0 Renesas Technology Corp. uPD720202 USB 3.0 Host Controller
+-1c.7-[0b]----00.0 ASMedia Technology Inc. ASM1062 Serial ATA Controller
+-1d.0 Intel Corporation 8 Series/C220 Series Chipset Family USB EHCI #1
+-1f.0 Intel Corporation C226 Series Chipset Family Server Advanced SKU LPC Controller
+-1f.2 Intel Corporation 8 Series/C220 Series Chipset Family 6-port SATA Controller 1 [AHCI mode]
+-1f.3 Intel Corporation 8 Series/C220 Series Chipset Family SMBus Controller
\-1f.6 Intel Corporation 8 Series Chipset Family Thermal Management ControllerQuoted 3 lines
It is genuinely the case that the bridge doesn't exist, or simply that it is not correctly attributed in the DMAR table?
It does not exist. The DMAR looks correct.
(XEN) [VT-D]dmar.c:778: Host address width 39
(XEN) [VT-D]dmar.c:792: found ACPI_DMAR_DRHD:
(XEN) [VT-D]dmar.c:472: dmaru->address = fed90000
(XEN) [VT-D]iommu.c:1158: drhd->address = fed90000 iommu->reg = ffff82c3ffd54000 (XEN) [VT-D]iommu.c:1160: cap = c0000020660462 ecap = f0101a
(XEN) [VT-D]dmar.c:383: endpoint: 0000:00:02.0
(XEN) [VT-D]dmar.c:792: found ACPI_DMAR_DRHD:
(XEN) [VT-D]dmar.c:472: dmaru->address = fed91000
(XEN) [VT-D]iommu.c:1158: drhd->address = fed91000 iommu->reg = ffff82c3ffd53000 (XEN) [VT-D]iommu.c:1160: cap = d2008020660462 ecap = f010da
(XEN) [VT-D]dmar.c:397: IOAPIC: 0000:f0:1f.0
(XEN) [VT-D]dmar.c:361: MSI HPET: 0000:f0:0f.0
(XEN) [VT-D]dmar.c:486: flags: INCLUDE_ALL
(XEN) [VT-D]dmar.c:797: found ACPI_DMAR_RMRR:
(XEN) [VT-D]dmar.c:383: endpoint: 0000:00:1d.0 (XEN) [VT-D]dmar.c:383: endpoint: 0000:00:1a.0 (XEN) [VT-D]dmar.c:383: endpoint: 0000:00:14.0
(XEN) [VT-D]dmar.c:666: RMRR region: base_addr b7530000 end_address b753cfff
(XEN) [VT-D]dmar.c:797: found ACPI_DMAR_RMRR:
(XEN) [VT-D]dmar.c:383: endpoint: 0000:00:02.0
(XEN) [VT-D]dmar.c:666: RMRR region: base_addr bc000000 end_address be1fffff
As it has the INCLUDE_ALL flag.
Quoted 5 lines
If the latter, it Xen can probably gain some DMAR[$FOO]=$BAR command line workarounds similar to the IVRS ones for AMD systems.
~Andrew
Quoted 4 lines
Quoted 1 line
Quoted 1 line · Konrad Rzeszutek Wilk
To use this hack, apply the 0001-xen-pci-Introduce-a-way-to-deal-with-buggy-hardware-.patch to your hypervisor, compile and install.
I'm still rather hesitant to consider such a pretty involved workaround for general inclusion. Did you investigate whether leveraging the grouping functionality (iommu_get_device_group()) might be possible instead? We're talking about a legacy PCI bridge after all, and if done that way also covering the AMD IOMMU case might be more straightforward (after all that case is missing from your already large patch).
While looking over this, I found that this only has a use in xend - another xl deficiency? And only for checking purposes, rather than to enforce the assignment of all (non-bridge?) devices in the group...
Jan
Quoted 5 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · Konrad Rzeszutek Wilk
To use this hack, apply the 0001-xen-pci-Introduce-a-way-to-deal-with-buggy-hardware-.patch to your hypervisor, compile and install.
Quoted 7 lines
I'm still rather hesitant to consider such a pretty involved workaround for general inclusion. Did you investigate whether leveraging the grouping functionality (
iommu_get_device_group()) might be possible instead? We're talking about a legacy PCI bridge after all, and if done that way also covering the AMD IOMMU case might be more straightforward (after all that case is missing from your already large patch).
<nods>
I think other people have experienced other non-bridge issues. I have CC-ed Gordan on this as he had a LSI card that was misbehaving.
I am curious to see what his lspci and lspci -vt looks for his culprit.
Quoted 3 lines
While looking over this, I found that this only has a use in xend - another xl deficiency? And only for checking purposes, rather
Gosh.
Quoted 5 lines
than to enforce the assignment of all (non-bridge?) devices in the group...
Jan
Quoted 14 lines · Konrad Rzeszutek Wilk
Quoted 5 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · Konrad Rzeszutek Wilk
To use this hack, apply the 0001-xen-pci-Introduce-a-way-to-deal-with-buggy-hardware-.patch to your hypervisor, compile and install.
Quoted 7 lines
I'm still rather hesitant to consider such a pretty involved workaround for general inclusion. Did you investigate whether leveraging the grouping functionality (
iommu_get_device_group()) might be possible instead? We're talking about a legacy PCI bridge after all, and if done that way also covering the AMD IOMMU case might be more straightforward (after all that case is missing from your already large patch).
Quoted 4 lines
<nods>
I think other people have experienced other non-bridge issues. I have CC-ed Gordan on this as he had a LSI card that was misbehaving.
Not one but two different LSI 8-port SAS cards, and an Adaptec 16-port SAS card. As far as I can tell this is related to the cards not being native PCIe but being bridged. The very latest LSI cards are native PCIe and don't seem to suffer from the same problem (I only did 5 minutes of testing with a borrowed recent LSI card, but the problem is very obvious (disks don't show up!), so I'm quite confident the problem doesn't manifest on the new one.
Quoted 1 line
I am curious to see what his lspci and lspci -vt looks for his culprit.
I'll try to put this together in a few days when I have the test machine set up.
Quoted 4 lines
Quoted 2 lines
While looking over this, I found that this only has a use in xend - another xl deficiency? And only for checking purposes, rather
Gosh.
That could make it rather difficult to test with latest 4.4.x code...
Gordan
Konrad Rzeszutek Wilk wrote on 2014-03-12:
Quoted 137 lines · Andrew Cooper
Quoted 4 lines · Konrad Rzeszutek Wilk
Quoted 3 lines
Hey,
I am one of those lucky folks who had purchased a motherboard that has
bugs.
Quoted 3 lines
You say this as if you expect someone has managed to find a bugfree motherboard :)
One can dream :-)
Quoted 66 lines
Quoted 66 lines
I figured I would post this email as way for a starting point for some discussion on this - and perhaps have a similar as 'pci-phantom' way of instructing the hypervisor what to do with them.
The problem I am seeing is that this device:
08:03.0 FireWire (IEEE 1394): Texas Instruments TSB43AB22A IEEE-1394a-2000 Controller (PHY/Link) [iOHCI-Lynx]
Can't be passed in the guest. Or rather it can - but everytime the guest (or domain0) tries to access I see:
(XEN) [VT-D]iommu.c:885:
iommu_fault_status: Fault Overflow (XEN) [VT-D]iommu.c:887:iommu_fault_status: Primary Pending Fault (XEN) [VT-D]iommu.c:865: DMAR:[DMA Write] Request device [0000:08:00.0] fault addr 0, iommu reg =ffff82c3ffd53000(XEN) DMAR:[fault reason 02h] Present bit in context entry is clear (XEN)print_vtd_entries: iommuffff83043dca99b0dev 0000:08:00.0 gmfn 0(XEN) root_entry = ffff83043dc6b000 (XEN) root_entry[8] = 3326b5001 (XEN) context = ffff8303326b5000 (XEN) context[0] = 0_0 (XEN) ctxt_entry[0] not presentOf course the '08:00.0' device does not exist. It is rather this chipset:
07:00.0 PCI bridge: Tundra Semiconductor Corp. Device 8113 (rev 01)that is buggy and using the wrong BDF when forwarding DMA requests from devices underneath it (like this Firewire chip).
The hack I came up with was to create in the Xen code that deals with PCI passthrough a copy of the bridge (so 07:00.0) but with a new
BDF: 08:00.0. And link it to the PCI device that I am passing to the guest (so 08:03.0).The end result is that when loading the driver (
hack.c) one should see:(XEN) 0000:08:00.0 linked with 08:03.0 (XEN) [VT-D]iommu.c:1456: d0:PCI: map 0000:08:00.0 (XEN) [VT-D]iommu.c:1476: d0:PCI: map 0000:08:03.0 (XEN) PCI add link 0000:08:00.0
And when launching a guest with the BDF:
pci = ["08:03.0"]the hypervisor will automatically also create an VT-d context for the
08:00.0 device.To use this hack, apply the 0001-xen-pci-Introduce-a-way-to-deal-with-buggy-hardware-.patch to your hypervisor, compile and install.
And also compile the '
hack.c' module. There is an attached 'Makefile' that will do it for you. Make sure you edit it to set the right BDF entries in it.Once done install your new hypervisor, and insmod ./hack.ko and try passing in the device to your guest (or use it normally). The 'DMAR:[DMA Write]' error should go away.
Quoted 5 lines
Quoted 2 lines
This should be generic enough for most devices. It needn't be a bridge that is spewing out these DMAR errors.
Do you have an lspci -tv for the system?
Yes of course:
-[0000:00]-+-00.0 Intel Corporation Xeon E3-1200 v3 Processor DRAM Controller
+-01.0-[01]--+-00.0 Intel Corporation 82576 Gigabit Network Connection | \-00.1 Intel Corporation 82576 Gigabit Network Connection +-01.1-[02]----00.0 LSI Logic / Symbios Logic SAS2008 PCI-Express Fusion-MPT SAS-2 [Falcon] +-02.0 Intel Corporation Xeon E3-1200 v3 Processor Integrated Graphics Controller +-03.0 Intel Corporation Xeon E3-1200 v3/4th Gen CoreProcessor HD Audio Controller
+-14.0 Intel Corporation 8 Series/C220 Series Chipset Family
USB xHCI
+-16.0 Intel Corporation 8 Series/C220 Series Chipset Family
MEI Controller #1+-19.0 Intel Corporation Ethernet Connection I217-LM +-1a.0 Intel Corporation 8 Series/C220 Series Chipset Family USB EHCI #2 +-1b.0 Intel Corporation 8 Series/C220 Series Chipset High Definition Audio Controller +-1c.0-[03]----00.0 Intel Corporation 82574L Gigabit Network Connection +-1c.1-[04]----00.0 Intel Corporation 82574L Gigabit Network Connection +-1c.3-[05]----00.0 Intel Corporation I210 Gigabit Network Connection +-1c.4-[06]--+-00.0 Intel Corporation 82571EB Gigabit Ethernet Controller | \-00.1 Intel Corporation 82571EB Gigabit Ethernet Controller +-1c.5-[07-09]----00.0-[08-09]--+-01.0-[09]--+-08.0 BrooktreeCorporation Bt878 Video Capture
| | +-08.1
Brooktree Corporation Bt878 Audio Capture
| | +-09.0
Brooktree Corporation Bt878 Video Capture
| | +-09.1
Brooktree Corporation Bt878 Audio Capture
| | +-0a.0
Brooktree Corporation Bt878 Video Capture
| | +-0a.1
Brooktree Corporation Bt878 Audio Capture
| | +-0b.0
Brooktree Corporation Bt878 Video Capture
| | \-0b.1
Brooktree Corporation Bt878 Audio Capture
| \-03.0 Texas
Instruments TSB43AB22A IEEE-1394a-2000 Controller (PHY/Link) [iOHCI-Lynx]+-1c.6-[0a]----00.0 Renesas Technology Corp. uPD720202 USB 3.0 Host Controller +-1c.7-[0b]----00.0 ASMedia Technology Inc. ASM1062 Serial ATA
Quoted 12 lines
Controller
+-1d.0 Intel Corporation 8 Series/C220 Series Chipset Family
USB EHCI #1
+-1f.0 Intel Corporation C226 Series Chipset Family Server
Advanced SKU LPC Controller
+-1f.2 Intel Corporation 8 Series/C220 Series Chipset Family
6-port SATA Controller 1 [AHCI mode]
+-1f.3 Intel Corporation 8 Series/C220 Series Chipset Family
SMBus Controller
\-1f.6 Intel Corporation 8 Series Chipset Family Thermal
Management Controller
What happens if you assign the devices under bus 09 to another guest?
Is it better to add Xen command line to add such devices to a group and assign the whole group to a guest when trying to assign a device of the group to guest?
Quoted 40 lines
Quoted 3 lines
It is genuinely the case that the bridge doesn't exist, or simply that it is not correctly attributed in the DMAR table?
It does not exist. The DMAR looks correct.
(XEN) [VT-D]dmar.c:778: Host address width 39
(XEN) [VT-D]dmar.c:792: foundACPI_DMAR_DRHD:
(XEN) [VT-D]dmar.c:472:dmaru->address=fed90000
(XEN) [VT-D]iommu.c:1158:drhd->address=fed90000iommu->reg=ffff82c3ffd54000
(XEN) [VT-D]iommu.c:1160: cap =c0000020660462ecap = f0101a (XEN) [VT-D]dmar.c:383: endpoint: 0000:00:02.0
(XEN) [VT-D]dmar.c:792: foundACPI_DMAR_DRHD:
(XEN) [VT-D]dmar.c:472:dmaru->address=fed91000
(XEN) [VT-D]iommu.c:1158:drhd->address=fed91000iommu->reg=ffff82c3ffd53000
(XEN) [VT-D]iommu.c:1160: cap =d2008020660462ecap = f010da (XEN) [VT-D]dmar.c:397: IOAPIC: 0000:f0:1f.0
(XEN) [VT-D]dmar.c:361: MSI HPET: 0000:f0:0f.0
(XEN) [VT-D]dmar.c:486: flags:INCLUDE_ALL
(XEN) [VT-D]dmar.c:797: foundACPI_DMAR_RMRR:(XEN) [VT-D]dmar.c:383: endpoint: 0000:00:1d.0 (XEN) [VT-D]dmar.c:383: endpoint: 0000:00:1a.0 (XEN) [VT-D]dmar.c:383: endpoint: 0000:00:14.0(XEN) [VT-D]dmar.c:666: RMRR region:
base_addrb7530000end_addressb753cfff
(XEN) [VT-D]dmar.c:797: foundACPI_DMAR_RMRR:
(XEN) [VT-D]dmar.c:383: endpoint: 0000:00:02.0
(XEN) [VT-D]dmar.c:666: RMRR region:base_addrbc000000end_addressbe1fffffAs it has the
INCLUDE_ALLflag.Quoted 7 lines
If the latter, it Xen can probably gain some DMAR[$FOO]=$BAR command line workarounds similar to the IVRS ones for AMD systems.
Quoted 5 lines
Quoted 1 line
~Andrew>
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Best regards,
Yang
Quoted 151 lines · Yang Z
Konrad Rzeszutek Wilk wrote on 2014-03-12:
Quoted 137 lines · Andrew Cooper
Quoted 4 lines · Konrad Rzeszutek Wilk
Quoted 3 lines
Hey,
I am one of those lucky folks who had purchased a motherboard that has
bugs.
Quoted 3 lines
You say this as if you expect someone has managed to find a bugfree motherboard :)
One can dream :-)
Quoted 66 lines
Quoted 66 lines
I figured I would post this email as way for a starting point for some discussion on this - and perhaps have a similar as 'pci-phantom' way of instructing the hypervisor what to do with them.
The problem I am seeing is that this device:
08:03.0 FireWire (IEEE 1394): Texas Instruments TSB43AB22A IEEE-1394a-2000 Controller (PHY/Link) [iOHCI-Lynx]
Can't be passed in the guest. Or rather it can - but everytime the guest (or domain0) tries to access I see:
(XEN) [VT-D]iommu.c:885:
iommu_fault_status: Fault Overflow (XEN) [VT-D]iommu.c:887:iommu_fault_status: Primary Pending Fault (XEN) [VT-D]iommu.c:865: DMAR:[DMA Write] Request device [0000:08:00.0] fault addr 0, iommu reg =ffff82c3ffd53000(XEN) DMAR:[fault reason 02h] Present bit in context entry is clear (XEN)print_vtd_entries: iommuffff83043dca99b0dev 0000:08:00.0 gmfn 0(XEN) root_entry = ffff83043dc6b000 (XEN) root_entry[8] = 3326b5001 (XEN) context = ffff8303326b5000 (XEN) context[0] = 0_0 (XEN) ctxt_entry[0] not presentOf course the '08:00.0' device does not exist. It is rather this chipset:
07:00.0 PCI bridge: Tundra Semiconductor Corp. Device 8113 (rev 01)that is buggy and using the wrong BDF when forwarding DMA requests from devices underneath it (like this Firewire chip).
The hack I came up with was to create in the Xen code that deals with PCI passthrough a copy of the bridge (so 07:00.0) but with a new
BDF: 08:00.0. And link it to the PCI device that I am passing to the guest (so 08:03.0).The end result is that when loading the driver (
hack.c) one should see:(XEN) 0000:08:00.0 linked with 08:03.0 (XEN) [VT-D]iommu.c:1456: d0:PCI: map 0000:08:00.0 (XEN) [VT-D]iommu.c:1476: d0:PCI: map 0000:08:03.0 (XEN) PCI add link 0000:08:00.0
And when launching a guest with the BDF:
pci = ["08:03.0"]the hypervisor will automatically also create an VT-d context for the
08:00.0 device.To use this hack, apply the 0001-xen-pci-Introduce-a-way-to-deal-with-buggy-hardware-.patch to your hypervisor, compile and install.
And also compile the '
hack.c' module. There is an attached 'Makefile' that will do it for you. Make sure you edit it to set the right BDF entries in it.Once done install your new hypervisor, and insmod ./hack.ko and try passing in the device to your guest (or use it normally). The 'DMAR:[DMA Write]' error should go away.
Quoted 5 lines
Quoted 2 lines
This should be generic enough for most devices. It needn't be a bridge that is spewing out these DMAR errors.
Do you have an lspci -tv for the system?
Yes of course:
-[0000:00]-+-00.0 Intel Corporation Xeon E3-1200 v3 Processor DRAM Controller
+-01.0-[01]--+-00.0 Intel Corporation 82576 Gigabit Network Connection | \-00.1 Intel Corporation 82576 Gigabit Network Connection +-01.1-[02]----00.0 LSI Logic / Symbios Logic SAS2008 PCI-Express Fusion-MPT SAS-2 [Falcon] +-02.0 Intel Corporation Xeon E3-1200 v3 Processor Integrated Graphics Controller +-03.0 Intel Corporation Xeon E3-1200 v3/4th Gen CoreProcessor HD Audio Controller
+-14.0 Intel Corporation 8 Series/C220 Series Chipset Family
USB xHCI
+-16.0 Intel Corporation 8 Series/C220 Series Chipset Family
MEI Controller #1+-19.0 Intel Corporation Ethernet Connection I217-LM +-1a.0 Intel Corporation 8 Series/C220 Series Chipset Family USB EHCI #2 +-1b.0 Intel Corporation 8 Series/C220 Series Chipset High Definition Audio Controller +-1c.0-[03]----00.0 Intel Corporation 82574L Gigabit Network Connection +-1c.1-[04]----00.0 Intel Corporation 82574L Gigabit Network Connection +-1c.3-[05]----00.0 Intel Corporation I210 Gigabit Network Connection +-1c.4-[06]--+-00.0 Intel Corporation 82571EB Gigabit Ethernet Controller | \-00.1 Intel Corporation 82571EB Gigabit Ethernet Controller +-1c.5-[07-09]----00.0-[08-09]--+-01.0-[09]--+-08.0 BrooktreeCorporation Bt878 Video Capture
| | +-08.1
Brooktree Corporation Bt878 Audio Capture
| | +-09.0
Brooktree Corporation Bt878 Video Capture
| | +-09.1
Brooktree Corporation Bt878 Audio Capture
| | +-0a.0
Brooktree Corporation Bt878 Video Capture
| | +-0a.1
Brooktree Corporation Bt878 Audio Capture
| | +-0b.0
Brooktree Corporation Bt878 Video Capture
| | \-0b.1
Brooktree Corporation Bt878 Audio Capture
| \-03.0 Texas
Instruments TSB43AB22A IEEE-1394a-2000 Controller (PHY/Link) [iOHCI-Lynx]+-1c.6-[0a]----00.0 Renesas Technology Corp. uPD720202 USB 3.0 Host Controller +-1c.7-[0b]----00.0 ASMedia Technology Inc. ASM1062 Serial ATAQuoted 12 lines
Controller
+-1d.0 Intel Corporation 8 Series/C220 Series Chipset Family
USB EHCI #1
+-1f.0 Intel Corporation C226 Series Chipset Family Server
Advanced SKU LPC Controller
+-1f.2 Intel Corporation 8 Series/C220 Series Chipset Family
6-port SATA Controller 1 [AHCI mode]
+-1f.3 Intel Corporation 8 Series/C220 Series Chipset Family
SMBus Controller
\-1f.6 Intel Corporation 8 Series Chipset Family Thermal
Management Controller
Quoted 1 line
What happens if you assign the devices under bus 09 to another guest?
Hadn't tried that. I think it would all blow up as the the non-existent bridge is now assigned to one guest and the phantom DMA requests for the 09 would show up under the 08 device. I think I would corrupt the guest memory with random DMA writes.
Quoted 1 line
Is it better to add Xen command line to add such devices to a group and assign the whole group to a guest when trying to assign a device of the group to guest?
Or implement the group assigment in QEMU or libxl so that nobody tries doing it.
Quoted 52 lines
Quoted 41 lines
Quoted 4 lines
It is genuinely the case that the bridge doesn't exist, or simply that it is not correctly attributed in the DMAR table?
It does not exist. The DMAR looks correct.
(XEN) [VT-D]dmar.c:778: Host address width 39
(XEN) [VT-D]dmar.c:792: foundACPI_DMAR_DRHD:
(XEN) [VT-D]dmar.c:472:dmaru->address=fed90000
(XEN) [VT-D]iommu.c:1158:drhd->address=fed90000iommu->reg=ffff82c3ffd54000
(XEN) [VT-D]iommu.c:1160: cap =c0000020660462ecap = f0101a (XEN) [VT-D]dmar.c:383: endpoint: 0000:00:02.0
(XEN) [VT-D]dmar.c:792: foundACPI_DMAR_DRHD:
(XEN) [VT-D]dmar.c:472:dmaru->address=fed91000
(XEN) [VT-D]iommu.c:1158:drhd->address=fed91000iommu->reg=ffff82c3ffd53000
(XEN) [VT-D]iommu.c:1160: cap =d2008020660462ecap = f010da (XEN) [VT-D]dmar.c:397: IOAPIC: 0000:f0:1f.0
(XEN) [VT-D]dmar.c:361: MSI HPET: 0000:f0:0f.0
(XEN) [VT-D]dmar.c:486: flags:INCLUDE_ALL
(XEN) [VT-D]dmar.c:797: foundACPI_DMAR_RMRR:(XEN) [VT-D]dmar.c:383: endpoint: 0000:00:1d.0 (XEN) [VT-D]dmar.c:383: endpoint: 0000:00:1a.0 (XEN) [VT-D]dmar.c:383: endpoint: 0000:00:14.0(XEN) [VT-D]dmar.c:666: RMRR region:
base_addrb7530000end_addressb753cfff
(XEN) [VT-D]dmar.c:797: foundACPI_DMAR_RMRR:
(XEN) [VT-D]dmar.c:383: endpoint: 0000:00:02.0
(XEN) [VT-D]dmar.c:666: RMRR region:base_addrbc000000end_addressbe1fffffAs it has the
INCLUDE_ALLflag.Quoted 7 lines
If the latter, it Xen can probably gain some DMAR[$FOO]=$BAR command line workarounds similar to the IVRS ones for AMD systems.
Quoted 5 lines
Quoted 1 line
~Andrew>
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-develBest regards,
Yang
Konrad Rzeszutek Wilk wrote on 2014-03-15:
Quoted 9 lines
Quoted 2 lines
What happens if you assign the devices under bus 09 to another guest?
Hadn't tried that. I think it would all blow up as the the non-existent bridge is now assigned to one guest and the phantom DMA requests for the
09 would show up under the 08 device. I think I would corrupt the guest memory with random DMA writes.
Quoted 7 lines
Quoted 2 lines
Is it better to add Xen command line to add such devices to a group and
assign the whole group to a guest when trying to assign a device of the group to guest?
Or implement the group assigment in QEMU or libxl so that nobody tries doing it.
But I think user still need to tell which device is buggy manually and I don't think QEMU or libxl can do it.
Best regards,
Yang
Quoted 12 lines · Yang Z
Konrad Rzeszutek Wilk wrote on 2014-03-15:
Quoted 11 lines
Quoted 2 lines
What happens if you assign the devices under bus 09 to another guest?
Hadn't tried that. I think it would all blow up as the the non-existent bridge is now assigned to one guest and the phantom DMA requests for the
09 would show up under the 08 device. I think I would corrupt the guest memory with random DMA writes.Quoted 2 lines
Is it better to add Xen command line to add such devices to a group and
Quoted 7 lines
Quoted 5 lines
assign the whole group to a guest when trying to assign a device of the group to guest?
Or implement the group assigment in QEMU or libxl so that nobody tries doing it.
But I think user still need to tell which device is buggy manually and I don't think QEMU or libxl can do it.
I think there are two issues here:
a) Missing device assigments via groups. That should be done irregardless if the device / hardware is buggy.
b) Buggy devices like the IDT bridge that I see. That is a seperate issue - and we just discussion if we want to inject that in the VT-d (or AMD-VI) what would be the mechanism to do that.
Quoted 5 lines
Best regards,
Yang
Konrad Rzeszutek Wilk wrote on 2014-03-18:
Quoted 19 lines · Yang Z
Quoted 18 lines
Konrad Rzeszutek Wilk wrote on 2014-03-15:
Quoted 16 lines
Quoted 2 lines
What happens if you assign the devices under bus 09 to another guest?
Hadn't tried that. I think it would all blow up as the the non-existent bridge is now assigned to one guest and the phantom DMA requests for the
09 would show up under the 08 device. I think I would corrupt the guest memory with random DMA writes.Quoted 2 lines
Is it better to add Xen command line to add such devices to a group and
assign the whole group to a guest when trying to assign a device of the group to guest?
Or implement the group assigment in QEMU or libxl so that nobody tries doing it.
Quoted 9 lines
Quoted 2 lines
But I think user still need to tell which device is buggy manually and I don't
think QEMU or libxl can do it.
I think there are two issues here:
a) Missing device assigments via groups. That should be done irregardless if the device / hardware is buggy.
Yes, this is missing.
Quoted 3 lines
b) Buggy devices like the IDT bridge that I see. That is a seperate issue - and we just discussion if we want to inject that in the VT-d (or AMD-VI) what would be the mechanism to do that.
The question is that device 08:00.0 doesn't exist in your platform, you only saw the BDF in the DMA transaction. How can you add a non-exist device to a group?
Quoted 5 lines
Quoted 5 lines
Best regards,
Yang
Best regards,
Yang
Quoted 30 lines · Yang Z
Konrad Rzeszutek Wilk wrote on 2014-03-18:
Quoted 19 lines · Yang Z
Quoted 18 lines
Konrad Rzeszutek Wilk wrote on 2014-03-15:
Quoted 16 lines
Quoted 2 lines
What happens if you assign the devices under bus 09 to another guest?
Hadn't tried that. I think it would all blow up as the the non-existent bridge is now assigned to one guest and the phantom DMA requests for the
09 would show up under the 08 device. I think I would corrupt the guest memory with random DMA writes.Quoted 2 lines
Is it better to add Xen command line to add such devices to a group and
assign the whole group to a guest when trying to assign a device of the group to guest?
Or implement the group assigment in QEMU or libxl so that nobody tries doing it.
Quoted 9 lines
Quoted 2 lines
But I think user still need to tell which device is buggy manually and I don't
think QEMU or libxl can do it.
I think there are two issues here:
a) Missing device assigments via groups. That should be done irregardless if the device / hardware is buggy.
Quoted 7 lines
Yes, this is missing.
Quoted 3 lines
b) Buggy devices like the IDT bridge that I see. That is a seperate issue - and we just discussion if we want to inject that in the VT-d (or AMD-VI) what would be the mechanism to do that.
The question is that device 08:00.0 doesn't exist in your platform, you only saw the BDF in the DMA transaction. How can you add a non-exist device to a group?
Why do I need to add it to a group? The patch I posted (see first email in this thread) just made a fake PCI device in the Xen hypervisor. But I don't see libxl nor QEMU doing any group operations - so why are they required? If I just bundle all of the PCI devices underneath that bridge to the guest it should be OK, shouldn't it?
Quoted 11 lines
Quoted 6 lines
Quoted 6 lines
Best regards,
YangBest regards,
Yang
Quoted 21 lines
Quoted 1 line
Quoted 1 line · Konrad Rzeszutek Wilk
Quoted 11 lines · Yang Z
Konrad Rzeszutek Wilk wrote on 2014-03-18:
Quoted 6 lines · Yang Z
I think there are two issues here:
a) Missing device assigments via groups. That should be done irregardless if the device / hardware is buggy.
Yes, this is missing.
Quoted 1 line
b) Buggy devices like the IDT bridge that I see. That is a seperate issue -
and
Quoted 4 lines
Quoted 2 lines
we just discussion if we want to inject that in the VT-d (or AMD-VI) what would be the mechanism to do that.
The question is that device 08:00.0 doesn't exist in your platform, you only
saw the BDF in the DMA transaction. How can you add a non-exist device to a group?
Quoted 6 lines
Why do I need to add it to a group? The patch I posted (see first email in this thread)
just made a fake PCI device in the Xen hypervisor. But I don't see libxl nor QEMU doing any group operations - so why are they required? If I just bundle all of the PCI devices underneath that bridge to the guest it should be OK, shouldn't it?
It should. You're in trouble if (by mistake) you don't pass them all, and to avoid that is what the grouping seems to have been intended for. The fact that only xend used it (and even then only for checking rather to enforce the grouping) doesn't help it of course. But that grouping issue is orthogonal to your issue, it's just that the group assignment (if it were there) could take care of the assignment part of your issue - the create-a-fake-device part would remain.
Jan
Jan Beulich wrote on 2014-03-19:
Quoted 33 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
On 19.03.14 at 13:57, Konrad Rzeszutek Wilk
<[email protected]>Quoted 5 lines · wrote:
Quoted 4 lines · Yang Z
Konrad Rzeszutek Wilk wrote on 2014-03-18:
Quoted 3 lines · Yang Z
I think there are two issues here:
Quoted 10 lines
Quoted 7 lines
Quoted 2 lines
a) Missing device assigments via groups. That should be done irregardless if the device / hardware is buggy.
Yes, this is missing.
Quoted 2 lines
b) Buggy devices like the IDT bridge that I see. That is a seperate issue -
and
Quoted 2 lines
Quoted 2 lines
we just discussion if we want to inject that in the VT-d (or
AMD-VI)what
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
would be the mechanism to do that.
The question is that device 08:00.0 doesn't exist in your platform, you only
saw the BDF in the DMA transaction. How can you add a non-exist device to a group?
Quoted 6 lines
Why do I need to add it to a group? The patch I posted (see first email in this thread) just made a fake PCI device in the Xen hypervisor. But I don't see libxl nor QEMU doing any group operations
- so why are they required? If I just bundle all of the PCI devices underneath that bridge to the guest it should be OK, shouldn't it?
Quoted 6 lines
It should. You're in trouble if (by mistake) you don't pass them all,
and to avoid that is what the grouping seems to have been intended
for. The fact that only xend used it (and even then only for checking
rather to enforce the grouping) doesn't help it of course. But that
grouping issue is orthogonal to your issue, it's just that the group
assignment (if it were there) could take care of the assignment part of your issue - the create-a-fake-device part would remain.
fake a device is a solution. But I am thinking (maybe I am wrong) why not setup all VT-d entries under a bridge if passing a PCI device under a bridge. Because when passing a PCI device under a bridge, all devices under bridge should be assigned to the guest too. What current Xen dose is only set the entry which has device, so why not extend it to setup all entries? In this case, there is no user input is required.
Quoted 2 lines
Jan
Best regards,
Yang
Quoted 42 lines · Yang Z
Jan Beulich wrote on 2014-03-19:
Quoted 33 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
On 19.03.14 at 13:57, Konrad Rzeszutek Wilk
<[email protected]>Quoted 5 lines · wrote:
Quoted 4 lines · Yang Z
Konrad Rzeszutek Wilk wrote on 2014-03-18:
Quoted 3 lines · Yang Z
I think there are two issues here:
Quoted 10 lines
Quoted 7 lines
Quoted 2 lines
a) Missing device assigments via groups. That should be done irregardless if the device / hardware is buggy.
Yes, this is missing.
Quoted 2 lines
b) Buggy devices like the IDT bridge that I see. That is a seperate issue -
and
Quoted 2 lines
Quoted 2 lines
we just discussion if we want to inject that in the VT-d (or
AMD-VI)what
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
would be the mechanism to do that.
The question is that device 08:00.0 doesn't exist in your platform, you only
saw the BDF in the DMA transaction. How can you add a non-exist device to a group?
Quoted 6 lines
Why do I need to add it to a group? The patch I posted (see first email in this thread) just made a fake PCI device in the Xen hypervisor. But I don't see libxl nor QEMU doing any group operations
- so why are they required? If I just bundle all of the PCI devices underneath that bridge to the guest it should be OK, shouldn't it?Quoted 7 lines
It should. You're in trouble if (by mistake) you don't pass them all, and to avoid that is what the grouping seems to have been intended for. The fact that only xend used it (and even then only for checking rather to enforce the grouping) doesn't help it of course. But that grouping issue is orthogonal to your issue, it's just that the group assignment (if it were there) could take care of the assignment part of your issue - the create-a-fake-device part would remain.
Quoted 6 lines
fake a device is a solution. But I am thinking (maybe I am wrong) why not setup all VT-d entries under a bridge if passing a PCI device under a bridge. Because when passing a PCI device under a bridge, all devices under bridge should be assigned to the guest too. What current Xen dose is only set the entry which has device, so why not extend it to setup all entries? In this case, there is no user input is required.
I'm not sure if I'm reading this right, but you wouldn't necessarily be passing all devices under a particular bridge to guests (and certainly not necessarily to the same guest). You could have multiple levels of bridges to provide extra PCIe links. One obvious example is dual GPU cards where both GPUs are under a bridge, but you wouldn't necessarily be passing both devices to a guest (one might be the primary GPU for the host).
Gordan
Quoted 7 lines
Quoted 1 line
Quoted 1 line · Yang Z
fake a device is a solution. But I am thinking (maybe I am wrong) why not setup all VT-d entries under a bridge if passing a PCI device under a bridge. Because when passing a PCI device under a bridge, all devices under bridge should be assigned to the guest too. What current Xen dose is only set the entry which has device, so why not extend it to setup all entries? In this case, there is no user input is required.
You'd have to prove that this doesn't impact isolation/security. Just look at xend: It checks that all devices in a group are owned by pciback/pci-stub, but it doesn't enforce assignment of all of them. This might be intentional (namely for any intermediate bridges).
But yes, I think this would address Konrad's problem.
Jan
Quoted 9 lines
Quoted 1 line
Quoted 1 line · Gordan Bobic
Quoted 6 lines · Yang Z
fake a device is a solution. But I am thinking (maybe I am wrong) why not setup all VT-d entries under a bridge if passing a PCI device under a bridge. Because when passing a PCI device under a bridge, all devices under bridge should be assigned to the guest too. What current Xen dose is only set the entry which has device, so why not extend it to setup all entries? In this case, there is no user input is required.
Quoted 7 lines
I'm not sure if I'm reading this right, but you wouldn't necessarily be passing all devices under a particular bridge to guests (and certainly not necessarily to the same guest). You could have multiple levels of bridges to provide extra PCIe links. One obvious example is dual GPU cards where both GPUs are under a bridge, but you wouldn't necessarily be passing both devices to a guest (one might be the primary GPU for the host).
PCIe devices behind PCI bridges still need to be treated as PCI ones (i.e. not necessarily presenting their own IDs in transactions, due to the intermediate non-express bridge). And it's only the non-PCIe case we're talking about here - no problems of this kind are known for PCIe devices.
Jan
Jan Beulich wrote on 2014-03-20:
Quoted 9 lines
Quoted 7 lines
Quoted 1 line
Quoted 1 line · Yang Z
fake a device is a solution. But I am thinking (maybe I am wrong) why not setup all VT-d entries under a bridge if passing a PCI device under a bridge. Because when passing a PCI device under a bridge, all devices under bridge should be assigned to the guest too. What current Xen dose is only set the entry which has device, so why not extend it to setup all entries? In this case, there is no user input is required.
You'd have to prove that this doesn't impact isolation/security.
Yes, this need more deeply think.
BTW, do you see any potential issue with doing this?
Quoted 7 lines
Just look at xend: It checks that all devices in a group are owned by pciback/pci-stub, but it doesn't enforce assignment of all of them. This might be intentional (namely for any intermediate bridges).
But yes, I think this would address Konrad's problem.
Jan
Best regards,
Yang
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 24.03.14 at 03:37, <[email protected]> wrote:
Jan Beulich wrote on 2014-03-20:
Quoted 8 lines
Quoted 7 lines
Quoted 1 line
Quoted 1 line · Yang Z
fake a device is a solution. But I am thinking (maybe I am wrong) why not setup all VT-d entries under a bridge if passing a PCI device under a bridge. Because when passing a PCI device under a bridge, all devices under bridge should be assigned to the guest too. What current Xen dose is only set the entry which has device, so why not extend it to setup all entries? In this case, there is no user input is required.
Quoted 5 lines
Quoted 1 line
You'd have to prove that this doesn't impact isolation/security.
Yes, this need more deeply think.
BTW, do you see any potential issue with doing this?
Not a concrete one - I simply think that security/isolation guarantees are easier to validate if permissions for a guest are kept to the smallest possible set. So without full proof of the security of above concept I think we should accept the new behavior only as an opt-in (via command line or domain config option).
Jan