[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [v8][PATCH 17/17] xen/vtd: re-enable USB device assignment if enable pci_force
Before we refine RMRR mechanism, USB RMRR may conflict with guest bios region so we always ignore USB RMRR. Now this can be gone when we enable pci_force to check/reserve RMRR. Signed-off-by: Tiejun Chen <tiejun.chen@xxxxxxxxx> --- xen/drivers/passthrough/vtd/dmar.h | 1 + xen/drivers/passthrough/vtd/iommu.c | 12 ++++++++---- xen/drivers/passthrough/vtd/utils.c | 18 ++++++++++++++++++ 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/xen/drivers/passthrough/vtd/dmar.h b/xen/drivers/passthrough/vtd/dmar.h index a57c0d4..832dc32 100644 --- a/xen/drivers/passthrough/vtd/dmar.h +++ b/xen/drivers/passthrough/vtd/dmar.h @@ -132,6 +132,7 @@ do { \ int vtd_hw_check(void); void disable_pmr(struct iommu *iommu); int is_usb_device(u16 seg, u8 bus, u8 devfn); +int is_reserve_device_memory(struct domain *d, u8 bus, u8 devfn); int is_igd_drhd(struct acpi_drhd_unit *drhd); #endif /* _DMAR_H_ */ diff --git a/xen/drivers/passthrough/vtd/iommu.c b/xen/drivers/passthrough/vtd/iommu.c index ba40209..1f1ceb7 100644 --- a/xen/drivers/passthrough/vtd/iommu.c +++ b/xen/drivers/passthrough/vtd/iommu.c @@ -2264,9 +2264,11 @@ static int reassign_device_ownership( * remove it from the hardware domain, because BIOS may use RMRR at * booting time. Also account for the special casing of USB below (in * intel_iommu_assign_device()). + * But if we already check to reserve RMRR, this should be fine. */ if ( !is_hardware_domain(source) && - !is_usb_device(pdev->seg, pdev->bus, pdev->devfn) ) + !is_usb_device(pdev->seg, pdev->bus, pdev->devfn) && + !is_reserve_device_memory(source, pdev->bus, pdev->devfn) ) { const struct acpi_rmrr_unit *rmrr; u16 bdf; @@ -2315,12 +2317,14 @@ static int intel_iommu_assign_device( if ( ret ) return ret; - /* FIXME: Because USB RMRR conflicts with guest bios region, - * ignore USB RMRR temporarily. + /* + * Because USB RMRR conflicts with guest bios region, + * ignore USB RMRR temporarily in case of non-reserving-RMRR. */ seg = pdev->seg; bus = pdev->bus; - if ( is_usb_device(seg, bus, pdev->devfn) ) + if ( is_usb_device(seg, bus, pdev->devfn) && + !is_reserve_device_memory(d, bus, pdev->devfn) ) return 0; /* Setup rmrr identity mapping */ diff --git a/xen/drivers/passthrough/vtd/utils.c b/xen/drivers/passthrough/vtd/utils.c index a33564b..1045ac1 100644 --- a/xen/drivers/passthrough/vtd/utils.c +++ b/xen/drivers/passthrough/vtd/utils.c @@ -36,6 +36,24 @@ int is_usb_device(u16 seg, u8 bus, u8 devfn) return (class == 0xc03); } +int is_reserve_device_memory(struct domain *d, u8 bus, u8 devfn) +{ + int i = 0; + + if ( d->arch.hvm_domain.pci_force == PCI_DEV_RDM_CHECK ) + return 1; + + for ( i = 0; i < d->arch.hvm_domain.num_pcidevs; i++ ) + { + if ( d->arch.hvm_domain.pcidevs[i].bus == bus && + d->arch.hvm_domain.pcidevs[i].devfn == devfn && + d->arch.hvm_domain.pcidevs[i].flags == PCI_DEV_RDM_CHECK ) + return 1; + } + + return 0; +} + /* Disable vt-d protected memory registers. */ void disable_pmr(struct iommu *iommu) { -- 1.9.1 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |