BUG();
}
/* Note: set drain read/write */
-#if 0
- /*
- * This is probably to be super secure.. Looks like we can
- * ignore it without any impact.
- */
if ( cap_read_drain(iommu->cap) )
val |= DMA_TLB_READ_DRAIN;
-#endif
if ( cap_write_drain(iommu->cap) )
val |= DMA_TLB_WRITE_DRAIN;
unsigned long flags;
if ( iommu == NULL )
+ {
gdprintk(XENLOG_ERR VTDPREFIX,
"iommu_set_root_entry: iommu == NULL\n");
+ return -EINVAL;
+ }
if ( unlikely(!iommu->root_entry) )
{
u32 type;
type = pdev_type(pdev);
- if ( type == DEV_TYPE_PCI_BRIDGE )
+ switch ( type )
{
+ case DEV_TYPE_PCI_BRIDGE:
sec_bus = read_pci_config_byte(
pdev->bus, PCI_SLOT(pdev->devfn),
PCI_FUNC(pdev->devfn), PCI_SECONDARY_BUS);
pdev->bus, PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn),
sec_bus, sub_bus);
}
- }
-
- if ( type == DEV_TYPE_PCIe_ENDPOINT )
- {
+ break;
+ case DEV_TYPE_PCIe_ENDPOINT:
gdprintk(XENLOG_INFO VTDPREFIX,
"domain_context_mapping:PCIe : bdf = %x:%x:%x\n",
pdev->bus, PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn));
ret = domain_context_mapping_one(domain, iommu,
- (u8)(pdev->bus), (u8) (pdev->devfn));
- }
-
- /* PCI devices */
- if ( type == DEV_TYPE_PCI )
- {
+ (u8)(pdev->bus), (u8)(pdev->devfn));
+ break;
+ case DEV_TYPE_PCI:
gdprintk(XENLOG_INFO VTDPREFIX,
"domain_context_mapping:PCI: bdf = %x:%x:%x\n",
pdev->bus, PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn));
if ( pdev->bus == 0 )
{
ret = domain_context_mapping_one(
- domain, iommu, (u8)(pdev->bus), (u8) (pdev->devfn));
+ domain, iommu, (u8)(pdev->bus), (u8)(pdev->devfn));
}
else
{
if ( bus2bridge[pdev->bus].bus != 0 )
gdprintk(XENLOG_ERR VTDPREFIX,
"domain_context_mapping:bus2bridge"
- "[pdev->bus].bus==0\n");
+ "[pdev->bus].bus != 0\n");
ret = domain_context_mapping_one(
domain, iommu,
}
}
}
+ break;
+ default:
+ gdprintk(XENLOG_ERR VTDPREFIX,
+ "domain_context_mapping:unknown type : bdf = %x:%x:%x\n",
+ pdev->bus, PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn));
+ ret = -EINVAL;
+ break;
}
return ret;
u32 type;
type = pdev_type(pdev);
- if ( type == DEV_TYPE_PCI_BRIDGE )
+ switch ( type )
{
+ case DEV_TYPE_PCI_BRIDGE:
sec_bus = read_pci_config_byte(
pdev->bus, PCI_SLOT(pdev->devfn),
PCI_FUNC(pdev->devfn), PCI_SECONDARY_BUS);
"sec_bus=%x sub_bus=%x\n",
pdev->bus, PCI_SLOT(pdev->devfn),
PCI_FUNC(pdev->devfn), sec_bus, sub_bus);
- }
-
- if ( type == DEV_TYPE_PCIe_ENDPOINT )
- {
+ break;
+ case DEV_TYPE_PCIe_ENDPOINT:
gdprintk(XENLOG_INFO VTDPREFIX,
"domain_context_unmap:PCIe : bdf = %x:%x:%x\n",
pdev->bus, PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn));
ret = domain_context_unmap_one(domain, iommu,
- (u8)(pdev->bus), (u8) (pdev->devfn));
- }
-
- /* PCI devices */
- if ( type == DEV_TYPE_PCI )
- {
+ (u8)(pdev->bus), (u8)(pdev->devfn));
+ break;
+ case DEV_TYPE_PCI:
gdprintk(XENLOG_INFO VTDPREFIX,
"domain_context_unmap:PCI: bdf = %x:%x:%x\n",
pdev->bus, PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn));
{
ret = domain_context_unmap_one(
domain, iommu,
- (u8)(pdev->bus), (u8) (pdev->devfn));
+ (u8)(pdev->bus), (u8)(pdev->devfn));
}
else
{
if ( bus2bridge[pdev->bus].bus != 0 )
gdprintk(XENLOG_INFO VTDPREFIX,
"domain_context_mapping:"
- "bus2bridge[pdev->bus].bus==0\n");
+ "bus2bridge[pdev->bus].bus != 0\n");
ret = domain_context_unmap_one(domain, iommu,
(u8)(bus2bridge[pdev->bus].bus),
}
}
}
+ break;
+ default:
+ gdprintk(XENLOG_ERR VTDPREFIX,
+ "domain_context_unmap:unknown type: bdf = %x:%x:%x\n",
+ pdev->bus, PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn));
+ ret = -EINVAL;
+ break;
}
return ret;
if ( pgd[0].val != 0 )
free_xenheap_page((void*)maddr_to_virt(
dma_pte_addr(pgd[0])));
+
+ free_xenheap_page((void *)hd->pgd);
}
break;
default:
iommu_flush_cache_entry(iommu, pte);
}
-int prepare_device(struct domain *domain, struct pci_dev dev)
-{
- return 0;
-}
-
static int iommu_prepare_rmrr_dev(
struct domain *d,
struct acpi_rmrr_unit *rmrr,