13ed34463SSteve Sistare /* 23ed34463SSteve Sistare * VFIO CPR 33ed34463SSteve Sistare * 43ed34463SSteve Sistare * Copyright (c) 2025 Oracle and/or its affiliates. 53ed34463SSteve Sistare * 63ed34463SSteve Sistare * SPDX-License-Identifier: GPL-2.0-or-later 73ed34463SSteve Sistare */ 83ed34463SSteve Sistare 93ed34463SSteve Sistare #ifndef HW_VFIO_VFIO_CPR_H 103ed34463SSteve Sistare #define HW_VFIO_VFIO_CPR_H 113ed34463SSteve Sistare 1254857b08SSteve Sistare #include "migration/misc.h" 13*eba1f657SSteve Sistare #include "system/memory.h" 1454857b08SSteve Sistare 1554857b08SSteve Sistare struct VFIOContainer; 163ed34463SSteve Sistare struct VFIOContainerBase; 17c29a65edSSteve Sistare struct VFIOGroup; 183ed34463SSteve Sistare 1954857b08SSteve Sistare typedef struct VFIOContainerCPR { 2054857b08SSteve Sistare Error *blocker; 21*eba1f657SSteve Sistare bool vaddr_unmapped; 22*eba1f657SSteve Sistare NotifierWithReturn transfer_notifier; 23*eba1f657SSteve Sistare MemoryListener remap_listener; 247e9f2141SSteve Sistare int (*saved_dma_map)(const struct VFIOContainerBase *bcontainer, 257e9f2141SSteve Sistare hwaddr iova, ram_addr_t size, 267e9f2141SSteve Sistare void *vaddr, bool readonly, MemoryRegion *mr); 2754857b08SSteve Sistare } VFIOContainerCPR; 2854857b08SSteve Sistare 29dac0dd68SSteve Sistare typedef struct VFIODeviceCPR { 30dac0dd68SSteve Sistare Error *mdev_blocker; 31dac0dd68SSteve Sistare } VFIODeviceCPR; 3254857b08SSteve Sistare 3354857b08SSteve Sistare bool vfio_legacy_cpr_register_container(struct VFIOContainer *container, 3454857b08SSteve Sistare Error **errp); 3554857b08SSteve Sistare void vfio_legacy_cpr_unregister_container(struct VFIOContainer *container); 3654857b08SSteve Sistare 3754857b08SSteve Sistare int vfio_cpr_reboot_notifier(NotifierWithReturn *notifier, MigrationEvent *e, 3854857b08SSteve Sistare Error **errp); 3954857b08SSteve Sistare 403ed34463SSteve Sistare bool vfio_cpr_register_container(struct VFIOContainerBase *bcontainer, 413ed34463SSteve Sistare Error **errp); 423ed34463SSteve Sistare void vfio_cpr_unregister_container(struct VFIOContainerBase *bcontainer); 433ed34463SSteve Sistare 44c29a65edSSteve Sistare int vfio_cpr_group_get_device_fd(int d, const char *name); 45c29a65edSSteve Sistare 46c29a65edSSteve Sistare bool vfio_cpr_container_match(struct VFIOContainer *container, 47c29a65edSSteve Sistare struct VFIOGroup *group, int fd); 48c29a65edSSteve Sistare 49*eba1f657SSteve Sistare void vfio_cpr_giommu_remap(struct VFIOContainerBase *bcontainer, 50*eba1f657SSteve Sistare MemoryRegionSection *section); 51*eba1f657SSteve Sistare 52*eba1f657SSteve Sistare bool vfio_cpr_ram_discard_register_listener( 53*eba1f657SSteve Sistare struct VFIOContainerBase *bcontainer, MemoryRegionSection *section); 54*eba1f657SSteve Sistare 553ed34463SSteve Sistare #endif /* HW_VFIO_VFIO_CPR_H */ 56