return 1ULL << tcet->page_shift;
}
+static void spapr_tce_notify_flag_changed(MemoryRegion *iommu,
+ IOMMUNotifierFlag old,
+ IOMMUNotifierFlag new)
+{
+ struct sPAPRTCETable *tbl = container_of(iommu, sPAPRTCETable, iommu);
+
+ if (old == IOMMU_NOTIFIER_NONE && new != IOMMU_NOTIFIER_NONE) {
+ spapr_tce_set_need_vfio(tbl, true);
+ } else if (old != IOMMU_NOTIFIER_NONE && new == IOMMU_NOTIFIER_NONE) {
+ spapr_tce_set_need_vfio(tbl, false);
+ }
+}
+
static int spapr_tce_table_post_load(void *opaque, int version_id)
{
sPAPRTCETable *tcet = SPAPR_TCE_TABLE(opaque);
static MemoryRegionIOMMUOps spapr_iommu_ops = {
.translate = spapr_tce_translate_iommu,
.get_min_page_size = spapr_tce_get_min_page_size,
+ .notify_flag_changed = spapr_tce_notify_flag_changed,
};
static int spapr_tce_table_realize(DeviceState *dev)
char tmp[32];
if (spapr_tce_find_by_liobn(liobn)) {
- fprintf(stderr, "Attempted to create TCE table with duplicate"
- " LIOBN 0x%x\n", liobn);
+ error_report("Attempted to create TCE table with duplicate"
+ " LIOBN 0x%x", liobn);
return NULL;
}
sPAPRTCETable *tcet = SPAPR_TCE_TABLE(dev);
size_t table_size = tcet->nb_table * sizeof(uint64_t);
- memset(tcet->table, 0, table_size);
+ if (tcet->nb_table) {
+ memset(tcet->table, 0, table_size);
+ }
}
static target_ulong put_tce_emu(sPAPRTCETable *tcet, target_ulong ioba,
dc->init = spapr_tce_table_realize;
dc->reset = spapr_tce_reset;
dc->unrealize = spapr_tce_table_unrealize;
+ /* Reason: This is just an internal device for handling the hypercalls */
+ dc->user_creatable = false;
QLIST_INIT(&spapr_tce_tables);