mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-05 16:53:55 -06:00
memory/iommu: QOM'fy IOMMU MemoryRegion
This defines new QOM object - IOMMUMemoryRegion - with MemoryRegion as a parent. This moves IOMMU-related fields from MR to IOMMU MR. However to avoid dymanic QOM casting in fast path (address_space_translate, etc), this adds an @is_iommu boolean flag to MR and provides new helper to do simple cast to IOMMU MR - memory_region_get_iommu. The flag is set in the instance init callback. This defines memory_region_is_iommu as memory_region_get_iommu()!=NULL. This switches MemoryRegion to IOMMUMemoryRegion in most places except the ones where MemoryRegion may be an alias. Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru> Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Message-Id: <20170711035620.4232-2-aik@ozlabs.ru> Acked-by: Cornelia Huck <cohuck@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
98fab4c163
commit
3df9d74806
20 changed files with 170 additions and 109 deletions
|
@ -972,9 +972,9 @@ static bool vtd_switch_address_space(VTDAddressSpace *as)
|
|||
/* Turn off first then on the other */
|
||||
if (use_iommu) {
|
||||
memory_region_set_enabled(&as->sys_alias, false);
|
||||
memory_region_set_enabled(&as->iommu, true);
|
||||
memory_region_set_enabled(MEMORY_REGION(&as->iommu), true);
|
||||
} else {
|
||||
memory_region_set_enabled(&as->iommu, false);
|
||||
memory_region_set_enabled(MEMORY_REGION(&as->iommu), false);
|
||||
memory_region_set_enabled(&as->sys_alias, true);
|
||||
}
|
||||
|
||||
|
@ -1366,7 +1366,7 @@ static void vtd_iotlb_domain_invalidate(IntelIOMMUState *s, uint16_t domain_id)
|
|||
static int vtd_page_invalidate_notify_hook(IOMMUTLBEntry *entry,
|
||||
void *private)
|
||||
{
|
||||
memory_region_notify_iommu((MemoryRegion *)private, *entry);
|
||||
memory_region_notify_iommu((IOMMUMemoryRegion *)private, *entry);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -2264,7 +2264,7 @@ static void vtd_mem_write(void *opaque, hwaddr addr,
|
|||
}
|
||||
}
|
||||
|
||||
static IOMMUTLBEntry vtd_iommu_translate(MemoryRegion *iommu, hwaddr addr,
|
||||
static IOMMUTLBEntry vtd_iommu_translate(IOMMUMemoryRegion *iommu, hwaddr addr,
|
||||
IOMMUAccessFlags flag)
|
||||
{
|
||||
VTDAddressSpace *vtd_as = container_of(iommu, VTDAddressSpace, iommu);
|
||||
|
@ -2303,7 +2303,7 @@ static IOMMUTLBEntry vtd_iommu_translate(MemoryRegion *iommu, hwaddr addr,
|
|||
return iotlb;
|
||||
}
|
||||
|
||||
static void vtd_iommu_notify_flag_changed(MemoryRegion *iommu,
|
||||
static void vtd_iommu_notify_flag_changed(IOMMUMemoryRegion *iommu,
|
||||
IOMMUNotifierFlag old,
|
||||
IOMMUNotifierFlag new)
|
||||
{
|
||||
|
@ -2736,7 +2736,8 @@ VTDAddressSpace *vtd_find_add_as(IntelIOMMUState *s, PCIBus *bus, int devfn)
|
|||
memory_region_add_subregion_overlap(&vtd_dev_as->root, 0,
|
||||
&vtd_dev_as->sys_alias, 1);
|
||||
memory_region_add_subregion_overlap(&vtd_dev_as->root, 0,
|
||||
&vtd_dev_as->iommu, 1);
|
||||
MEMORY_REGION(&vtd_dev_as->iommu),
|
||||
1);
|
||||
vtd_switch_address_space(vtd_dev_as);
|
||||
}
|
||||
return vtd_dev_as;
|
||||
|
@ -2816,9 +2817,9 @@ static int vtd_replay_hook(IOMMUTLBEntry *entry, void *private)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void vtd_iommu_replay(MemoryRegion *mr, IOMMUNotifier *n)
|
||||
static void vtd_iommu_replay(IOMMUMemoryRegion *iommu_mr, IOMMUNotifier *n)
|
||||
{
|
||||
VTDAddressSpace *vtd_as = container_of(mr, VTDAddressSpace, iommu);
|
||||
VTDAddressSpace *vtd_as = container_of(iommu_mr, VTDAddressSpace, iommu);
|
||||
IntelIOMMUState *s = vtd_as->iommu_state;
|
||||
uint8_t bus_n = pci_bus_num(vtd_as->bus);
|
||||
VTDContextEntry ce;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue