Lines Matching full:section
79 static bool vfio_listener_skipped_section(MemoryRegionSection *section) in vfio_listener_skipped_section() argument
81 return (!memory_region_is_ram(section->mr) && in vfio_listener_skipped_section()
82 !memory_region_is_iommu(section->mr)) || in vfio_listener_skipped_section()
83 memory_region_is_protected(section->mr) || in vfio_listener_skipped_section()
90 section->offset_within_address_space & (1ULL << 63); in vfio_listener_skipped_section()
201 MemoryRegionSection *section) in vfio_ram_discard_notify_discard() argument
206 const hwaddr size = int128_get64(section->size); in vfio_ram_discard_notify_discard()
207 const hwaddr iova = section->offset_within_address_space; in vfio_ram_discard_notify_discard()
219 MemoryRegionSection *section) in vfio_ram_discard_notify_populate() argument
224 const hwaddr end = section->offset_within_region + in vfio_ram_discard_notify_populate()
225 int128_get64(section->size); in vfio_ram_discard_notify_populate()
234 for (start = section->offset_within_region; start < end; start = next) { in vfio_ram_discard_notify_populate()
238 iova = start - section->offset_within_region + in vfio_ram_discard_notify_populate()
239 section->offset_within_address_space; in vfio_ram_discard_notify_populate()
240 vaddr = memory_region_get_ram_ptr(section->mr) + start; in vfio_ram_discard_notify_populate()
243 vaddr, section->readonly, section->mr); in vfio_ram_discard_notify_populate()
246 vfio_ram_discard_notify_discard(rdl, section); in vfio_ram_discard_notify_populate()
254 MemoryRegionSection *section) in vfio_ram_discard_register_listener() argument
256 RamDiscardManager *rdm = memory_region_get_ram_discard_manager(section->mr); in vfio_ram_discard_register_listener()
261 g_assert(QEMU_IS_ALIGNED(section->offset_within_region, target_page_size)); in vfio_ram_discard_register_listener()
262 g_assert(QEMU_IS_ALIGNED(section->offset_within_address_space, in vfio_ram_discard_register_listener()
264 g_assert(QEMU_IS_ALIGNED(int128_get64(section->size), target_page_size)); in vfio_ram_discard_register_listener()
268 vrdl->mr = section->mr; in vfio_ram_discard_register_listener()
269 vrdl->offset_within_address_space = section->offset_within_address_space; in vfio_ram_discard_register_listener()
270 vrdl->size = int128_get64(section->size); in vfio_ram_discard_register_listener()
272 section->mr); in vfio_ram_discard_register_listener()
281 ram_discard_manager_register_listener(rdm, &vrdl->listener, section); in vfio_ram_discard_register_listener()
287 * that each mapped section in the same address space as a RamDiscardManager in vfio_ram_discard_register_listener()
288 * section consumes exactly one DMA mapping, with the exception of in vfio_ram_discard_register_listener()
292 * We assume that each section in the address space consumes one memslot. in vfio_ram_discard_register_listener()
329 MemoryRegionSection *section) in vfio_ram_discard_unregister_listener() argument
331 RamDiscardManager *rdm = memory_region_get_ram_discard_manager(section->mr); in vfio_ram_discard_unregister_listener()
335 if (vrdl->mr == section->mr && in vfio_ram_discard_unregister_listener()
337 section->offset_within_address_space) { in vfio_ram_discard_unregister_listener()
351 static bool vfio_known_safe_misalignment(MemoryRegionSection *section) in vfio_known_safe_misalignment() argument
353 MemoryRegion *mr = section->mr; in vfio_known_safe_misalignment()
361 section->offset_within_address_space, in vfio_known_safe_misalignment()
362 section->offset_within_region, in vfio_known_safe_misalignment()
367 static bool vfio_listener_valid_section(MemoryRegionSection *section, in vfio_listener_valid_section() argument
370 if (vfio_listener_skipped_section(section)) { in vfio_listener_valid_section()
372 section->offset_within_address_space, in vfio_listener_valid_section()
373 section->offset_within_address_space + in vfio_listener_valid_section()
374 int128_get64(int128_sub(section->size, int128_one()))); in vfio_listener_valid_section()
378 if (unlikely((section->offset_within_address_space & in vfio_listener_valid_section()
380 (section->offset_within_region & ~qemu_real_host_page_mask()))) { in vfio_listener_valid_section()
381 if (!vfio_known_safe_misalignment(section)) { in vfio_listener_valid_section()
385 __func__, memory_region_name(section->mr), in vfio_listener_valid_section()
386 section->offset_within_address_space, in vfio_listener_valid_section()
387 section->offset_within_region, in vfio_listener_valid_section()
397 MemoryRegionSection *section, in vfio_get_section_iova_range() argument
404 iova = REAL_HOST_PAGE_ALIGN(section->offset_within_address_space); in vfio_get_section_iova_range()
405 llend = int128_make64(section->offset_within_address_space); in vfio_get_section_iova_range()
406 llend = int128_add(llend, section->size); in vfio_get_section_iova_range()
460 VFIOContainerBase *bcontainer, MemoryRegionSection *section) in vfio_find_ram_discard_listener() argument
465 if (vrdl->mr == section->mr && in vfio_find_ram_discard_listener()
467 section->offset_within_address_space) { in vfio_find_ram_discard_listener()
480 MemoryRegionSection *section) in vfio_listener_region_add() argument
490 if (!vfio_listener_valid_section(section, "region_add")) { in vfio_listener_region_add()
494 if (!vfio_get_section_iova_range(bcontainer, section, &iova, &end, in vfio_listener_region_add()
496 if (memory_region_is_ram_device(section->mr)) { in vfio_listener_region_add()
498 memory_region_name(section->mr), in vfio_listener_region_add()
499 section->offset_within_address_space, in vfio_listener_region_add()
500 int128_getlo(section->size), in vfio_listener_region_add()
507 if (!vfio_container_add_section_window(bcontainer, section, &err)) { in vfio_listener_region_add()
511 memory_region_ref(section->mr); in vfio_listener_region_add()
513 if (memory_region_is_iommu(section->mr)) { in vfio_listener_region_add()
515 IOMMUMemoryRegion *iommu_mr = IOMMU_MEMORY_REGION(section->mr); in vfio_listener_region_add()
518 trace_vfio_listener_region_add_iommu(section->mr->name, iova, end); in vfio_listener_region_add()
527 giommu->iommu_offset = section->offset_within_address_space - in vfio_listener_region_add()
528 section->offset_within_region; in vfio_listener_region_add()
530 llend = int128_add(int128_make64(section->offset_within_region), in vfio_listener_region_add()
531 section->size); in vfio_listener_region_add()
537 section->offset_within_region, in vfio_listener_region_add()
541 ret = memory_region_register_iommu_notifier(section->mr, &giommu->n, in vfio_listener_region_add()
553 /* Here we assume that memory_region_is_ram(section->mr)==true */ in vfio_listener_region_add()
560 if (memory_region_has_ram_discard_manager(section->mr)) { in vfio_listener_region_add()
561 vfio_ram_discard_register_listener(bcontainer, section); in vfio_listener_region_add()
565 vaddr = memory_region_get_ram_ptr(section->mr) + in vfio_listener_region_add()
566 section->offset_within_region + in vfio_listener_region_add()
567 (iova - section->offset_within_address_space); in vfio_listener_region_add()
573 if (memory_region_is_ram_device(section->mr)) { in vfio_listener_region_add()
578 memory_region_name(section->mr), in vfio_listener_region_add()
579 section->offset_within_address_space, in vfio_listener_region_add()
580 int128_getlo(section->size), in vfio_listener_region_add()
587 vaddr, section->readonly, section->mr); in vfio_listener_region_add()
594 if (memory_region_is_ram_device(section->mr)) { in vfio_listener_region_add()
597 vfio_get_vfio_device(memory_region_owner(section->mr)); in vfio_listener_region_add()
617 memory_region_name(section->mr)); in vfio_listener_region_add()
632 MemoryRegionSection *section) in vfio_listener_region_del() argument
641 if (!vfio_listener_valid_section(section, "region_del")) { in vfio_listener_region_del()
645 if (memory_region_is_iommu(section->mr)) { in vfio_listener_region_del()
648 trace_vfio_listener_region_del_iommu(section->mr->name); in vfio_listener_region_del()
650 if (MEMORY_REGION(giommu->iommu_mr) == section->mr && in vfio_listener_region_del()
651 giommu->n.start == section->offset_within_region) { in vfio_listener_region_del()
652 memory_region_unregister_iommu_notifier(section->mr, in vfio_listener_region_del()
669 if (!vfio_get_section_iova_range(bcontainer, section, &iova, &end, in vfio_listener_region_del()
678 if (memory_region_is_ram_device(section->mr)) { in vfio_listener_region_del()
683 } else if (memory_region_has_ram_discard_manager(section->mr)) { in vfio_listener_region_del()
684 vfio_ram_discard_unregister_listener(bcontainer, section); in vfio_listener_region_del()
706 memory_region_unref(section->mr); in vfio_listener_region_del()
709 vfio_container_del_section_window(bcontainer, section); in vfio_listener_region_del()
727 static bool vfio_section_is_vfio_pci(MemoryRegionSection *section, in vfio_section_is_vfio_pci() argument
734 owner = memory_region_owner(section->mr); in vfio_section_is_vfio_pci()
792 MemoryRegionSection *section) in vfio_dirty_tracking_update() argument
798 if (!vfio_listener_valid_section(section, "tracking_update") || in vfio_dirty_tracking_update()
799 !vfio_get_section_iova_range(dirty->bcontainer, section, in vfio_dirty_tracking_update()
805 vfio_section_is_vfio_pci(section, dirty->bcontainer)); in vfio_dirty_tracking_update()
1081 static int vfio_ram_discard_query_dirty_bitmap(MemoryRegionSection *section, in vfio_ram_discard_query_dirty_bitmap() argument
1084 const hwaddr size = int128_get64(section->size); in vfio_ram_discard_query_dirty_bitmap()
1085 const hwaddr iova = section->offset_within_address_space; in vfio_ram_discard_query_dirty_bitmap()
1086 const ram_addr_t ram_addr = memory_region_get_ram_addr(section->mr) + in vfio_ram_discard_query_dirty_bitmap()
1087 section->offset_within_region; in vfio_ram_discard_query_dirty_bitmap()
1106 MemoryRegionSection *section) in vfio_sync_ram_discard_listener_dirty_bitmap() argument
1108 RamDiscardManager *rdm = memory_region_get_ram_discard_manager(section->mr); in vfio_sync_ram_discard_listener_dirty_bitmap()
1110 vfio_find_ram_discard_listener(bcontainer, section); in vfio_sync_ram_discard_listener_dirty_bitmap()
1116 return ram_discard_manager_replay_populated(rdm, section, in vfio_sync_ram_discard_listener_dirty_bitmap()
1122 MemoryRegionSection *section) in vfio_sync_iommu_dirty_bitmap() argument
1131 if (MEMORY_REGION(giommu->iommu_mr) == section->mr && in vfio_sync_iommu_dirty_bitmap()
1132 giommu->n.start == section->offset_within_region) { in vfio_sync_iommu_dirty_bitmap()
1146 llend = int128_add(int128_make64(section->offset_within_region), in vfio_sync_iommu_dirty_bitmap()
1147 section->size); in vfio_sync_iommu_dirty_bitmap()
1151 section->offset_within_region, int128_get64(llend), in vfio_sync_iommu_dirty_bitmap()
1159 MemoryRegionSection *section, Error **errp) in vfio_sync_dirty_bitmap() argument
1163 if (memory_region_is_iommu(section->mr)) { in vfio_sync_dirty_bitmap()
1164 return vfio_sync_iommu_dirty_bitmap(bcontainer, section); in vfio_sync_dirty_bitmap()
1165 } else if (memory_region_has_ram_discard_manager(section->mr)) { in vfio_sync_dirty_bitmap()
1168 ret = vfio_sync_ram_discard_listener_dirty_bitmap(bcontainer, section); in vfio_sync_dirty_bitmap()
1176 ram_addr = memory_region_get_ram_addr(section->mr) + in vfio_sync_dirty_bitmap()
1177 section->offset_within_region; in vfio_sync_dirty_bitmap()
1180 REAL_HOST_PAGE_ALIGN(section->offset_within_address_space), in vfio_sync_dirty_bitmap()
1181 int128_get64(section->size), ram_addr, errp); in vfio_sync_dirty_bitmap()
1185 MemoryRegionSection *section) in vfio_listener_log_sync() argument
1192 if (vfio_listener_skipped_section(section)) { in vfio_listener_log_sync()
1197 ret = vfio_sync_dirty_bitmap(bcontainer, section, &local_err); in vfio_listener_log_sync()