mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-07 09:43:56 -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
|
@ -110,7 +110,8 @@ static void spapr_tce_free_table(uint64_t *table, int fd, uint32_t nb_table)
|
|||
}
|
||||
|
||||
/* Called from RCU critical section */
|
||||
static IOMMUTLBEntry spapr_tce_translate_iommu(MemoryRegion *iommu, hwaddr addr,
|
||||
static IOMMUTLBEntry spapr_tce_translate_iommu(IOMMUMemoryRegion *iommu,
|
||||
hwaddr addr,
|
||||
IOMMUAccessFlags flag)
|
||||
{
|
||||
sPAPRTCETable *tcet = container_of(iommu, sPAPRTCETable, iommu);
|
||||
|
@ -150,14 +151,14 @@ static void spapr_tce_table_pre_save(void *opaque)
|
|||
tcet->bus_offset, tcet->page_shift);
|
||||
}
|
||||
|
||||
static uint64_t spapr_tce_get_min_page_size(MemoryRegion *iommu)
|
||||
static uint64_t spapr_tce_get_min_page_size(IOMMUMemoryRegion *iommu)
|
||||
{
|
||||
sPAPRTCETable *tcet = container_of(iommu, sPAPRTCETable, iommu);
|
||||
|
||||
return 1ULL << tcet->page_shift;
|
||||
}
|
||||
|
||||
static void spapr_tce_notify_flag_changed(MemoryRegion *iommu,
|
||||
static void spapr_tce_notify_flag_changed(IOMMUMemoryRegion *iommu,
|
||||
IOMMUNotifierFlag old,
|
||||
IOMMUNotifierFlag new)
|
||||
{
|
||||
|
@ -348,9 +349,10 @@ void spapr_tce_table_enable(sPAPRTCETable *tcet,
|
|||
&tcet->fd,
|
||||
tcet->need_vfio);
|
||||
|
||||
memory_region_set_size(&tcet->iommu,
|
||||
memory_region_set_size(MEMORY_REGION(&tcet->iommu),
|
||||
(uint64_t)tcet->nb_table << tcet->page_shift);
|
||||
memory_region_add_subregion(&tcet->root, tcet->bus_offset, &tcet->iommu);
|
||||
memory_region_add_subregion(&tcet->root, tcet->bus_offset,
|
||||
MEMORY_REGION(&tcet->iommu));
|
||||
}
|
||||
|
||||
void spapr_tce_table_disable(sPAPRTCETable *tcet)
|
||||
|
@ -359,8 +361,8 @@ void spapr_tce_table_disable(sPAPRTCETable *tcet)
|
|||
return;
|
||||
}
|
||||
|
||||
memory_region_del_subregion(&tcet->root, &tcet->iommu);
|
||||
memory_region_set_size(&tcet->iommu, 0);
|
||||
memory_region_del_subregion(&tcet->root, MEMORY_REGION(&tcet->iommu));
|
||||
memory_region_set_size(MEMORY_REGION(&tcet->iommu), 0);
|
||||
|
||||
spapr_tce_free_table(tcet->table, tcet->fd, tcet->nb_table);
|
||||
tcet->fd = -1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue