Changeset View
Changeset View
Standalone View
Standalone View
head/sys/amd64/vmm/io/iommu.c
Show First 20 Lines • Show All 168 Lines • ▼ Show 20 Lines | iommu_pci_delete(void *arg, device_t dev) | ||||
iommu_remove_device(host_domain, pci_get_rid(dev)); | iommu_remove_device(host_domain, pci_get_rid(dev)); | ||||
} | } | ||||
static void | static void | ||||
iommu_init(void) | iommu_init(void) | ||||
{ | { | ||||
int error, bus, slot, func; | int error, bus, slot, func; | ||||
vm_paddr_t maxaddr; | vm_paddr_t maxaddr; | ||||
devclass_t dc; | |||||
device_t dev; | device_t dev; | ||||
if (!iommu_enable) | if (!iommu_enable) | ||||
return; | return; | ||||
if (vmm_is_intel()) | if (vmm_is_intel()) | ||||
ops = &iommu_ops_intel; | ops = &iommu_ops_intel; | ||||
else if (vmm_is_amd()) | else if (vmm_is_amd()) | ||||
Show All 24 Lines | iommu_init(void) | ||||
* Create 1:1 mappings from '0' to 'maxaddr' for devices assigned to | * Create 1:1 mappings from '0' to 'maxaddr' for devices assigned to | ||||
* the host | * the host | ||||
*/ | */ | ||||
iommu_create_mapping(host_domain, 0, 0, maxaddr); | iommu_create_mapping(host_domain, 0, 0, maxaddr); | ||||
add_tag = EVENTHANDLER_REGISTER(pci_add_device, iommu_pci_add, NULL, 0); | add_tag = EVENTHANDLER_REGISTER(pci_add_device, iommu_pci_add, NULL, 0); | ||||
delete_tag = EVENTHANDLER_REGISTER(pci_delete_device, iommu_pci_delete, | delete_tag = EVENTHANDLER_REGISTER(pci_delete_device, iommu_pci_delete, | ||||
NULL, 0); | NULL, 0); | ||||
dc = devclass_find("ppt"); | |||||
for (bus = 0; bus <= PCI_BUSMAX; bus++) { | for (bus = 0; bus <= PCI_BUSMAX; bus++) { | ||||
for (slot = 0; slot <= PCI_SLOTMAX; slot++) { | for (slot = 0; slot <= PCI_SLOTMAX; slot++) { | ||||
for (func = 0; func <= PCI_FUNCMAX; func++) { | for (func = 0; func <= PCI_FUNCMAX; func++) { | ||||
dev = pci_find_dbsf(0, bus, slot, func); | dev = pci_find_dbsf(0, bus, slot, func); | ||||
if (dev == NULL) | if (dev == NULL) | ||||
continue; | continue; | ||||
/* Everything belongs to the host domain. */ | /* Skip passthrough devices. */ | ||||
if (dc != NULL && | |||||
device_get_devclass(dev) == dc) | |||||
continue; | |||||
/* | |||||
* Everything else belongs to the host | |||||
* domain. | |||||
*/ | |||||
iommu_add_device(host_domain, | iommu_add_device(host_domain, | ||||
pci_get_rid(dev)); | pci_get_rid(dev)); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
IOMMU_ENABLE(); | IOMMU_ENABLE(); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 97 Lines • Show Last 20 Lines |