... | ... | ||
---|---|---|---|
5 | devices, multifd support, etc. This adds up to the previous | 5 | devices, multifd support, etc. This adds up to the previous |
6 | extensions: vfio-platform, AP, CCW. The result is that VFIO is now a | 6 | extensions: vfio-platform, AP, CCW. The result is that VFIO is now a |
7 | subsystem of over +16,000 lines of code : | 7 | subsystem of over +16,000 lines of code : |
8 | 8 | ||
9 | QEMU 2.0 : 3988 total | 9 | QEMU 2.0 : 3988 total |
10 | QEMU 2.12 : 9336 total | 10 | ... |
11 | QEMU 6.2 : 12715 total | ||
12 | QEMU 8.2 : 13690 total | ||
13 | QEMU 9.2 : 15680 total | ||
14 | QEMU 10.0 : 16607 total | 11 | QEMU 10.0 : 16607 total |
15 | 12 | ||
16 | Organization is weak, naming inconsistent, the vfio-common.h header | 13 | Organization is weak, naming inconsistent, the vfio-common.h header |
17 | file and common.c are quite messy. It's time to address the technical | 14 | file and common.c are quite messy. It's time to address the technical |
18 | debt before adding new features. | 15 | debt before adding new features. |
... | ... | ||
21 | introduces new files and renames services to better reflect the | 18 | introduces new files and renames services to better reflect the |
22 | namespace they belong to. This is code reshuffling and there are no | 19 | namespace they belong to. This is code reshuffling and there are no |
23 | intentional functional changes. If more could be done, please propose ! | 20 | intentional functional changes. If more could be done, please propose ! |
24 | Timing seems right. | 21 | Timing seems right. |
25 | 22 | ||
23 | |||
24 | I have taken care to preserve all existing copyright notices in the | ||
25 | file headers. I have added one on behalf of my current employer for | ||
26 | newly created files. However, original authors may wish to include | ||
27 | their own notices as well. If so, please respond to the patch, and I | ||
28 | will update the patch in the next spin or before applying. | ||
29 | |||
30 | Here is a (short) list requiring your attention : | ||
31 | |||
32 | * include/hw/vfio/vfio-migration.h | ||
33 | * hw/vfio/vfio-migration-internal.h | ||
34 | Kirti Wankhede and Avihai Horon, NVIDIA | ||
35 | |||
36 | * hw/vfio/vfio-iommufd.h | ||
37 | Joao Martins and Yi Liu, Oracle and Intel | ||
38 | |||
39 | * include/hw/vfio/vfio-region.h | ||
40 | * hw/vfio/region.c | ||
41 | Eric Auger, may be we could reduce the list ? | ||
42 | |||
43 | * hw/vfio/vfio-cpr.h | ||
44 | Steve Sistare, Oracle | ||
45 | |||
46 | I think the remaining new files are correctly covered but I am human, | ||
47 | so please review and let me know. | ||
48 | |||
26 | I hope we can merge this when the QEMU 10.1 cycle starts and then | 49 | I hope we can merge this when the QEMU 10.1 cycle starts and then |
27 | address the two large series waiting : live update and vfio-user. | 50 | address the two large series waiting : live update and vfio-user. |
51 | |||
52 | |||
53 | What next in terms of cleanups : | ||
54 | |||
55 | - container.c is quite messy | ||
56 | - the pci* files need some love too (add vfio- prefix ?) | ||
57 | - improve overall documentation, structs and routines documentation | ||
58 | too would be great | ||
59 | - isolate all the low level routines (kvm ioctls) into helpers.c | ||
60 | to improve build ? | ||
61 | - improve build to reduce the number of files built per target | ||
62 | - continue the never ending quest of adding 'Error **' parameters, | ||
63 | Look for migration_file_set_error, in MemoryListener handlers : | ||
64 | vfio_listener_region_add | ||
65 | vfio_listener_log_global_stop | ||
66 | vfio_listener_log_sync | ||
67 | and in callback routines for IOMMU notifiers : | ||
68 | vfio_iommu_map_notify | ||
69 | vfio_iommu_map_dirty_notify | ||
70 | memory_region_iommu_replay() would be a start. | ||
71 | - remove vfio-platform (start of QEMU 10.2 cycle ~ September 2025) | ||
72 | |||
28 | 73 | ||
29 | Thanks, | 74 | Thanks, |
30 | 75 | ||
31 | C. | 76 | C. |
32 | 77 | ||
33 | Cédric Le Goater (32): | 78 | |
79 | Changes in v2: | ||
80 | |||
81 | - Dropped vfio_migration_set_error() | ||
82 | https://lore.kernel.org/qemu-devel/20250324123315.637827-1-clg@redhat.com/ | ||
83 | - Dropped R-b trailers on patches which were modified too much | ||
84 | (context changes are ok) | ||
85 | - Improved commit logs of patches adding new files | ||
86 | - Fixed top comment in header files | ||
87 | - Used a 'vfio_migration_' prefix instead of 'vfio_mig_' | ||
88 | - Made vfio_migration_add_bytes_transferred() internal | ||
89 | - Added extra patch for vfio_device_state_is_running/precopy() | ||
90 | - Moved vfio_reset_handler() in device.c | ||
91 | - Moved "dirty tracking" related services into container-base.c and | ||
92 | improved naming | ||
93 | - Introduced listener.* files instead of dirty-tracking.* | ||
94 | - Introduced vfio_listener_un/register() routines | ||
95 | |||
96 | |||
97 | Cédric Le Goater (37): | ||
34 | vfio: Move vfio_mig_active() into migration.c | 98 | vfio: Move vfio_mig_active() into migration.c |
35 | vfio: Rename vfio_reset_bytes_transferred() | 99 | vfio: Rename vfio_reset_bytes_transferred() |
36 | vfio: Introduce a new header file for external migration services | 100 | vfio: Introduce a new header file for external migration services |
37 | vfio: Make vfio_un/block_multiple_devices_migration() static | 101 | vfio: Make vfio_un/block_multiple_devices_migration() static |
38 | vfio: Make vfio_viommu_preset() static | 102 | vfio: Make vfio_viommu_preset() static |
39 | vfio: Introduce a new header file for internal migration services | 103 | vfio: Introduce a new header file for internal migration services |
104 | vfio: Move vfio_device_state_is_running/precopy() into migration.c | ||
40 | vfio: Introduce a new header file for VFIOdisplay declarations | 105 | vfio: Introduce a new header file for VFIOdisplay declarations |
41 | vfio: Move VFIOHostDMAWindow definition into spapr.c | 106 | vfio: Move VFIOHostDMAWindow definition into spapr.c |
42 | vfio: Introduce a new header file for VFIOIOMMUFD declarations | 107 | vfio: Introduce a new header file for VFIOIOMMUFD declarations |
43 | vfio: Introduce new files for VFIORegion definitions and declarations | 108 | vfio: Introduce new files for VFIORegion definitions and declarations |
44 | vfio: Introduce a new header file for VFIOcontainer declarations | 109 | vfio: Introduce a new header file for VFIOcontainer declarations |
... | ... | ||
52 | vfio: Introduce a new file for VFIODevice definitions | 117 | vfio: Introduce a new file for VFIODevice definitions |
53 | vfio: Introduce new files for CPR definitions and declarations | 118 | vfio: Introduce new files for CPR definitions and declarations |
54 | vfio: Move vfio_kvm_device_fd() into helpers.c | 119 | vfio: Move vfio_kvm_device_fd() into helpers.c |
55 | vfio: Move vfio_device_list into device.c | 120 | vfio: Move vfio_device_list into device.c |
56 | vfio: Move vfio_de/attach_device() into device.c | 121 | vfio: Move vfio_de/attach_device() into device.c |
57 | vfio: Introduce new files for dirty tracking definitions and | 122 | vfio: Move vfio_reset_handler() into device.c |
58 | declarations | 123 | vfio: Move dirty tracking related services into container-base.c |
59 | vfio: Move vfio_set_migration_error() into migration.c | 124 | vfio: Make vfio_devices_query_dirty_bitmap() static |
125 | vfio: Make vfio_container_query_dirty_bitmap() static | ||
126 | vfio: Rename vfio_devices_all_dirty_tracking_started() | ||
127 | vfio: Rename vfio_devices_all_device_dirty_tracking() | ||
128 | vfio: Rename vfio_get_dirty_bitmap() | ||
129 | vfio: Introduce new files for VFIO MemoryListener | ||
130 | vfio: Rename RAM discard related services | ||
131 | vfio: Introduce vfio_listener_un/register() routines | ||
60 | vfio: Rename vfio-common.h to vfio-device.h | 132 | vfio: Rename vfio-common.h to vfio-device.h |
61 | vfio: Rename VFIODevice related services | 133 | vfio: Rename VFIODevice related services |
62 | vfio: Make vfio_devices_query_dirty_bitmap() static | ||
63 | vfio: Rename VFIOContainer related services | 134 | vfio: Rename VFIOContainer related services |
64 | vfio: Rename VFIO dirty tracking services | ||
65 | vfio: Introduce vfio_dirty_tracking_un/register() routines | ||
66 | vfio: Rename RAM discard related services | ||
67 | 135 | ||
68 | hw/vfio/cpr.h | 15 + | 136 | hw/vfio/migration-multifd.h | 2 +- |
69 | hw/vfio/dirty-tracking.h | 19 + | 137 | hw/vfio/pci.h | 3 +- |
70 | hw/vfio/display.h | 42 ++ | 138 | hw/vfio/vfio-cpr.h | 15 + |
71 | hw/vfio/helpers.h | 35 ++ | 139 | hw/vfio/vfio-display.h | 42 ++ |
72 | hw/vfio/iommufd.h | 29 + | 140 | hw/vfio/vfio-helpers.h | 35 ++ |
73 | hw/vfio/migration-multifd.h | 2 +- | 141 | hw/vfio/vfio-iommufd.h | 34 ++ |
74 | hw/vfio/migration.h | 73 +++ | 142 | hw/vfio/vfio-listener.h | 15 + |
75 | hw/vfio/pci.h | 3 +- | 143 | hw/vfio/vfio-migration-internal.h | 74 +++ |
76 | include/hw/s390x/vfio-ccw.h | 2 +- | 144 | include/hw/s390x/vfio-ccw.h | 2 +- |
77 | include/hw/vfio/vfio-common.h | 346 ------------ | 145 | include/hw/vfio/vfio-common.h | 346 ------------- |
78 | include/hw/vfio/vfio-container-base.h | 5 + | 146 | include/hw/vfio/vfio-container-base.h | 12 +- |
79 | include/hw/vfio/vfio-container.h | 35 ++ | 147 | include/hw/vfio/vfio-container.h | 36 ++ |
80 | include/hw/vfio/vfio-device.h | 148 ++++++ | 148 | include/hw/vfio/vfio-device.h | 149 ++++++ |
81 | include/hw/vfio/vfio-migration.h | 17 + | 149 | include/hw/vfio/vfio-migration.h | 16 + |
82 | include/hw/vfio/vfio-platform.h | 4 +- | 150 | include/hw/vfio/vfio-platform.h | 4 +- |
83 | include/hw/vfio/vfio-region.h | 47 ++ | 151 | include/hw/vfio/vfio-region.h | 47 ++ |
84 | backends/iommufd.c | 2 +- | 152 | backends/iommufd.c | 2 +- |
85 | hw/core/sysbus-fdt.c | 1 + | 153 | hw/core/sysbus-fdt.c | 1 + |
86 | hw/ppc/spapr_pci_vfio.c | 6 +- | 154 | hw/ppc/spapr_pci_vfio.c | 6 +- |
87 | hw/s390x/s390-pci-vfio.c | 3 +- | 155 | hw/s390x/s390-pci-vfio.c | 3 +- |
88 | hw/vfio/ap.c | 10 +- | 156 | hw/vfio/ap.c | 10 +- |
89 | hw/vfio/ccw.c | 20 +- | 157 | hw/vfio/ccw.c | 20 +- |
90 | hw/vfio/container-base.c | 69 +++ | 158 | hw/vfio/container-base.c | 192 ++++++- |
91 | hw/vfio/container.c | 123 ++--- | 159 | hw/vfio/container.c | 123 ++--- |
92 | hw/vfio/cpr.c | 3 +- | 160 | hw/vfio/cpr.c | 3 +- |
93 | hw/vfio/device.c | 371 +++++++++++++ | 161 | hw/vfio/device.c | 405 +++++++++++++++ |
94 | hw/vfio/{common.c => dirty-tracking.c} | 382 ++------------ | 162 | hw/vfio/display.c | 4 +- |
95 | hw/vfio/display.c | 4 +- | 163 | hw/vfio/helpers.c | 702 +++----------------------- |
96 | hw/vfio/helpers.c | 702 +++---------------------- | 164 | hw/vfio/igd.c | 8 +- |
97 | hw/vfio/igd.c | 8 +- | 165 | hw/vfio/iommufd.c | 24 +- |
98 | hw/vfio/iommufd.c | 25 +- | 166 | hw/vfio/{common.c => listener.c} | 455 +---------------- |
99 | hw/vfio/migration-multifd.c | 4 +- | 167 | hw/vfio/migration-multifd.c | 8 +- |
100 | hw/vfio/migration.c | 112 +++- | 168 | hw/vfio/migration.c | 111 +++- |
101 | hw/vfio/pci-quirks.c | 1 + | 169 | hw/vfio/pci-quirks.c | 1 + |
102 | hw/vfio/pci.c | 51 +- | 170 | hw/vfio/pci.c | 51 +- |
103 | hw/vfio/platform.c | 11 +- | 171 | hw/vfio/platform.c | 11 +- |
104 | hw/vfio/region.c | 396 ++++++++++++++ | 172 | hw/vfio/region.c | 395 +++++++++++++++ |
105 | hw/vfio/spapr.c | 10 +- | 173 | hw/vfio/spapr.c | 10 +- |
106 | migration/target.c | 4 +- | 174 | migration/target.c | 8 +- |
107 | hw/vfio/meson.build | 8 +- | 175 | hw/vfio/meson.build | 10 +- |
108 | hw/vfio/trace-events | 36 +- | 176 | hw/vfio/trace-events | 36 +- |
109 | 41 files changed, 1711 insertions(+), 1473 deletions(-) | 177 | 41 files changed, 1854 insertions(+), 1577 deletions(-) |
110 | create mode 100644 hw/vfio/cpr.h | 178 | create mode 100644 hw/vfio/vfio-cpr.h |
111 | create mode 100644 hw/vfio/dirty-tracking.h | 179 | create mode 100644 hw/vfio/vfio-display.h |
112 | create mode 100644 hw/vfio/display.h | 180 | create mode 100644 hw/vfio/vfio-helpers.h |
113 | create mode 100644 hw/vfio/helpers.h | 181 | create mode 100644 hw/vfio/vfio-iommufd.h |
114 | create mode 100644 hw/vfio/iommufd.h | 182 | create mode 100644 hw/vfio/vfio-listener.h |
115 | create mode 100644 hw/vfio/migration.h | 183 | create mode 100644 hw/vfio/vfio-migration-internal.h |
116 | delete mode 100644 include/hw/vfio/vfio-common.h | 184 | delete mode 100644 include/hw/vfio/vfio-common.h |
117 | create mode 100644 include/hw/vfio/vfio-container.h | 185 | create mode 100644 include/hw/vfio/vfio-container.h |
118 | create mode 100644 include/hw/vfio/vfio-device.h | 186 | create mode 100644 include/hw/vfio/vfio-device.h |
119 | create mode 100644 include/hw/vfio/vfio-migration.h | 187 | create mode 100644 include/hw/vfio/vfio-migration.h |
120 | create mode 100644 include/hw/vfio/vfio-region.h | 188 | create mode 100644 include/hw/vfio/vfio-region.h |
121 | create mode 100644 hw/vfio/device.c | 189 | create mode 100644 hw/vfio/device.c |
122 | rename hw/vfio/{common.c => dirty-tracking.c} (81%) | 190 | rename hw/vfio/{common.c => listener.c} (76%) |
123 | create mode 100644 hw/vfio/region.c | 191 | create mode 100644 hw/vfio/region.c |
124 | 192 | ||
125 | -- | 193 | -- |
126 | 2.48.1 | 194 | 2.49.0 |
127 | 195 | ||
128 | 196 | diff view generated by jsdifflib |
1 | vfio_mig_active() is part of the VFIO migration API. Move the | 1 | vfio_mig_active() is part of the VFIO migration API. Move the |
---|---|---|---|
2 | definitions where VFIO migration is implemented. | 2 | definitions where VFIO migration is implemented. |
3 | 3 | ||
4 | Reviewed-by: Avihai Horon <avihaih@nvidia.com> | ||
5 | Reviewed-by: John Levon <john.levon@nutanix.com> | ||
6 | Link: https://lore.kernel.org/qemu-devel/20250318095415.670319-2-clg@redhat.com | ||
4 | Signed-off-by: Cédric Le Goater <clg@redhat.com> | 7 | Signed-off-by: Cédric Le Goater <clg@redhat.com> |
5 | --- | 8 | --- |
6 | hw/vfio/common.c | 16 ---------------- | 9 | hw/vfio/common.c | 16 ---------------- |
7 | hw/vfio/migration.c | 16 ++++++++++++++++ | 10 | hw/vfio/migration.c | 16 ++++++++++++++++ |
8 | 2 files changed, 16 insertions(+), 16 deletions(-) | 11 | 2 files changed, 16 insertions(+), 16 deletions(-) |
... | ... | ||
60 | + | 63 | + |
61 | /* | 64 | /* |
62 | * Return true when either migration initialized or blocker registered. | 65 | * Return true when either migration initialized or blocker registered. |
63 | * Currently only return false when adding blocker fails which will | 66 | * Currently only return false when adding blocker fails which will |
64 | -- | 67 | -- |
65 | 2.48.1 | 68 | 2.49.0 |
66 | 69 | ||
67 | 70 | diff view generated by jsdifflib |
1 | Enforce a 'vfio_mig_' prefix for the VFIO migration API to better | 1 | Enforce a 'vfio_mig_' prefix for the VFIO migration API to better |
---|---|---|---|
2 | reflect the namespace these routines belong to. | 2 | reflect the namespace these routines belong to. |
3 | 3 | ||
4 | Reviewed-by: Avihai Horon <avihaih@nvidia.com> | ||
5 | Reviewed-by: John Levon <john.levon@nutanix.com> | ||
6 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
7 | Link: https://lore.kernel.org/qemu-devel/20250318095415.670319-3-clg@redhat.com | ||
4 | Signed-off-by: Cédric Le Goater <clg@redhat.com> | 8 | Signed-off-by: Cédric Le Goater <clg@redhat.com> |
5 | --- | 9 | --- |
6 | include/hw/vfio/vfio-common.h | 2 +- | 10 | include/hw/vfio/vfio-common.h | 2 +- |
7 | hw/vfio/migration.c | 2 +- | 11 | hw/vfio/migration.c | 2 +- |
8 | migration/target.c | 2 +- | 12 | migration/target.c | 2 +- |
... | ... | ||
46 | + vfio_mig_reset_bytes_transferred(); | 50 | + vfio_mig_reset_bytes_transferred(); |
47 | } | 51 | } |
48 | #else | 52 | #else |
49 | void migration_populate_vfio_info(MigrationInfo *info) | 53 | void migration_populate_vfio_info(MigrationInfo *info) |
50 | -- | 54 | -- |
51 | 2.48.1 | 55 | 2.49.0 |
52 | 56 | ||
53 | 57 | diff view generated by jsdifflib |
1 | The migration core subsytem makes uses of the VFIO migration API to | 1 | The migration core subsystem makes use of the VFIO migration API to |
---|---|---|---|
2 | collect statistics on the number of bytes transferred. These services | 2 | collect statistics on the number of bytes transferred. These services |
3 | are declared in "hw/vfio/vfio-common.h" which also contains VFIO | 3 | are declared in "hw/vfio/vfio-common.h" which also contains VFIO |
4 | internal declarations. Move the migration declarations into a new | 4 | internal declarations. Move the migration declarations into a new |
5 | header file "hw/vfio/vfio-migration.h" to reduce the exposure of VFIO | 5 | header file "hw/vfio/vfio-migration.h" to reduce the exposure of VFIO |
6 | internals. | 6 | internals. |
7 | 7 | ||
8 | While at it, use a 'vfio_migration_' prefix for these services. | ||
9 | |||
10 | To be noted, vfio_migration_add_bytes_transferred() is a VFIO | ||
11 | migration internal service which we will moved in the subsequent | ||
12 | patches. | ||
13 | |||
14 | Cc: Kirti Wankhede <kwankhede@nvidia.com> | ||
15 | Cc: Avihai Horon <avihaih@nvidia.com> | ||
8 | Signed-off-by: Cédric Le Goater <clg@redhat.com> | 16 | Signed-off-by: Cédric Le Goater <clg@redhat.com> |
9 | --- | 17 | --- |
10 | include/hw/vfio/vfio-common.h | 4 ---- | 18 | include/hw/vfio/vfio-common.h | 5 +---- |
11 | include/hw/vfio/vfio-migration.h | 17 +++++++++++++++++ | 19 | include/hw/vfio/vfio-migration.h | 16 ++++++++++++++++ |
12 | hw/vfio/migration-multifd.c | 1 + | 20 | hw/vfio/migration-multifd.c | 5 +++-- |
13 | hw/vfio/migration.c | 1 + | 21 | hw/vfio/migration.c | 11 ++++++----- |
14 | migration/target.c | 2 +- | 22 | migration/target.c | 8 ++++---- |
15 | 5 files changed, 20 insertions(+), 5 deletions(-) | 23 | 5 files changed, 30 insertions(+), 15 deletions(-) |
16 | create mode 100644 include/hw/vfio/vfio-migration.h | 24 | create mode 100644 include/hw/vfio/vfio-migration.h |
17 | 25 | ||
18 | diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h | 26 | diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h |
19 | index XXXXXXX..XXXXXXX 100644 | 27 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/include/hw/vfio/vfio-common.h | 28 | --- a/include/hw/vfio/vfio-common.h |
... | ... | ||
28 | void vfio_unblock_multiple_devices_migration(void); | 36 | void vfio_unblock_multiple_devices_migration(void); |
29 | bool vfio_viommu_preset(VFIODevice *vbasedev); | 37 | bool vfio_viommu_preset(VFIODevice *vbasedev); |
30 | -int64_t vfio_mig_bytes_transferred(void); | 38 | -int64_t vfio_mig_bytes_transferred(void); |
31 | -void vfio_mig_reset_bytes_transferred(void); | 39 | -void vfio_mig_reset_bytes_transferred(void); |
32 | -void vfio_mig_add_bytes_transferred(unsigned long val); | 40 | -void vfio_mig_add_bytes_transferred(unsigned long val); |
41 | +void vfio_migration_add_bytes_transferred(unsigned long val); | ||
33 | bool vfio_device_state_is_running(VFIODevice *vbasedev); | 42 | bool vfio_device_state_is_running(VFIODevice *vbasedev); |
34 | bool vfio_device_state_is_precopy(VFIODevice *vbasedev); | 43 | bool vfio_device_state_is_precopy(VFIODevice *vbasedev); |
35 | 44 | ||
36 | diff --git a/include/hw/vfio/vfio-migration.h b/include/hw/vfio/vfio-migration.h | 45 | diff --git a/include/hw/vfio/vfio-migration.h b/include/hw/vfio/vfio-migration.h |
37 | new file mode 100644 | 46 | new file mode 100644 |
... | ... | ||
48 | + */ | 57 | + */ |
49 | + | 58 | + |
50 | +#ifndef HW_VFIO_VFIO_MIGRATION_H | 59 | +#ifndef HW_VFIO_VFIO_MIGRATION_H |
51 | +#define HW_VFIO_VFIO_MIGRATION_H | 60 | +#define HW_VFIO_VFIO_MIGRATION_H |
52 | + | 61 | + |
53 | +bool vfio_mig_active(void); | 62 | +bool vfio_migration_active(void); |
54 | +int64_t vfio_mig_bytes_transferred(void); | 63 | +int64_t vfio_migration_bytes_transferred(void); |
55 | +void vfio_mig_reset_bytes_transferred(void); | 64 | +void vfio_migration_reset_bytes_transferred(void); |
56 | +void vfio_mig_add_bytes_transferred(unsigned long val); | ||
57 | + | 65 | + |
58 | +#endif /* HW_VFIO_VFIO_MIGRATION_H */ | 66 | +#endif /* HW_VFIO_VFIO_MIGRATION_H */ |
59 | diff --git a/hw/vfio/migration-multifd.c b/hw/vfio/migration-multifd.c | 67 | diff --git a/hw/vfio/migration-multifd.c b/hw/vfio/migration-multifd.c |
60 | index XXXXXXX..XXXXXXX 100644 | 68 | index XXXXXXX..XXXXXXX 100644 |
61 | --- a/hw/vfio/migration-multifd.c | 69 | --- a/hw/vfio/migration-multifd.c |
... | ... | ||
66 | #include "hw/vfio/vfio-common.h" | 74 | #include "hw/vfio/vfio-common.h" |
67 | +#include "hw/vfio/vfio-migration.h" | 75 | +#include "hw/vfio/vfio-migration.h" |
68 | #include "migration/misc.h" | 76 | #include "migration/misc.h" |
69 | #include "qapi/error.h" | 77 | #include "qapi/error.h" |
70 | #include "qemu/bswap.h" | 78 | #include "qemu/bswap.h" |
79 | @@ -XXX,XX +XXX,XX @@ vfio_save_complete_precopy_thread_config_state(VFIODevice *vbasedev, | ||
80 | return false; | ||
81 | } | ||
82 | |||
83 | - vfio_mig_add_bytes_transferred(packet_len); | ||
84 | + vfio_migration_add_bytes_transferred(packet_len); | ||
85 | |||
86 | return true; | ||
87 | } | ||
88 | @@ -XXX,XX +XXX,XX @@ vfio_multifd_save_complete_precopy_thread(SaveLiveCompletePrecopyThreadData *d, | ||
89 | goto thread_exit; | ||
90 | } | ||
91 | |||
92 | - vfio_mig_add_bytes_transferred(packet_size); | ||
93 | + vfio_migration_add_bytes_transferred(packet_size); | ||
94 | } | ||
95 | |||
96 | if (!vfio_save_complete_precopy_thread_config_state(vbasedev, | ||
71 | diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c | 97 | diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c |
72 | index XXXXXXX..XXXXXXX 100644 | 98 | index XXXXXXX..XXXXXXX 100644 |
73 | --- a/hw/vfio/migration.c | 99 | --- a/hw/vfio/migration.c |
74 | +++ b/hw/vfio/migration.c | 100 | +++ b/hw/vfio/migration.c |
75 | @@ -XXX,XX +XXX,XX @@ | 101 | @@ -XXX,XX +XXX,XX @@ |
... | ... | ||
78 | #include "hw/vfio/vfio-common.h" | 104 | #include "hw/vfio/vfio-common.h" |
79 | +#include "hw/vfio/vfio-migration.h" | 105 | +#include "hw/vfio/vfio-migration.h" |
80 | #include "migration/misc.h" | 106 | #include "migration/misc.h" |
81 | #include "migration/savevm.h" | 107 | #include "migration/savevm.h" |
82 | #include "migration/vmstate.h" | 108 | #include "migration/vmstate.h" |
109 | @@ -XXX,XX +XXX,XX @@ static ssize_t vfio_save_block(QEMUFile *f, VFIOMigration *migration) | ||
110 | qemu_put_be64(f, VFIO_MIG_FLAG_DEV_DATA_STATE); | ||
111 | qemu_put_be64(f, data_size); | ||
112 | qemu_put_buffer(f, migration->data_buffer, data_size); | ||
113 | - vfio_mig_add_bytes_transferred(data_size); | ||
114 | + vfio_migration_add_bytes_transferred(data_size); | ||
115 | |||
116 | trace_vfio_save_block(migration->vbasedev->name, data_size); | ||
117 | |||
118 | @@ -XXX,XX +XXX,XX @@ static int vfio_block_migration(VFIODevice *vbasedev, Error *err, Error **errp) | ||
119 | |||
120 | /* ---------------------------------------------------------------------- */ | ||
121 | |||
122 | -int64_t vfio_mig_bytes_transferred(void) | ||
123 | +int64_t vfio_migration_bytes_transferred(void) | ||
124 | { | ||
125 | return MIN(qatomic_read(&bytes_transferred), INT64_MAX); | ||
126 | } | ||
127 | |||
128 | -void vfio_mig_reset_bytes_transferred(void) | ||
129 | +void vfio_migration_reset_bytes_transferred(void) | ||
130 | { | ||
131 | qatomic_set(&bytes_transferred, 0); | ||
132 | } | ||
133 | |||
134 | -void vfio_mig_add_bytes_transferred(unsigned long val) | ||
135 | +void vfio_migration_add_bytes_transferred(unsigned long val) | ||
136 | { | ||
137 | qatomic_add(&bytes_transferred, val); | ||
138 | } | ||
139 | |||
140 | -bool vfio_mig_active(void) | ||
141 | +bool vfio_migration_active(void) | ||
142 | { | ||
143 | VFIODevice *vbasedev; | ||
144 | |||
83 | diff --git a/migration/target.c b/migration/target.c | 145 | diff --git a/migration/target.c b/migration/target.c |
84 | index XXXXXXX..XXXXXXX 100644 | 146 | index XXXXXXX..XXXXXXX 100644 |
85 | --- a/migration/target.c | 147 | --- a/migration/target.c |
86 | +++ b/migration/target.c | 148 | +++ b/migration/target.c |
87 | @@ -XXX,XX +XXX,XX @@ | 149 | @@ -XXX,XX +XXX,XX @@ |
... | ... | ||
91 | -#include "hw/vfio/vfio-common.h" | 153 | -#include "hw/vfio/vfio-common.h" |
92 | +#include "hw/vfio/vfio-migration.h" | 154 | +#include "hw/vfio/vfio-migration.h" |
93 | #endif | 155 | #endif |
94 | 156 | ||
95 | #ifdef CONFIG_VFIO | 157 | #ifdef CONFIG_VFIO |
158 | void migration_populate_vfio_info(MigrationInfo *info) | ||
159 | { | ||
160 | - if (vfio_mig_active()) { | ||
161 | + if (vfio_migration_active()) { | ||
162 | info->vfio = g_malloc0(sizeof(*info->vfio)); | ||
163 | - info->vfio->transferred = vfio_mig_bytes_transferred(); | ||
164 | + info->vfio->transferred = vfio_migration_bytes_transferred(); | ||
165 | } | ||
166 | } | ||
167 | |||
168 | void migration_reset_vfio_bytes_transferred(void) | ||
169 | { | ||
170 | - vfio_mig_reset_bytes_transferred(); | ||
171 | + vfio_migration_reset_bytes_transferred(); | ||
172 | } | ||
173 | #else | ||
174 | void migration_populate_vfio_info(MigrationInfo *info) | ||
96 | -- | 175 | -- |
97 | 2.48.1 | 176 | 2.49.0 |
98 | 177 | ||
99 | 178 | diff view generated by jsdifflib |
1 | Both of these routines are only used in file "migration.c". Move them | 1 | Both of these routines are only used in file "migration.c". Move them |
---|---|---|---|
2 | there. | 2 | there. |
3 | 3 | ||
4 | Reviewed-by: Joao Martins <joao.m.martins@oracle.com> | ||
5 | Link: https://lore.kernel.org/qemu-devel/20250318095415.670319-5-clg@redhat.com | ||
4 | Signed-off-by: Cédric Le Goater <clg@redhat.com> | 6 | Signed-off-by: Cédric Le Goater <clg@redhat.com> |
5 | --- | 7 | --- |
6 | include/hw/vfio/vfio-common.h | 2 -- | 8 | include/hw/vfio/vfio-common.h | 2 -- |
7 | hw/vfio/common.c | 62 ----------------------------------- | 9 | hw/vfio/common.c | 62 ----------------------------------- |
8 | hw/vfio/migration.c | 62 +++++++++++++++++++++++++++++++++++ | 10 | hw/vfio/migration.c | 62 +++++++++++++++++++++++++++++++++++ |
... | ... | ||
17 | extern int vfio_kvm_device_fd; | 19 | extern int vfio_kvm_device_fd; |
18 | 20 | ||
19 | -int vfio_block_multiple_devices_migration(VFIODevice *vbasedev, Error **errp); | 21 | -int vfio_block_multiple_devices_migration(VFIODevice *vbasedev, Error **errp); |
20 | -void vfio_unblock_multiple_devices_migration(void); | 22 | -void vfio_unblock_multiple_devices_migration(void); |
21 | bool vfio_viommu_preset(VFIODevice *vbasedev); | 23 | bool vfio_viommu_preset(VFIODevice *vbasedev); |
24 | void vfio_migration_add_bytes_transferred(unsigned long val); | ||
22 | bool vfio_device_state_is_running(VFIODevice *vbasedev); | 25 | bool vfio_device_state_is_running(VFIODevice *vbasedev); |
23 | bool vfio_device_state_is_precopy(VFIODevice *vbasedev); | ||
24 | diff --git a/hw/vfio/common.c b/hw/vfio/common.c | 26 | diff --git a/hw/vfio/common.c b/hw/vfio/common.c |
25 | index XXXXXXX..XXXXXXX 100644 | 27 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/hw/vfio/common.c | 28 | --- a/hw/vfio/common.c |
27 | +++ b/hw/vfio/common.c | 29 | +++ b/hw/vfio/common.c |
28 | @@ -XXX,XX +XXX,XX @@ | 30 | @@ -XXX,XX +XXX,XX @@ |
... | ... | ||
173 | + | 175 | + |
174 | static void vfio_migration_deinit(VFIODevice *vbasedev) | 176 | static void vfio_migration_deinit(VFIODevice *vbasedev) |
175 | { | 177 | { |
176 | VFIOMigration *migration = vbasedev->migration; | 178 | VFIOMigration *migration = vbasedev->migration; |
177 | -- | 179 | -- |
178 | 2.48.1 | 180 | 2.49.0 |
179 | 181 | ||
180 | 182 | diff view generated by jsdifflib |
1 | This routine is only used in file "migration.c". Move it there. | 1 | This routine is only used in file "migration.c". Move it there. |
---|---|---|---|
2 | 2 | ||
3 | Reviewed-by: John Levon <john.levon@nutanix.com> | ||
4 | Reviewed-by: Joao Martins <joao.m.martins@oracle.com> | ||
5 | Link: https://lore.kernel.org/qemu-devel/20250318095415.670319-6-clg@redhat.com | ||
3 | Signed-off-by: Cédric Le Goater <clg@redhat.com> | 6 | Signed-off-by: Cédric Le Goater <clg@redhat.com> |
4 | --- | 7 | --- |
5 | include/hw/vfio/vfio-common.h | 1 - | 8 | include/hw/vfio/vfio-common.h | 1 - |
6 | hw/vfio/common.c | 6 ------ | 9 | hw/vfio/common.c | 5 ----- |
7 | hw/vfio/migration.c | 5 +++++ | 10 | hw/vfio/migration.c | 5 +++++ |
8 | 3 files changed, 5 insertions(+), 7 deletions(-) | 11 | 3 files changed, 5 insertions(+), 6 deletions(-) |
9 | 12 | ||
10 | diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h | 13 | diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h |
11 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
12 | --- a/include/hw/vfio/vfio-common.h | 15 | --- a/include/hw/vfio/vfio-common.h |
13 | +++ b/include/hw/vfio/vfio-common.h | 16 | +++ b/include/hw/vfio/vfio-common.h |
14 | @@ -XXX,XX +XXX,XX @@ extern VFIODeviceList vfio_device_list; | 17 | @@ -XXX,XX +XXX,XX @@ extern VFIODeviceList vfio_device_list; |
15 | extern const MemoryListener vfio_memory_listener; | 18 | extern const MemoryListener vfio_memory_listener; |
16 | extern int vfio_kvm_device_fd; | 19 | extern int vfio_kvm_device_fd; |
17 | 20 | ||
18 | -bool vfio_viommu_preset(VFIODevice *vbasedev); | 21 | -bool vfio_viommu_preset(VFIODevice *vbasedev); |
22 | void vfio_migration_add_bytes_transferred(unsigned long val); | ||
19 | bool vfio_device_state_is_running(VFIODevice *vbasedev); | 23 | bool vfio_device_state_is_running(VFIODevice *vbasedev); |
20 | bool vfio_device_state_is_precopy(VFIODevice *vbasedev); | 24 | bool vfio_device_state_is_precopy(VFIODevice *vbasedev); |
21 | |||
22 | diff --git a/hw/vfio/common.c b/hw/vfio/common.c | 25 | diff --git a/hw/vfio/common.c b/hw/vfio/common.c |
23 | index XXXXXXX..XXXXXXX 100644 | 26 | index XXXXXXX..XXXXXXX 100644 |
24 | --- a/hw/vfio/common.c | 27 | --- a/hw/vfio/common.c |
25 | +++ b/hw/vfio/common.c | 28 | +++ b/hw/vfio/common.c |
26 | @@ -XXX,XX +XXX,XX @@ int vfio_kvm_device_fd = -1; | 29 | @@ -XXX,XX +XXX,XX @@ int vfio_kvm_device_fd = -1; |
27 | * Device state interfaces | ||
28 | */ | 30 | */ |
29 | 31 | ||
30 | - | 32 | |
31 | -bool vfio_viommu_preset(VFIODevice *vbasedev) | 33 | -bool vfio_viommu_preset(VFIODevice *vbasedev) |
32 | -{ | 34 | -{ |
33 | - return vbasedev->bcontainer->space->as != &address_space_memory; | 35 | - return vbasedev->bcontainer->space->as != &address_space_memory; |
34 | -} | 36 | -} |
35 | - | 37 | - |
36 | static void vfio_set_migration_error(int ret) | 38 | bool vfio_device_state_is_running(VFIODevice *vbasedev) |
37 | { | 39 | { |
38 | if (migration_is_running()) { | 40 | VFIOMigration *migration = vbasedev->migration; |
39 | diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c | 41 | diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c |
40 | index XXXXXXX..XXXXXXX 100644 | 42 | index XXXXXXX..XXXXXXX 100644 |
41 | --- a/hw/vfio/migration.c | 43 | --- a/hw/vfio/migration.c |
42 | +++ b/hw/vfio/migration.c | 44 | +++ b/hw/vfio/migration.c |
43 | @@ -XXX,XX +XXX,XX @@ bool vfio_mig_active(void) | 45 | @@ -XXX,XX +XXX,XX @@ bool vfio_migration_active(void) |
44 | return true; | 46 | return true; |
45 | } | 47 | } |
46 | 48 | ||
47 | +static bool vfio_viommu_preset(VFIODevice *vbasedev) | 49 | +static bool vfio_viommu_preset(VFIODevice *vbasedev) |
48 | +{ | 50 | +{ |
... | ... | ||
51 | + | 53 | + |
52 | /* | 54 | /* |
53 | * Return true when either migration initialized or blocker registered. | 55 | * Return true when either migration initialized or blocker registered. |
54 | * Currently only return false when adding blocker fails which will | 56 | * Currently only return false when adding blocker fails which will |
55 | -- | 57 | -- |
56 | 2.48.1 | 58 | 2.49.0 |
57 | 59 | ||
58 | 60 | diff view generated by jsdifflib |
1 | Gather all VFIO migration related declarations into "migration.h" to | 1 | Gather all VFIO migration related declarations into |
---|---|---|---|
2 | reduce exposure of VFIO internals in "hw/vfio/vfio-common.h". | 2 | "vfio-migration-internal.h" to reduce exposure of VFIO internals in |
3 | 3 | "hw/vfio/vfio-common.h". | |
4 | |||
5 | Cc: Kirti Wankhede <kwankhede@nvidia.com> | ||
6 | Cc: Avihai Horon <avihaih@nvidia.com> | ||
4 | Signed-off-by: Cédric Le Goater <clg@redhat.com> | 7 | Signed-off-by: Cédric Le Goater <clg@redhat.com> |
5 | --- | 8 | --- |
6 | hw/vfio/migration.h | 72 +++++++++++++++++++++++++++++++++++ | 9 | hw/vfio/vfio-migration-internal.h | 72 +++++++++++++++++++++++++++++++ |
7 | include/hw/vfio/vfio-common.h | 54 +------------------------- | 10 | include/hw/vfio/vfio-common.h | 52 +--------------------- |
8 | hw/vfio/common.c | 17 +-------- | 11 | hw/vfio/common.c | 1 + |
9 | hw/vfio/iommufd.c | 1 + | 12 | hw/vfio/migration-multifd.c | 1 + |
10 | hw/vfio/migration-multifd.c | 1 + | 13 | hw/vfio/migration.c | 1 + |
11 | hw/vfio/migration.c | 17 +++++++++ | 14 | hw/vfio/pci.c | 1 + |
12 | hw/vfio/pci.c | 1 + | 15 | 6 files changed, 77 insertions(+), 51 deletions(-) |
13 | 7 files changed, 94 insertions(+), 69 deletions(-) | 16 | create mode 100644 hw/vfio/vfio-migration-internal.h |
14 | create mode 100644 hw/vfio/migration.h | 17 | |
15 | 18 | diff --git a/hw/vfio/vfio-migration-internal.h b/hw/vfio/vfio-migration-internal.h | |
16 | diff --git a/hw/vfio/migration.h b/hw/vfio/migration.h | ||
17 | new file mode 100644 | 19 | new file mode 100644 |
18 | index XXXXXXX..XXXXXXX | 20 | index XXXXXXX..XXXXXXX |
19 | --- /dev/null | 21 | --- /dev/null |
20 | +++ b/hw/vfio/migration.h | 22 | +++ b/hw/vfio/vfio-migration-internal.h |
21 | @@ -XXX,XX +XXX,XX @@ | 23 | @@ -XXX,XX +XXX,XX @@ |
22 | +/* | 24 | +/* |
23 | + * VFIO migration | 25 | + * VFIO migration |
24 | + * | 26 | + * |
25 | + * Copyright Red Hat, Inc. 2025 | 27 | + * Copyright Red Hat, Inc. 2025 |
26 | + * | 28 | + * |
27 | + * SPDX-License-Identifier: GPL-2.0-or-later | 29 | + * SPDX-License-Identifier: GPL-2.0-or-later |
28 | + */ | 30 | + */ |
29 | + | 31 | + |
30 | +#ifndef HW_VFIO_MIGRATION_H | 32 | +#ifndef HW_VFIO_VFIO_MIGRATION_INTERNAL_H |
31 | +#define HW_VFIO_MIGRATION_H | 33 | +#define HW_VFIO_VFIO_MIGRATION_INTERNAL_H |
32 | + | 34 | + |
33 | +#ifdef CONFIG_LINUX | 35 | +#ifdef CONFIG_LINUX |
34 | +#include <linux/vfio.h> | 36 | +#include <linux/vfio.h> |
35 | +#endif | 37 | +#endif |
36 | + | 38 | + |
39 | +#include "qemu/typedefs.h" | ||
37 | +#include "qemu/notify.h" | 40 | +#include "qemu/notify.h" |
38 | + | 41 | + |
39 | +/* | 42 | +/* |
40 | + * Flags to be used as unique delimiters for VFIO devices in the migration | 43 | + * Flags to be used as unique delimiters for VFIO devices in the migration |
41 | + * stream. These flags are composed as: | 44 | + * stream. These flags are composed as: |
... | ... | ||
73 | + | 76 | + |
74 | + bool event_save_iterate_started; | 77 | + bool event_save_iterate_started; |
75 | + bool event_precopy_empty_hit; | 78 | + bool event_precopy_empty_hit; |
76 | +} VFIOMigration; | 79 | +} VFIOMigration; |
77 | + | 80 | + |
78 | + | ||
79 | +bool vfio_migration_realize(VFIODevice *vbasedev, Error **errp); | 81 | +bool vfio_migration_realize(VFIODevice *vbasedev, Error **errp); |
80 | +void vfio_migration_exit(VFIODevice *vbasedev); | 82 | +void vfio_migration_exit(VFIODevice *vbasedev); |
81 | +bool vfio_device_state_is_running(VFIODevice *vbasedev); | ||
82 | +bool vfio_device_state_is_precopy(VFIODevice *vbasedev); | ||
83 | +int vfio_save_device_config_state(QEMUFile *f, void *opaque, Error **errp); | 83 | +int vfio_save_device_config_state(QEMUFile *f, void *opaque, Error **errp); |
84 | +int vfio_load_device_config_state(QEMUFile *f, void *opaque); | 84 | +int vfio_load_device_config_state(QEMUFile *f, void *opaque); |
85 | + | 85 | + |
86 | +#ifdef CONFIG_LINUX | 86 | +#ifdef CONFIG_LINUX |
87 | +int vfio_migration_set_state(VFIODevice *vbasedev, | 87 | +int vfio_migration_set_state(VFIODevice *vbasedev, |
88 | + enum vfio_device_mig_state new_state, | 88 | + enum vfio_device_mig_state new_state, |
89 | + enum vfio_device_mig_state recover_state, | 89 | + enum vfio_device_mig_state recover_state, |
90 | + Error **errp); | 90 | + Error **errp); |
91 | +#endif | 91 | +#endif |
92 | + | 92 | + |
93 | +#endif /* HW_VFIO_MIGRATION_H */ | 93 | +void vfio_migration_add_bytes_transferred(unsigned long val); |
94 | + | ||
95 | +#endif /* HW_VFIO_VFIO_MIGRATION_INTERNAL_H */ | ||
94 | diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h | 96 | diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h |
95 | index XXXXXXX..XXXXXXX 100644 | 97 | index XXXXXXX..XXXXXXX 100644 |
96 | --- a/include/hw/vfio/vfio-common.h | 98 | --- a/include/hw/vfio/vfio-common.h |
97 | +++ b/include/hw/vfio/vfio-common.h | 99 | +++ b/include/hw/vfio/vfio-common.h |
98 | @@ -XXX,XX +XXX,XX @@ | 100 | @@ -XXX,XX +XXX,XX @@ |
... | ... | ||
165 | QLIST_ENTRY(VFIODevice) next; | 167 | QLIST_ENTRY(VFIODevice) next; |
166 | @@ -XXX,XX +XXX,XX @@ extern VFIODeviceList vfio_device_list; | 168 | @@ -XXX,XX +XXX,XX @@ extern VFIODeviceList vfio_device_list; |
167 | extern const MemoryListener vfio_memory_listener; | 169 | extern const MemoryListener vfio_memory_listener; |
168 | extern int vfio_kvm_device_fd; | 170 | extern int vfio_kvm_device_fd; |
169 | 171 | ||
170 | -bool vfio_device_state_is_running(VFIODevice *vbasedev); | 172 | -void vfio_migration_add_bytes_transferred(unsigned long val); |
171 | -bool vfio_device_state_is_precopy(VFIODevice *vbasedev); | 173 | bool vfio_device_state_is_running(VFIODevice *vbasedev); |
172 | - | 174 | bool vfio_device_state_is_precopy(VFIODevice *vbasedev); |
175 | |||
173 | -int vfio_save_device_config_state(QEMUFile *f, void *opaque, Error **errp); | 176 | -int vfio_save_device_config_state(QEMUFile *f, void *opaque, Error **errp); |
174 | -int vfio_load_device_config_state(QEMUFile *f, void *opaque); | 177 | -int vfio_load_device_config_state(QEMUFile *f, void *opaque); |
175 | - | 178 | - |
176 | #ifdef CONFIG_LINUX | 179 | #ifdef CONFIG_LINUX |
177 | int vfio_get_region_info(VFIODevice *vbasedev, int index, | 180 | int vfio_get_region_info(VFIODevice *vbasedev, int index, |
... | ... | ||
199 | +++ b/hw/vfio/common.c | 202 | +++ b/hw/vfio/common.c |
200 | @@ -XXX,XX +XXX,XX @@ | 203 | @@ -XXX,XX +XXX,XX @@ |
201 | #include "migration/qemu-file.h" | 204 | #include "migration/qemu-file.h" |
202 | #include "system/tcg.h" | 205 | #include "system/tcg.h" |
203 | #include "system/tpm.h" | 206 | #include "system/tpm.h" |
204 | +#include "migration.h" | 207 | +#include "vfio-migration-internal.h" |
205 | 208 | ||
206 | VFIODeviceList vfio_device_list = | 209 | VFIODeviceList vfio_device_list = |
207 | QLIST_HEAD_INITIALIZER(vfio_device_list); | 210 | QLIST_HEAD_INITIALIZER(vfio_device_list); |
208 | @@ -XXX,XX +XXX,XX @@ static void vfio_set_migration_error(int ret) | ||
209 | } | ||
210 | } | ||
211 | |||
212 | -bool vfio_device_state_is_running(VFIODevice *vbasedev) | ||
213 | -{ | ||
214 | - VFIOMigration *migration = vbasedev->migration; | ||
215 | - | ||
216 | - return migration->device_state == VFIO_DEVICE_STATE_RUNNING || | ||
217 | - migration->device_state == VFIO_DEVICE_STATE_RUNNING_P2P; | ||
218 | -} | ||
219 | - | ||
220 | -bool vfio_device_state_is_precopy(VFIODevice *vbasedev) | ||
221 | -{ | ||
222 | - VFIOMigration *migration = vbasedev->migration; | ||
223 | - | ||
224 | - return migration->device_state == VFIO_DEVICE_STATE_PRE_COPY || | ||
225 | - migration->device_state == VFIO_DEVICE_STATE_PRE_COPY_P2P; | ||
226 | -} | ||
227 | - | ||
228 | static bool vfio_devices_all_device_dirty_tracking_started( | ||
229 | const VFIOContainerBase *bcontainer) | ||
230 | { | ||
231 | diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c | ||
232 | index XXXXXXX..XXXXXXX 100644 | ||
233 | --- a/hw/vfio/iommufd.c | ||
234 | +++ b/hw/vfio/iommufd.c | ||
235 | @@ -XXX,XX +XXX,XX @@ | ||
236 | #include "qemu/cutils.h" | ||
237 | #include "qemu/chardev_open.h" | ||
238 | #include "pci.h" | ||
239 | +#include "migration.h" | ||
240 | |||
241 | static int iommufd_cdev_map(const VFIOContainerBase *bcontainer, hwaddr iova, | ||
242 | ram_addr_t size, void *vaddr, bool readonly) | ||
243 | diff --git a/hw/vfio/migration-multifd.c b/hw/vfio/migration-multifd.c | 211 | diff --git a/hw/vfio/migration-multifd.c b/hw/vfio/migration-multifd.c |
244 | index XXXXXXX..XXXXXXX 100644 | 212 | index XXXXXXX..XXXXXXX 100644 |
245 | --- a/hw/vfio/migration-multifd.c | 213 | --- a/hw/vfio/migration-multifd.c |
246 | +++ b/hw/vfio/migration-multifd.c | 214 | +++ b/hw/vfio/migration-multifd.c |
247 | @@ -XXX,XX +XXX,XX @@ | 215 | @@ -XXX,XX +XXX,XX @@ |
248 | #include "io/channel-buffer.h" | 216 | #include "io/channel-buffer.h" |
249 | #include "migration/qemu-file.h" | 217 | #include "migration/qemu-file.h" |
250 | #include "migration-multifd.h" | 218 | #include "migration-multifd.h" |
251 | +#include "migration.h" | 219 | +#include "vfio-migration-internal.h" |
252 | #include "trace.h" | 220 | #include "trace.h" |
253 | 221 | ||
254 | #define VFIO_DEVICE_STATE_CONFIG_STATE (1) | 222 | #define VFIO_DEVICE_STATE_CONFIG_STATE (1) |
255 | diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c | 223 | diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c |
256 | index XXXXXXX..XXXXXXX 100644 | 224 | index XXXXXXX..XXXXXXX 100644 |
257 | --- a/hw/vfio/migration.c | 225 | --- a/hw/vfio/migration.c |
258 | +++ b/hw/vfio/migration.c | 226 | +++ b/hw/vfio/migration.c |
259 | @@ -XXX,XX +XXX,XX @@ | 227 | @@ -XXX,XX +XXX,XX @@ |
260 | #include "pci.h" | 228 | #include "pci.h" |
261 | #include "trace.h" | 229 | #include "trace.h" |
262 | #include "hw/hw.h" | 230 | #include "hw/hw.h" |
263 | +#include "migration.h" | 231 | +#include "vfio-migration-internal.h" |
264 | 232 | ||
265 | /* | 233 | /* |
266 | * This is an arbitrary size based on migration of mlx5 devices, where typically | 234 | * This is an arbitrary size based on migration of mlx5 devices, where typically |
267 | @@ -XXX,XX +XXX,XX @@ void vfio_migration_exit(VFIODevice *vbasedev) | ||
268 | |||
269 | migrate_del_blocker(&vbasedev->migration_blocker); | ||
270 | } | ||
271 | + | ||
272 | +bool vfio_device_state_is_running(VFIODevice *vbasedev) | ||
273 | +{ | ||
274 | + VFIOMigration *migration = vbasedev->migration; | ||
275 | + | ||
276 | + return migration->device_state == VFIO_DEVICE_STATE_RUNNING || | ||
277 | + migration->device_state == VFIO_DEVICE_STATE_RUNNING_P2P; | ||
278 | +} | ||
279 | + | ||
280 | +bool vfio_device_state_is_precopy(VFIODevice *vbasedev) | ||
281 | +{ | ||
282 | + VFIOMigration *migration = vbasedev->migration; | ||
283 | + | ||
284 | + return migration->device_state == VFIO_DEVICE_STATE_PRE_COPY || | ||
285 | + migration->device_state == VFIO_DEVICE_STATE_PRE_COPY_P2P; | ||
286 | +} | ||
287 | diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c | 235 | diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c |
288 | index XXXXXXX..XXXXXXX 100644 | 236 | index XXXXXXX..XXXXXXX 100644 |
289 | --- a/hw/vfio/pci.c | 237 | --- a/hw/vfio/pci.c |
290 | +++ b/hw/vfio/pci.c | 238 | +++ b/hw/vfio/pci.c |
291 | @@ -XXX,XX +XXX,XX @@ | 239 | @@ -XXX,XX +XXX,XX @@ |
292 | #include "migration/blocker.h" | 240 | #include "migration/blocker.h" |
293 | #include "migration/qemu-file.h" | 241 | #include "migration/qemu-file.h" |
294 | #include "system/iommufd.h" | 242 | #include "system/iommufd.h" |
295 | +#include "migration.h" | 243 | +#include "vfio-migration-internal.h" |
296 | 244 | ||
297 | #define TYPE_VFIO_PCI_NOHOTPLUG "vfio-pci-nohotplug" | 245 | #define TYPE_VFIO_PCI_NOHOTPLUG "vfio-pci-nohotplug" |
298 | 246 | ||
299 | -- | 247 | -- |
300 | 2.48.1 | 248 | 2.49.0 |
301 | 249 | ||
302 | 250 | diff view generated by jsdifflib |
1 | This routine is related to VFIO migration. It belongs to "migration.c". | 1 | These routines are migration related. Move their declaration and |
---|---|---|---|
2 | While at it, rename it to better reflect the namespace it belongs to. | 2 | implementation under the migration files. |
3 | 3 | ||
4 | Signed-off-by: Cédric Le Goater <clg@redhat.com> | 4 | Signed-off-by: Cédric Le Goater <clg@redhat.com> |
5 | --- | 5 | --- |
6 | hw/vfio/migration.h | 1 + | 6 | hw/vfio/vfio-migration-internal.h | 2 ++ |
7 | hw/vfio/dirty-tracking.c | 19 +++++-------------- | 7 | include/hw/vfio/vfio-common.h | 3 --- |
8 | hw/vfio/migration.c | 7 +++++++ | 8 | hw/vfio/common.c | 16 ---------------- |
9 | 3 files changed, 13 insertions(+), 14 deletions(-) | 9 | hw/vfio/migration.c | 16 ++++++++++++++++ |
10 | 4 files changed, 18 insertions(+), 19 deletions(-) | ||
10 | 11 | ||
11 | diff --git a/hw/vfio/migration.h b/hw/vfio/migration.h | 12 | diff --git a/hw/vfio/vfio-migration-internal.h b/hw/vfio/vfio-migration-internal.h |
12 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/hw/vfio/migration.h | 14 | --- a/hw/vfio/vfio-migration-internal.h |
14 | +++ b/hw/vfio/migration.h | 15 | +++ b/hw/vfio/vfio-migration-internal.h |
15 | @@ -XXX,XX +XXX,XX @@ int vfio_migration_set_state(VFIODevice *vbasedev, | 16 | @@ -XXX,XX +XXX,XX @@ typedef struct VFIOMigration { |
16 | enum vfio_device_mig_state recover_state, | 17 | |
17 | Error **errp); | 18 | bool vfio_migration_realize(VFIODevice *vbasedev, Error **errp); |
18 | #endif | 19 | void vfio_migration_exit(VFIODevice *vbasedev); |
19 | +void vfio_migration_set_error(int ret); | 20 | +bool vfio_device_state_is_running(VFIODevice *vbasedev); |
20 | 21 | +bool vfio_device_state_is_precopy(VFIODevice *vbasedev); | |
21 | #endif /* HW_VFIO_MIGRATION_H */ | 22 | int vfio_save_device_config_state(QEMUFile *f, void *opaque, Error **errp); |
22 | diff --git a/hw/vfio/dirty-tracking.c b/hw/vfio/dirty-tracking.c | 23 | int vfio_load_device_config_state(QEMUFile *f, void *opaque); |
24 | |||
25 | diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h | ||
23 | index XXXXXXX..XXXXXXX 100644 | 26 | index XXXXXXX..XXXXXXX 100644 |
24 | --- a/hw/vfio/dirty-tracking.c | 27 | --- a/include/hw/vfio/vfio-common.h |
25 | +++ b/hw/vfio/dirty-tracking.c | 28 | +++ b/include/hw/vfio/vfio-common.h |
26 | @@ -XXX,XX +XXX,XX @@ | 29 | @@ -XXX,XX +XXX,XX @@ extern VFIODeviceList vfio_device_list; |
27 | #include "system/runstate.h" | 30 | extern const MemoryListener vfio_memory_listener; |
28 | #include "trace.h" | 31 | extern int vfio_kvm_device_fd; |
29 | #include "qapi/error.h" | 32 | |
30 | -#include "migration/misc.h" | 33 | -bool vfio_device_state_is_running(VFIODevice *vbasedev); |
31 | -#include "migration/qemu-file.h" | 34 | -bool vfio_device_state_is_precopy(VFIODevice *vbasedev); |
32 | #include "system/tcg.h" | 35 | - |
33 | #include "system/tpm.h" | 36 | #ifdef CONFIG_LINUX |
34 | #include "migration.h" | 37 | int vfio_get_region_info(VFIODevice *vbasedev, int index, |
35 | @@ -XXX,XX +XXX,XX @@ | 38 | struct vfio_region_info **info); |
36 | * Device state interfaces | 39 | diff --git a/hw/vfio/common.c b/hw/vfio/common.c |
40 | index XXXXXXX..XXXXXXX 100644 | ||
41 | --- a/hw/vfio/common.c | ||
42 | +++ b/hw/vfio/common.c | ||
43 | @@ -XXX,XX +XXX,XX @@ int vfio_kvm_device_fd = -1; | ||
37 | */ | 44 | */ |
38 | 45 | ||
39 | -static void vfio_set_migration_error(int ret) | 46 | |
47 | -bool vfio_device_state_is_running(VFIODevice *vbasedev) | ||
40 | -{ | 48 | -{ |
41 | - if (migration_is_running()) { | 49 | - VFIOMigration *migration = vbasedev->migration; |
42 | - migration_file_set_error(ret, NULL); | 50 | - |
43 | - } | 51 | - return migration->device_state == VFIO_DEVICE_STATE_RUNNING || |
52 | - migration->device_state == VFIO_DEVICE_STATE_RUNNING_P2P; | ||
53 | -} | ||
54 | - | ||
55 | -bool vfio_device_state_is_precopy(VFIODevice *vbasedev) | ||
56 | -{ | ||
57 | - VFIOMigration *migration = vbasedev->migration; | ||
58 | - | ||
59 | - return migration->device_state == VFIO_DEVICE_STATE_PRE_COPY || | ||
60 | - migration->device_state == VFIO_DEVICE_STATE_PRE_COPY_P2P; | ||
44 | -} | 61 | -} |
45 | - | 62 | - |
46 | static bool vfio_devices_all_device_dirty_tracking_started( | 63 | static bool vfio_devices_all_device_dirty_tracking_started( |
47 | const VFIOContainerBase *bcontainer) | 64 | const VFIOContainerBase *bcontainer) |
48 | { | 65 | { |
49 | @@ -XXX,XX +XXX,XX @@ static void vfio_iommu_map_notify(IOMMUNotifier *n, IOMMUTLBEntry *iotlb) | ||
50 | if (iotlb->target_as != &address_space_memory) { | ||
51 | error_report("Wrong target AS \"%s\", only system memory is allowed", | ||
52 | iotlb->target_as->name ? iotlb->target_as->name : "none"); | ||
53 | - vfio_set_migration_error(-EINVAL); | ||
54 | + vfio_migration_set_error(-EINVAL); | ||
55 | return; | ||
56 | } | ||
57 | |||
58 | @@ -XXX,XX +XXX,XX @@ static void vfio_iommu_map_notify(IOMMUNotifier *n, IOMMUTLBEntry *iotlb) | ||
59 | "0x%"HWADDR_PRIx") = %d (%s)", | ||
60 | bcontainer, iova, | ||
61 | iotlb->addr_mask + 1, ret, strerror(-ret)); | ||
62 | - vfio_set_migration_error(ret); | ||
63 | + vfio_migration_set_error(ret); | ||
64 | } | ||
65 | } | ||
66 | out: | ||
67 | @@ -XXX,XX +XXX,XX @@ static void vfio_listener_log_global_stop(MemoryListener *listener) | ||
68 | error_prepend(&local_err, | ||
69 | "vfio: Could not stop dirty page tracking - "); | ||
70 | error_report_err(local_err); | ||
71 | - vfio_set_migration_error(ret); | ||
72 | + vfio_migration_set_error(ret); | ||
73 | } | ||
74 | } | ||
75 | |||
76 | @@ -XXX,XX +XXX,XX @@ out_unlock: | ||
77 | |||
78 | out: | ||
79 | if (ret) { | ||
80 | - vfio_set_migration_error(ret); | ||
81 | + vfio_migration_set_error(ret); | ||
82 | } | ||
83 | } | ||
84 | |||
85 | @@ -XXX,XX +XXX,XX @@ static void vfio_listener_log_sync(MemoryListener *listener, | ||
86 | ret = vfio_sync_dirty_bitmap(bcontainer, section, &local_err); | ||
87 | if (ret) { | ||
88 | error_report_err(local_err); | ||
89 | - vfio_set_migration_error(ret); | ||
90 | + vfio_migration_set_error(ret); | ||
91 | } | ||
92 | } | ||
93 | } | ||
94 | diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c | 66 | diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c |
95 | index XXXXXXX..XXXXXXX 100644 | 67 | index XXXXXXX..XXXXXXX 100644 |
96 | --- a/hw/vfio/migration.c | 68 | --- a/hw/vfio/migration.c |
97 | +++ b/hw/vfio/migration.c | 69 | +++ b/hw/vfio/migration.c |
98 | @@ -XXX,XX +XXX,XX @@ bool vfio_device_state_is_precopy(VFIODevice *vbasedev) | 70 | @@ -XXX,XX +XXX,XX @@ void vfio_migration_exit(VFIODevice *vbasedev) |
99 | return migration->device_state == VFIO_DEVICE_STATE_PRE_COPY || | 71 | |
100 | migration->device_state == VFIO_DEVICE_STATE_PRE_COPY_P2P; | 72 | migrate_del_blocker(&vbasedev->migration_blocker); |
101 | } | 73 | } |
102 | + | 74 | + |
103 | +void vfio_migration_set_error(int ret) | 75 | +bool vfio_device_state_is_running(VFIODevice *vbasedev) |
104 | +{ | 76 | +{ |
105 | + if (migration_is_running()) { | 77 | + VFIOMigration *migration = vbasedev->migration; |
106 | + migration_file_set_error(ret, NULL); | 78 | + |
107 | + } | 79 | + return migration->device_state == VFIO_DEVICE_STATE_RUNNING || |
80 | + migration->device_state == VFIO_DEVICE_STATE_RUNNING_P2P; | ||
81 | +} | ||
82 | + | ||
83 | +bool vfio_device_state_is_precopy(VFIODevice *vbasedev) | ||
84 | +{ | ||
85 | + VFIOMigration *migration = vbasedev->migration; | ||
86 | + | ||
87 | + return migration->device_state == VFIO_DEVICE_STATE_PRE_COPY || | ||
88 | + migration->device_state == VFIO_DEVICE_STATE_PRE_COPY_P2P; | ||
108 | +} | 89 | +} |
109 | -- | 90 | -- |
110 | 2.48.1 | 91 | 2.49.0 |
111 | 92 | ||
112 | 93 | diff view generated by jsdifflib |
1 | Gather all VFIOdisplay related declarations into "display.h" to | 1 | Gather all VFIOdisplay related declarations into "vfio-display.h" to |
---|---|---|---|
2 | reduce exposure of VFIO internals in "hw/vfio/vfio-common.h". | 2 | reduce exposure of VFIO internals in "hw/vfio/vfio-common.h". |
3 | 3 | ||
4 | Reviewed-by: John Levon <john.levon@nutanix.com> | ||
5 | Link: https://lore.kernel.org/qemu-devel/20250318095415.670319-8-clg@redhat.com | ||
4 | Signed-off-by: Cédric Le Goater <clg@redhat.com> | 6 | Signed-off-by: Cédric Le Goater <clg@redhat.com> |
5 | --- | 7 | --- |
6 | hw/vfio/display.h | 41 +++++++++++++++++++++++++++++++++++ | ||
7 | hw/vfio/pci.h | 1 + | 8 | hw/vfio/pci.h | 1 + |
9 | hw/vfio/vfio-display.h | 41 +++++++++++++++++++++++++++++++++++ | ||
8 | include/hw/vfio/vfio-common.h | 28 ------------------------ | 10 | include/hw/vfio/vfio-common.h | 28 ------------------------ |
9 | hw/vfio/display.c | 2 +- | 11 | hw/vfio/display.c | 2 +- |
10 | 4 files changed, 43 insertions(+), 29 deletions(-) | 12 | 4 files changed, 43 insertions(+), 29 deletions(-) |
11 | create mode 100644 hw/vfio/display.h | 13 | create mode 100644 hw/vfio/vfio-display.h |
12 | 14 | ||
13 | diff --git a/hw/vfio/display.h b/hw/vfio/display.h | 15 | diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h |
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/hw/vfio/pci.h | ||
18 | +++ b/hw/vfio/pci.h | ||
19 | @@ -XXX,XX +XXX,XX @@ | ||
20 | #include "qemu/timer.h" | ||
21 | #include "qom/object.h" | ||
22 | #include "system/kvm.h" | ||
23 | +#include "vfio-display.h" | ||
24 | |||
25 | #define PCI_ANY_ID (~0) | ||
26 | |||
27 | diff --git a/hw/vfio/vfio-display.h b/hw/vfio/vfio-display.h | ||
14 | new file mode 100644 | 28 | new file mode 100644 |
15 | index XXXXXXX..XXXXXXX | 29 | index XXXXXXX..XXXXXXX |
16 | --- /dev/null | 30 | --- /dev/null |
17 | +++ b/hw/vfio/display.h | 31 | +++ b/hw/vfio/vfio-display.h |
18 | @@ -XXX,XX +XXX,XX @@ | 32 | @@ -XXX,XX +XXX,XX @@ |
19 | +/* | 33 | +/* |
20 | + * VFIO display | 34 | + * VFIO display |
21 | + * | 35 | + * |
22 | + * Copyright Red Hat, Inc. 2025 | 36 | + * Copyright Red Hat, Inc. 2025 |
23 | + * | 37 | + * |
24 | + * SPDX-License-Identifier: GPL-2.0-or-later | 38 | + * SPDX-License-Identifier: GPL-2.0-or-later |
25 | + */ | 39 | + */ |
26 | + | 40 | + |
27 | +#ifndef HW_VFIO_DISPLAY_H | 41 | +#ifndef HW_VFIO_VFIO_DISPLAY_H |
28 | +#define HW_VFIO_DISPLAY_H | 42 | +#define HW_VFIO_VFIO_DISPLAY_H |
29 | + | 43 | + |
30 | +#include "ui/console.h" | 44 | +#include "ui/console.h" |
31 | +#include "hw/display/ramfb.h" | 45 | +#include "hw/display/ramfb.h" |
32 | + | 46 | + |
33 | +typedef struct VFIODMABuf { | 47 | +typedef struct VFIODMABuf { |
... | ... | ||
54 | + VFIODMABuf *primary; | 68 | + VFIODMABuf *primary; |
55 | + VFIODMABuf *cursor; | 69 | + VFIODMABuf *cursor; |
56 | + } dmabuf; | 70 | + } dmabuf; |
57 | +} VFIODisplay; | 71 | +} VFIODisplay; |
58 | + | 72 | + |
59 | +#endif /* HW_VFIO_DISPLAY_H */ | 73 | +#endif /* HW_VFIO_VFIO_DISPLAY_H */ |
60 | diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h | ||
61 | index XXXXXXX..XXXXXXX 100644 | ||
62 | --- a/hw/vfio/pci.h | ||
63 | +++ b/hw/vfio/pci.h | ||
64 | @@ -XXX,XX +XXX,XX @@ | ||
65 | #include "qemu/timer.h" | ||
66 | #include "qom/object.h" | ||
67 | #include "system/kvm.h" | ||
68 | +#include "display.h" | ||
69 | |||
70 | #define PCI_ANY_ID (~0) | ||
71 | |||
72 | diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h | 74 | diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h |
73 | index XXXXXXX..XXXXXXX 100644 | 75 | index XXXXXXX..XXXXXXX 100644 |
74 | --- a/include/hw/vfio/vfio-common.h | 76 | --- a/include/hw/vfio/vfio-common.h |
75 | +++ b/include/hw/vfio/vfio-common.h | 77 | +++ b/include/hw/vfio/vfio-common.h |
76 | @@ -XXX,XX +XXX,XX @@ | 78 | @@ -XXX,XX +XXX,XX @@ |
... | ... | ||
124 | #include "qemu/error-report.h" | 126 | #include "qemu/error-report.h" |
125 | #include "hw/display/edid.h" | 127 | #include "hw/display/edid.h" |
126 | -#include "ui/console.h" | 128 | -#include "ui/console.h" |
127 | #include "qapi/error.h" | 129 | #include "qapi/error.h" |
128 | #include "pci.h" | 130 | #include "pci.h" |
129 | +#include "display.h" | 131 | +#include "vfio-display.h" |
130 | #include "trace.h" | 132 | #include "trace.h" |
131 | 133 | ||
132 | #ifndef DRM_PLANE_TYPE_PRIMARY | 134 | #ifndef DRM_PLANE_TYPE_PRIMARY |
133 | -- | 135 | -- |
134 | 2.48.1 | 136 | 2.49.0 |
135 | 137 | ||
136 | 138 | diff view generated by jsdifflib |
1 | VFIOHostDMAWindow is only used in file "spapr.c". Move it there. | 1 | VFIOHostDMAWindow is only used in file "spapr.c". Move it there. |
---|---|---|---|
2 | 2 | ||
3 | Reviewed-by: John Levon <john.levon@nutanix.com> | ||
4 | Link: https://lore.kernel.org/qemu-devel/20250318095415.670319-9-clg@redhat.com | ||
3 | Signed-off-by: Cédric Le Goater <clg@redhat.com> | 5 | Signed-off-by: Cédric Le Goater <clg@redhat.com> |
4 | --- | 6 | --- |
5 | include/hw/vfio/vfio-common.h | 7 ------- | 7 | include/hw/vfio/vfio-common.h | 7 ------- |
6 | hw/vfio/spapr.c | 7 +++++++ | 8 | hw/vfio/spapr.c | 7 +++++++ |
7 | 2 files changed, 7 insertions(+), 7 deletions(-) | 9 | 2 files changed, 7 insertions(+), 7 deletions(-) |
... | ... | ||
41 | + | 43 | + |
42 | typedef struct VFIOSpaprContainer { | 44 | typedef struct VFIOSpaprContainer { |
43 | VFIOContainer container; | 45 | VFIOContainer container; |
44 | MemoryListener prereg_listener; | 46 | MemoryListener prereg_listener; |
45 | -- | 47 | -- |
46 | 2.48.1 | 48 | 2.49.0 |
47 | 49 | ||
48 | 50 | diff view generated by jsdifflib |
1 | Gather all VFIOIOMMUFD related declarations into "iommufd.h" to | 1 | Gather all VFIOIOMMUFD related declarations introduced by commits |
---|---|---|---|
2 | reduce exposure of VFIO internals in "hw/vfio/vfio-common.h". | 2 | 5ee3dc7af785 ("vfio/iommufd: Implement the iommufd backend") and |
3 | 5b1e96e65403 ("vfio/iommufd: Introduce auto domain creation") into | ||
4 | "vfio-iommufd.h". This to reduce exposure of VFIO internals in | ||
5 | "hw/vfio/vfio-common.h". | ||
3 | 6 | ||
7 | Cc: Joao Martins <joao.m.martins@oracle.com> | ||
8 | Cc: Yi Liu <yi.l.liu@intel.com> | ||
9 | Reviewed-by: John Levon <john.levon@nutanix.com> | ||
10 | Link: https://lore.kernel.org/qemu-devel/20250318095415.670319-10-clg@redhat.com | ||
4 | Signed-off-by: Cédric Le Goater <clg@redhat.com> | 11 | Signed-off-by: Cédric Le Goater <clg@redhat.com> |
5 | --- | 12 | --- |
6 | hw/vfio/iommufd.h | 29 +++++++++++++++++++++++++++++ | 13 | hw/vfio/vfio-iommufd.h | 34 ++++++++++++++++++++++++++++++++++ |
7 | include/hw/vfio/vfio-common.h | 21 +++------------------ | 14 | include/hw/vfio/vfio-common.h | 21 +++------------------ |
8 | hw/vfio/iommufd.c | 1 + | 15 | hw/vfio/iommufd.c | 1 + |
9 | 3 files changed, 33 insertions(+), 18 deletions(-) | 16 | 3 files changed, 38 insertions(+), 18 deletions(-) |
10 | create mode 100644 hw/vfio/iommufd.h | 17 | create mode 100644 hw/vfio/vfio-iommufd.h |
11 | 18 | ||
12 | diff --git a/hw/vfio/iommufd.h b/hw/vfio/iommufd.h | 19 | diff --git a/hw/vfio/vfio-iommufd.h b/hw/vfio/vfio-iommufd.h |
13 | new file mode 100644 | 20 | new file mode 100644 |
14 | index XXXXXXX..XXXXXXX | 21 | index XXXXXXX..XXXXXXX |
15 | --- /dev/null | 22 | --- /dev/null |
16 | +++ b/hw/vfio/iommufd.h | 23 | +++ b/hw/vfio/vfio-iommufd.h |
17 | @@ -XXX,XX +XXX,XX @@ | 24 | @@ -XXX,XX +XXX,XX @@ |
18 | +/* | 25 | +/* |
19 | + * VFIO iommufd | 26 | + * VFIO iommufd |
20 | + * | 27 | + * |
21 | + * Copyright Red Hat, Inc. 2025 | 28 | + * Copyright Red Hat, Inc. 2025 |
22 | + * | 29 | + * |
23 | + * SPDX-License-Identifier: GPL-2.0-or-later | 30 | + * SPDX-License-Identifier: GPL-2.0-or-later |
24 | + */ | 31 | + */ |
25 | + | 32 | + |
26 | +#ifndef HW_VFIO_IOMMUFD_H | 33 | +#ifndef HW_VFIO_VFIO_IOMMUFD_H |
27 | +#define HW_VFIO_IOMMUFD_H | 34 | +#define HW_VFIO_VFIO_IOMMUFD_H |
28 | + | 35 | + |
36 | +#include "hw/vfio/vfio-container-base.h" | ||
37 | + | ||
38 | +typedef struct VFIODevice VFIODevice; | ||
29 | + | 39 | + |
30 | +typedef struct VFIOIOASHwpt { | 40 | +typedef struct VFIOIOASHwpt { |
31 | + uint32_t hwpt_id; | 41 | + uint32_t hwpt_id; |
32 | + uint32_t hwpt_flags; | 42 | + uint32_t hwpt_flags; |
33 | + QLIST_HEAD(, VFIODevice) device_list; | 43 | + QLIST_HEAD(, VFIODevice) device_list; |
34 | + QLIST_ENTRY(VFIOIOASHwpt) next; | 44 | + QLIST_ENTRY(VFIOIOASHwpt) next; |
35 | +} VFIOIOASHwpt; | 45 | +} VFIOIOASHwpt; |
46 | + | ||
47 | +typedef struct IOMMUFDBackend IOMMUFDBackend; | ||
36 | + | 48 | + |
37 | +typedef struct VFIOIOMMUFDContainer { | 49 | +typedef struct VFIOIOMMUFDContainer { |
38 | + VFIOContainerBase bcontainer; | 50 | + VFIOContainerBase bcontainer; |
39 | + IOMMUFDBackend *be; | 51 | + IOMMUFDBackend *be; |
40 | + uint32_t ioas_id; | 52 | + uint32_t ioas_id; |
41 | + QLIST_HEAD(, VFIOIOASHwpt) hwpt_list; | 53 | + QLIST_HEAD(, VFIOIOASHwpt) hwpt_list; |
42 | +} VFIOIOMMUFDContainer; | 54 | +} VFIOIOMMUFDContainer; |
43 | + | 55 | + |
44 | +OBJECT_DECLARE_SIMPLE_TYPE(VFIOIOMMUFDContainer, VFIO_IOMMU_IOMMUFD); | 56 | +OBJECT_DECLARE_SIMPLE_TYPE(VFIOIOMMUFDContainer, VFIO_IOMMU_IOMMUFD); |
45 | + | 57 | + |
46 | +#endif /* HW_VFIO_IOMMUFD_H */ | 58 | +#endif /* HW_VFIO_VFIO_IOMMUFD_H */ |
47 | diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h | 59 | diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h |
48 | index XXXXXXX..XXXXXXX 100644 | 60 | index XXXXXXX..XXXXXXX 100644 |
49 | --- a/include/hw/vfio/vfio-common.h | 61 | --- a/include/hw/vfio/vfio-common.h |
50 | +++ b/include/hw/vfio/vfio-common.h | 62 | +++ b/include/hw/vfio/vfio-common.h |
51 | @@ -XXX,XX +XXX,XX @@ typedef struct VFIOContainer { | 63 | @@ -XXX,XX +XXX,XX @@ typedef struct VFIOContainer { |
... | ... | ||
82 | diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c | 94 | diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c |
83 | index XXXXXXX..XXXXXXX 100644 | 95 | index XXXXXXX..XXXXXXX 100644 |
84 | --- a/hw/vfio/iommufd.c | 96 | --- a/hw/vfio/iommufd.c |
85 | +++ b/hw/vfio/iommufd.c | 97 | +++ b/hw/vfio/iommufd.c |
86 | @@ -XXX,XX +XXX,XX @@ | 98 | @@ -XXX,XX +XXX,XX @@ |
99 | #include "qemu/cutils.h" | ||
87 | #include "qemu/chardev_open.h" | 100 | #include "qemu/chardev_open.h" |
88 | #include "pci.h" | 101 | #include "pci.h" |
89 | #include "migration.h" | 102 | +#include "vfio-iommufd.h" |
90 | +#include "iommufd.h" | ||
91 | 103 | ||
92 | static int iommufd_cdev_map(const VFIOContainerBase *bcontainer, hwaddr iova, | 104 | static int iommufd_cdev_map(const VFIOContainerBase *bcontainer, hwaddr iova, |
93 | ram_addr_t size, void *vaddr, bool readonly) | 105 | ram_addr_t size, void *vaddr, bool readonly) |
94 | -- | 106 | -- |
95 | 2.48.1 | 107 | 2.49.0 |
96 | 108 | ||
97 | 109 | diff view generated by jsdifflib |
1 | Gather all VFIORegion related declarations and definitions into their | 1 | Gather all VFIORegion related declarations and definitions into their |
---|---|---|---|
2 | own files to reduce exposure of VFIO internals in "hw/vfio/vfio-common.h". | 2 | own files to reduce exposure of VFIO internals in "hw/vfio/vfio-common.h". |
3 | They were introduced for 'vfio-platform' support in commits | ||
4 | db0da029a185 ("vfio: Generalize region support") and a664477db8da | ||
5 | ("hw/vfio/pci: Introduce VFIORegion"). | ||
3 | 6 | ||
4 | These declarations are made available externally (for "sysbus-fdt.c"). | 7 | To be noted that the 'vfio-platform' devices have been deprecated and |
5 | This is for 'vfio-platform' devices which have been deprecated and | 8 | will be removed in QEMU 10.2. Until then, make the declarations |
6 | will be removed in QEMU 10.2. | 9 | available externally for 'sysbus-fdt.c'. |
7 | 10 | ||
11 | Cc: Eric Auger <eric.auger@redhat.com> | ||
8 | Signed-off-by: Cédric Le Goater <clg@redhat.com> | 12 | Signed-off-by: Cédric Le Goater <clg@redhat.com> |
9 | --- | 13 | --- |
10 | hw/vfio/display.h | 1 + | 14 | hw/vfio/vfio-display.h | 1 + |
11 | include/hw/vfio/vfio-common.h | 32 +-- | 15 | include/hw/vfio/vfio-common.h | 32 +-- |
12 | include/hw/vfio/vfio-platform.h | 2 + | 16 | include/hw/vfio/vfio-platform.h | 2 + |
13 | include/hw/vfio/vfio-region.h | 47 ++++ | 17 | include/hw/vfio/vfio-region.h | 47 ++++ |
14 | hw/core/sysbus-fdt.c | 1 + | 18 | hw/core/sysbus-fdt.c | 1 + |
15 | hw/vfio/helpers.c | 363 ----------------------------- | 19 | hw/vfio/helpers.c | 363 ----------------------------- |
16 | hw/vfio/pci-quirks.c | 1 + | 20 | hw/vfio/pci-quirks.c | 1 + |
17 | hw/vfio/pci.c | 1 + | 21 | hw/vfio/pci.c | 1 + |
18 | hw/vfio/platform.c | 1 + | 22 | hw/vfio/platform.c | 1 + |
19 | hw/vfio/region.c | 395 ++++++++++++++++++++++++++++++++ | 23 | hw/vfio/region.c | 394 ++++++++++++++++++++++++++++++++ |
20 | hw/vfio/meson.build | 1 + | 24 | hw/vfio/meson.build | 1 + |
21 | hw/vfio/trace-events | 16 +- | 25 | hw/vfio/trace-events | 16 +- |
22 | 12 files changed, 460 insertions(+), 401 deletions(-) | 26 | 12 files changed, 459 insertions(+), 401 deletions(-) |
23 | create mode 100644 include/hw/vfio/vfio-region.h | 27 | create mode 100644 include/hw/vfio/vfio-region.h |
24 | create mode 100644 hw/vfio/region.c | 28 | create mode 100644 hw/vfio/region.c |
25 | 29 | ||
26 | diff --git a/hw/vfio/display.h b/hw/vfio/display.h | 30 | diff --git a/hw/vfio/vfio-display.h b/hw/vfio/vfio-display.h |
27 | index XXXXXXX..XXXXXXX 100644 | 31 | index XXXXXXX..XXXXXXX 100644 |
28 | --- a/hw/vfio/display.h | 32 | --- a/hw/vfio/vfio-display.h |
29 | +++ b/hw/vfio/display.h | 33 | +++ b/hw/vfio/vfio-display.h |
30 | @@ -XXX,XX +XXX,XX @@ | 34 | @@ -XXX,XX +XXX,XX @@ |
31 | 35 | ||
32 | #include "ui/console.h" | 36 | #include "ui/console.h" |
33 | #include "hw/display/ramfb.h" | 37 | #include "hw/display/ramfb.h" |
34 | +#include "hw/vfio/vfio-region.h" | 38 | +#include "hw/vfio/vfio-region.h" |
... | ... | ||
122 | +#ifndef HW_VFIO_REGION_H | 126 | +#ifndef HW_VFIO_REGION_H |
123 | +#define HW_VFIO_REGION_H | 127 | +#define HW_VFIO_REGION_H |
124 | + | 128 | + |
125 | +#include "exec/memory.h" | 129 | +#include "exec/memory.h" |
126 | + | 130 | + |
127 | +typedef struct VFIODevice VFIODevice; | ||
128 | + | ||
129 | +typedef struct VFIOMmap { | 131 | +typedef struct VFIOMmap { |
130 | + MemoryRegion mem; | 132 | + MemoryRegion mem; |
131 | + void *mmap; | 133 | + void *mmap; |
132 | + off_t offset; | 134 | + off_t offset; |
133 | + size_t size; | 135 | + size_t size; |
134 | +} VFIOMmap; | 136 | +} VFIOMmap; |
137 | + | ||
138 | +typedef struct VFIODevice VFIODevice; | ||
135 | + | 139 | + |
136 | +typedef struct VFIORegion { | 140 | +typedef struct VFIORegion { |
137 | + struct VFIODevice *vbasedev; | 141 | + struct VFIODevice *vbasedev; |
138 | + off_t fd_offset; /* offset of region within device fd */ | 142 | + off_t fd_offset; /* offset of region within device fd */ |
139 | + MemoryRegion *mem; /* slow, read/write access */ | 143 | + MemoryRegion *mem; /* slow, read/write access */ |
... | ... | ||
568 | --- a/hw/vfio/pci.c | 572 | --- a/hw/vfio/pci.c |
569 | +++ b/hw/vfio/pci.c | 573 | +++ b/hw/vfio/pci.c |
570 | @@ -XXX,XX +XXX,XX @@ | 574 | @@ -XXX,XX +XXX,XX @@ |
571 | #include "migration/qemu-file.h" | 575 | #include "migration/qemu-file.h" |
572 | #include "system/iommufd.h" | 576 | #include "system/iommufd.h" |
573 | #include "migration.h" | 577 | #include "vfio-migration-internal.h" |
574 | +#include "hw/vfio/vfio-region.h" | 578 | +#include "hw/vfio/vfio-region.h" |
575 | 579 | ||
576 | #define TYPE_VFIO_PCI_NOHOTPLUG "vfio-pci-nohotplug" | 580 | #define TYPE_VFIO_PCI_NOHOTPLUG "vfio-pci-nohotplug" |
577 | 581 | ||
578 | diff --git a/hw/vfio/platform.c b/hw/vfio/platform.c | 582 | diff --git a/hw/vfio/platform.c b/hw/vfio/platform.c |
... | ... | ||
592 | index XXXXXXX..XXXXXXX | 596 | index XXXXXXX..XXXXXXX |
593 | --- /dev/null | 597 | --- /dev/null |
594 | +++ b/hw/vfio/region.c | 598 | +++ b/hw/vfio/region.c |
595 | @@ -XXX,XX +XXX,XX @@ | 599 | @@ -XXX,XX +XXX,XX @@ |
596 | +/* | 600 | +/* |
597 | + * low level and IOMMU backend agnostic helpers used by VFIO devices, | 601 | + * VFIO regions |
598 | + * related to regions, interrupts, capabilities | ||
599 | + * | 602 | + * |
600 | + * Copyright Red Hat, Inc. 2012 | 603 | + * Copyright Red Hat, Inc. 2012 |
601 | + * | 604 | + * |
602 | + * Authors: | 605 | + * Authors: |
603 | + * Alex Williamson <alex.williamson@redhat.com> | 606 | + * Alex Williamson <alex.williamson@redhat.com> |
... | ... | ||
1040 | -vfio_reset_handler(void) "" | 1043 | -vfio_reset_handler(void) "" |
1041 | 1044 | ||
1042 | # platform.c | 1045 | # platform.c |
1043 | vfio_platform_realize(char *name, char *compat) "vfio device %s, compat = %s" | 1046 | vfio_platform_realize(char *name, char *compat) "vfio device %s, compat = %s" |
1044 | -- | 1047 | -- |
1045 | 2.48.1 | 1048 | 2.49.0 |
1046 | 1049 | ||
1047 | 1050 | diff view generated by jsdifflib |
1 | Gather all VFIOcontainer related declarations into "container.h" to | 1 | Gather all VFIOcontainer related declarations into |
---|---|---|---|
2 | reduce exposure of VFIO internals in "hw/vfio/vfio-common.h". | 2 | "hw/vfio/vfio-container.h" to reduce exposure of VFIO internals in |
3 | "hw/vfio/vfio-common.h". These declarations were initially introduced | ||
4 | in commit 65501a745dba ("vfio: vfio-pci device assignment driver"). | ||
5 | They are made available externally for PPC and s390x. | ||
3 | 6 | ||
4 | These declarations are made available externally for PPC and s390x. | 7 | Reviewed-by: Zhenzhong Duan <zhenzhong.duan@intel.com> |
5 | 8 | Reviewed-by: John Levon <john.levon@nutanix.com> | |
9 | Link: https://lore.kernel.org/qemu-devel/20250318095415.670319-12-clg@redhat.com | ||
6 | Signed-off-by: Cédric Le Goater <clg@redhat.com> | 10 | Signed-off-by: Cédric Le Goater <clg@redhat.com> |
7 | --- | 11 | --- |
8 | include/hw/vfio/vfio-common.h | 19 ----------------- | 12 | include/hw/vfio/vfio-common.h | 19 ----------------- |
9 | include/hw/vfio/vfio-container.h | 35 ++++++++++++++++++++++++++++++++ | 13 | include/hw/vfio/vfio-container.h | 36 ++++++++++++++++++++++++++++++++ |
10 | hw/ppc/spapr_pci_vfio.c | 1 + | 14 | hw/ppc/spapr_pci_vfio.c | 1 + |
11 | hw/s390x/s390-pci-vfio.c | 2 +- | 15 | hw/s390x/s390-pci-vfio.c | 2 +- |
12 | hw/vfio/container.c | 1 + | 16 | hw/vfio/container.c | 1 + |
13 | hw/vfio/spapr.c | 1 + | 17 | hw/vfio/spapr.c | 1 + |
14 | 6 files changed, 39 insertions(+), 20 deletions(-) | 18 | 6 files changed, 40 insertions(+), 20 deletions(-) |
15 | create mode 100644 include/hw/vfio/vfio-container.h | 19 | create mode 100644 include/hw/vfio/vfio-container.h |
16 | 20 | ||
17 | diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h | 21 | diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h |
18 | index XXXXXXX..XXXXXXX 100644 | 22 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/include/hw/vfio/vfio-common.h | 23 | --- a/include/hw/vfio/vfio-common.h |
... | ... | ||
69 | +#define HW_VFIO_CONTAINER_H | 73 | +#define HW_VFIO_CONTAINER_H |
70 | + | 74 | + |
71 | +#include "hw/vfio/vfio-container-base.h" | 75 | +#include "hw/vfio/vfio-container-base.h" |
72 | + | 76 | + |
73 | +typedef struct VFIOContainer VFIOContainer; | 77 | +typedef struct VFIOContainer VFIOContainer; |
78 | +typedef struct VFIODevice VFIODevice; | ||
74 | + | 79 | + |
75 | +typedef struct VFIOGroup { | 80 | +typedef struct VFIOGroup { |
76 | + int fd; | 81 | + int fd; |
77 | + int groupid; | 82 | + int groupid; |
78 | + VFIOContainer *container; | 83 | + VFIOContainer *container; |
... | ... | ||
140 | +#include "hw/vfio/vfio-container.h" | 145 | +#include "hw/vfio/vfio-container.h" |
141 | #include "hw/hw.h" | 146 | #include "hw/hw.h" |
142 | #include "exec/ram_addr.h" | 147 | #include "exec/ram_addr.h" |
143 | #include "qemu/error-report.h" | 148 | #include "qemu/error-report.h" |
144 | -- | 149 | -- |
145 | 2.48.1 | 150 | 2.49.0 |
146 | 151 | ||
147 | 152 | diff view generated by jsdifflib |
1 | vfio_group_list is only used in file "container.c". | 1 | vfio_group_list is only used in file "container.c". |
---|---|---|---|
2 | 2 | ||
3 | Reviewed-by: John Levon <john.levon@nutanix.com> | ||
4 | Reviewed-by: Zhenzhong Duan <zhenzhong.duan@intel.com> | ||
5 | Link: https://lore.kernel.org/qemu-devel/20250318095415.670319-13-clg@redhat.com | ||
3 | Signed-off-by: Cédric Le Goater <clg@redhat.com> | 6 | Signed-off-by: Cédric Le Goater <clg@redhat.com> |
4 | --- | 7 | --- |
5 | include/hw/vfio/vfio-common.h | 2 -- | 8 | include/hw/vfio/vfio-common.h | 2 -- |
6 | hw/vfio/container.c | 3 ++- | 9 | hw/vfio/container.c | 3 ++- |
7 | 2 files changed, 2 insertions(+), 3 deletions(-) | 10 | 2 files changed, 2 insertions(+), 3 deletions(-) |
... | ... | ||
33 | +static VFIOGroupList vfio_group_list = | 36 | +static VFIOGroupList vfio_group_list = |
34 | QLIST_HEAD_INITIALIZER(vfio_group_list); | 37 | QLIST_HEAD_INITIALIZER(vfio_group_list); |
35 | 38 | ||
36 | static int vfio_ram_block_discard_disable(VFIOContainer *container, bool state) | 39 | static int vfio_ram_block_discard_disable(VFIOContainer *container, bool state) |
37 | -- | 40 | -- |
38 | 2.48.1 | 41 | 2.49.0 |
39 | 42 | ||
40 | 43 | diff view generated by jsdifflib |
... | ... | ||
---|---|---|---|
9 | 9 | ||
10 | to better reflect the namespace these routines belong to. | 10 | to better reflect the namespace these routines belong to. |
11 | 11 | ||
12 | Signed-off-by: Cédric Le Goater <clg@redhat.com> | 12 | Signed-off-by: Cédric Le Goater <clg@redhat.com> |
13 | --- | 13 | --- |
14 | include/hw/vfio/vfio-common.h | 6 --- | 14 | include/hw/vfio/vfio-common.h | 5 --- |
15 | include/hw/vfio/vfio-container-base.h | 5 ++ | 15 | include/hw/vfio/vfio-container-base.h | 6 ++++ |
16 | hw/ppc/spapr_pci_vfio.c | 5 +- | 16 | hw/ppc/spapr_pci_vfio.c | 5 ++- |
17 | hw/vfio/common.c | 66 ------------------------- | 17 | hw/vfio/common.c | 47 ------------------------- |
18 | hw/vfio/container-base.c | 69 +++++++++++++++++++++++++++ | 18 | hw/vfio/container-base.c | 50 +++++++++++++++++++++++++++ |
19 | hw/vfio/container.c | 6 +-- | 19 | hw/vfio/container.c | 6 ++-- |
20 | hw/vfio/iommufd.c | 6 +-- | 20 | hw/vfio/iommufd.c | 6 ++-- |
21 | hw/vfio/trace-events | 4 +- | 21 | 7 files changed, 64 insertions(+), 61 deletions(-) |
22 | 8 files changed, 85 insertions(+), 82 deletions(-) | ||
23 | 22 | ||
24 | diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h | 23 | diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h |
25 | index XXXXXXX..XXXXXXX 100644 | 24 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/include/hw/vfio/vfio-common.h | 25 | --- a/include/hw/vfio/vfio-common.h |
27 | +++ b/include/hw/vfio/vfio-common.h | 26 | +++ b/include/hw/vfio/vfio-common.h |
... | ... | ||
35 | - VFIOContainerBase *bcontainer); | 34 | - VFIOContainerBase *bcontainer); |
36 | - | 35 | - |
37 | void vfio_disable_irqindex(VFIODevice *vbasedev, int index); | 36 | void vfio_disable_irqindex(VFIODevice *vbasedev, int index); |
38 | void vfio_unmask_single_irqindex(VFIODevice *vbasedev, int index); | 37 | void vfio_unmask_single_irqindex(VFIODevice *vbasedev, int index); |
39 | void vfio_mask_single_irqindex(VFIODevice *vbasedev, int index); | 38 | void vfio_mask_single_irqindex(VFIODevice *vbasedev, int index); |
40 | bool vfio_set_irq_signaling(VFIODevice *vbasedev, int index, int subindex, | ||
41 | int action, int fd, Error **errp); | ||
42 | |||
43 | -void vfio_reset_handler(void *opaque); | ||
44 | struct vfio_device_info *vfio_get_device_info(int fd); | ||
45 | bool vfio_device_is_mdev(VFIODevice *vbasedev); | ||
46 | bool vfio_device_hiod_realize(VFIODevice *vbasedev, Error **errp); | ||
47 | diff --git a/include/hw/vfio/vfio-container-base.h b/include/hw/vfio/vfio-container-base.h | 39 | diff --git a/include/hw/vfio/vfio-container-base.h b/include/hw/vfio/vfio-container-base.h |
48 | index XXXXXXX..XXXXXXX 100644 | 40 | index XXXXXXX..XXXXXXX 100644 |
49 | --- a/include/hw/vfio/vfio-container-base.h | 41 | --- a/include/hw/vfio/vfio-container-base.h |
50 | +++ b/include/hw/vfio/vfio-container-base.h | 42 | +++ b/include/hw/vfio/vfio-container-base.h |
51 | @@ -XXX,XX +XXX,XX @@ typedef struct VFIORamDiscardListener { | 43 | @@ -XXX,XX +XXX,XX @@ typedef struct VFIORamDiscardListener { |
... | ... | ||
58 | + VFIOContainerBase *bcontainer); | 50 | + VFIOContainerBase *bcontainer); |
59 | + | 51 | + |
60 | int vfio_container_dma_map(VFIOContainerBase *bcontainer, | 52 | int vfio_container_dma_map(VFIOContainerBase *bcontainer, |
61 | hwaddr iova, ram_addr_t size, | 53 | hwaddr iova, ram_addr_t size, |
62 | void *vaddr, bool readonly); | 54 | void *vaddr, bool readonly); |
55 | @@ -XXX,XX +XXX,XX @@ struct VFIOIOMMUClass { | ||
56 | MemoryRegionSection *section); | ||
57 | void (*release)(VFIOContainerBase *bcontainer); | ||
58 | }; | ||
59 | + | ||
60 | #endif /* HW_VFIO_VFIO_CONTAINER_BASE_H */ | ||
63 | diff --git a/hw/ppc/spapr_pci_vfio.c b/hw/ppc/spapr_pci_vfio.c | 61 | diff --git a/hw/ppc/spapr_pci_vfio.c b/hw/ppc/spapr_pci_vfio.c |
64 | index XXXXXXX..XXXXXXX 100644 | 62 | index XXXXXXX..XXXXXXX 100644 |
65 | --- a/hw/ppc/spapr_pci_vfio.c | 63 | --- a/hw/ppc/spapr_pci_vfio.c |
66 | +++ b/hw/ppc/spapr_pci_vfio.c | 64 | +++ b/hw/ppc/spapr_pci_vfio.c |
67 | @@ -XXX,XX +XXX,XX @@ | 65 | @@ -XXX,XX +XXX,XX @@ |
... | ... | ||
93 | diff --git a/hw/vfio/common.c b/hw/vfio/common.c | 91 | diff --git a/hw/vfio/common.c b/hw/vfio/common.c |
94 | index XXXXXXX..XXXXXXX 100644 | 92 | index XXXXXXX..XXXXXXX 100644 |
95 | --- a/hw/vfio/common.c | 93 | --- a/hw/vfio/common.c |
96 | +++ b/hw/vfio/common.c | 94 | +++ b/hw/vfio/common.c |
97 | @@ -XXX,XX +XXX,XX @@ | 95 | @@ -XXX,XX +XXX,XX @@ |
98 | #include "qemu/main-loop.h" | ||
99 | #include "qemu/range.h" | ||
100 | #include "system/kvm.h" | ||
101 | -#include "system/reset.h" | ||
102 | #include "system/runstate.h" | ||
103 | #include "trace.h" | ||
104 | #include "qapi/error.h" | ||
105 | @@ -XXX,XX +XXX,XX @@ | ||
106 | 96 | ||
107 | VFIODeviceList vfio_device_list = | 97 | VFIODeviceList vfio_device_list = |
108 | QLIST_HEAD_INITIALIZER(vfio_device_list); | 98 | QLIST_HEAD_INITIALIZER(vfio_device_list); |
109 | -static QLIST_HEAD(, VFIOAddressSpace) vfio_address_spaces = | 99 | -static QLIST_HEAD(, VFIOAddressSpace) vfio_address_spaces = |
110 | - QLIST_HEAD_INITIALIZER(vfio_address_spaces); | 100 | - QLIST_HEAD_INITIALIZER(vfio_address_spaces); |
111 | 101 | ||
112 | #ifdef CONFIG_KVM | 102 | #ifdef CONFIG_KVM |
113 | /* | 103 | /* |
114 | @@ -XXX,XX +XXX,XX @@ const MemoryListener vfio_memory_listener = { | ||
115 | .log_sync = vfio_listener_log_sync, | ||
116 | }; | ||
117 | |||
118 | -void vfio_reset_handler(void *opaque) | ||
119 | -{ | ||
120 | - VFIODevice *vbasedev; | ||
121 | - | ||
122 | - trace_vfio_reset_handler(); | ||
123 | - QLIST_FOREACH(vbasedev, &vfio_device_list, global_next) { | ||
124 | - if (vbasedev->dev->realized) { | ||
125 | - vbasedev->ops->vfio_compute_needs_reset(vbasedev); | ||
126 | - } | ||
127 | - } | ||
128 | - | ||
129 | - QLIST_FOREACH(vbasedev, &vfio_device_list, global_next) { | ||
130 | - if (vbasedev->dev->realized && vbasedev->needs_reset) { | ||
131 | - vbasedev->ops->vfio_hot_reset_multi(vbasedev); | ||
132 | - } | ||
133 | - } | ||
134 | -} | ||
135 | - | ||
136 | int vfio_kvm_device_add_fd(int fd, Error **errp) | ||
137 | { | ||
138 | #ifdef CONFIG_KVM | ||
139 | @@ -XXX,XX +XXX,XX @@ int vfio_kvm_device_del_fd(int fd, Error **errp) | 104 | @@ -XXX,XX +XXX,XX @@ int vfio_kvm_device_del_fd(int fd, Error **errp) |
140 | return 0; | 105 | return 0; |
141 | } | 106 | } |
142 | 107 | ||
143 | -VFIOAddressSpace *vfio_get_address_space(AddressSpace *as) | 108 | -VFIOAddressSpace *vfio_get_address_space(AddressSpace *as) |
... | ... | ||
191 | diff --git a/hw/vfio/container-base.c b/hw/vfio/container-base.c | 156 | diff --git a/hw/vfio/container-base.c b/hw/vfio/container-base.c |
192 | index XXXXXXX..XXXXXXX 100644 | 157 | index XXXXXXX..XXXXXXX 100644 |
193 | --- a/hw/vfio/container-base.c | 158 | --- a/hw/vfio/container-base.c |
194 | +++ b/hw/vfio/container-base.c | 159 | +++ b/hw/vfio/container-base.c |
195 | @@ -XXX,XX +XXX,XX @@ | 160 | @@ -XXX,XX +XXX,XX @@ |
196 | #include "qemu/osdep.h" | ||
197 | #include "qapi/error.h" | 161 | #include "qapi/error.h" |
198 | #include "qemu/error-report.h" | 162 | #include "qemu/error-report.h" |
163 | #include "hw/vfio/vfio-container-base.h" | ||
164 | +#include "hw/vfio/vfio-common.h" /* vfio_reset_handler */ | ||
199 | +#include "system/reset.h" | 165 | +#include "system/reset.h" |
200 | #include "hw/vfio/vfio-container-base.h" | ||
201 | +#include "hw/vfio/vfio-common.h" /* for vfio_device_list */ | ||
202 | +#include "trace.h" | ||
203 | + | 166 | + |
204 | +static QLIST_HEAD(, VFIOAddressSpace) vfio_address_spaces = | 167 | +static QLIST_HEAD(, VFIOAddressSpace) vfio_address_spaces = |
205 | + QLIST_HEAD_INITIALIZER(vfio_address_spaces); | 168 | + QLIST_HEAD_INITIALIZER(vfio_address_spaces); |
206 | + | ||
207 | +static void vfio_reset_handler(void *opaque) | ||
208 | +{ | ||
209 | + VFIODevice *vbasedev; | ||
210 | + | ||
211 | + trace_vfio_reset_handler(); | ||
212 | + QLIST_FOREACH(vbasedev, &vfio_device_list, global_next) { | ||
213 | + if (vbasedev->dev->realized) { | ||
214 | + vbasedev->ops->vfio_compute_needs_reset(vbasedev); | ||
215 | + } | ||
216 | + } | ||
217 | + | ||
218 | + QLIST_FOREACH(vbasedev, &vfio_device_list, global_next) { | ||
219 | + if (vbasedev->dev->realized && vbasedev->needs_reset) { | ||
220 | + vbasedev->ops->vfio_hot_reset_multi(vbasedev); | ||
221 | + } | ||
222 | + } | ||
223 | +} | ||
224 | + | 169 | + |
225 | +VFIOAddressSpace *vfio_address_space_get(AddressSpace *as) | 170 | +VFIOAddressSpace *vfio_address_space_get(AddressSpace *as) |
226 | +{ | 171 | +{ |
227 | + VFIOAddressSpace *space; | 172 | + VFIOAddressSpace *space; |
228 | + | 173 | + |
... | ... | ||
329 | - vfio_put_address_space(space); | 274 | - vfio_put_address_space(space); |
330 | + vfio_address_space_put(space); | 275 | + vfio_address_space_put(space); |
331 | 276 | ||
332 | iommufd_cdev_unbind_and_disconnect(vbasedev); | 277 | iommufd_cdev_unbind_and_disconnect(vbasedev); |
333 | close(vbasedev->fd); | 278 | close(vbasedev->fd); |
334 | diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events | ||
335 | index XXXXXXX..XXXXXXX 100644 | ||
336 | --- a/hw/vfio/trace-events | ||
337 | +++ b/hw/vfio/trace-events | ||
338 | @@ -XXX,XX +XXX,XX @@ vfio_get_dev_region(const char *name, int index, uint32_t type, uint32_t subtype | ||
339 | vfio_legacy_dma_unmap_overflow_workaround(void) "" | ||
340 | vfio_get_dirty_bitmap(uint64_t iova, uint64_t size, uint64_t bitmap_size, uint64_t start, uint64_t dirty_pages) "iova=0x%"PRIx64" size= 0x%"PRIx64" bitmap_size=0x%"PRIx64" start=0x%"PRIx64" dirty_pages=%"PRIu64 | ||
341 | vfio_iommu_map_dirty_notify(uint64_t iova_start, uint64_t iova_end) "iommu dirty @ 0x%"PRIx64" - 0x%"PRIx64 | ||
342 | -vfio_reset_handler(void) "" | ||
343 | |||
344 | # region.c | ||
345 | vfio_region_write(const char *name, int index, uint64_t addr, uint64_t data, unsigned size) " (%s:region%d+0x%"PRIx64", 0x%"PRIx64 ", %d)" | ||
346 | @@ -XXX,XX +XXX,XX @@ iommufd_cdev_fail_attach_existing_container(const char *msg) " %s" | ||
347 | iommufd_cdev_alloc_ioas(int iommufd, int ioas_id) " [iommufd=%d] new IOMMUFD container with ioasid=%d" | ||
348 | iommufd_cdev_device_info(char *name, int devfd, int num_irqs, int num_regions, int flags) " %s (%d) num_irqs=%d num_regions=%d flags=%d" | ||
349 | iommufd_cdev_pci_hot_reset_dep_devices(int domain, int bus, int slot, int function, int dev_id) "\t%04x:%02x:%02x.%x devid %d" | ||
350 | + | ||
351 | +# container-base.c | ||
352 | +vfio_reset_handler(void) "" | ||
353 | -- | 279 | -- |
354 | 2.48.1 | 280 | 2.49.0 |
355 | 281 | ||
356 | 282 | diff view generated by jsdifflib |
1 | These definitions don't have any use outside of their respective | 1 | These definitions don't have any use outside of their respective |
---|---|---|---|
2 | submodules. There is no need to expose them externally. Keep them | 2 | submodules. There is no need to expose them externally. Keep them |
3 | private. | 3 | private. |
4 | 4 | ||
5 | Reviewed-by: Zhenzhong Duan <zhenzhong.duan@intel.com> | ||
6 | Reviewed-by: John Levon <john.levon@nutanix.com> | ||
7 | Link: https://lore.kernel.org/qemu-devel/20250318095415.670319-15-clg@redhat.com | ||
5 | Signed-off-by: Cédric Le Goater <clg@redhat.com> | 8 | Signed-off-by: Cédric Le Goater <clg@redhat.com> |
6 | --- | 9 | --- |
7 | include/hw/vfio/vfio-common.h | 5 ----- | 10 | include/hw/vfio/vfio-common.h | 5 ----- |
8 | hw/vfio/container.c | 2 ++ | 11 | hw/vfio/container.c | 2 ++ |
9 | hw/vfio/iommufd.c | 3 +++ | 12 | hw/vfio/iommufd.c | 3 +++ |
... | ... | ||
41 | diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c | 44 | diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c |
42 | index XXXXXXX..XXXXXXX 100644 | 45 | index XXXXXXX..XXXXXXX 100644 |
43 | --- a/hw/vfio/iommufd.c | 46 | --- a/hw/vfio/iommufd.c |
44 | +++ b/hw/vfio/iommufd.c | 47 | +++ b/hw/vfio/iommufd.c |
45 | @@ -XXX,XX +XXX,XX @@ | 48 | @@ -XXX,XX +XXX,XX @@ |
46 | #include "migration.h" | 49 | #include "pci.h" |
47 | #include "iommufd.h" | 50 | #include "vfio-iommufd.h" |
48 | 51 | ||
49 | +#define TYPE_HOST_IOMMU_DEVICE_IOMMUFD_VFIO \ | 52 | +#define TYPE_HOST_IOMMU_DEVICE_IOMMUFD_VFIO \ |
50 | + TYPE_HOST_IOMMU_DEVICE_IOMMUFD "-vfio" | 53 | + TYPE_HOST_IOMMU_DEVICE_IOMMUFD "-vfio" |
51 | + | 54 | + |
52 | static int iommufd_cdev_map(const VFIOContainerBase *bcontainer, hwaddr iova, | 55 | static int iommufd_cdev_map(const VFIOContainerBase *bcontainer, hwaddr iova, |
53 | ram_addr_t size, void *vaddr, bool readonly) | 56 | ram_addr_t size, void *vaddr, bool readonly) |
54 | { | 57 | { |
55 | -- | 58 | -- |
56 | 2.48.1 | 59 | 2.49.0 |
57 | 60 | ||
58 | 61 | diff view generated by jsdifflib |
1 | Gather all helper routine declarations into "helpers.h" to reduce | 1 | Gather all helper routine declarations into "vfio-helpers.h" to reduce |
---|---|---|---|
2 | exposure of VFIO internals in "hw/vfio/vfio-common.h". | 2 | exposure of VFIO internals in "hw/vfio/vfio-common.h". |
3 | 3 | ||
4 | Reviewed-by: John Levon <john.levon@nutanix.com> | ||
5 | Link: https://lore.kernel.org/qemu-devel/20250318095415.670319-16-clg@redhat.com | ||
4 | Signed-off-by: Cédric Le Goater <clg@redhat.com> | 6 | Signed-off-by: Cédric Le Goater <clg@redhat.com> |
5 | --- | 7 | --- |
6 | hw/vfio/helpers.h | 26 ++++++++++++++++++++++++++ | 8 | hw/vfio/vfio-helpers.h | 26 ++++++++++++++++++++++++++ |
7 | include/hw/vfio/vfio-common.h | 7 ------- | 9 | include/hw/vfio/vfio-common.h | 7 ------- |
8 | hw/s390x/s390-pci-vfio.c | 1 + | 10 | hw/s390x/s390-pci-vfio.c | 1 + |
9 | hw/vfio/common.c | 1 + | 11 | hw/vfio/common.c | 1 + |
10 | hw/vfio/container.c | 1 + | 12 | hw/vfio/container.c | 1 + |
11 | hw/vfio/helpers.c | 1 + | 13 | hw/vfio/helpers.c | 1 + |
12 | hw/vfio/pci.c | 1 + | 14 | hw/vfio/pci.c | 1 + |
13 | hw/vfio/region.c | 1 + | 15 | hw/vfio/region.c | 1 + |
14 | 8 files changed, 32 insertions(+), 7 deletions(-) | 16 | 8 files changed, 32 insertions(+), 7 deletions(-) |
15 | create mode 100644 hw/vfio/helpers.h | 17 | create mode 100644 hw/vfio/vfio-helpers.h |
16 | 18 | ||
17 | diff --git a/hw/vfio/helpers.h b/hw/vfio/helpers.h | 19 | diff --git a/hw/vfio/vfio-helpers.h b/hw/vfio/vfio-helpers.h |
18 | new file mode 100644 | 20 | new file mode 100644 |
19 | index XXXXXXX..XXXXXXX | 21 | index XXXXXXX..XXXXXXX |
20 | --- /dev/null | 22 | --- /dev/null |
21 | +++ b/hw/vfio/helpers.h | 23 | +++ b/hw/vfio/vfio-helpers.h |
22 | @@ -XXX,XX +XXX,XX @@ | 24 | @@ -XXX,XX +XXX,XX @@ |
23 | +/* | 25 | +/* |
24 | + * VFIO helpers | 26 | + * VFIO helpers |
25 | + * | 27 | + * |
26 | + * Copyright Red Hat, Inc. 2025 | 28 | + * Copyright Red Hat, Inc. 2025 |
27 | + * | 29 | + * |
28 | + * SPDX-License-Identifier: GPL-2.0-or-later | 30 | + * SPDX-License-Identifier: GPL-2.0-or-later |
29 | + */ | 31 | + */ |
30 | + | 32 | + |
31 | +#ifndef HW_VFIO_HELPERS_H | 33 | +#ifndef HW_VFIO_VFIO_HELPERS_H |
32 | +#define HW_VFIO_HELPERS_H | 34 | +#define HW_VFIO_VFIO_HELPERS_H |
33 | + | 35 | + |
34 | +#ifdef CONFIG_LINUX | 36 | +#ifdef CONFIG_LINUX |
35 | +#include <linux/vfio.h> | 37 | +#include <linux/vfio.h> |
36 | + | 38 | + |
37 | +struct vfio_info_cap_header * | 39 | +struct vfio_info_cap_header * |
... | ... | ||
43 | + | 45 | + |
44 | +#endif | 46 | +#endif |
45 | + | 47 | + |
46 | +int vfio_bitmap_alloc(VFIOBitmap *vbmap, hwaddr size); | 48 | +int vfio_bitmap_alloc(VFIOBitmap *vbmap, hwaddr size); |
47 | + | 49 | + |
48 | +#endif /* HW_VFIO_HELPERS_H */ | 50 | +#endif /* HW_VFIO_VFIO_HELPERS_H */ |
49 | diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h | 51 | diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h |
50 | index XXXXXXX..XXXXXXX 100644 | 52 | index XXXXXXX..XXXXXXX 100644 |
51 | --- a/include/hw/vfio/vfio-common.h | 53 | --- a/include/hw/vfio/vfio-common.h |
52 | +++ b/include/hw/vfio/vfio-common.h | 54 | +++ b/include/hw/vfio/vfio-common.h |
53 | @@ -XXX,XX +XXX,XX @@ int vfio_get_region_info(VFIODevice *vbasedev, int index, | 55 | @@ -XXX,XX +XXX,XX @@ int vfio_get_region_info(VFIODevice *vbasedev, int index, |
... | ... | ||
74 | +++ b/hw/s390x/s390-pci-vfio.c | 76 | +++ b/hw/s390x/s390-pci-vfio.c |
75 | @@ -XXX,XX +XXX,XX @@ | 77 | @@ -XXX,XX +XXX,XX @@ |
76 | #include "hw/s390x/s390-pci-vfio.h" | 78 | #include "hw/s390x/s390-pci-vfio.h" |
77 | #include "hw/vfio/pci.h" | 79 | #include "hw/vfio/pci.h" |
78 | #include "hw/vfio/vfio-container.h" | 80 | #include "hw/vfio/vfio-container.h" |
79 | +#include "hw/vfio/helpers.h" | 81 | +#include "hw/vfio/vfio-helpers.h" |
80 | 82 | ||
81 | /* | 83 | /* |
82 | * Get the current DMA available count from vfio. Returns true if vfio is | 84 | * Get the current DMA available count from vfio. Returns true if vfio is |
83 | diff --git a/hw/vfio/common.c b/hw/vfio/common.c | 85 | diff --git a/hw/vfio/common.c b/hw/vfio/common.c |
84 | index XXXXXXX..XXXXXXX 100644 | 86 | index XXXXXXX..XXXXXXX 100644 |
85 | --- a/hw/vfio/common.c | 87 | --- a/hw/vfio/common.c |
86 | +++ b/hw/vfio/common.c | 88 | +++ b/hw/vfio/common.c |
87 | @@ -XXX,XX +XXX,XX @@ | 89 | @@ -XXX,XX +XXX,XX @@ |
88 | #include "system/tcg.h" | 90 | #include "system/tcg.h" |
89 | #include "system/tpm.h" | 91 | #include "system/tpm.h" |
90 | #include "migration.h" | 92 | #include "vfio-migration-internal.h" |
91 | +#include "helpers.h" | 93 | +#include "vfio-helpers.h" |
92 | 94 | ||
93 | VFIODeviceList vfio_device_list = | 95 | VFIODeviceList vfio_device_list = |
94 | QLIST_HEAD_INITIALIZER(vfio_device_list); | 96 | QLIST_HEAD_INITIALIZER(vfio_device_list); |
95 | diff --git a/hw/vfio/container.c b/hw/vfio/container.c | 97 | diff --git a/hw/vfio/container.c b/hw/vfio/container.c |
96 | index XXXXXXX..XXXXXXX 100644 | 98 | index XXXXXXX..XXXXXXX 100644 |
97 | --- a/hw/vfio/container.c | 99 | --- a/hw/vfio/container.c |
98 | +++ b/hw/vfio/container.c | 100 | +++ b/hw/vfio/container.c |
99 | @@ -XXX,XX +XXX,XX @@ | 101 | @@ -XXX,XX +XXX,XX @@ |
100 | #include "qapi/error.h" | 102 | #include "qapi/error.h" |
101 | #include "pci.h" | 103 | #include "pci.h" |
102 | #include "hw/vfio/vfio-container.h" | 104 | #include "hw/vfio/vfio-container.h" |
103 | +#include "helpers.h" | 105 | +#include "vfio-helpers.h" |
104 | 106 | ||
105 | #define TYPE_HOST_IOMMU_DEVICE_LEGACY_VFIO TYPE_HOST_IOMMU_DEVICE "-legacy-vfio" | 107 | #define TYPE_HOST_IOMMU_DEVICE_LEGACY_VFIO TYPE_HOST_IOMMU_DEVICE "-legacy-vfio" |
106 | 108 | ||
107 | diff --git a/hw/vfio/helpers.c b/hw/vfio/helpers.c | 109 | diff --git a/hw/vfio/helpers.c b/hw/vfio/helpers.c |
108 | index XXXXXXX..XXXXXXX 100644 | 110 | index XXXXXXX..XXXXXXX 100644 |
109 | --- a/hw/vfio/helpers.c | 111 | --- a/hw/vfio/helpers.c |
110 | +++ b/hw/vfio/helpers.c | 112 | +++ b/hw/vfio/helpers.c |
111 | @@ -XXX,XX +XXX,XX @@ | 113 | @@ -XXX,XX +XXX,XX @@ |
112 | #include "qemu/error-report.h" | 114 | #include "qemu/error-report.h" |
113 | #include "qemu/units.h" | 115 | #include "qemu/units.h" |
114 | #include "monitor/monitor.h" | 116 | #include "monitor/monitor.h" |
115 | +#include "helpers.h" | 117 | +#include "vfio-helpers.h" |
116 | 118 | ||
117 | /* | 119 | /* |
118 | * Common VFIO interrupt disable | 120 | * Common VFIO interrupt disable |
119 | diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c | 121 | diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c |
120 | index XXXXXXX..XXXXXXX 100644 | 122 | index XXXXXXX..XXXXXXX 100644 |
121 | --- a/hw/vfio/pci.c | 123 | --- a/hw/vfio/pci.c |
122 | +++ b/hw/vfio/pci.c | 124 | +++ b/hw/vfio/pci.c |
123 | @@ -XXX,XX +XXX,XX @@ | 125 | @@ -XXX,XX +XXX,XX @@ |
124 | #include "system/iommufd.h" | 126 | #include "system/iommufd.h" |
125 | #include "migration.h" | 127 | #include "vfio-migration-internal.h" |
126 | #include "hw/vfio/vfio-region.h" | 128 | #include "hw/vfio/vfio-region.h" |
127 | +#include "helpers.h" | 129 | +#include "vfio-helpers.h" |
128 | 130 | ||
129 | #define TYPE_VFIO_PCI_NOHOTPLUG "vfio-pci-nohotplug" | 131 | #define TYPE_VFIO_PCI_NOHOTPLUG "vfio-pci-nohotplug" |
130 | 132 | ||
131 | diff --git a/hw/vfio/region.c b/hw/vfio/region.c | 133 | diff --git a/hw/vfio/region.c b/hw/vfio/region.c |
132 | index XXXXXXX..XXXXXXX 100644 | 134 | index XXXXXXX..XXXXXXX 100644 |
133 | --- a/hw/vfio/region.c | 135 | --- a/hw/vfio/region.c |
134 | +++ b/hw/vfio/region.c | 136 | +++ b/hw/vfio/region.c |
135 | @@ -XXX,XX +XXX,XX @@ | 137 | @@ -XXX,XX +XXX,XX @@ |
136 | #include "qemu/error-report.h" | 138 | #include "qemu/error-report.h" |
137 | #include "qemu/units.h" | 139 | #include "qemu/units.h" |
138 | #include "monitor/monitor.h" | 140 | #include "monitor/monitor.h" |
139 | +#include "helpers.h" | 141 | +#include "vfio-helpers.h" |
140 | 142 | ||
141 | /* | 143 | /* |
142 | * IO Port/MMIO - Beware of the endians, VFIO is always little endian | 144 | * IO Port/MMIO - Beware of the endians, VFIO is always little endian |
143 | -- | 145 | -- |
144 | 2.48.1 | 146 | 2.49.0 |
145 | 147 | ||
146 | 148 | diff view generated by jsdifflib |
1 | vfio_get_info_dma_avail() is a low level routine similar to the other | 1 | vfio_get_info_dma_avail() is a low level routine similar to the other |
---|---|---|---|
2 | routines extracting capabilities from 'struct vfio_iommu_type1_info'. | 2 | routines extracting capabilities from 'struct vfio_iommu_type1_info'. |
3 | It belongs to file "helpers.c". | 3 | It belongs to file "helpers.c". |
4 | 4 | ||
5 | Reviewed-by: John Levon <john.levon@nutanix.com> | ||
6 | Link: https://lore.kernel.org/qemu-devel/20250318095415.670319-17-clg@redhat.com | ||
5 | Signed-off-by: Cédric Le Goater <clg@redhat.com> | 7 | Signed-off-by: Cédric Le Goater <clg@redhat.com> |
6 | --- | 8 | --- |
7 | hw/vfio/helpers.h | 5 ++++- | 9 | hw/vfio/vfio-helpers.h | 5 ++++- |
8 | include/hw/vfio/vfio-common.h | 2 -- | 10 | include/hw/vfio/vfio-common.h | 2 -- |
9 | hw/vfio/container.c | 31 ------------------------------- | 11 | hw/vfio/container.c | 31 ------------------------------- |
10 | hw/vfio/helpers.c | 31 +++++++++++++++++++++++++++++++ | 12 | hw/vfio/helpers.c | 31 +++++++++++++++++++++++++++++++ |
11 | 4 files changed, 35 insertions(+), 34 deletions(-) | 13 | 4 files changed, 35 insertions(+), 34 deletions(-) |
12 | 14 | ||
13 | diff --git a/hw/vfio/helpers.h b/hw/vfio/helpers.h | 15 | diff --git a/hw/vfio/vfio-helpers.h b/hw/vfio/vfio-helpers.h |
14 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/hw/vfio/helpers.h | 17 | --- a/hw/vfio/vfio-helpers.h |
16 | +++ b/hw/vfio/helpers.h | 18 | +++ b/hw/vfio/vfio-helpers.h |
17 | @@ -XXX,XX +XXX,XX @@ struct vfio_info_cap_header * | 19 | @@ -XXX,XX +XXX,XX @@ struct vfio_info_cap_header * |
18 | vfio_get_device_info_cap(struct vfio_device_info *info, uint16_t id); | 20 | vfio_get_device_info_cap(struct vfio_device_info *info, uint16_t id); |
19 | struct vfio_info_cap_header * | 21 | struct vfio_info_cap_header * |
20 | vfio_get_region_info_cap(struct vfio_region_info *info, uint16_t id); | 22 | vfio_get_region_info_cap(struct vfio_region_info *info, uint16_t id); |
21 | - | 23 | - |
... | ... | ||
122 | + | 124 | + |
123 | int vfio_get_dev_region_info(VFIODevice *vbasedev, uint32_t type, | 125 | int vfio_get_dev_region_info(VFIODevice *vbasedev, uint32_t type, |
124 | uint32_t subtype, struct vfio_region_info **info) | 126 | uint32_t subtype, struct vfio_region_info **info) |
125 | { | 127 | { |
126 | -- | 128 | -- |
127 | 2.48.1 | 129 | 2.49.0 |
128 | 130 | ||
129 | 131 | diff view generated by jsdifflib |
1 | vfio_kvm_device_add/del_fd() are low level routines. Move them with | 1 | vfio_kvm_device_add/del_fd() are low level routines. Move them with |
---|---|---|---|
2 | the other helpers. | 2 | the other helpers. |
3 | 3 | ||
4 | Reviewed-by: Zhenzhong Duan <zhenzhong.duan@intel.com> | ||
5 | Reviewed-by: John Levon <john.levon@nutanix.com> | ||
6 | Link: https://lore.kernel.org/qemu-devel/20250318095415.670319-18-clg@redhat.com | ||
4 | Signed-off-by: Cédric Le Goater <clg@redhat.com> | 7 | Signed-off-by: Cédric Le Goater <clg@redhat.com> |
5 | --- | 8 | --- |
6 | hw/vfio/helpers.h | 3 ++ | 9 | hw/vfio/vfio-helpers.h | 3 ++ |
7 | include/hw/vfio/vfio-common.h | 3 -- | 10 | include/hw/vfio/vfio-common.h | 3 -- |
8 | hw/vfio/common.c | 58 ---------------------------------- | 11 | hw/vfio/common.c | 58 ---------------------------------- |
9 | hw/vfio/helpers.c | 59 +++++++++++++++++++++++++++++++++++ | 12 | hw/vfio/helpers.c | 59 +++++++++++++++++++++++++++++++++++ |
10 | hw/vfio/iommufd.c | 1 + | 13 | hw/vfio/iommufd.c | 1 + |
11 | hw/vfio/meson.build | 2 +- | 14 | hw/vfio/meson.build | 2 +- |
12 | 6 files changed, 64 insertions(+), 62 deletions(-) | 15 | 6 files changed, 64 insertions(+), 62 deletions(-) |
13 | 16 | ||
14 | diff --git a/hw/vfio/helpers.h b/hw/vfio/helpers.h | 17 | diff --git a/hw/vfio/vfio-helpers.h b/hw/vfio/vfio-helpers.h |
15 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/hw/vfio/helpers.h | 19 | --- a/hw/vfio/vfio-helpers.h |
17 | +++ b/hw/vfio/helpers.h | 20 | +++ b/hw/vfio/vfio-helpers.h |
18 | @@ -XXX,XX +XXX,XX @@ bool vfio_get_info_dma_avail(struct vfio_iommu_type1_info *info, | 21 | @@ -XXX,XX +XXX,XX @@ bool vfio_get_info_dma_avail(struct vfio_iommu_type1_info *info, |
19 | 22 | ||
20 | int vfio_bitmap_alloc(VFIOBitmap *vbmap, hwaddr size); | 23 | int vfio_bitmap_alloc(VFIOBitmap *vbmap, hwaddr size); |
21 | 24 | ||
22 | +int vfio_kvm_device_add_fd(int fd, Error **errp); | 25 | +int vfio_kvm_device_add_fd(int fd, Error **errp); |
23 | +int vfio_kvm_device_del_fd(int fd, Error **errp); | 26 | +int vfio_kvm_device_del_fd(int fd, Error **errp); |
24 | + | 27 | + |
25 | #endif /* HW_VFIO_HELPERS_H */ | 28 | #endif /* HW_VFIO_VFIO_HELPERS_H */ |
26 | diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h | 29 | diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h |
27 | index XXXXXXX..XXXXXXX 100644 | 30 | index XXXXXXX..XXXXXXX 100644 |
28 | --- a/include/hw/vfio/vfio-common.h | 31 | --- a/include/hw/vfio/vfio-common.h |
29 | +++ b/include/hw/vfio/vfio-common.h | 32 | +++ b/include/hw/vfio/vfio-common.h |
30 | @@ -XXX,XX +XXX,XX @@ bool vfio_attach_device(char *name, VFIODevice *vbasedev, | 33 | @@ -XXX,XX +XXX,XX @@ bool vfio_attach_device(char *name, VFIODevice *vbasedev, |
... | ... | ||
39 | 42 | ||
40 | diff --git a/hw/vfio/common.c b/hw/vfio/common.c | 43 | diff --git a/hw/vfio/common.c b/hw/vfio/common.c |
41 | index XXXXXXX..XXXXXXX 100644 | 44 | index XXXXXXX..XXXXXXX 100644 |
42 | --- a/hw/vfio/common.c | 45 | --- a/hw/vfio/common.c |
43 | +++ b/hw/vfio/common.c | 46 | +++ b/hw/vfio/common.c |
44 | @@ -XXX,XX +XXX,XX @@ const MemoryListener vfio_memory_listener = { | 47 | @@ -XXX,XX +XXX,XX @@ void vfio_reset_handler(void *opaque) |
45 | .log_sync = vfio_listener_log_sync, | 48 | } |
46 | }; | 49 | } |
47 | 50 | ||
48 | -int vfio_kvm_device_add_fd(int fd, Error **errp) | 51 | -int vfio_kvm_device_add_fd(int fd, Error **errp) |
49 | -{ | 52 | -{ |
50 | -#ifdef CONFIG_KVM | 53 | -#ifdef CONFIG_KVM |
51 | - struct kvm_device_attr attr = { | 54 | - struct kvm_device_attr attr = { |
... | ... | ||
186 | diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c | 189 | diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c |
187 | index XXXXXXX..XXXXXXX 100644 | 190 | index XXXXXXX..XXXXXXX 100644 |
188 | --- a/hw/vfio/iommufd.c | 191 | --- a/hw/vfio/iommufd.c |
189 | +++ b/hw/vfio/iommufd.c | 192 | +++ b/hw/vfio/iommufd.c |
190 | @@ -XXX,XX +XXX,XX @@ | 193 | @@ -XXX,XX +XXX,XX @@ |
194 | #include "qemu/chardev_open.h" | ||
191 | #include "pci.h" | 195 | #include "pci.h" |
192 | #include "migration.h" | 196 | #include "vfio-iommufd.h" |
193 | #include "iommufd.h" | 197 | +#include "vfio-helpers.h" |
194 | +#include "helpers.h" | ||
195 | 198 | ||
196 | #define TYPE_HOST_IOMMU_DEVICE_IOMMUFD_VFIO \ | 199 | #define TYPE_HOST_IOMMU_DEVICE_IOMMUFD_VFIO \ |
197 | TYPE_HOST_IOMMU_DEVICE_IOMMUFD "-vfio" | 200 | TYPE_HOST_IOMMU_DEVICE_IOMMUFD "-vfio" |
198 | diff --git a/hw/vfio/meson.build b/hw/vfio/meson.build | 201 | diff --git a/hw/vfio/meson.build b/hw/vfio/meson.build |
199 | index XXXXXXX..XXXXXXX 100644 | 202 | index XXXXXXX..XXXXXXX 100644 |
... | ... | ||
214 | - 'helpers.c', | 217 | - 'helpers.c', |
215 | 'container-base.c', | 218 | 'container-base.c', |
216 | 'migration.c', | 219 | 'migration.c', |
217 | 'migration-multifd.c', | 220 | 'migration-multifd.c', |
218 | -- | 221 | -- |
219 | 2.48.1 | 222 | 2.49.0 |
220 | 223 | ||
221 | 224 | diff view generated by jsdifflib |
1 | vfio_get_device_info() is a low level routine. Move it with the other | 1 | vfio_get_device_info() is a low level routine. Move it with the other |
---|---|---|---|
2 | helpers. | 2 | helpers. |
3 | 3 | ||
4 | Reviewed-by: Zhenzhong Duan <zhenzhong.duan@intel.com> | ||
5 | Reviewed-by: John Levon <john.levon@nutanix.com> | ||
6 | Link: https://lore.kernel.org/qemu-devel/20250318095415.670319-19-clg@redhat.com | ||
4 | Signed-off-by: Cédric Le Goater <clg@redhat.com> | 7 | Signed-off-by: Cédric Le Goater <clg@redhat.com> |
5 | --- | 8 | --- |
6 | hw/vfio/helpers.h | 1 + | 9 | hw/vfio/vfio-helpers.h | 1 + |
7 | include/hw/vfio/vfio-common.h | 1 - | 10 | include/hw/vfio/vfio-common.h | 1 - |
8 | hw/vfio/common.c | 24 ------------------------ | 11 | hw/vfio/common.c | 24 ------------------------ |
9 | hw/vfio/helpers.c | 24 ++++++++++++++++++++++++ | 12 | hw/vfio/helpers.c | 24 ++++++++++++++++++++++++ |
10 | 4 files changed, 25 insertions(+), 25 deletions(-) | 13 | 4 files changed, 25 insertions(+), 25 deletions(-) |
11 | 14 | ||
12 | diff --git a/hw/vfio/helpers.h b/hw/vfio/helpers.h | 15 | diff --git a/hw/vfio/vfio-helpers.h b/hw/vfio/vfio-helpers.h |
13 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/hw/vfio/helpers.h | 17 | --- a/hw/vfio/vfio-helpers.h |
15 | +++ b/hw/vfio/helpers.h | 18 | +++ b/hw/vfio/vfio-helpers.h |
16 | @@ -XXX,XX +XXX,XX @@ bool vfio_get_info_dma_avail(struct vfio_iommu_type1_info *info, | 19 | @@ -XXX,XX +XXX,XX @@ bool vfio_get_info_dma_avail(struct vfio_iommu_type1_info *info, |
17 | #endif | 20 | #endif |
18 | 21 | ||
19 | int vfio_bitmap_alloc(VFIOBitmap *vbmap, hwaddr size); | 22 | int vfio_bitmap_alloc(VFIOBitmap *vbmap, hwaddr size); |
20 | +struct vfio_device_info *vfio_get_device_info(int fd); | 23 | +struct vfio_device_info *vfio_get_device_info(int fd); |
... | ... | ||
23 | int vfio_kvm_device_del_fd(int fd, Error **errp); | 26 | int vfio_kvm_device_del_fd(int fd, Error **errp); |
24 | diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h | 27 | diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h |
25 | index XXXXXXX..XXXXXXX 100644 | 28 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/include/hw/vfio/vfio-common.h | 29 | --- a/include/hw/vfio/vfio-common.h |
27 | +++ b/include/hw/vfio/vfio-common.h | 30 | +++ b/include/hw/vfio/vfio-common.h |
28 | @@ -XXX,XX +XXX,XX @@ void vfio_mask_single_irqindex(VFIODevice *vbasedev, int index); | 31 | @@ -XXX,XX +XXX,XX @@ bool vfio_set_irq_signaling(VFIODevice *vbasedev, int index, int subindex, |
29 | bool vfio_set_irq_signaling(VFIODevice *vbasedev, int index, int subindex, | ||
30 | int action, int fd, Error **errp); | 32 | int action, int fd, Error **errp); |
31 | 33 | ||
34 | void vfio_reset_handler(void *opaque); | ||
32 | -struct vfio_device_info *vfio_get_device_info(int fd); | 35 | -struct vfio_device_info *vfio_get_device_info(int fd); |
33 | bool vfio_device_is_mdev(VFIODevice *vbasedev); | 36 | bool vfio_device_is_mdev(VFIODevice *vbasedev); |
34 | bool vfio_device_hiod_realize(VFIODevice *vbasedev, Error **errp); | 37 | bool vfio_device_hiod_realize(VFIODevice *vbasedev, Error **errp); |
35 | bool vfio_attach_device(char *name, VFIODevice *vbasedev, | 38 | bool vfio_attach_device(char *name, VFIODevice *vbasedev, |
36 | diff --git a/hw/vfio/common.c b/hw/vfio/common.c | 39 | diff --git a/hw/vfio/common.c b/hw/vfio/common.c |
37 | index XXXXXXX..XXXXXXX 100644 | 40 | index XXXXXXX..XXXXXXX 100644 |
38 | --- a/hw/vfio/common.c | 41 | --- a/hw/vfio/common.c |
39 | +++ b/hw/vfio/common.c | 42 | +++ b/hw/vfio/common.c |
40 | @@ -XXX,XX +XXX,XX @@ const MemoryListener vfio_memory_listener = { | 43 | @@ -XXX,XX +XXX,XX @@ void vfio_reset_handler(void *opaque) |
41 | .log_sync = vfio_listener_log_sync, | 44 | } |
42 | }; | 45 | } |
43 | 46 | ||
44 | -struct vfio_device_info *vfio_get_device_info(int fd) | 47 | -struct vfio_device_info *vfio_get_device_info(int fd) |
45 | -{ | 48 | -{ |
46 | - struct vfio_device_info *info; | 49 | - struct vfio_device_info *info; |
47 | - uint32_t argsz = sizeof(*info); | 50 | - uint32_t argsz = sizeof(*info); |
... | ... | ||
102 | + | 105 | + |
103 | int vfio_get_dev_region_info(VFIODevice *vbasedev, uint32_t type, | 106 | int vfio_get_dev_region_info(VFIODevice *vbasedev, uint32_t type, |
104 | uint32_t subtype, struct vfio_region_info **info) | 107 | uint32_t subtype, struct vfio_region_info **info) |
105 | { | 108 | { |
106 | -- | 109 | -- |
107 | 2.48.1 | 110 | 2.49.0 |
108 | 111 | ||
109 | 112 | diff view generated by jsdifflib |
1 | Move all VFIODevice related routines of helpers.c into a new "device.c" | 1 | Move all VFIODevice related routines of "helpers.c" into a new "device.c" |
---|---|---|---|
2 | file. | 2 | file. |
3 | 3 | ||
4 | Signed-off-by: Cédric Le Goater <clg@redhat.com> | 4 | Signed-off-by: Cédric Le Goater <clg@redhat.com> |
5 | --- | 5 | --- |
6 | hw/vfio/device.c | 331 +++++++++++++++++++++++++++++++++++++++++++ | 6 | hw/vfio/device.c | 330 +++++++++++++++++++++++++++++++++++++++++++ |
7 | hw/vfio/helpers.c | 303 --------------------------------------- | 7 | hw/vfio/helpers.c | 303 --------------------------------------- |
8 | hw/vfio/meson.build | 1 + | 8 | hw/vfio/meson.build | 1 + |
9 | hw/vfio/trace-events | 4 +- | 9 | hw/vfio/trace-events | 4 +- |
10 | 4 files changed, 335 insertions(+), 304 deletions(-) | 10 | 4 files changed, 334 insertions(+), 304 deletions(-) |
11 | create mode 100644 hw/vfio/device.c | 11 | create mode 100644 hw/vfio/device.c |
12 | 12 | ||
13 | diff --git a/hw/vfio/device.c b/hw/vfio/device.c | 13 | diff --git a/hw/vfio/device.c b/hw/vfio/device.c |
14 | new file mode 100644 | 14 | new file mode 100644 |
15 | index XXXXXXX..XXXXXXX | 15 | index XXXXXXX..XXXXXXX |
16 | --- /dev/null | 16 | --- /dev/null |
17 | +++ b/hw/vfio/device.c | 17 | +++ b/hw/vfio/device.c |
18 | @@ -XXX,XX +XXX,XX @@ | 18 | @@ -XXX,XX +XXX,XX @@ |
19 | +/* | 19 | +/* |
20 | + * low level and IOMMU backend agnostic helpers used by VFIO devices, | 20 | + * VFIO device |
21 | + * related to regions, interrupts, capabilities | ||
22 | + * | 21 | + * |
23 | + * Copyright Red Hat, Inc. 2012 | 22 | + * Copyright Red Hat, Inc. 2012 |
24 | + * | 23 | + * |
25 | + * Authors: | 24 | + * Authors: |
26 | + * Alex Williamson <alex.williamson@redhat.com> | 25 | + * Alex Williamson <alex.williamson@redhat.com> |
... | ... | ||
46 | +#include "trace.h" | 45 | +#include "trace.h" |
47 | +#include "qapi/error.h" | 46 | +#include "qapi/error.h" |
48 | +#include "qemu/error-report.h" | 47 | +#include "qemu/error-report.h" |
49 | +#include "qemu/units.h" | 48 | +#include "qemu/units.h" |
50 | +#include "monitor/monitor.h" | 49 | +#include "monitor/monitor.h" |
51 | +#include "helpers.h" | 50 | +#include "vfio-helpers.h" |
52 | + | 51 | + |
53 | +/* | 52 | +/* |
54 | + * Common VFIO interrupt disable | 53 | + * Common VFIO interrupt disable |
55 | + */ | 54 | + */ |
56 | +void vfio_disable_irqindex(VFIODevice *vbasedev, int index) | 55 | +void vfio_disable_irqindex(VFIODevice *vbasedev, int index) |
... | ... | ||
360 | -#include "trace.h" | 359 | -#include "trace.h" |
361 | #include "qapi/error.h" | 360 | #include "qapi/error.h" |
362 | -#include "qemu/error-report.h" | 361 | -#include "qemu/error-report.h" |
363 | -#include "qemu/units.h" | 362 | -#include "qemu/units.h" |
364 | -#include "monitor/monitor.h" | 363 | -#include "monitor/monitor.h" |
365 | #include "helpers.h" | 364 | #include "vfio-helpers.h" |
366 | 365 | ||
367 | -/* | 366 | -/* |
368 | - * Common VFIO interrupt disable | 367 | - * Common VFIO interrupt disable |
369 | - */ | 368 | - */ |
370 | -void vfio_disable_irqindex(VFIODevice *vbasedev, int index) | 369 | -void vfio_disable_irqindex(VFIODevice *vbasedev, int index) |
... | ... | ||
698 | vfio_put_base_device(int fd) "close vdev->fd=%d" | 697 | vfio_put_base_device(int fd) "close vdev->fd=%d" |
699 | -vfio_get_dev_region(const char *name, int index, uint32_t type, uint32_t subtype) "%s index %d, %08x/%08x" | 698 | -vfio_get_dev_region(const char *name, int index, uint32_t type, uint32_t subtype) "%s index %d, %08x/%08x" |
700 | vfio_legacy_dma_unmap_overflow_workaround(void) "" | 699 | vfio_legacy_dma_unmap_overflow_workaround(void) "" |
701 | vfio_get_dirty_bitmap(uint64_t iova, uint64_t size, uint64_t bitmap_size, uint64_t start, uint64_t dirty_pages) "iova=0x%"PRIx64" size= 0x%"PRIx64" bitmap_size=0x%"PRIx64" start=0x%"PRIx64" dirty_pages=%"PRIu64 | 700 | vfio_get_dirty_bitmap(uint64_t iova, uint64_t size, uint64_t bitmap_size, uint64_t start, uint64_t dirty_pages) "iova=0x%"PRIx64" size= 0x%"PRIx64" bitmap_size=0x%"PRIx64" start=0x%"PRIx64" dirty_pages=%"PRIu64 |
702 | vfio_iommu_map_dirty_notify(uint64_t iova_start, uint64_t iova_end) "iommu dirty @ 0x%"PRIx64" - 0x%"PRIx64 | 701 | vfio_iommu_map_dirty_notify(uint64_t iova_start, uint64_t iova_end) "iommu dirty @ 0x%"PRIx64" - 0x%"PRIx64 |
703 | @@ -XXX,XX +XXX,XX @@ iommufd_cdev_pci_hot_reset_dep_devices(int domain, int bus, int slot, int functi | 702 | @@ -XXX,XX +XXX,XX @@ iommufd_cdev_fail_attach_existing_container(const char *msg) " %s" |
704 | 703 | iommufd_cdev_alloc_ioas(int iommufd, int ioas_id) " [iommufd=%d] new IOMMUFD container with ioasid=%d" | |
705 | # container-base.c | 704 | iommufd_cdev_device_info(char *name, int devfd, int num_irqs, int num_regions, int flags) " %s (%d) num_irqs=%d num_regions=%d flags=%d" |
706 | vfio_reset_handler(void) "" | 705 | iommufd_cdev_pci_hot_reset_dep_devices(int domain, int bus, int slot, int function, int dev_id) "\t%04x:%02x:%02x.%x devid %d" |
707 | + | 706 | + |
708 | +# device.c | 707 | +# device.c |
709 | +vfio_get_dev_region(const char *name, int index, uint32_t type, uint32_t subtype) "%s index %d, %08x/%08x" | 708 | +vfio_get_dev_region(const char *name, int index, uint32_t type, uint32_t subtype) "%s index %d, %08x/%08x" |
710 | -- | 709 | -- |
711 | 2.48.1 | 710 | 2.49.0 |
712 | 711 | ||
713 | 712 | diff view generated by jsdifflib |
1 | Gather all CPR related declarations into "cpr.h" to reduce exposure | 1 | Gather all CPR related declarations into "vfio-cpr.h" to reduce exposure |
---|---|---|---|
2 | of VFIO internals in "hw/vfio/vfio-common.h". | 2 | of VFIO internals in "hw/vfio/vfio-common.h". These were introduced in |
3 | commit d9fa4223b30a ("vfio: register container for cpr"). | ||
3 | 4 | ||
4 | Order file list in meson.build while at it. | 5 | Order file list in meson.build while at it. |
5 | 6 | ||
7 | Cc: Steve Sistare <steven.sistare@oracle.com> | ||
6 | Signed-off-by: Cédric Le Goater <clg@redhat.com> | 8 | Signed-off-by: Cédric Le Goater <clg@redhat.com> |
7 | --- | 9 | --- |
8 | hw/vfio/cpr.h | 15 +++++++++++++++ | 10 | hw/vfio/vfio-cpr.h | 15 +++++++++++++++ |
9 | include/hw/vfio/vfio-common.h | 3 --- | 11 | include/hw/vfio/vfio-common.h | 3 --- |
10 | hw/vfio/container.c | 1 + | 12 | hw/vfio/container.c | 1 + |
11 | hw/vfio/cpr.c | 1 + | 13 | hw/vfio/cpr.c | 1 + |
12 | hw/vfio/iommufd.c | 1 + | 14 | hw/vfio/iommufd.c | 1 + |
13 | hw/vfio/meson.build | 2 +- | 15 | hw/vfio/meson.build | 2 +- |
14 | 6 files changed, 19 insertions(+), 4 deletions(-) | 16 | 6 files changed, 19 insertions(+), 4 deletions(-) |
15 | create mode 100644 hw/vfio/cpr.h | 17 | create mode 100644 hw/vfio/vfio-cpr.h |
16 | 18 | ||
17 | diff --git a/hw/vfio/cpr.h b/hw/vfio/cpr.h | 19 | diff --git a/hw/vfio/vfio-cpr.h b/hw/vfio/vfio-cpr.h |
18 | new file mode 100644 | 20 | new file mode 100644 |
19 | index XXXXXXX..XXXXXXX | 21 | index XXXXXXX..XXXXXXX |
20 | --- /dev/null | 22 | --- /dev/null |
21 | +++ b/hw/vfio/cpr.h | 23 | +++ b/hw/vfio/vfio-cpr.h |
22 | @@ -XXX,XX +XXX,XX @@ | 24 | @@ -XXX,XX +XXX,XX @@ |
23 | +/* | 25 | +/* |
24 | + * VFIO display | 26 | + * VFIO CPR |
25 | + * | 27 | + * |
26 | + * Copyright Red Hat, Inc. 2025 | 28 | + * Copyright Red Hat, Inc. 2025 |
27 | + * | 29 | + * |
28 | + * SPDX-License-Identifier: GPL-2.0-or-later | 30 | + * SPDX-License-Identifier: GPL-2.0-or-later |
29 | + */ | 31 | + */ |
... | ... | ||
54 | --- a/hw/vfio/container.c | 56 | --- a/hw/vfio/container.c |
55 | +++ b/hw/vfio/container.c | 57 | +++ b/hw/vfio/container.c |
56 | @@ -XXX,XX +XXX,XX @@ | 58 | @@ -XXX,XX +XXX,XX @@ |
57 | #include "pci.h" | 59 | #include "pci.h" |
58 | #include "hw/vfio/vfio-container.h" | 60 | #include "hw/vfio/vfio-container.h" |
59 | #include "helpers.h" | 61 | #include "vfio-helpers.h" |
60 | +#include "cpr.h" | 62 | +#include "vfio-cpr.h" |
61 | 63 | ||
62 | #define TYPE_HOST_IOMMU_DEVICE_LEGACY_VFIO TYPE_HOST_IOMMU_DEVICE "-legacy-vfio" | 64 | #define TYPE_HOST_IOMMU_DEVICE_LEGACY_VFIO TYPE_HOST_IOMMU_DEVICE "-legacy-vfio" |
63 | 65 | ||
64 | diff --git a/hw/vfio/cpr.c b/hw/vfio/cpr.c | 66 | diff --git a/hw/vfio/cpr.c b/hw/vfio/cpr.c |
65 | index XXXXXXX..XXXXXXX 100644 | 67 | index XXXXXXX..XXXXXXX 100644 |
66 | --- a/hw/vfio/cpr.c | 68 | --- a/hw/vfio/cpr.c |
67 | +++ b/hw/vfio/cpr.c | 69 | +++ b/hw/vfio/cpr.c |
68 | @@ -XXX,XX +XXX,XX @@ | 70 | @@ -XXX,XX +XXX,XX @@ |
69 | #include "migration/misc.h" | 71 | #include "migration/misc.h" |
70 | #include "qapi/error.h" | 72 | #include "qapi/error.h" |
71 | #include "system/runstate.h" | 73 | #include "system/runstate.h" |
72 | +#include "cpr.h" | 74 | +#include "vfio-cpr.h" |
73 | 75 | ||
74 | static int vfio_cpr_reboot_notifier(NotifierWithReturn *notifier, | 76 | static int vfio_cpr_reboot_notifier(NotifierWithReturn *notifier, |
75 | MigrationEvent *e, Error **errp) | 77 | MigrationEvent *e, Error **errp) |
76 | diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c | 78 | diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c |
77 | index XXXXXXX..XXXXXXX 100644 | 79 | index XXXXXXX..XXXXXXX 100644 |
78 | --- a/hw/vfio/iommufd.c | 80 | --- a/hw/vfio/iommufd.c |
79 | +++ b/hw/vfio/iommufd.c | 81 | +++ b/hw/vfio/iommufd.c |
80 | @@ -XXX,XX +XXX,XX @@ | 82 | @@ -XXX,XX +XXX,XX @@ |
81 | #include "migration.h" | 83 | #include "pci.h" |
82 | #include "iommufd.h" | 84 | #include "vfio-iommufd.h" |
83 | #include "helpers.h" | 85 | #include "vfio-helpers.h" |
84 | +#include "cpr.h" | 86 | +#include "vfio-cpr.h" |
85 | 87 | ||
86 | #define TYPE_HOST_IOMMU_DEVICE_IOMMUFD_VFIO \ | 88 | #define TYPE_HOST_IOMMU_DEVICE_IOMMUFD_VFIO \ |
87 | TYPE_HOST_IOMMU_DEVICE_IOMMUFD "-vfio" | 89 | TYPE_HOST_IOMMU_DEVICE_IOMMUFD "-vfio" |
88 | diff --git a/hw/vfio/meson.build b/hw/vfio/meson.build | 90 | diff --git a/hw/vfio/meson.build b/hw/vfio/meson.build |
89 | index XXXXXXX..XXXXXXX 100644 | 91 | index XXXXXXX..XXXXXXX 100644 |
... | ... | ||
100 | - 'cpr.c', | 102 | - 'cpr.c', |
101 | 'region.c', | 103 | 'region.c', |
102 | )) | 104 | )) |
103 | system_ss.add(when: ['CONFIG_VFIO', 'CONFIG_IOMMUFD'], if_true: files( | 105 | system_ss.add(when: ['CONFIG_VFIO', 'CONFIG_IOMMUFD'], if_true: files( |
104 | -- | 106 | -- |
105 | 2.48.1 | 107 | 2.49.0 |
106 | 108 | ||
107 | 109 | diff view generated by jsdifflib |
1 | The vfio_kvm_device_add/del_fd() routines opening the VFIO pseudo | 1 | The vfio_kvm_device_add/del_fd() routines opening the VFIO pseudo |
---|---|---|---|
2 | device are defined in "helpers.c". Move 'vfio_kvm_device_fd' | 2 | device are defined in "helpers.c". Move 'vfio_kvm_device_fd' |
3 | definition there and its declaration into "helpers.h" to reduce | 3 | definition there and its declaration into "vfio-helpers.h" to reduce |
4 | exposure of VFIO internals in "hw/vfio/vfio-common.h". | 4 | exposure of VFIO internals in "hw/vfio/vfio-common.h". |
5 | 5 | ||
6 | Reviewed-by: John Levon <john.levon@nutanix.com> | ||
7 | Link: https://lore.kernel.org/qemu-devel/20250318095415.670319-22-clg@redhat.com | ||
6 | Signed-off-by: Cédric Le Goater <clg@redhat.com> | 8 | Signed-off-by: Cédric Le Goater <clg@redhat.com> |
7 | --- | 9 | --- |
8 | hw/vfio/helpers.h | 2 ++ | 10 | hw/vfio/vfio-helpers.h | 2 ++ |
9 | include/hw/vfio/vfio-common.h | 1 - | 11 | include/hw/vfio/vfio-common.h | 1 - |
10 | hw/vfio/common.c | 11 ----------- | 12 | hw/vfio/common.c | 11 ----------- |
11 | hw/vfio/helpers.c | 11 +++++++++++ | 13 | hw/vfio/helpers.c | 11 +++++++++++ |
12 | hw/vfio/spapr.c | 2 +- | 14 | hw/vfio/spapr.c | 2 +- |
13 | 5 files changed, 14 insertions(+), 13 deletions(-) | 15 | 5 files changed, 14 insertions(+), 13 deletions(-) |
14 | 16 | ||
15 | diff --git a/hw/vfio/helpers.h b/hw/vfio/helpers.h | 17 | diff --git a/hw/vfio/vfio-helpers.h b/hw/vfio/vfio-helpers.h |
16 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/hw/vfio/helpers.h | 19 | --- a/hw/vfio/vfio-helpers.h |
18 | +++ b/hw/vfio/helpers.h | 20 | +++ b/hw/vfio/vfio-helpers.h |
19 | @@ -XXX,XX +XXX,XX @@ | 21 | @@ -XXX,XX +XXX,XX @@ |
20 | #ifdef CONFIG_LINUX | 22 | #ifdef CONFIG_LINUX |
21 | #include <linux/vfio.h> | 23 | #include <linux/vfio.h> |
22 | 24 | ||
23 | +extern int vfio_kvm_device_fd; | 25 | +extern int vfio_kvm_device_fd; |
... | ... | ||
94 | #include "hw/hw.h" | 96 | #include "hw/hw.h" |
95 | #include "exec/ram_addr.h" | 97 | #include "exec/ram_addr.h" |
96 | #include "qemu/error-report.h" | 98 | #include "qemu/error-report.h" |
97 | #include "qapi/error.h" | 99 | #include "qapi/error.h" |
98 | #include "trace.h" | 100 | #include "trace.h" |
99 | +#include "helpers.h" | 101 | +#include "vfio-helpers.h" |
100 | 102 | ||
101 | typedef struct VFIOHostDMAWindow { | 103 | typedef struct VFIOHostDMAWindow { |
102 | hwaddr min_iova; | 104 | hwaddr min_iova; |
103 | -- | 105 | -- |
104 | 2.48.1 | 106 | 2.49.0 |
105 | 107 | ||
106 | 108 | diff view generated by jsdifflib |
1 | 'vfio_device_list' is VFIODevice related. Move its definitions into | 1 | 'vfio_device_list' is VFIODevice related. Move its definitions into |
---|---|---|---|
2 | "device.c". | 2 | "device.c". |
3 | 3 | ||
4 | Reviewed-by: John Levon <john.levon@nutanix.com> | ||
5 | Link: https://lore.kernel.org/qemu-devel/20250318095415.670319-23-clg@redhat.com | ||
4 | Signed-off-by: Cédric Le Goater <clg@redhat.com> | 6 | Signed-off-by: Cédric Le Goater <clg@redhat.com> |
5 | --- | 7 | --- |
6 | hw/vfio/common.c | 3 --- | 8 | hw/vfio/common.c | 3 --- |
7 | hw/vfio/device.c | 3 +++ | 9 | hw/vfio/device.c | 3 +++ |
8 | 2 files changed, 3 insertions(+), 3 deletions(-) | 10 | 2 files changed, 3 insertions(+), 3 deletions(-) |
9 | 11 | ||
10 | diff --git a/hw/vfio/common.c b/hw/vfio/common.c | 12 | diff --git a/hw/vfio/common.c b/hw/vfio/common.c |
11 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
12 | --- a/hw/vfio/common.c | 14 | --- a/hw/vfio/common.c |
13 | +++ b/hw/vfio/common.c | 15 | +++ b/hw/vfio/common.c |
14 | @@ -XXX,XX +XXX,XX @@ | 16 | @@ -XXX,XX +XXX,XX @@ |
15 | #include "migration.h" | 17 | #include "vfio-migration-internal.h" |
16 | #include "helpers.h" | 18 | #include "vfio-helpers.h" |
17 | 19 | ||
18 | -VFIODeviceList vfio_device_list = | 20 | -VFIODeviceList vfio_device_list = |
19 | - QLIST_HEAD_INITIALIZER(vfio_device_list); | 21 | - QLIST_HEAD_INITIALIZER(vfio_device_list); |
20 | - | 22 | - |
21 | /* | 23 | /* |
... | ... | ||
25 | index XXXXXXX..XXXXXXX 100644 | 27 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/hw/vfio/device.c | 28 | --- a/hw/vfio/device.c |
27 | +++ b/hw/vfio/device.c | 29 | +++ b/hw/vfio/device.c |
28 | @@ -XXX,XX +XXX,XX @@ | 30 | @@ -XXX,XX +XXX,XX @@ |
29 | #include "monitor/monitor.h" | 31 | #include "monitor/monitor.h" |
30 | #include "helpers.h" | 32 | #include "vfio-helpers.h" |
31 | 33 | ||
32 | +VFIODeviceList vfio_device_list = | 34 | +VFIODeviceList vfio_device_list = |
33 | + QLIST_HEAD_INITIALIZER(vfio_device_list); | 35 | + QLIST_HEAD_INITIALIZER(vfio_device_list); |
34 | + | 36 | + |
35 | /* | 37 | /* |
36 | * Common VFIO interrupt disable | 38 | * Common VFIO interrupt disable |
37 | */ | 39 | */ |
38 | -- | 40 | -- |
39 | 2.48.1 | 41 | 2.49.0 |
40 | 42 | ||
41 | 43 | diff view generated by jsdifflib |
1 | These routines are VFIODevice related. Move their definitions into | 1 | These routines are VFIODevice related. Move their definitions into |
---|---|---|---|
2 | "device.c". | 2 | "device.c". |
3 | 3 | ||
4 | Reviewed-by: John Levon <john.levon@nutanix.com> | ||
5 | Link: https://lore.kernel.org/qemu-devel/20250318095415.670319-24-clg@redhat.com | ||
4 | Signed-off-by: Cédric Le Goater <clg@redhat.com> | 6 | Signed-off-by: Cédric Le Goater <clg@redhat.com> |
5 | --- | 7 | --- |
6 | hw/vfio/common.c | 37 ------------------------------------- | 8 | hw/vfio/common.c | 37 ------------------------------------- |
7 | hw/vfio/device.c | 37 +++++++++++++++++++++++++++++++++++++ | 9 | hw/vfio/device.c | 37 +++++++++++++++++++++++++++++++++++++ |
8 | 2 files changed, 37 insertions(+), 37 deletions(-) | 10 | 2 files changed, 37 insertions(+), 37 deletions(-) |
9 | 11 | ||
10 | diff --git a/hw/vfio/common.c b/hw/vfio/common.c | 12 | diff --git a/hw/vfio/common.c b/hw/vfio/common.c |
11 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
12 | --- a/hw/vfio/common.c | 14 | --- a/hw/vfio/common.c |
13 | +++ b/hw/vfio/common.c | 15 | +++ b/hw/vfio/common.c |
14 | @@ -XXX,XX +XXX,XX @@ const MemoryListener vfio_memory_listener = { | 16 | @@ -XXX,XX +XXX,XX @@ void vfio_reset_handler(void *opaque) |
15 | .log_global_stop = vfio_listener_log_global_stop, | 17 | } |
16 | .log_sync = vfio_listener_log_sync, | 18 | } |
17 | }; | 19 | } |
18 | - | 20 | - |
19 | -bool vfio_attach_device(char *name, VFIODevice *vbasedev, | 21 | -bool vfio_attach_device(char *name, VFIODevice *vbasedev, |
20 | - AddressSpace *as, Error **errp) | 22 | - AddressSpace *as, Error **errp) |
21 | -{ | 23 | -{ |
22 | - const VFIOIOMMUClass *ops = | 24 | - const VFIOIOMMUClass *ops = |
... | ... | ||
96 | + } | 98 | + } |
97 | + object_unref(vbasedev->hiod); | 99 | + object_unref(vbasedev->hiod); |
98 | + VFIO_IOMMU_GET_CLASS(vbasedev->bcontainer)->detach_device(vbasedev); | 100 | + VFIO_IOMMU_GET_CLASS(vbasedev->bcontainer)->detach_device(vbasedev); |
99 | +} | 101 | +} |
100 | -- | 102 | -- |
101 | 2.48.1 | 103 | 2.49.0 |
102 | 104 | ||
103 | 105 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Pass-through devices of a VM are not necessarily in the same group and | ||
2 | all groups/address_spaces need to be scanned when the machine is | ||
3 | reset. Commit f16f39c3fc97 ("Implement PCI hot reset") introduced a VM | ||
4 | reset handler for this purpose. Move it under device.c | ||
1 | 5 | ||
6 | Also reintroduce the comment which explained the context and was lost | ||
7 | along the way. | ||
8 | |||
9 | Signed-off-by: Cédric Le Goater <clg@redhat.com> | ||
10 | --- | ||
11 | hw/vfio/common.c | 18 ------------------ | ||
12 | hw/vfio/device.c | 35 +++++++++++++++++++++++++++++++++++ | ||
13 | hw/vfio/trace-events | 2 +- | ||
14 | 3 files changed, 36 insertions(+), 19 deletions(-) | ||
15 | |||
16 | diff --git a/hw/vfio/common.c b/hw/vfio/common.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/hw/vfio/common.c | ||
19 | +++ b/hw/vfio/common.c | ||
20 | @@ -XXX,XX +XXX,XX @@ const MemoryListener vfio_memory_listener = { | ||
21 | .log_global_stop = vfio_listener_log_global_stop, | ||
22 | .log_sync = vfio_listener_log_sync, | ||
23 | }; | ||
24 | - | ||
25 | -void vfio_reset_handler(void *opaque) | ||
26 | -{ | ||
27 | - VFIODevice *vbasedev; | ||
28 | - | ||
29 | - trace_vfio_reset_handler(); | ||
30 | - QLIST_FOREACH(vbasedev, &vfio_device_list, global_next) { | ||
31 | - if (vbasedev->dev->realized) { | ||
32 | - vbasedev->ops->vfio_compute_needs_reset(vbasedev); | ||
33 | - } | ||
34 | - } | ||
35 | - | ||
36 | - QLIST_FOREACH(vbasedev, &vfio_device_list, global_next) { | ||
37 | - if (vbasedev->dev->realized && vbasedev->needs_reset) { | ||
38 | - vbasedev->ops->vfio_hot_reset_multi(vbasedev); | ||
39 | - } | ||
40 | - } | ||
41 | -} | ||
42 | diff --git a/hw/vfio/device.c b/hw/vfio/device.c | ||
43 | index XXXXXXX..XXXXXXX 100644 | ||
44 | --- a/hw/vfio/device.c | ||
45 | +++ b/hw/vfio/device.c | ||
46 | @@ -XXX,XX +XXX,XX @@ | ||
47 | VFIODeviceList vfio_device_list = | ||
48 | QLIST_HEAD_INITIALIZER(vfio_device_list); | ||
49 | |||
50 | +/* | ||
51 | + * We want to differentiate hot reset of multiple in-use devices vs | ||
52 | + * hot reset of a single in-use device. VFIO_DEVICE_RESET will already | ||
53 | + * handle the case of doing hot resets when there is only a single | ||
54 | + * device per bus. The in-use here refers to how many VFIODevices are | ||
55 | + * affected. A hot reset that affects multiple devices, but only a | ||
56 | + * single in-use device, means that we can call it from our bus | ||
57 | + * ->reset() callback since the extent is effectively a single | ||
58 | + * device. This allows us to make use of it in the hotplug path. When | ||
59 | + * there are multiple in-use devices, we can only trigger the hot | ||
60 | + * reset during a system reset and thus from our reset handler. We | ||
61 | + * separate _one vs _multi here so that we don't overlap and do a | ||
62 | + * double reset on the system reset path where both our reset handler | ||
63 | + * and ->reset() callback are used. Calling _one() will only do a hot | ||
64 | + * reset for the one in-use devices case, calling _multi() will do | ||
65 | + * nothing if a _one() would have been sufficient. | ||
66 | + */ | ||
67 | +void vfio_reset_handler(void *opaque) | ||
68 | +{ | ||
69 | + VFIODevice *vbasedev; | ||
70 | + | ||
71 | + trace_vfio_reset_handler(); | ||
72 | + QLIST_FOREACH(vbasedev, &vfio_device_list, global_next) { | ||
73 | + if (vbasedev->dev->realized) { | ||
74 | + vbasedev->ops->vfio_compute_needs_reset(vbasedev); | ||
75 | + } | ||
76 | + } | ||
77 | + | ||
78 | + QLIST_FOREACH(vbasedev, &vfio_device_list, global_next) { | ||
79 | + if (vbasedev->dev->realized && vbasedev->needs_reset) { | ||
80 | + vbasedev->ops->vfio_hot_reset_multi(vbasedev); | ||
81 | + } | ||
82 | + } | ||
83 | +} | ||
84 | + | ||
85 | /* | ||
86 | * Common VFIO interrupt disable | ||
87 | */ | ||
88 | diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events | ||
89 | index XXXXXXX..XXXXXXX 100644 | ||
90 | --- a/hw/vfio/trace-events | ||
91 | +++ b/hw/vfio/trace-events | ||
92 | @@ -XXX,XX +XXX,XX @@ vfio_put_base_device(int fd) "close vdev->fd=%d" | ||
93 | vfio_legacy_dma_unmap_overflow_workaround(void) "" | ||
94 | vfio_get_dirty_bitmap(uint64_t iova, uint64_t size, uint64_t bitmap_size, uint64_t start, uint64_t dirty_pages) "iova=0x%"PRIx64" size= 0x%"PRIx64" bitmap_size=0x%"PRIx64" start=0x%"PRIx64" dirty_pages=%"PRIu64 | ||
95 | vfio_iommu_map_dirty_notify(uint64_t iova_start, uint64_t iova_end) "iommu dirty @ 0x%"PRIx64" - 0x%"PRIx64 | ||
96 | -vfio_reset_handler(void) "" | ||
97 | |||
98 | # region.c | ||
99 | vfio_region_write(const char *name, int index, uint64_t addr, uint64_t data, unsigned size) " (%s:region%d+0x%"PRIx64", 0x%"PRIx64 ", %d)" | ||
100 | @@ -XXX,XX +XXX,XX @@ iommufd_cdev_pci_hot_reset_dep_devices(int domain, int bus, int slot, int functi | ||
101 | |||
102 | # device.c | ||
103 | vfio_get_dev_region(const char *name, int index, uint32_t type, uint32_t subtype) "%s index %d, %08x/%08x" | ||
104 | +vfio_reset_handler(void) "" | ||
105 | -- | ||
106 | 2.49.0 | ||
107 | |||
108 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | 1 | Routines of common.c : | |
2 | |||
3 | vfio_devices_all_dirty_tracking_started | ||
4 | vfio_devices_all_device_dirty_tracking | ||
5 | vfio_devices_query_dirty_bitmap | ||
6 | vfio_get_dirty_bitmap | ||
7 | |||
8 | are all related to dirty page tracking directly at the container level | ||
9 | or at the container device level. Naming is a bit confusing. We will | ||
10 | propose new names in the following changes. | ||
11 | |||
12 | Signed-off-by: Cédric Le Goater <clg@redhat.com> | ||
13 | --- | ||
14 | include/hw/vfio/vfio-common.h | 9 -- | ||
15 | include/hw/vfio/vfio-container-base.h | 7 ++ | ||
16 | hw/vfio/common.c | 130 ------------------------ | ||
17 | hw/vfio/container-base.c | 138 ++++++++++++++++++++++++++ | ||
18 | hw/vfio/meson.build | 2 +- | ||
19 | hw/vfio/trace-events | 4 +- | ||
20 | 6 files changed, 149 insertions(+), 141 deletions(-) | ||
21 | |||
22 | diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h | ||
23 | index XXXXXXX..XXXXXXX 100644 | ||
24 | --- a/include/hw/vfio/vfio-common.h | ||
25 | +++ b/include/hw/vfio/vfio-common.h | ||
26 | @@ -XXX,XX +XXX,XX @@ int vfio_get_dev_region_info(VFIODevice *vbasedev, uint32_t type, | ||
27 | bool vfio_has_region_cap(VFIODevice *vbasedev, int region, uint16_t cap_type); | ||
28 | #endif | ||
29 | |||
30 | -bool vfio_devices_all_dirty_tracking_started( | ||
31 | - const VFIOContainerBase *bcontainer); | ||
32 | -bool | ||
33 | -vfio_devices_all_device_dirty_tracking(const VFIOContainerBase *bcontainer); | ||
34 | -int vfio_devices_query_dirty_bitmap(const VFIOContainerBase *bcontainer, | ||
35 | - VFIOBitmap *vbmap, hwaddr iova, hwaddr size, Error **errp); | ||
36 | -int vfio_get_dirty_bitmap(const VFIOContainerBase *bcontainer, uint64_t iova, | ||
37 | - uint64_t size, ram_addr_t ram_addr, Error **errp); | ||
38 | - | ||
39 | /* Returns 0 on success, or a negative errno. */ | ||
40 | bool vfio_device_get_name(VFIODevice *vbasedev, Error **errp); | ||
41 | void vfio_device_set_fd(VFIODevice *vbasedev, const char *str, Error **errp); | ||
42 | diff --git a/include/hw/vfio/vfio-container-base.h b/include/hw/vfio/vfio-container-base.h | ||
43 | index XXXXXXX..XXXXXXX 100644 | ||
44 | --- a/include/hw/vfio/vfio-container-base.h | ||
45 | +++ b/include/hw/vfio/vfio-container-base.h | ||
46 | @@ -XXX,XX +XXX,XX @@ int vfio_container_set_dirty_page_tracking(VFIOContainerBase *bcontainer, | ||
47 | bool start, Error **errp); | ||
48 | int vfio_container_query_dirty_bitmap(const VFIOContainerBase *bcontainer, | ||
49 | VFIOBitmap *vbmap, hwaddr iova, hwaddr size, Error **errp); | ||
50 | +bool vfio_devices_all_dirty_tracking_started(const VFIOContainerBase *bcontainer); | ||
51 | +bool vfio_devices_all_device_dirty_tracking(const VFIOContainerBase *bcontainer); | ||
52 | +int vfio_devices_query_dirty_bitmap(const VFIOContainerBase *bcontainer, | ||
53 | + VFIOBitmap *vbmap, hwaddr iova, hwaddr size, | ||
54 | + Error **errp); | ||
55 | +int vfio_get_dirty_bitmap(const VFIOContainerBase *bcontainer, uint64_t iova, | ||
56 | + uint64_t size, ram_addr_t ram_addr, Error **errp); | ||
57 | |||
58 | GList *vfio_container_get_iova_ranges(const VFIOContainerBase *bcontainer); | ||
59 | |||
60 | diff --git a/hw/vfio/common.c b/hw/vfio/common.c | ||
61 | index XXXXXXX..XXXXXXX 100644 | ||
62 | --- a/hw/vfio/common.c | ||
63 | +++ b/hw/vfio/common.c | ||
64 | @@ -XXX,XX +XXX,XX @@ | ||
65 | */ | ||
66 | |||
67 | |||
68 | -static bool vfio_devices_all_device_dirty_tracking_started( | ||
69 | - const VFIOContainerBase *bcontainer) | ||
70 | -{ | ||
71 | - VFIODevice *vbasedev; | ||
72 | - | ||
73 | - QLIST_FOREACH(vbasedev, &bcontainer->device_list, container_next) { | ||
74 | - if (!vbasedev->dirty_tracking) { | ||
75 | - return false; | ||
76 | - } | ||
77 | - } | ||
78 | - | ||
79 | - return true; | ||
80 | -} | ||
81 | - | ||
82 | -bool vfio_devices_all_dirty_tracking_started( | ||
83 | - const VFIOContainerBase *bcontainer) | ||
84 | -{ | ||
85 | - return vfio_devices_all_device_dirty_tracking_started(bcontainer) || | ||
86 | - bcontainer->dirty_pages_started; | ||
87 | -} | ||
88 | - | ||
89 | static bool vfio_log_sync_needed(const VFIOContainerBase *bcontainer) | ||
90 | { | ||
91 | VFIODevice *vbasedev; | ||
92 | @@ -XXX,XX +XXX,XX @@ static bool vfio_log_sync_needed(const VFIOContainerBase *bcontainer) | ||
93 | return true; | ||
94 | } | ||
95 | |||
96 | -bool vfio_devices_all_device_dirty_tracking(const VFIOContainerBase *bcontainer) | ||
97 | -{ | ||
98 | - VFIODevice *vbasedev; | ||
99 | - | ||
100 | - QLIST_FOREACH(vbasedev, &bcontainer->device_list, container_next) { | ||
101 | - if (vbasedev->device_dirty_page_tracking == ON_OFF_AUTO_OFF) { | ||
102 | - return false; | ||
103 | - } | ||
104 | - if (!vbasedev->dirty_pages_supported) { | ||
105 | - return false; | ||
106 | - } | ||
107 | - } | ||
108 | - | ||
109 | - return true; | ||
110 | -} | ||
111 | - | ||
112 | static bool vfio_listener_skipped_section(MemoryRegionSection *section) | ||
113 | { | ||
114 | return (!memory_region_is_ram(section->mr) && | ||
115 | @@ -XXX,XX +XXX,XX @@ static void vfio_listener_log_global_stop(MemoryListener *listener) | ||
116 | } | ||
117 | } | ||
118 | |||
119 | -static int vfio_device_dma_logging_report(VFIODevice *vbasedev, hwaddr iova, | ||
120 | - hwaddr size, void *bitmap) | ||
121 | -{ | ||
122 | - uint64_t buf[DIV_ROUND_UP(sizeof(struct vfio_device_feature) + | ||
123 | - sizeof(struct vfio_device_feature_dma_logging_report), | ||
124 | - sizeof(uint64_t))] = {}; | ||
125 | - struct vfio_device_feature *feature = (struct vfio_device_feature *)buf; | ||
126 | - struct vfio_device_feature_dma_logging_report *report = | ||
127 | - (struct vfio_device_feature_dma_logging_report *)feature->data; | ||
128 | - | ||
129 | - report->iova = iova; | ||
130 | - report->length = size; | ||
131 | - report->page_size = qemu_real_host_page_size(); | ||
132 | - report->bitmap = (uintptr_t)bitmap; | ||
133 | - | ||
134 | - feature->argsz = sizeof(buf); | ||
135 | - feature->flags = VFIO_DEVICE_FEATURE_GET | | ||
136 | - VFIO_DEVICE_FEATURE_DMA_LOGGING_REPORT; | ||
137 | - | ||
138 | - if (ioctl(vbasedev->fd, VFIO_DEVICE_FEATURE, feature)) { | ||
139 | - return -errno; | ||
140 | - } | ||
141 | - | ||
142 | - return 0; | ||
143 | -} | ||
144 | - | ||
145 | -int vfio_devices_query_dirty_bitmap(const VFIOContainerBase *bcontainer, | ||
146 | - VFIOBitmap *vbmap, hwaddr iova, hwaddr size, Error **errp) | ||
147 | -{ | ||
148 | - VFIODevice *vbasedev; | ||
149 | - int ret; | ||
150 | - | ||
151 | - QLIST_FOREACH(vbasedev, &bcontainer->device_list, container_next) { | ||
152 | - ret = vfio_device_dma_logging_report(vbasedev, iova, size, | ||
153 | - vbmap->bitmap); | ||
154 | - if (ret) { | ||
155 | - error_setg_errno(errp, -ret, | ||
156 | - "%s: Failed to get DMA logging report, iova: " | ||
157 | - "0x%" HWADDR_PRIx ", size: 0x%" HWADDR_PRIx, | ||
158 | - vbasedev->name, iova, size); | ||
159 | - | ||
160 | - return ret; | ||
161 | - } | ||
162 | - } | ||
163 | - | ||
164 | - return 0; | ||
165 | -} | ||
166 | - | ||
167 | -int vfio_get_dirty_bitmap(const VFIOContainerBase *bcontainer, uint64_t iova, | ||
168 | - uint64_t size, ram_addr_t ram_addr, Error **errp) | ||
169 | -{ | ||
170 | - bool all_device_dirty_tracking = | ||
171 | - vfio_devices_all_device_dirty_tracking(bcontainer); | ||
172 | - uint64_t dirty_pages; | ||
173 | - VFIOBitmap vbmap; | ||
174 | - int ret; | ||
175 | - | ||
176 | - if (!bcontainer->dirty_pages_supported && !all_device_dirty_tracking) { | ||
177 | - cpu_physical_memory_set_dirty_range(ram_addr, size, | ||
178 | - tcg_enabled() ? DIRTY_CLIENTS_ALL : | ||
179 | - DIRTY_CLIENTS_NOCODE); | ||
180 | - return 0; | ||
181 | - } | ||
182 | - | ||
183 | - ret = vfio_bitmap_alloc(&vbmap, size); | ||
184 | - if (ret) { | ||
185 | - error_setg_errno(errp, -ret, | ||
186 | - "Failed to allocate dirty tracking bitmap"); | ||
187 | - return ret; | ||
188 | - } | ||
189 | - | ||
190 | - if (all_device_dirty_tracking) { | ||
191 | - ret = vfio_devices_query_dirty_bitmap(bcontainer, &vbmap, iova, size, | ||
192 | - errp); | ||
193 | - } else { | ||
194 | - ret = vfio_container_query_dirty_bitmap(bcontainer, &vbmap, iova, size, | ||
195 | - errp); | ||
196 | - } | ||
197 | - | ||
198 | - if (ret) { | ||
199 | - goto out; | ||
200 | - } | ||
201 | - | ||
202 | - dirty_pages = cpu_physical_memory_set_dirty_lebitmap(vbmap.bitmap, ram_addr, | ||
203 | - vbmap.pages); | ||
204 | - | ||
205 | - trace_vfio_get_dirty_bitmap(iova, size, vbmap.size, ram_addr, dirty_pages); | ||
206 | -out: | ||
207 | - g_free(vbmap.bitmap); | ||
208 | - | ||
209 | - return ret; | ||
210 | -} | ||
211 | - | ||
212 | typedef struct { | ||
213 | IOMMUNotifier n; | ||
214 | VFIOGuestIOMMU *giommu; | ||
215 | diff --git a/hw/vfio/container-base.c b/hw/vfio/container-base.c | ||
216 | index XXXXXXX..XXXXXXX 100644 | ||
217 | --- a/hw/vfio/container-base.c | ||
218 | +++ b/hw/vfio/container-base.c | ||
219 | @@ -XXX,XX +XXX,XX @@ | ||
220 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
221 | */ | ||
222 | |||
223 | +#include <sys/ioctl.h> | ||
224 | +#include <linux/vfio.h> | ||
225 | + | ||
226 | +#include "system/tcg.h" | ||
227 | #include "qemu/osdep.h" | ||
228 | +#include "exec/ram_addr.h" | ||
229 | #include "qapi/error.h" | ||
230 | #include "qemu/error-report.h" | ||
231 | #include "hw/vfio/vfio-container-base.h" | ||
232 | #include "hw/vfio/vfio-common.h" /* vfio_reset_handler */ | ||
233 | #include "system/reset.h" | ||
234 | +#include "vfio-helpers.h" | ||
235 | + | ||
236 | +#include "trace.h" | ||
237 | |||
238 | static QLIST_HEAD(, VFIOAddressSpace) vfio_address_spaces = | ||
239 | QLIST_HEAD_INITIALIZER(vfio_address_spaces); | ||
240 | @@ -XXX,XX +XXX,XX @@ int vfio_container_query_dirty_bitmap(const VFIOContainerBase *bcontainer, | ||
241 | errp); | ||
242 | } | ||
243 | |||
244 | +static bool vfio_devices_all_device_dirty_tracking_started( | ||
245 | + const VFIOContainerBase *bcontainer) | ||
246 | +{ | ||
247 | + VFIODevice *vbasedev; | ||
248 | + | ||
249 | + QLIST_FOREACH(vbasedev, &bcontainer->device_list, container_next) { | ||
250 | + if (!vbasedev->dirty_tracking) { | ||
251 | + return false; | ||
252 | + } | ||
253 | + } | ||
254 | + | ||
255 | + return true; | ||
256 | +} | ||
257 | + | ||
258 | +bool vfio_devices_all_dirty_tracking_started( | ||
259 | + const VFIOContainerBase *bcontainer) | ||
260 | +{ | ||
261 | + return vfio_devices_all_device_dirty_tracking_started(bcontainer) || | ||
262 | + bcontainer->dirty_pages_started; | ||
263 | +} | ||
264 | + | ||
265 | +bool vfio_devices_all_device_dirty_tracking(const VFIOContainerBase *bcontainer) | ||
266 | +{ | ||
267 | + VFIODevice *vbasedev; | ||
268 | + | ||
269 | + QLIST_FOREACH(vbasedev, &bcontainer->device_list, container_next) { | ||
270 | + if (vbasedev->device_dirty_page_tracking == ON_OFF_AUTO_OFF) { | ||
271 | + return false; | ||
272 | + } | ||
273 | + if (!vbasedev->dirty_pages_supported) { | ||
274 | + return false; | ||
275 | + } | ||
276 | + } | ||
277 | + | ||
278 | + return true; | ||
279 | +} | ||
280 | + | ||
281 | +static int vfio_device_dma_logging_report(VFIODevice *vbasedev, hwaddr iova, | ||
282 | + hwaddr size, void *bitmap) | ||
283 | +{ | ||
284 | + uint64_t buf[DIV_ROUND_UP(sizeof(struct vfio_device_feature) + | ||
285 | + sizeof(struct vfio_device_feature_dma_logging_report), | ||
286 | + sizeof(uint64_t))] = {}; | ||
287 | + struct vfio_device_feature *feature = (struct vfio_device_feature *)buf; | ||
288 | + struct vfio_device_feature_dma_logging_report *report = | ||
289 | + (struct vfio_device_feature_dma_logging_report *)feature->data; | ||
290 | + | ||
291 | + report->iova = iova; | ||
292 | + report->length = size; | ||
293 | + report->page_size = qemu_real_host_page_size(); | ||
294 | + report->bitmap = (uintptr_t)bitmap; | ||
295 | + | ||
296 | + feature->argsz = sizeof(buf); | ||
297 | + feature->flags = VFIO_DEVICE_FEATURE_GET | | ||
298 | + VFIO_DEVICE_FEATURE_DMA_LOGGING_REPORT; | ||
299 | + | ||
300 | + if (ioctl(vbasedev->fd, VFIO_DEVICE_FEATURE, feature)) { | ||
301 | + return -errno; | ||
302 | + } | ||
303 | + | ||
304 | + return 0; | ||
305 | +} | ||
306 | + | ||
307 | +int vfio_devices_query_dirty_bitmap(const VFIOContainerBase *bcontainer, | ||
308 | + VFIOBitmap *vbmap, hwaddr iova, hwaddr size, Error **errp) | ||
309 | +{ | ||
310 | + VFIODevice *vbasedev; | ||
311 | + int ret; | ||
312 | + | ||
313 | + QLIST_FOREACH(vbasedev, &bcontainer->device_list, container_next) { | ||
314 | + ret = vfio_device_dma_logging_report(vbasedev, iova, size, | ||
315 | + vbmap->bitmap); | ||
316 | + if (ret) { | ||
317 | + error_setg_errno(errp, -ret, | ||
318 | + "%s: Failed to get DMA logging report, iova: " | ||
319 | + "0x%" HWADDR_PRIx ", size: 0x%" HWADDR_PRIx, | ||
320 | + vbasedev->name, iova, size); | ||
321 | + | ||
322 | + return ret; | ||
323 | + } | ||
324 | + } | ||
325 | + | ||
326 | + return 0; | ||
327 | +} | ||
328 | + | ||
329 | +int vfio_get_dirty_bitmap(const VFIOContainerBase *bcontainer, uint64_t iova, | ||
330 | + uint64_t size, ram_addr_t ram_addr, Error **errp) | ||
331 | +{ | ||
332 | + bool all_device_dirty_tracking = | ||
333 | + vfio_devices_all_device_dirty_tracking(bcontainer); | ||
334 | + uint64_t dirty_pages; | ||
335 | + VFIOBitmap vbmap; | ||
336 | + int ret; | ||
337 | + | ||
338 | + if (!bcontainer->dirty_pages_supported && !all_device_dirty_tracking) { | ||
339 | + cpu_physical_memory_set_dirty_range(ram_addr, size, | ||
340 | + tcg_enabled() ? DIRTY_CLIENTS_ALL : | ||
341 | + DIRTY_CLIENTS_NOCODE); | ||
342 | + return 0; | ||
343 | + } | ||
344 | + | ||
345 | + ret = vfio_bitmap_alloc(&vbmap, size); | ||
346 | + if (ret) { | ||
347 | + error_setg_errno(errp, -ret, | ||
348 | + "Failed to allocate dirty tracking bitmap"); | ||
349 | + return ret; | ||
350 | + } | ||
351 | + | ||
352 | + if (all_device_dirty_tracking) { | ||
353 | + ret = vfio_devices_query_dirty_bitmap(bcontainer, &vbmap, iova, size, | ||
354 | + errp); | ||
355 | + } else { | ||
356 | + ret = vfio_container_query_dirty_bitmap(bcontainer, &vbmap, iova, size, | ||
357 | + errp); | ||
358 | + } | ||
359 | + | ||
360 | + if (ret) { | ||
361 | + goto out; | ||
362 | + } | ||
363 | + | ||
364 | + dirty_pages = cpu_physical_memory_set_dirty_lebitmap(vbmap.bitmap, ram_addr, | ||
365 | + vbmap.pages); | ||
366 | + | ||
367 | + trace_vfio_get_dirty_bitmap(iova, size, vbmap.size, ram_addr, dirty_pages); | ||
368 | +out: | ||
369 | + g_free(vbmap.bitmap); | ||
370 | + | ||
371 | + return ret; | ||
372 | +} | ||
373 | + | ||
374 | static gpointer copy_iova_range(gconstpointer src, gpointer data) | ||
375 | { | ||
376 | Range *source = (Range *)src; | ||
377 | diff --git a/hw/vfio/meson.build b/hw/vfio/meson.build | ||
378 | index XXXXXXX..XXXXXXX 100644 | ||
379 | --- a/hw/vfio/meson.build | ||
380 | +++ b/hw/vfio/meson.build | ||
381 | @@ -XXX,XX +XXX,XX @@ | ||
382 | vfio_ss = ss.source_set() | ||
383 | vfio_ss.add(files( | ||
384 | 'common.c', | ||
385 | + 'container-base.c', | ||
386 | 'container.c', | ||
387 | 'helpers.c', | ||
388 | )) | ||
389 | @@ -XXX,XX +XXX,XX @@ specific_ss.add_all(when: 'CONFIG_VFIO', if_true: vfio_ss) | ||
390 | system_ss.add(when: 'CONFIG_VFIO_XGMAC', if_true: files('calxeda-xgmac.c')) | ||
391 | system_ss.add(when: 'CONFIG_VFIO_AMD_XGBE', if_true: files('amd-xgbe.c')) | ||
392 | system_ss.add(when: 'CONFIG_VFIO', if_true: files( | ||
393 | - 'container-base.c', | ||
394 | 'cpr.c', | ||
395 | 'device.c', | ||
396 | 'migration.c', | ||
397 | diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events | ||
398 | index XXXXXXX..XXXXXXX 100644 | ||
399 | --- a/hw/vfio/trace-events | ||
400 | +++ b/hw/vfio/trace-events | ||
401 | @@ -XXX,XX +XXX,XX @@ vfio_put_group(int fd) "close group->fd=%d" | ||
402 | vfio_get_device(const char * name, unsigned int flags, unsigned int num_regions, unsigned int num_irqs) "Device %s flags: %u, regions: %u, irqs: %u" | ||
403 | vfio_put_base_device(int fd) "close vdev->fd=%d" | ||
404 | vfio_legacy_dma_unmap_overflow_workaround(void) "" | ||
405 | -vfio_get_dirty_bitmap(uint64_t iova, uint64_t size, uint64_t bitmap_size, uint64_t start, uint64_t dirty_pages) "iova=0x%"PRIx64" size= 0x%"PRIx64" bitmap_size=0x%"PRIx64" start=0x%"PRIx64" dirty_pages=%"PRIu64 | ||
406 | vfio_iommu_map_dirty_notify(uint64_t iova_start, uint64_t iova_end) "iommu dirty @ 0x%"PRIx64" - 0x%"PRIx64 | ||
407 | |||
408 | +# container-base.c | ||
409 | +vfio_get_dirty_bitmap(uint64_t iova, uint64_t size, uint64_t bitmap_size, uint64_t start, uint64_t dirty_pages) "iova=0x%"PRIx64" size= 0x%"PRIx64" bitmap_size=0x%"PRIx64" start=0x%"PRIx64" dirty_pages=%"PRIu64 | ||
410 | + | ||
411 | # region.c | ||
412 | vfio_region_write(const char *name, int index, uint64_t addr, uint64_t data, unsigned size) " (%s:region%d+0x%"PRIx64", 0x%"PRIx64 ", %d)" | ||
413 | vfio_region_read(char *name, int index, uint64_t addr, unsigned size, uint64_t data) " (%s:region%d+0x%"PRIx64", %d) = 0x%"PRIx64 | ||
414 | -- | ||
415 | 2.49.0 | ||
416 | |||
417 | diff view generated by jsdifflib |
1 | vfio_devices_query_dirty_bitmap() is only used in "dirty-tracking.c". | 1 | vfio_devices_query_dirty_bitmap() is only used in "container-base.c". |
---|---|---|---|
2 | Also, rename to vfio_container_devices_query_dirty_bitmap() to reflect | ||
3 | with the prefix 'vfio_container_devices_' that it simply loops over | ||
4 | the container's device list. | ||
5 | |||
6 | This rename also frees the vfio_devices_query_dirty_bitmap() name | ||
7 | which we will reuse in the next changes. | ||
2 | 8 | ||
3 | Signed-off-by: Cédric Le Goater <clg@redhat.com> | 9 | Signed-off-by: Cédric Le Goater <clg@redhat.com> |
4 | --- | 10 | --- |
5 | hw/vfio/dirty-tracking.h | 3 --- | 11 | include/hw/vfio/vfio-container-base.h | 3 --- |
6 | hw/vfio/dirty-tracking.c | 2 +- | 12 | hw/vfio/container-base.c | 6 +++--- |
7 | 2 files changed, 1 insertion(+), 4 deletions(-) | 13 | 2 files changed, 3 insertions(+), 6 deletions(-) |
8 | 14 | ||
9 | diff --git a/hw/vfio/dirty-tracking.h b/hw/vfio/dirty-tracking.h | 15 | diff --git a/include/hw/vfio/vfio-container-base.h b/include/hw/vfio/vfio-container-base.h |
10 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
11 | --- a/hw/vfio/dirty-tracking.h | 17 | --- a/include/hw/vfio/vfio-container-base.h |
12 | +++ b/hw/vfio/dirty-tracking.h | 18 | +++ b/include/hw/vfio/vfio-container-base.h |
13 | @@ -XXX,XX +XXX,XX @@ extern const MemoryListener vfio_memory_listener; | 19 | @@ -XXX,XX +XXX,XX @@ int vfio_container_query_dirty_bitmap(const VFIOContainerBase *bcontainer, |
14 | 20 | VFIOBitmap *vbmap, hwaddr iova, hwaddr size, Error **errp); | |
15 | bool vfio_devices_all_dirty_tracking_started(const VFIOContainerBase *bcontainer); | 21 | bool vfio_devices_all_dirty_tracking_started(const VFIOContainerBase *bcontainer); |
16 | bool vfio_devices_all_device_dirty_tracking(const VFIOContainerBase *bcontainer); | 22 | bool vfio_devices_all_device_dirty_tracking(const VFIOContainerBase *bcontainer); |
17 | -int vfio_devices_query_dirty_bitmap(const VFIOContainerBase *bcontainer, | 23 | -int vfio_devices_query_dirty_bitmap(const VFIOContainerBase *bcontainer, |
18 | - VFIOBitmap *vbmap, hwaddr iova, hwaddr size, | 24 | - VFIOBitmap *vbmap, hwaddr iova, hwaddr size, |
19 | - Error **errp); | 25 | - Error **errp); |
20 | int vfio_get_dirty_bitmap(const VFIOContainerBase *bcontainer, uint64_t iova, | 26 | int vfio_get_dirty_bitmap(const VFIOContainerBase *bcontainer, uint64_t iova, |
21 | uint64_t size, ram_addr_t ram_addr, Error **errp); | 27 | uint64_t size, ram_addr_t ram_addr, Error **errp); |
22 | 28 | ||
23 | diff --git a/hw/vfio/dirty-tracking.c b/hw/vfio/dirty-tracking.c | 29 | diff --git a/hw/vfio/container-base.c b/hw/vfio/container-base.c |
24 | index XXXXXXX..XXXXXXX 100644 | 30 | index XXXXXXX..XXXXXXX 100644 |
25 | --- a/hw/vfio/dirty-tracking.c | 31 | --- a/hw/vfio/container-base.c |
26 | +++ b/hw/vfio/dirty-tracking.c | 32 | +++ b/hw/vfio/container-base.c |
27 | @@ -XXX,XX +XXX,XX @@ static int vfio_device_dma_logging_report(VFIODevice *vbasedev, hwaddr iova, | 33 | @@ -XXX,XX +XXX,XX @@ static int vfio_device_dma_logging_report(VFIODevice *vbasedev, hwaddr iova, |
28 | return 0; | 34 | return 0; |
29 | } | 35 | } |
30 | 36 | ||
31 | -int vfio_devices_query_dirty_bitmap(const VFIOContainerBase *bcontainer, | 37 | -int vfio_devices_query_dirty_bitmap(const VFIOContainerBase *bcontainer, |
32 | +static int vfio_devices_query_dirty_bitmap(const VFIOContainerBase *bcontainer, | 38 | +static int vfio_container_devices_query_dirty_bitmap(const VFIOContainerBase *bcontainer, |
33 | VFIOBitmap *vbmap, hwaddr iova, hwaddr size, Error **errp) | 39 | VFIOBitmap *vbmap, hwaddr iova, hwaddr size, Error **errp) |
34 | { | 40 | { |
35 | VFIODevice *vbasedev; | 41 | VFIODevice *vbasedev; |
42 | @@ -XXX,XX +XXX,XX @@ int vfio_get_dirty_bitmap(const VFIOContainerBase *bcontainer, uint64_t iova, | ||
43 | } | ||
44 | |||
45 | if (all_device_dirty_tracking) { | ||
46 | - ret = vfio_devices_query_dirty_bitmap(bcontainer, &vbmap, iova, size, | ||
47 | - errp); | ||
48 | + ret = vfio_container_devices_query_dirty_bitmap(bcontainer, &vbmap, iova, size, | ||
49 | + errp); | ||
50 | } else { | ||
51 | ret = vfio_container_query_dirty_bitmap(bcontainer, &vbmap, iova, size, | ||
52 | errp); | ||
36 | -- | 53 | -- |
37 | 2.48.1 | 54 | 2.49.0 |
38 | 55 | ||
39 | 56 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | vfio_container_query_dirty_bitmap() is only used in "container-base.c". | ||
2 | Also, rename to vfio_container_vioc_query_dirty_bitmap() to reflect it | ||
3 | is using the VFIO IOMMU backend device ->query_dirty_bitmap() handler. | ||
1 | 4 | ||
5 | Signed-off-by: Cédric Le Goater <clg@redhat.com> | ||
6 | --- | ||
7 | include/hw/vfio/vfio-container-base.h | 2 -- | ||
8 | hw/vfio/container-base.c | 24 ++++++++++++------------ | ||
9 | 2 files changed, 12 insertions(+), 14 deletions(-) | ||
10 | |||
11 | diff --git a/include/hw/vfio/vfio-container-base.h b/include/hw/vfio/vfio-container-base.h | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/include/hw/vfio/vfio-container-base.h | ||
14 | +++ b/include/hw/vfio/vfio-container-base.h | ||
15 | @@ -XXX,XX +XXX,XX @@ void vfio_container_del_section_window(VFIOContainerBase *bcontainer, | ||
16 | MemoryRegionSection *section); | ||
17 | int vfio_container_set_dirty_page_tracking(VFIOContainerBase *bcontainer, | ||
18 | bool start, Error **errp); | ||
19 | -int vfio_container_query_dirty_bitmap(const VFIOContainerBase *bcontainer, | ||
20 | - VFIOBitmap *vbmap, hwaddr iova, hwaddr size, Error **errp); | ||
21 | bool vfio_devices_all_dirty_tracking_started(const VFIOContainerBase *bcontainer); | ||
22 | bool vfio_devices_all_device_dirty_tracking(const VFIOContainerBase *bcontainer); | ||
23 | int vfio_get_dirty_bitmap(const VFIOContainerBase *bcontainer, uint64_t iova, | ||
24 | diff --git a/hw/vfio/container-base.c b/hw/vfio/container-base.c | ||
25 | index XXXXXXX..XXXXXXX 100644 | ||
26 | --- a/hw/vfio/container-base.c | ||
27 | +++ b/hw/vfio/container-base.c | ||
28 | @@ -XXX,XX +XXX,XX @@ int vfio_container_set_dirty_page_tracking(VFIOContainerBase *bcontainer, | ||
29 | return ret; | ||
30 | } | ||
31 | |||
32 | -int vfio_container_query_dirty_bitmap(const VFIOContainerBase *bcontainer, | ||
33 | - VFIOBitmap *vbmap, hwaddr iova, hwaddr size, Error **errp) | ||
34 | -{ | ||
35 | - VFIOIOMMUClass *vioc = VFIO_IOMMU_GET_CLASS(bcontainer); | ||
36 | - | ||
37 | - g_assert(vioc->query_dirty_bitmap); | ||
38 | - return vioc->query_dirty_bitmap(bcontainer, vbmap, iova, size, | ||
39 | - errp); | ||
40 | -} | ||
41 | - | ||
42 | static bool vfio_devices_all_device_dirty_tracking_started( | ||
43 | const VFIOContainerBase *bcontainer) | ||
44 | { | ||
45 | @@ -XXX,XX +XXX,XX @@ static int vfio_device_dma_logging_report(VFIODevice *vbasedev, hwaddr iova, | ||
46 | return 0; | ||
47 | } | ||
48 | |||
49 | +static int vfio_container_vioc_query_dirty_bitmap(const VFIOContainerBase *bcontainer, | ||
50 | + VFIOBitmap *vbmap, hwaddr iova, hwaddr size, Error **errp) | ||
51 | +{ | ||
52 | + VFIOIOMMUClass *vioc = VFIO_IOMMU_GET_CLASS(bcontainer); | ||
53 | + | ||
54 | + g_assert(vioc->query_dirty_bitmap); | ||
55 | + return vioc->query_dirty_bitmap(bcontainer, vbmap, iova, size, | ||
56 | + errp); | ||
57 | +} | ||
58 | + | ||
59 | static int vfio_container_devices_query_dirty_bitmap(const VFIOContainerBase *bcontainer, | ||
60 | VFIOBitmap *vbmap, hwaddr iova, hwaddr size, Error **errp) | ||
61 | { | ||
62 | @@ -XXX,XX +XXX,XX @@ int vfio_get_dirty_bitmap(const VFIOContainerBase *bcontainer, uint64_t iova, | ||
63 | ret = vfio_container_devices_query_dirty_bitmap(bcontainer, &vbmap, iova, size, | ||
64 | errp); | ||
65 | } else { | ||
66 | - ret = vfio_container_query_dirty_bitmap(bcontainer, &vbmap, iova, size, | ||
67 | - errp); | ||
68 | + ret = vfio_container_vioc_query_dirty_bitmap(bcontainer, &vbmap, iova, size, | ||
69 | + errp); | ||
70 | } | ||
71 | |||
72 | if (ret) { | ||
73 | -- | ||
74 | 2.49.0 | ||
75 | |||
76 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Also rename vfio_devices_all_device_dirty_tracking_started() while at | ||
2 | it and use the prefix 'vfio_container_devices_' for routines simply | ||
3 | looping over the container's device list. | ||
1 | 4 | ||
5 | Signed-off-by: Cédric Le Goater <clg@redhat.com> | ||
6 | --- | ||
7 | include/hw/vfio/vfio-container-base.h | 3 ++- | ||
8 | hw/vfio/common.c | 2 +- | ||
9 | hw/vfio/container-base.c | 6 +++--- | ||
10 | hw/vfio/container.c | 2 +- | ||
11 | 4 files changed, 7 insertions(+), 6 deletions(-) | ||
12 | |||
13 | diff --git a/include/hw/vfio/vfio-container-base.h b/include/hw/vfio/vfio-container-base.h | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/include/hw/vfio/vfio-container-base.h | ||
16 | +++ b/include/hw/vfio/vfio-container-base.h | ||
17 | @@ -XXX,XX +XXX,XX @@ void vfio_container_del_section_window(VFIOContainerBase *bcontainer, | ||
18 | MemoryRegionSection *section); | ||
19 | int vfio_container_set_dirty_page_tracking(VFIOContainerBase *bcontainer, | ||
20 | bool start, Error **errp); | ||
21 | -bool vfio_devices_all_dirty_tracking_started(const VFIOContainerBase *bcontainer); | ||
22 | +bool vfio_container_dirty_tracking_is_started( | ||
23 | + const VFIOContainerBase *bcontainer); | ||
24 | bool vfio_devices_all_device_dirty_tracking(const VFIOContainerBase *bcontainer); | ||
25 | int vfio_get_dirty_bitmap(const VFIOContainerBase *bcontainer, uint64_t iova, | ||
26 | uint64_t size, ram_addr_t ram_addr, Error **errp); | ||
27 | diff --git a/hw/vfio/common.c b/hw/vfio/common.c | ||
28 | index XXXXXXX..XXXXXXX 100644 | ||
29 | --- a/hw/vfio/common.c | ||
30 | +++ b/hw/vfio/common.c | ||
31 | @@ -XXX,XX +XXX,XX @@ static bool vfio_log_sync_needed(const VFIOContainerBase *bcontainer) | ||
32 | { | ||
33 | VFIODevice *vbasedev; | ||
34 | |||
35 | - if (!vfio_devices_all_dirty_tracking_started(bcontainer)) { | ||
36 | + if (!vfio_container_dirty_tracking_is_started(bcontainer)) { | ||
37 | return false; | ||
38 | } | ||
39 | |||
40 | diff --git a/hw/vfio/container-base.c b/hw/vfio/container-base.c | ||
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/hw/vfio/container-base.c | ||
43 | +++ b/hw/vfio/container-base.c | ||
44 | @@ -XXX,XX +XXX,XX @@ int vfio_container_set_dirty_page_tracking(VFIOContainerBase *bcontainer, | ||
45 | return ret; | ||
46 | } | ||
47 | |||
48 | -static bool vfio_devices_all_device_dirty_tracking_started( | ||
49 | +static bool vfio_container_devices_dirty_tracking_is_started( | ||
50 | const VFIOContainerBase *bcontainer) | ||
51 | { | ||
52 | VFIODevice *vbasedev; | ||
53 | @@ -XXX,XX +XXX,XX @@ static bool vfio_devices_all_device_dirty_tracking_started( | ||
54 | return true; | ||
55 | } | ||
56 | |||
57 | -bool vfio_devices_all_dirty_tracking_started( | ||
58 | +bool vfio_container_dirty_tracking_is_started( | ||
59 | const VFIOContainerBase *bcontainer) | ||
60 | { | ||
61 | - return vfio_devices_all_device_dirty_tracking_started(bcontainer) || | ||
62 | + return vfio_container_devices_dirty_tracking_is_started(bcontainer) || | ||
63 | bcontainer->dirty_pages_started; | ||
64 | } | ||
65 | |||
66 | diff --git a/hw/vfio/container.c b/hw/vfio/container.c | ||
67 | index XXXXXXX..XXXXXXX 100644 | ||
68 | --- a/hw/vfio/container.c | ||
69 | +++ b/hw/vfio/container.c | ||
70 | @@ -XXX,XX +XXX,XX @@ static int vfio_legacy_dma_unmap(const VFIOContainerBase *bcontainer, | ||
71 | int ret; | ||
72 | Error *local_err = NULL; | ||
73 | |||
74 | - if (iotlb && vfio_devices_all_dirty_tracking_started(bcontainer)) { | ||
75 | + if (iotlb && vfio_container_dirty_tracking_is_started(bcontainer)) { | ||
76 | if (!vfio_devices_all_device_dirty_tracking(bcontainer) && | ||
77 | bcontainer->dirty_pages_supported) { | ||
78 | return vfio_dma_unmap_bitmap(container, iova, size, iotlb); | ||
79 | -- | ||
80 | 2.49.0 | ||
81 | |||
82 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Use the prefix 'vfio_container_devices_' to reflect the routine simply | ||
2 | loops over the container's device list. | ||
1 | 3 | ||
4 | Signed-off-by: Cédric Le Goater <clg@redhat.com> | ||
5 | --- | ||
6 | include/hw/vfio/vfio-container-base.h | 3 ++- | ||
7 | hw/vfio/common.c | 4 ++-- | ||
8 | hw/vfio/container-base.c | 5 +++-- | ||
9 | hw/vfio/container.c | 2 +- | ||
10 | 4 files changed, 8 insertions(+), 6 deletions(-) | ||
11 | |||
12 | diff --git a/include/hw/vfio/vfio-container-base.h b/include/hw/vfio/vfio-container-base.h | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/include/hw/vfio/vfio-container-base.h | ||
15 | +++ b/include/hw/vfio/vfio-container-base.h | ||
16 | @@ -XXX,XX +XXX,XX @@ int vfio_container_set_dirty_page_tracking(VFIOContainerBase *bcontainer, | ||
17 | bool start, Error **errp); | ||
18 | bool vfio_container_dirty_tracking_is_started( | ||
19 | const VFIOContainerBase *bcontainer); | ||
20 | -bool vfio_devices_all_device_dirty_tracking(const VFIOContainerBase *bcontainer); | ||
21 | +bool vfio_container_devices_dirty_tracking_is_supported( | ||
22 | + const VFIOContainerBase *bcontainer); | ||
23 | int vfio_get_dirty_bitmap(const VFIOContainerBase *bcontainer, uint64_t iova, | ||
24 | uint64_t size, ram_addr_t ram_addr, Error **errp); | ||
25 | |||
26 | diff --git a/hw/vfio/common.c b/hw/vfio/common.c | ||
27 | index XXXXXXX..XXXXXXX 100644 | ||
28 | --- a/hw/vfio/common.c | ||
29 | +++ b/hw/vfio/common.c | ||
30 | @@ -XXX,XX +XXX,XX @@ static bool vfio_listener_log_global_start(MemoryListener *listener, | ||
31 | listener); | ||
32 | bool ret; | ||
33 | |||
34 | - if (vfio_devices_all_device_dirty_tracking(bcontainer)) { | ||
35 | + if (vfio_container_devices_dirty_tracking_is_supported(bcontainer)) { | ||
36 | ret = vfio_devices_dma_logging_start(bcontainer, errp); | ||
37 | } else { | ||
38 | ret = vfio_container_set_dirty_page_tracking(bcontainer, true, errp) == 0; | ||
39 | @@ -XXX,XX +XXX,XX @@ static void vfio_listener_log_global_stop(MemoryListener *listener) | ||
40 | Error *local_err = NULL; | ||
41 | int ret = 0; | ||
42 | |||
43 | - if (vfio_devices_all_device_dirty_tracking(bcontainer)) { | ||
44 | + if (vfio_container_devices_dirty_tracking_is_supported(bcontainer)) { | ||
45 | vfio_devices_dma_logging_stop(bcontainer); | ||
46 | } else { | ||
47 | ret = vfio_container_set_dirty_page_tracking(bcontainer, false, | ||
48 | diff --git a/hw/vfio/container-base.c b/hw/vfio/container-base.c | ||
49 | index XXXXXXX..XXXXXXX 100644 | ||
50 | --- a/hw/vfio/container-base.c | ||
51 | +++ b/hw/vfio/container-base.c | ||
52 | @@ -XXX,XX +XXX,XX @@ bool vfio_container_dirty_tracking_is_started( | ||
53 | bcontainer->dirty_pages_started; | ||
54 | } | ||
55 | |||
56 | -bool vfio_devices_all_device_dirty_tracking(const VFIOContainerBase *bcontainer) | ||
57 | +bool vfio_container_devices_dirty_tracking_is_supported( | ||
58 | + const VFIOContainerBase *bcontainer) | ||
59 | { | ||
60 | VFIODevice *vbasedev; | ||
61 | |||
62 | @@ -XXX,XX +XXX,XX @@ int vfio_get_dirty_bitmap(const VFIOContainerBase *bcontainer, uint64_t iova, | ||
63 | uint64_t size, ram_addr_t ram_addr, Error **errp) | ||
64 | { | ||
65 | bool all_device_dirty_tracking = | ||
66 | - vfio_devices_all_device_dirty_tracking(bcontainer); | ||
67 | + vfio_container_devices_dirty_tracking_is_supported(bcontainer); | ||
68 | uint64_t dirty_pages; | ||
69 | VFIOBitmap vbmap; | ||
70 | int ret; | ||
71 | diff --git a/hw/vfio/container.c b/hw/vfio/container.c | ||
72 | index XXXXXXX..XXXXXXX 100644 | ||
73 | --- a/hw/vfio/container.c | ||
74 | +++ b/hw/vfio/container.c | ||
75 | @@ -XXX,XX +XXX,XX @@ static int vfio_legacy_dma_unmap(const VFIOContainerBase *bcontainer, | ||
76 | Error *local_err = NULL; | ||
77 | |||
78 | if (iotlb && vfio_container_dirty_tracking_is_started(bcontainer)) { | ||
79 | - if (!vfio_devices_all_device_dirty_tracking(bcontainer) && | ||
80 | + if (!vfio_container_devices_dirty_tracking_is_supported(bcontainer) && | ||
81 | bcontainer->dirty_pages_supported) { | ||
82 | return vfio_dma_unmap_bitmap(container, iova, size, iotlb); | ||
83 | } | ||
84 | -- | ||
85 | 2.49.0 | ||
86 | |||
87 | diff view generated by jsdifflib |
1 | Rename these routines : | 1 | vfio_container_query_dirty_bitmap() is consistent the VFIO container |
---|---|---|---|
2 | 2 | routine naming scheme and is now free to use. | |
3 | vfio_devices_all_device_dirty_tracking_started -> vfio_dirty_tracking_devices_is_started_all | ||
4 | vfio_devices_all_dirty_tracking_started -> vfio_dirty_tracking_devices_is_started | ||
5 | vfio_devices_all_device_dirty_tracking -> vfio_dirty_tracking_devices_is_supported | ||
6 | vfio_devices_dma_logging_start -> vfio_dirty_tracking_devices_dma_logging_start | ||
7 | vfio_devices_dma_logging_stop -> vfio_dirty_tracking_devices_dma_logging_stop | ||
8 | vfio_devices_query_dirty_bitmap -> vfio_dirty_tracking_devices_query_dirty_bitmap | ||
9 | vfio_get_dirty_bitmap -> vfio_dirty_tracking_query_dirty_bitmap | ||
10 | |||
11 | to better reflect the namespace they belong to. | ||
12 | 3 | ||
13 | Signed-off-by: Cédric Le Goater <clg@redhat.com> | 4 | Signed-off-by: Cédric Le Goater <clg@redhat.com> |
14 | --- | 5 | --- |
15 | hw/vfio/dirty-tracking.h | 6 +++--- | 6 | include/hw/vfio/vfio-container-base.h | 4 ++-- |
16 | hw/vfio/container.c | 6 +++--- | 7 | hw/vfio/common.c | 6 +++--- |
17 | hw/vfio/dirty-tracking.c | 44 ++++++++++++++++++++-------------------- | 8 | hw/vfio/container-base.c | 5 +++-- |
18 | hw/vfio/trace-events | 2 +- | 9 | hw/vfio/container.c | 2 +- |
19 | 4 files changed, 29 insertions(+), 29 deletions(-) | 10 | hw/vfio/trace-events | 2 +- |
11 | 5 files changed, 10 insertions(+), 9 deletions(-) | ||
20 | 12 | ||
21 | diff --git a/hw/vfio/dirty-tracking.h b/hw/vfio/dirty-tracking.h | 13 | diff --git a/include/hw/vfio/vfio-container-base.h b/include/hw/vfio/vfio-container-base.h |
22 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/hw/vfio/dirty-tracking.h | 15 | --- a/include/hw/vfio/vfio-container-base.h |
24 | +++ b/hw/vfio/dirty-tracking.h | 16 | +++ b/include/hw/vfio/vfio-container-base.h |
25 | @@ -XXX,XX +XXX,XX @@ | 17 | @@ -XXX,XX +XXX,XX @@ bool vfio_container_dirty_tracking_is_started( |
26 | 18 | const VFIOContainerBase *bcontainer); | |
27 | extern const MemoryListener vfio_memory_listener; | 19 | bool vfio_container_devices_dirty_tracking_is_supported( |
28 | 20 | const VFIOContainerBase *bcontainer); | |
29 | -bool vfio_devices_all_dirty_tracking_started(const VFIOContainerBase *bcontainer); | ||
30 | -bool vfio_devices_all_device_dirty_tracking(const VFIOContainerBase *bcontainer); | ||
31 | -int vfio_get_dirty_bitmap(const VFIOContainerBase *bcontainer, uint64_t iova, | 21 | -int vfio_get_dirty_bitmap(const VFIOContainerBase *bcontainer, uint64_t iova, |
32 | +bool vfio_dirty_tracking_devices_is_started(const VFIOContainerBase *bcontainer); | 22 | - uint64_t size, ram_addr_t ram_addr, Error **errp); |
33 | +bool vfio_dirty_tracking_devices_is_supported(const VFIOContainerBase *bcontainer); | 23 | +int vfio_container_query_dirty_bitmap(const VFIOContainerBase *bcontainer, |
34 | +int vfio_dirty_tracking_query_dirty_bitmap(const VFIOContainerBase *bcontainer, uint64_t iova, | 24 | + uint64_t iova, uint64_t size, ram_addr_t ram_addr, Error **errp); |
35 | uint64_t size, ram_addr_t ram_addr, Error **errp); | 25 | |
36 | 26 | GList *vfio_container_get_iova_ranges(const VFIOContainerBase *bcontainer); | |
37 | #endif /* HW_VFIO_DIRTY_TRACKING_H */ | 27 | |
38 | diff --git a/hw/vfio/container.c b/hw/vfio/container.c | 28 | diff --git a/hw/vfio/common.c b/hw/vfio/common.c |
39 | index XXXXXXX..XXXXXXX 100644 | 29 | index XXXXXXX..XXXXXXX 100644 |
40 | --- a/hw/vfio/container.c | 30 | --- a/hw/vfio/common.c |
41 | +++ b/hw/vfio/container.c | 31 | +++ b/hw/vfio/common.c |
42 | @@ -XXX,XX +XXX,XX @@ static int vfio_legacy_dma_unmap(const VFIOContainerBase *bcontainer, | ||
43 | int ret; | ||
44 | Error *local_err = NULL; | ||
45 | |||
46 | - if (iotlb && vfio_devices_all_dirty_tracking_started(bcontainer)) { | ||
47 | - if (!vfio_devices_all_device_dirty_tracking(bcontainer) && | ||
48 | + if (iotlb && vfio_dirty_tracking_devices_is_started(bcontainer)) { | ||
49 | + if (!vfio_dirty_tracking_devices_is_supported(bcontainer) && | ||
50 | bcontainer->dirty_pages_supported) { | ||
51 | return vfio_dma_unmap_bitmap(container, iova, size, iotlb); | ||
52 | } | ||
53 | @@ -XXX,XX +XXX,XX @@ static int vfio_legacy_dma_unmap(const VFIOContainerBase *bcontainer, | ||
54 | } | ||
55 | |||
56 | if (need_dirty_sync) { | ||
57 | - ret = vfio_get_dirty_bitmap(bcontainer, iova, size, | ||
58 | + ret = vfio_dirty_tracking_query_dirty_bitmap(bcontainer, iova, size, | ||
59 | iotlb->translated_addr, &local_err); | ||
60 | if (ret) { | ||
61 | error_report_err(local_err); | ||
62 | diff --git a/hw/vfio/dirty-tracking.c b/hw/vfio/dirty-tracking.c | ||
63 | index XXXXXXX..XXXXXXX 100644 | ||
64 | --- a/hw/vfio/dirty-tracking.c | ||
65 | +++ b/hw/vfio/dirty-tracking.c | ||
66 | @@ -XXX,XX +XXX,XX @@ | ||
67 | * Device state interfaces | ||
68 | */ | ||
69 | |||
70 | -static bool vfio_devices_all_device_dirty_tracking_started( | ||
71 | +static bool vfio_dirty_tracking_devices_is_started_all( | ||
72 | const VFIOContainerBase *bcontainer) | ||
73 | { | ||
74 | VFIODevice *vbasedev; | ||
75 | @@ -XXX,XX +XXX,XX @@ static bool vfio_devices_all_device_dirty_tracking_started( | ||
76 | return true; | ||
77 | } | ||
78 | |||
79 | -bool vfio_devices_all_dirty_tracking_started( | ||
80 | - const VFIOContainerBase *bcontainer) | ||
81 | +bool vfio_dirty_tracking_devices_is_started(const VFIOContainerBase *bcontainer) | ||
82 | { | ||
83 | - return vfio_devices_all_device_dirty_tracking_started(bcontainer) || | ||
84 | + return vfio_dirty_tracking_devices_is_started_all(bcontainer) || | ||
85 | bcontainer->dirty_pages_started; | ||
86 | } | ||
87 | |||
88 | @@ -XXX,XX +XXX,XX @@ static bool vfio_log_sync_needed(const VFIOContainerBase *bcontainer) | ||
89 | { | ||
90 | VFIODevice *vbasedev; | ||
91 | |||
92 | - if (!vfio_devices_all_dirty_tracking_started(bcontainer)) { | ||
93 | + if (!vfio_dirty_tracking_devices_is_started(bcontainer)) { | ||
94 | return false; | ||
95 | } | ||
96 | |||
97 | @@ -XXX,XX +XXX,XX @@ static bool vfio_log_sync_needed(const VFIOContainerBase *bcontainer) | ||
98 | return true; | ||
99 | } | ||
100 | |||
101 | -bool vfio_devices_all_device_dirty_tracking(const VFIOContainerBase *bcontainer) | ||
102 | +bool vfio_dirty_tracking_devices_is_supported(const VFIOContainerBase *bcontainer) | ||
103 | { | ||
104 | VFIODevice *vbasedev; | ||
105 | |||
106 | @@ -XXX,XX +XXX,XX @@ static void vfio_dirty_tracking_init(VFIOContainerBase *bcontainer, | ||
107 | memory_listener_unregister(&dirty.listener); | ||
108 | } | ||
109 | |||
110 | -static void vfio_devices_dma_logging_stop(VFIOContainerBase *bcontainer) | ||
111 | +static void vfio_dirty_tracking_devices_dma_logging_stop(VFIOContainerBase *bcontainer) | ||
112 | { | ||
113 | uint64_t buf[DIV_ROUND_UP(sizeof(struct vfio_device_feature), | ||
114 | sizeof(uint64_t))] = {}; | ||
115 | @@ -XXX,XX +XXX,XX @@ static void vfio_device_feature_dma_logging_start_destroy( | ||
116 | g_free(feature); | ||
117 | } | ||
118 | |||
119 | -static bool vfio_devices_dma_logging_start(VFIOContainerBase *bcontainer, | ||
120 | +static bool vfio_dirty_tracking_devices_dma_logging_start(VFIOContainerBase *bcontainer, | ||
121 | Error **errp) | ||
122 | { | ||
123 | struct vfio_device_feature *feature; | ||
124 | @@ -XXX,XX +XXX,XX @@ static bool vfio_devices_dma_logging_start(VFIOContainerBase *bcontainer, | ||
125 | |||
126 | out: | ||
127 | if (ret) { | ||
128 | - vfio_devices_dma_logging_stop(bcontainer); | ||
129 | + vfio_dirty_tracking_devices_dma_logging_stop(bcontainer); | ||
130 | } | ||
131 | |||
132 | vfio_device_feature_dma_logging_start_destroy(feature); | ||
133 | @@ -XXX,XX +XXX,XX @@ static bool vfio_listener_log_global_start(MemoryListener *listener, | ||
134 | listener); | ||
135 | bool ret; | ||
136 | |||
137 | - if (vfio_devices_all_device_dirty_tracking(bcontainer)) { | ||
138 | - ret = vfio_devices_dma_logging_start(bcontainer, errp); | ||
139 | + if (vfio_dirty_tracking_devices_is_supported(bcontainer)) { | ||
140 | + ret = vfio_dirty_tracking_devices_dma_logging_start(bcontainer, errp); | ||
141 | } else { | ||
142 | ret = vfio_container_set_dirty_page_tracking(bcontainer, true, errp) == 0; | ||
143 | } | ||
144 | @@ -XXX,XX +XXX,XX @@ static void vfio_listener_log_global_stop(MemoryListener *listener) | ||
145 | Error *local_err = NULL; | ||
146 | int ret = 0; | ||
147 | |||
148 | - if (vfio_devices_all_device_dirty_tracking(bcontainer)) { | ||
149 | - vfio_devices_dma_logging_stop(bcontainer); | ||
150 | + if (vfio_dirty_tracking_devices_is_supported(bcontainer)) { | ||
151 | + vfio_dirty_tracking_devices_dma_logging_stop(bcontainer); | ||
152 | } else { | ||
153 | ret = vfio_container_set_dirty_page_tracking(bcontainer, false, | ||
154 | &local_err); | ||
155 | @@ -XXX,XX +XXX,XX @@ static int vfio_device_dma_logging_report(VFIODevice *vbasedev, hwaddr iova, | ||
156 | return 0; | ||
157 | } | ||
158 | |||
159 | -static int vfio_devices_query_dirty_bitmap(const VFIOContainerBase *bcontainer, | ||
160 | +static int vfio_dirty_tracking_devices_query_dirty_bitmap(const VFIOContainerBase *bcontainer, | ||
161 | VFIOBitmap *vbmap, hwaddr iova, hwaddr size, Error **errp) | ||
162 | { | ||
163 | VFIODevice *vbasedev; | ||
164 | @@ -XXX,XX +XXX,XX @@ static int vfio_devices_query_dirty_bitmap(const VFIOContainerBase *bcontainer, | ||
165 | return 0; | ||
166 | } | ||
167 | |||
168 | -int vfio_get_dirty_bitmap(const VFIOContainerBase *bcontainer, uint64_t iova, | ||
169 | +int vfio_dirty_tracking_query_dirty_bitmap(const VFIOContainerBase *bcontainer, uint64_t iova, | ||
170 | uint64_t size, ram_addr_t ram_addr, Error **errp) | ||
171 | { | ||
172 | bool all_device_dirty_tracking = | ||
173 | - vfio_devices_all_device_dirty_tracking(bcontainer); | ||
174 | + vfio_dirty_tracking_devices_is_supported(bcontainer); | ||
175 | uint64_t dirty_pages; | ||
176 | VFIOBitmap vbmap; | ||
177 | int ret; | ||
178 | @@ -XXX,XX +XXX,XX @@ int vfio_get_dirty_bitmap(const VFIOContainerBase *bcontainer, uint64_t iova, | ||
179 | } | ||
180 | |||
181 | if (all_device_dirty_tracking) { | ||
182 | - ret = vfio_devices_query_dirty_bitmap(bcontainer, &vbmap, iova, size, | ||
183 | - errp); | ||
184 | + ret = vfio_dirty_tracking_devices_query_dirty_bitmap(bcontainer, &vbmap, | ||
185 | + iova, size, errp); | ||
186 | } else { | ||
187 | ret = vfio_container_query_dirty_bitmap(bcontainer, &vbmap, iova, size, | ||
188 | errp); | ||
189 | @@ -XXX,XX +XXX,XX @@ int vfio_get_dirty_bitmap(const VFIOContainerBase *bcontainer, uint64_t iova, | ||
190 | dirty_pages = cpu_physical_memory_set_dirty_lebitmap(vbmap.bitmap, ram_addr, | ||
191 | vbmap.pages); | ||
192 | |||
193 | - trace_vfio_get_dirty_bitmap(iova, size, vbmap.size, ram_addr, dirty_pages); | ||
194 | + trace_vfio_dirty_tracking_query_dirty_bitmap(iova, size, vbmap.size, ram_addr, | ||
195 | + dirty_pages); | ||
196 | out: | ||
197 | g_free(vbmap.bitmap); | ||
198 | |||
199 | @@ -XXX,XX +XXX,XX @@ static void vfio_iommu_map_dirty_notify(IOMMUNotifier *n, IOMMUTLBEntry *iotlb) | 32 | @@ -XXX,XX +XXX,XX @@ static void vfio_iommu_map_dirty_notify(IOMMUNotifier *n, IOMMUTLBEntry *iotlb) |
200 | goto out_unlock; | 33 | goto out_unlock; |
201 | } | 34 | } |
202 | 35 | ||
203 | - ret = vfio_get_dirty_bitmap(bcontainer, iova, iotlb->addr_mask + 1, | 36 | - ret = vfio_get_dirty_bitmap(bcontainer, iova, iotlb->addr_mask + 1, |
204 | + ret = vfio_dirty_tracking_query_dirty_bitmap(bcontainer, iova, iotlb->addr_mask + 1, | 37 | + ret = vfio_container_query_dirty_bitmap(bcontainer, iova, iotlb->addr_mask + 1, |
205 | translated_addr, &local_err); | 38 | translated_addr, &local_err); |
206 | if (ret) { | 39 | if (ret) { |
207 | error_prepend(&local_err, | 40 | error_prepend(&local_err, |
208 | @@ -XXX,XX +XXX,XX @@ static int vfio_ram_discard_get_dirty_bitmap(MemoryRegionSection *section, | 41 | @@ -XXX,XX +XXX,XX @@ static int vfio_ram_discard_get_dirty_bitmap(MemoryRegionSection *section, |
209 | * Sync the whole mapped region (spanning multiple individual mappings) | 42 | * Sync the whole mapped region (spanning multiple individual mappings) |
210 | * in one go. | 43 | * in one go. |
211 | */ | 44 | */ |
212 | - ret = vfio_get_dirty_bitmap(vrdl->bcontainer, iova, size, ram_addr, | 45 | - ret = vfio_get_dirty_bitmap(vrdl->bcontainer, iova, size, ram_addr, |
213 | + ret = vfio_dirty_tracking_query_dirty_bitmap(vrdl->bcontainer, iova, size, ram_addr, | 46 | + ret = vfio_container_query_dirty_bitmap(vrdl->bcontainer, iova, size, ram_addr, |
214 | &local_err); | 47 | &local_err); |
215 | if (ret) { | 48 | if (ret) { |
216 | error_report_err(local_err); | 49 | error_report_err(local_err); |
217 | @@ -XXX,XX +XXX,XX @@ static int vfio_sync_dirty_bitmap(VFIOContainerBase *bcontainer, | 50 | @@ -XXX,XX +XXX,XX @@ static int vfio_sync_dirty_bitmap(VFIOContainerBase *bcontainer, |
218 | ram_addr = memory_region_get_ram_addr(section->mr) + | 51 | ram_addr = memory_region_get_ram_addr(section->mr) + |
219 | section->offset_within_region; | 52 | section->offset_within_region; |
220 | 53 | ||
221 | - return vfio_get_dirty_bitmap(bcontainer, | 54 | - return vfio_get_dirty_bitmap(bcontainer, |
222 | + return vfio_dirty_tracking_query_dirty_bitmap(bcontainer, | 55 | + return vfio_container_query_dirty_bitmap(bcontainer, |
223 | REAL_HOST_PAGE_ALIGN(section->offset_within_address_space), | 56 | REAL_HOST_PAGE_ALIGN(section->offset_within_address_space), |
224 | int128_get64(section->size), ram_addr, errp); | 57 | int128_get64(section->size), ram_addr, errp); |
225 | } | 58 | } |
59 | diff --git a/hw/vfio/container-base.c b/hw/vfio/container-base.c | ||
60 | index XXXXXXX..XXXXXXX 100644 | ||
61 | --- a/hw/vfio/container-base.c | ||
62 | +++ b/hw/vfio/container-base.c | ||
63 | @@ -XXX,XX +XXX,XX @@ static int vfio_container_devices_query_dirty_bitmap(const VFIOContainerBase *bc | ||
64 | return 0; | ||
65 | } | ||
66 | |||
67 | -int vfio_get_dirty_bitmap(const VFIOContainerBase *bcontainer, uint64_t iova, | ||
68 | +int vfio_container_query_dirty_bitmap(const VFIOContainerBase *bcontainer, uint64_t iova, | ||
69 | uint64_t size, ram_addr_t ram_addr, Error **errp) | ||
70 | { | ||
71 | bool all_device_dirty_tracking = | ||
72 | @@ -XXX,XX +XXX,XX @@ int vfio_get_dirty_bitmap(const VFIOContainerBase *bcontainer, uint64_t iova, | ||
73 | dirty_pages = cpu_physical_memory_set_dirty_lebitmap(vbmap.bitmap, ram_addr, | ||
74 | vbmap.pages); | ||
75 | |||
76 | - trace_vfio_get_dirty_bitmap(iova, size, vbmap.size, ram_addr, dirty_pages); | ||
77 | + trace_vfio_container_query_dirty_bitmap(iova, size, vbmap.size, ram_addr, | ||
78 | + dirty_pages); | ||
79 | out: | ||
80 | g_free(vbmap.bitmap); | ||
81 | |||
82 | diff --git a/hw/vfio/container.c b/hw/vfio/container.c | ||
83 | index XXXXXXX..XXXXXXX 100644 | ||
84 | --- a/hw/vfio/container.c | ||
85 | +++ b/hw/vfio/container.c | ||
86 | @@ -XXX,XX +XXX,XX @@ static int vfio_legacy_dma_unmap(const VFIOContainerBase *bcontainer, | ||
87 | } | ||
88 | |||
89 | if (need_dirty_sync) { | ||
90 | - ret = vfio_get_dirty_bitmap(bcontainer, iova, size, | ||
91 | + ret = vfio_container_query_dirty_bitmap(bcontainer, iova, size, | ||
92 | iotlb->translated_addr, &local_err); | ||
93 | if (ret) { | ||
94 | error_report_err(local_err); | ||
226 | diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events | 95 | diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events |
227 | index XXXXXXX..XXXXXXX 100644 | 96 | index XXXXXXX..XXXXXXX 100644 |
228 | --- a/hw/vfio/trace-events | 97 | --- a/hw/vfio/trace-events |
229 | +++ b/hw/vfio/trace-events | 98 | +++ b/hw/vfio/trace-events |
230 | @@ -XXX,XX +XXX,XX @@ vfio_listener_region_del(uint64_t start, uint64_t end) "region_del 0x%"PRIx64" - | 99 | @@ -XXX,XX +XXX,XX @@ vfio_legacy_dma_unmap_overflow_workaround(void) "" |
231 | vfio_device_dirty_tracking_update(uint64_t start, uint64_t end, uint64_t min, uint64_t max) "section 0x%"PRIx64" - 0x%"PRIx64" -> update [0x%"PRIx64" - 0x%"PRIx64"]" | 100 | vfio_iommu_map_dirty_notify(uint64_t iova_start, uint64_t iova_end) "iommu dirty @ 0x%"PRIx64" - 0x%"PRIx64 |
232 | vfio_device_dirty_tracking_start(int nr_ranges, uint64_t min32, uint64_t max32, uint64_t min64, uint64_t max64, uint64_t minpci, uint64_t maxpci) "nr_ranges %d 32:[0x%"PRIx64" - 0x%"PRIx64"], 64:[0x%"PRIx64" - 0x%"PRIx64"], pci64:[0x%"PRIx64" - 0x%"PRIx64"]" | 101 | |
233 | vfio_legacy_dma_unmap_overflow_workaround(void) "" | 102 | # container-base.c |
234 | -vfio_get_dirty_bitmap(uint64_t iova, uint64_t size, uint64_t bitmap_size, uint64_t start, uint64_t dirty_pages) "iova=0x%"PRIx64" size= 0x%"PRIx64" bitmap_size=0x%"PRIx64" start=0x%"PRIx64" dirty_pages=%"PRIu64 | 103 | -vfio_get_dirty_bitmap(uint64_t iova, uint64_t size, uint64_t bitmap_size, uint64_t start, uint64_t dirty_pages) "iova=0x%"PRIx64" size= 0x%"PRIx64" bitmap_size=0x%"PRIx64" start=0x%"PRIx64" dirty_pages=%"PRIu64 |
235 | +vfio_dirty_tracking_query_dirty_bitmap(uint64_t iova, uint64_t size, uint64_t bitmap_size, uint64_t start, uint64_t dirty_pages) "iova=0x%"PRIx64" size= 0x%"PRIx64" bitmap_size=0x%"PRIx64" start=0x%"PRIx64" dirty_pages=%"PRIu64 | 104 | +vfio_container_query_dirty_bitmap(uint64_t iova, uint64_t size, uint64_t bitmap_size, uint64_t start, uint64_t dirty_pages) "iova=0x%"PRIx64" size= 0x%"PRIx64" bitmap_size=0x%"PRIx64" start=0x%"PRIx64" dirty_pages=%"PRIu64 |
236 | vfio_iommu_map_dirty_notify(uint64_t iova_start, uint64_t iova_end) "iommu dirty @ 0x%"PRIx64" - 0x%"PRIx64 | ||
237 | 105 | ||
238 | # region.c | 106 | # region.c |
107 | vfio_region_write(const char *name, int index, uint64_t addr, uint64_t data, unsigned size) " (%s:region%d+0x%"PRIx64", 0x%"PRIx64 ", %d)" | ||
239 | -- | 108 | -- |
240 | 2.48.1 | 109 | 2.49.0 |
241 | 110 | ||
242 | 111 | diff view generated by jsdifflib |
1 | File "common.c" has been emptied of most of its definitions by the | 1 | File "common.c" has been emptied of most of its definitions by the |
---|---|---|---|
2 | previous changes and the only definitions left are related to dirty | 2 | previous changes and the only definitions left are related to the VFIO |
3 | tracking. Rename it to "dirty-tracking.c" and introduce its associated | 3 | MemoryListener handlers. Rename it to "listener.c" and introduce its |
4 | "dirty-tracking.h" header file for the declarations. | 4 | associated "vfio-listener.h" header file for the declarations. |
5 | 5 | ||
6 | Cleanup a little the includes while at it. | 6 | Cleanup a little the includes while at it. |
7 | 7 | ||
8 | Signed-off-by: Cédric Le Goater <clg@redhat.com> | 8 | Signed-off-by: Cédric Le Goater <clg@redhat.com> |
9 | --- | 9 | --- |
10 | hw/vfio/dirty-tracking.h | 22 ++++++++++++++++++++++ | 10 | hw/vfio/vfio-listener.h | 14 ++++++++++++++ |
11 | include/hw/vfio/vfio-common.h | 10 ---------- | 11 | include/hw/vfio/vfio-common.h | 1 - |
12 | hw/vfio/container.c | 1 + | 12 | hw/vfio/container.c | 1 + |
13 | hw/vfio/{common.c => dirty-tracking.c} | 5 +---- | 13 | hw/vfio/iommufd.c | 1 + |
14 | hw/vfio/iommufd.c | 1 + | 14 | hw/vfio/{common.c => listener.c} | 0 |
15 | hw/vfio/meson.build | 2 +- | 15 | hw/vfio/meson.build | 2 +- |
16 | hw/vfio/trace-events | 2 +- | 16 | hw/vfio/trace-events | 2 +- |
17 | 7 files changed, 27 insertions(+), 16 deletions(-) | 17 | 7 files changed, 18 insertions(+), 3 deletions(-) |
18 | create mode 100644 hw/vfio/dirty-tracking.h | 18 | create mode 100644 hw/vfio/vfio-listener.h |
19 | rename hw/vfio/{common.c => dirty-tracking.c} (99%) | 19 | rename hw/vfio/{common.c => listener.c} (100%) |
20 | 20 | ||
21 | diff --git a/hw/vfio/dirty-tracking.h b/hw/vfio/dirty-tracking.h | 21 | diff --git a/hw/vfio/vfio-listener.h b/hw/vfio/vfio-listener.h |
22 | new file mode 100644 | 22 | new file mode 100644 |
23 | index XXXXXXX..XXXXXXX | 23 | index XXXXXXX..XXXXXXX |
24 | --- /dev/null | 24 | --- /dev/null |
25 | +++ b/hw/vfio/dirty-tracking.h | 25 | +++ b/hw/vfio/vfio-listener.h |
26 | @@ -XXX,XX +XXX,XX @@ | 26 | @@ -XXX,XX +XXX,XX @@ |
27 | +/* | 27 | +/* |
28 | + * VFIO dirty page tracking routines | 28 | + * VFIO MemoryListener services |
29 | + * | 29 | + * |
30 | + * Copyright Red Hat, Inc. 2025 | 30 | + * Copyright Red Hat, Inc. 2025 |
31 | + * | 31 | + * |
32 | + * SPDX-License-Identifier: GPL-2.0-or-later | 32 | + * SPDX-License-Identifier: GPL-2.0-or-later |
33 | + */ | 33 | + */ |
34 | + | 34 | + |
35 | +#ifndef HW_VFIO_DIRTY_TRACKING_H | 35 | +#ifndef HW_VFIO_VFIO_LISTENER_H |
36 | +#define HW_VFIO_DIRTY_TRACKING_H | 36 | +#define HW_VFIO_VFIO_LISTENER_H |
37 | + | 37 | + |
38 | +extern const MemoryListener vfio_memory_listener; | 38 | +extern const MemoryListener vfio_memory_listener; |
39 | + | 39 | + |
40 | +bool vfio_devices_all_dirty_tracking_started(const VFIOContainerBase *bcontainer); | 40 | +#endif /* HW_VFIO_VFIO_LISTENER_H */ |
41 | +bool vfio_devices_all_device_dirty_tracking(const VFIOContainerBase *bcontainer); | ||
42 | +int vfio_devices_query_dirty_bitmap(const VFIOContainerBase *bcontainer, | ||
43 | + VFIOBitmap *vbmap, hwaddr iova, hwaddr size, | ||
44 | + Error **errp); | ||
45 | +int vfio_get_dirty_bitmap(const VFIOContainerBase *bcontainer, uint64_t iova, | ||
46 | + uint64_t size, ram_addr_t ram_addr, Error **errp); | ||
47 | + | ||
48 | +#endif /* HW_VFIO_DIRTY_TRACKING_H */ | ||
49 | diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h | 41 | diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h |
50 | index XXXXXXX..XXXXXXX 100644 | 42 | index XXXXXXX..XXXXXXX 100644 |
51 | --- a/include/hw/vfio/vfio-common.h | 43 | --- a/include/hw/vfio/vfio-common.h |
52 | +++ b/include/hw/vfio/vfio-common.h | 44 | +++ b/include/hw/vfio/vfio-common.h |
53 | @@ -XXX,XX +XXX,XX @@ VFIODevice *vfio_get_vfio_device(Object *obj); | 45 | @@ -XXX,XX +XXX,XX @@ VFIODevice *vfio_get_vfio_device(Object *obj); |
... | ... | ||
56 | extern VFIODeviceList vfio_device_list; | 48 | extern VFIODeviceList vfio_device_list; |
57 | -extern const MemoryListener vfio_memory_listener; | 49 | -extern const MemoryListener vfio_memory_listener; |
58 | 50 | ||
59 | #ifdef CONFIG_LINUX | 51 | #ifdef CONFIG_LINUX |
60 | int vfio_get_region_info(VFIODevice *vbasedev, int index, | 52 | int vfio_get_region_info(VFIODevice *vbasedev, int index, |
61 | @@ -XXX,XX +XXX,XX @@ int vfio_get_dev_region_info(VFIODevice *vbasedev, uint32_t type, | ||
62 | bool vfio_has_region_cap(VFIODevice *vbasedev, int region, uint16_t cap_type); | ||
63 | #endif | ||
64 | |||
65 | -bool vfio_devices_all_dirty_tracking_started( | ||
66 | - const VFIOContainerBase *bcontainer); | ||
67 | -bool | ||
68 | -vfio_devices_all_device_dirty_tracking(const VFIOContainerBase *bcontainer); | ||
69 | -int vfio_devices_query_dirty_bitmap(const VFIOContainerBase *bcontainer, | ||
70 | - VFIOBitmap *vbmap, hwaddr iova, hwaddr size, Error **errp); | ||
71 | -int vfio_get_dirty_bitmap(const VFIOContainerBase *bcontainer, uint64_t iova, | ||
72 | - uint64_t size, ram_addr_t ram_addr, Error **errp); | ||
73 | - | ||
74 | /* Returns 0 on success, or a negative errno. */ | ||
75 | bool vfio_device_get_name(VFIODevice *vbasedev, Error **errp); | ||
76 | void vfio_device_set_fd(VFIODevice *vbasedev, const char *str, Error **errp); | ||
77 | diff --git a/hw/vfio/container.c b/hw/vfio/container.c | 53 | diff --git a/hw/vfio/container.c b/hw/vfio/container.c |
78 | index XXXXXXX..XXXXXXX 100644 | 54 | index XXXXXXX..XXXXXXX 100644 |
79 | --- a/hw/vfio/container.c | 55 | --- a/hw/vfio/container.c |
80 | +++ b/hw/vfio/container.c | 56 | +++ b/hw/vfio/container.c |
81 | @@ -XXX,XX +XXX,XX @@ | 57 | @@ -XXX,XX +XXX,XX @@ |
82 | #include "hw/vfio/vfio-container.h" | 58 | #include "hw/vfio/vfio-container.h" |
83 | #include "helpers.h" | 59 | #include "vfio-helpers.h" |
84 | #include "cpr.h" | 60 | #include "vfio-cpr.h" |
85 | +#include "dirty-tracking.h" | 61 | +#include "vfio-listener.h" |
86 | 62 | ||
87 | #define TYPE_HOST_IOMMU_DEVICE_LEGACY_VFIO TYPE_HOST_IOMMU_DEVICE "-legacy-vfio" | 63 | #define TYPE_HOST_IOMMU_DEVICE_LEGACY_VFIO TYPE_HOST_IOMMU_DEVICE "-legacy-vfio" |
88 | 64 | ||
89 | diff --git a/hw/vfio/common.c b/hw/vfio/dirty-tracking.c | ||
90 | similarity index 99% | ||
91 | rename from hw/vfio/common.c | ||
92 | rename to hw/vfio/dirty-tracking.c | ||
93 | index XXXXXXX..XXXXXXX 100644 | ||
94 | --- a/hw/vfio/common.c | ||
95 | +++ b/hw/vfio/dirty-tracking.c | ||
96 | @@ -XXX,XX +XXX,XX @@ | ||
97 | |||
98 | #include "qemu/osdep.h" | ||
99 | #include <sys/ioctl.h> | ||
100 | -#ifdef CONFIG_KVM | ||
101 | -#include <linux/kvm.h> | ||
102 | -#endif | ||
103 | #include <linux/vfio.h> | ||
104 | |||
105 | #include "hw/vfio/vfio-common.h" | ||
106 | #include "hw/vfio/pci.h" | ||
107 | -#include "exec/address-spaces.h" | ||
108 | #include "exec/memory.h" | ||
109 | #include "exec/ram_addr.h" | ||
110 | #include "exec/target_page.h" | ||
111 | @@ -XXX,XX +XXX,XX @@ | ||
112 | #include "system/tpm.h" | ||
113 | #include "migration.h" | ||
114 | #include "helpers.h" | ||
115 | +#include "dirty-tracking.h" | ||
116 | |||
117 | /* | ||
118 | * Device state interfaces | ||
119 | diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c | 65 | diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c |
120 | index XXXXXXX..XXXXXXX 100644 | 66 | index XXXXXXX..XXXXXXX 100644 |
121 | --- a/hw/vfio/iommufd.c | 67 | --- a/hw/vfio/iommufd.c |
122 | +++ b/hw/vfio/iommufd.c | 68 | +++ b/hw/vfio/iommufd.c |
123 | @@ -XXX,XX +XXX,XX @@ | 69 | @@ -XXX,XX +XXX,XX @@ |
124 | #include "iommufd.h" | 70 | #include "vfio-iommufd.h" |
125 | #include "helpers.h" | 71 | #include "vfio-helpers.h" |
126 | #include "cpr.h" | 72 | #include "vfio-cpr.h" |
127 | +#include "dirty-tracking.h" | 73 | +#include "vfio-listener.h" |
128 | 74 | ||
129 | #define TYPE_HOST_IOMMU_DEVICE_IOMMUFD_VFIO \ | 75 | #define TYPE_HOST_IOMMU_DEVICE_IOMMUFD_VFIO \ |
130 | TYPE_HOST_IOMMU_DEVICE_IOMMUFD "-vfio" | 76 | TYPE_HOST_IOMMU_DEVICE_IOMMUFD "-vfio" |
77 | diff --git a/hw/vfio/common.c b/hw/vfio/listener.c | ||
78 | similarity index 100% | ||
79 | rename from hw/vfio/common.c | ||
80 | rename to hw/vfio/listener.c | ||
131 | diff --git a/hw/vfio/meson.build b/hw/vfio/meson.build | 81 | diff --git a/hw/vfio/meson.build b/hw/vfio/meson.build |
132 | index XXXXXXX..XXXXXXX 100644 | 82 | index XXXXXXX..XXXXXXX 100644 |
133 | --- a/hw/vfio/meson.build | 83 | --- a/hw/vfio/meson.build |
134 | +++ b/hw/vfio/meson.build | 84 | +++ b/hw/vfio/meson.build |
135 | @@ -XXX,XX +XXX,XX @@ | 85 | @@ -XXX,XX +XXX,XX @@ |
136 | vfio_ss = ss.source_set() | 86 | vfio_ss = ss.source_set() |
137 | vfio_ss.add(files( | 87 | vfio_ss.add(files( |
138 | - 'common.c', | 88 | - 'common.c', |
139 | + 'dirty-tracking.c', | 89 | + 'listener.c', |
90 | 'container-base.c', | ||
140 | 'container.c', | 91 | 'container.c', |
141 | 'helpers.c', | 92 | 'helpers.c', |
142 | )) | ||
143 | diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events | 93 | diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events |
144 | index XXXXXXX..XXXXXXX 100644 | 94 | index XXXXXXX..XXXXXXX 100644 |
145 | --- a/hw/vfio/trace-events | 95 | --- a/hw/vfio/trace-events |
146 | +++ b/hw/vfio/trace-events | 96 | +++ b/hw/vfio/trace-events |
147 | @@ -XXX,XX +XXX,XX @@ vfio_pci_igd_bdsm_enabled(const char *name, int size) "%s %dMB" | 97 | @@ -XXX,XX +XXX,XX @@ vfio_pci_igd_bdsm_enabled(const char *name, int size) "%s %dMB" |
148 | vfio_pci_igd_host_bridge_enabled(const char *name) "%s" | 98 | vfio_pci_igd_host_bridge_enabled(const char *name) "%s" |
149 | vfio_pci_igd_lpc_bridge_enabled(const char *name) "%s" | 99 | vfio_pci_igd_lpc_bridge_enabled(const char *name) "%s" |
150 | 100 | ||
151 | -# common.c | 101 | -# common.c |
152 | +# dirty-tracking.c | 102 | +# listener.c |
153 | vfio_iommu_map_notify(const char *op, uint64_t iova_start, uint64_t iova_end) "iommu %s @ 0x%"PRIx64" - 0x%"PRIx64 | 103 | vfio_iommu_map_notify(const char *op, uint64_t iova_start, uint64_t iova_end) "iommu %s @ 0x%"PRIx64" - 0x%"PRIx64 |
154 | vfio_listener_region_skip(const char *name, uint64_t start, uint64_t end) "SKIPPING %s 0x%"PRIx64" - 0x%"PRIx64 | 104 | vfio_listener_region_skip(const char *name, uint64_t start, uint64_t end) "SKIPPING %s 0x%"PRIx64" - 0x%"PRIx64 |
155 | vfio_spapr_group_attach(int groupfd, int tablefd) "Attached groupfd %d to liobn fd %d" | 105 | vfio_spapr_group_attach(int groupfd, int tablefd) "Attached groupfd %d to liobn fd %d" |
156 | -- | 106 | -- |
157 | 2.48.1 | 107 | 2.49.0 |
158 | 108 | ||
159 | 109 | diff view generated by jsdifflib |
1 | Rename some routines to better reflect the namespace they belong to. | 1 | Rename some routines to better reflect the namespace they belong to. |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Cédric Le Goater <clg@redhat.com> | 3 | Signed-off-by: Cédric Le Goater <clg@redhat.com> |
4 | --- | 4 | --- |
5 | hw/vfio/dirty-tracking.c | 12 ++++++------ | 5 | hw/vfio/listener.c | 12 ++++++------ |
6 | 1 file changed, 6 insertions(+), 6 deletions(-) | 6 | 1 file changed, 6 insertions(+), 6 deletions(-) |
7 | 7 | ||
8 | diff --git a/hw/vfio/dirty-tracking.c b/hw/vfio/dirty-tracking.c | 8 | diff --git a/hw/vfio/listener.c b/hw/vfio/listener.c |
9 | index XXXXXXX..XXXXXXX 100644 | 9 | index XXXXXXX..XXXXXXX 100644 |
10 | --- a/hw/vfio/dirty-tracking.c | 10 | --- a/hw/vfio/listener.c |
11 | +++ b/hw/vfio/dirty-tracking.c | 11 | +++ b/hw/vfio/listener.c |
12 | @@ -XXX,XX +XXX,XX @@ static int vfio_ram_discard_notify_populate(RamDiscardListener *rdl, | 12 | @@ -XXX,XX +XXX,XX @@ static int vfio_ram_discard_notify_populate(RamDiscardListener *rdl, |
13 | return 0; | 13 | return 0; |
14 | } | 14 | } |
15 | 15 | ||
16 | -static void vfio_register_ram_discard_listener(VFIOContainerBase *bcontainer, | 16 | -static void vfio_register_ram_discard_listener(VFIOContainerBase *bcontainer, |
... | ... | ||
62 | + vfio_ram_discard_query_dirty_bitmap, | 62 | + vfio_ram_discard_query_dirty_bitmap, |
63 | &vrdl); | 63 | &vrdl); |
64 | } | 64 | } |
65 | 65 | ||
66 | -- | 66 | -- |
67 | 2.48.1 | 67 | 2.49.0 |
68 | 68 | ||
69 | 69 | diff view generated by jsdifflib |
1 | This hides the MemoryListener implementation and makes the code common | 1 | This hides the MemoryListener implementation and makes the code common |
---|---|---|---|
2 | to both IOMMU backends, legacy and IOMMUFD. | 2 | to both IOMMU backends, legacy and IOMMUFD. |
3 | 3 | ||
4 | Signed-off-by: Cédric Le Goater <clg@redhat.com> | 4 | Signed-off-by: Cédric Le Goater <clg@redhat.com> |
5 | --- | 5 | --- |
6 | hw/vfio/dirty-tracking.h | 4 ++-- | 6 | hw/vfio/vfio-listener.h | 3 ++- |
7 | hw/vfio/container.c | 11 +++-------- | 7 | hw/vfio/container.c | 11 +++-------- |
8 | hw/vfio/dirty-tracking.c | 21 ++++++++++++++++++++- | 8 | hw/vfio/iommufd.c | 9 ++------- |
9 | hw/vfio/iommufd.c | 9 ++------- | 9 | hw/vfio/listener.c | 22 +++++++++++++++++++++- |
10 | 4 files changed, 27 insertions(+), 18 deletions(-) | 10 | 4 files changed, 28 insertions(+), 17 deletions(-) |
11 | 11 | ||
12 | diff --git a/hw/vfio/dirty-tracking.h b/hw/vfio/dirty-tracking.h | 12 | diff --git a/hw/vfio/vfio-listener.h b/hw/vfio/vfio-listener.h |
13 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/hw/vfio/dirty-tracking.h | 14 | --- a/hw/vfio/vfio-listener.h |
15 | +++ b/hw/vfio/dirty-tracking.h | 15 | +++ b/hw/vfio/vfio-listener.h |
16 | @@ -XXX,XX +XXX,XX @@ | 16 | @@ -XXX,XX +XXX,XX @@ |
17 | #ifndef HW_VFIO_DIRTY_TRACKING_H | 17 | #ifndef HW_VFIO_VFIO_LISTENER_H |
18 | #define HW_VFIO_DIRTY_TRACKING_H | 18 | #define HW_VFIO_VFIO_LISTENER_H |
19 | 19 | ||
20 | -extern const MemoryListener vfio_memory_listener; | 20 | -extern const MemoryListener vfio_memory_listener; |
21 | - | 21 | +bool vfio_listener_register(VFIOContainerBase *bcontainer, Error **errp); |
22 | bool vfio_dirty_tracking_devices_is_started(const VFIOContainerBase *bcontainer); | 22 | +void vfio_listener_unregister(VFIOContainerBase *bcontainer); |
23 | bool vfio_dirty_tracking_devices_is_supported(const VFIOContainerBase *bcontainer); | 23 | |
24 | int vfio_dirty_tracking_query_dirty_bitmap(const VFIOContainerBase *bcontainer, uint64_t iova, | 24 | #endif /* HW_VFIO_VFIO_LISTENER_H */ |
25 | uint64_t size, ram_addr_t ram_addr, Error **errp); | ||
26 | +bool vfio_dirty_tracking_register(VFIOContainerBase *bcontainer, Error **errp); | ||
27 | +void vfio_dirty_tracking_unregister(VFIOContainerBase *bcontainer); | ||
28 | |||
29 | #endif /* HW_VFIO_DIRTY_TRACKING_H */ | ||
30 | diff --git a/hw/vfio/container.c b/hw/vfio/container.c | 25 | diff --git a/hw/vfio/container.c b/hw/vfio/container.c |
31 | index XXXXXXX..XXXXXXX 100644 | 26 | index XXXXXXX..XXXXXXX 100644 |
32 | --- a/hw/vfio/container.c | 27 | --- a/hw/vfio/container.c |
33 | +++ b/hw/vfio/container.c | 28 | +++ b/hw/vfio/container.c |
34 | @@ -XXX,XX +XXX,XX @@ static bool vfio_container_connect(VFIOGroup *group, AddressSpace *as, | 29 | @@ -XXX,XX +XXX,XX @@ static bool vfio_connect_container(VFIOGroup *group, AddressSpace *as, |
35 | group->container = container; | 30 | group->container = container; |
36 | QLIST_INSERT_HEAD(&container->group_list, group, container_next); | 31 | QLIST_INSERT_HEAD(&container->group_list, group, container_next); |
37 | 32 | ||
38 | - bcontainer->listener = vfio_memory_listener; | 33 | - bcontainer->listener = vfio_memory_listener; |
39 | - memory_listener_register(&bcontainer->listener, bcontainer->space->as); | 34 | - memory_listener_register(&bcontainer->listener, bcontainer->space->as); |
40 | - | 35 | - |
41 | - if (bcontainer->error) { | 36 | - if (bcontainer->error) { |
42 | - error_propagate_prepend(errp, bcontainer->error, | 37 | - error_propagate_prepend(errp, bcontainer->error, |
43 | - "memory listener initialization failed: "); | 38 | - "memory listener initialization failed: "); |
44 | + if (!vfio_dirty_tracking_register(bcontainer, errp)) { | 39 | + if (!vfio_listener_register(bcontainer, errp)) { |
45 | goto listener_release_exit; | 40 | goto listener_release_exit; |
46 | } | 41 | } |
47 | 42 | ||
48 | @@ -XXX,XX +XXX,XX @@ static bool vfio_container_connect(VFIOGroup *group, AddressSpace *as, | 43 | @@ -XXX,XX +XXX,XX @@ static bool vfio_connect_container(VFIOGroup *group, AddressSpace *as, |
49 | listener_release_exit: | 44 | listener_release_exit: |
50 | QLIST_REMOVE(group, container_next); | 45 | QLIST_REMOVE(group, container_next); |
51 | vfio_group_del_kvm_device(group); | 46 | vfio_kvm_device_del_group(group); |
52 | - memory_listener_unregister(&bcontainer->listener); | 47 | - memory_listener_unregister(&bcontainer->listener); |
53 | + vfio_dirty_tracking_unregister(bcontainer); | 48 | + vfio_listener_unregister(bcontainer); |
54 | if (vioc->release) { | 49 | if (vioc->release) { |
55 | vioc->release(bcontainer); | 50 | vioc->release(bcontainer); |
56 | } | 51 | } |
57 | @@ -XXX,XX +XXX,XX @@ static void vfio_container_disconnect(VFIOGroup *group) | 52 | @@ -XXX,XX +XXX,XX @@ static void vfio_disconnect_container(VFIOGroup *group) |
58 | * group. | 53 | * group. |
59 | */ | 54 | */ |
60 | if (QLIST_EMPTY(&container->group_list)) { | 55 | if (QLIST_EMPTY(&container->group_list)) { |
61 | - memory_listener_unregister(&bcontainer->listener); | 56 | - memory_listener_unregister(&bcontainer->listener); |
62 | + vfio_dirty_tracking_unregister(bcontainer); | 57 | + vfio_listener_unregister(bcontainer); |
63 | if (vioc->release) { | 58 | if (vioc->release) { |
64 | vioc->release(bcontainer); | 59 | vioc->release(bcontainer); |
65 | } | 60 | } |
66 | diff --git a/hw/vfio/dirty-tracking.c b/hw/vfio/dirty-tracking.c | 61 | diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c |
67 | index XXXXXXX..XXXXXXX 100644 | 62 | index XXXXXXX..XXXXXXX 100644 |
68 | --- a/hw/vfio/dirty-tracking.c | 63 | --- a/hw/vfio/iommufd.c |
69 | +++ b/hw/vfio/dirty-tracking.c | 64 | +++ b/hw/vfio/iommufd.c |
65 | @@ -XXX,XX +XXX,XX @@ static void iommufd_cdev_container_destroy(VFIOIOMMUFDContainer *container) | ||
66 | if (!QLIST_EMPTY(&bcontainer->device_list)) { | ||
67 | return; | ||
68 | } | ||
69 | - memory_listener_unregister(&bcontainer->listener); | ||
70 | + vfio_listener_unregister(bcontainer); | ||
71 | iommufd_backend_free_id(container->be, container->ioas_id); | ||
72 | object_unref(container); | ||
73 | } | ||
74 | @@ -XXX,XX +XXX,XX @@ static bool iommufd_cdev_attach(const char *name, VFIODevice *vbasedev, | ||
75 | bcontainer->pgsizes = qemu_real_host_page_size(); | ||
76 | } | ||
77 | |||
78 | - bcontainer->listener = vfio_memory_listener; | ||
79 | - memory_listener_register(&bcontainer->listener, bcontainer->space->as); | ||
80 | - | ||
81 | - if (bcontainer->error) { | ||
82 | - error_propagate_prepend(errp, bcontainer->error, | ||
83 | - "memory listener initialization failed: "); | ||
84 | + if (!vfio_listener_register(bcontainer, errp)) { | ||
85 | goto err_listener_register; | ||
86 | } | ||
87 | |||
88 | diff --git a/hw/vfio/listener.c b/hw/vfio/listener.c | ||
89 | index XXXXXXX..XXXXXXX 100644 | ||
90 | --- a/hw/vfio/listener.c | ||
91 | +++ b/hw/vfio/listener.c | ||
92 | @@ -XXX,XX +XXX,XX @@ | ||
93 | #include "system/tpm.h" | ||
94 | #include "vfio-migration-internal.h" | ||
95 | #include "vfio-helpers.h" | ||
96 | +#include "vfio-listener.h" | ||
97 | |||
98 | /* | ||
99 | * Device state interfaces | ||
70 | @@ -XXX,XX +XXX,XX @@ static void vfio_listener_log_sync(MemoryListener *listener, | 100 | @@ -XXX,XX +XXX,XX @@ static void vfio_listener_log_sync(MemoryListener *listener, |
71 | } | 101 | } |
72 | } | 102 | } |
73 | 103 | ||
74 | -const MemoryListener vfio_memory_listener = { | 104 | -const MemoryListener vfio_memory_listener = { |
... | ... | ||
79 | @@ -XXX,XX +XXX,XX @@ const MemoryListener vfio_memory_listener = { | 109 | @@ -XXX,XX +XXX,XX @@ const MemoryListener vfio_memory_listener = { |
80 | .log_global_stop = vfio_listener_log_global_stop, | 110 | .log_global_stop = vfio_listener_log_global_stop, |
81 | .log_sync = vfio_listener_log_sync, | 111 | .log_sync = vfio_listener_log_sync, |
82 | }; | 112 | }; |
83 | + | 113 | + |
84 | +bool vfio_dirty_tracking_register(VFIOContainerBase *bcontainer, Error **errp) | 114 | +bool vfio_listener_register(VFIOContainerBase *bcontainer, Error **errp) |
85 | +{ | 115 | +{ |
86 | + bcontainer->listener = vfio_memory_listener; | 116 | + bcontainer->listener = vfio_memory_listener; |
87 | + memory_listener_register(&bcontainer->listener, bcontainer->space->as); | 117 | + memory_listener_register(&bcontainer->listener, bcontainer->space->as); |
88 | + | 118 | + |
89 | + if (bcontainer->error) { | 119 | + if (bcontainer->error) { |
... | ... | ||
93 | + } | 123 | + } |
94 | + | 124 | + |
95 | + return true; | 125 | + return true; |
96 | +} | 126 | +} |
97 | + | 127 | + |
98 | +void vfio_dirty_tracking_unregister(VFIOContainerBase *bcontainer) | 128 | +void vfio_listener_unregister(VFIOContainerBase *bcontainer) |
99 | +{ | 129 | +{ |
100 | + memory_listener_unregister(&bcontainer->listener); | 130 | + memory_listener_unregister(&bcontainer->listener); |
101 | +} | 131 | +} |
102 | diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c | ||
103 | index XXXXXXX..XXXXXXX 100644 | ||
104 | --- a/hw/vfio/iommufd.c | ||
105 | +++ b/hw/vfio/iommufd.c | ||
106 | @@ -XXX,XX +XXX,XX @@ static void iommufd_cdev_container_destroy(VFIOIOMMUFDContainer *container) | ||
107 | if (!QLIST_EMPTY(&bcontainer->device_list)) { | ||
108 | return; | ||
109 | } | ||
110 | - memory_listener_unregister(&bcontainer->listener); | ||
111 | + vfio_dirty_tracking_unregister(bcontainer); | ||
112 | iommufd_backend_free_id(container->be, container->ioas_id); | ||
113 | object_unref(container); | ||
114 | } | ||
115 | @@ -XXX,XX +XXX,XX @@ static bool iommufd_cdev_attach(const char *name, VFIODevice *vbasedev, | ||
116 | bcontainer->pgsizes = qemu_real_host_page_size(); | ||
117 | } | ||
118 | |||
119 | - bcontainer->listener = vfio_memory_listener; | ||
120 | - memory_listener_register(&bcontainer->listener, bcontainer->space->as); | ||
121 | - | ||
122 | - if (bcontainer->error) { | ||
123 | - error_propagate_prepend(errp, bcontainer->error, | ||
124 | - "memory listener initialization failed: "); | ||
125 | + if (!vfio_dirty_tracking_register(bcontainer, errp)) { | ||
126 | goto err_listener_register; | ||
127 | } | ||
128 | |||
129 | -- | 132 | -- |
130 | 2.48.1 | 133 | 2.49.0 |
131 | 134 | ||
132 | 135 | diff view generated by jsdifflib |
... | ... | ||
---|---|---|---|
15 | hw/vfio/ccw.c | 2 +- | 15 | hw/vfio/ccw.c | 2 +- |
16 | hw/vfio/container-base.c | 2 +- | 16 | hw/vfio/container-base.c | 2 +- |
17 | hw/vfio/container.c | 2 +- | 17 | hw/vfio/container.c | 2 +- |
18 | hw/vfio/cpr.c | 2 +- | 18 | hw/vfio/cpr.c | 2 +- |
19 | hw/vfio/device.c | 2 +- | 19 | hw/vfio/device.c | 2 +- |
20 | hw/vfio/dirty-tracking.c | 2 +- | ||
21 | hw/vfio/helpers.c | 2 +- | 20 | hw/vfio/helpers.c | 2 +- |
22 | hw/vfio/iommufd.c | 2 +- | 21 | hw/vfio/iommufd.c | 2 +- |
22 | hw/vfio/listener.c | 2 +- | ||
23 | hw/vfio/migration-multifd.c | 2 +- | 23 | hw/vfio/migration-multifd.c | 2 +- |
24 | hw/vfio/migration.c | 2 +- | 24 | hw/vfio/migration.c | 2 +- |
25 | hw/vfio/region.c | 4 ++-- | 25 | hw/vfio/region.c | 4 ++-- |
26 | 18 files changed, 18 insertions(+), 18 deletions(-) | 26 | 18 files changed, 18 insertions(+), 18 deletions(-) |
27 | rename include/hw/vfio/{vfio-common.h => vfio-device.h} (100%) | 27 | rename include/hw/vfio/{vfio-common.h => vfio-device.h} (100%) |
... | ... | ||
124 | diff --git a/hw/vfio/container-base.c b/hw/vfio/container-base.c | 124 | diff --git a/hw/vfio/container-base.c b/hw/vfio/container-base.c |
125 | index XXXXXXX..XXXXXXX 100644 | 125 | index XXXXXXX..XXXXXXX 100644 |
126 | --- a/hw/vfio/container-base.c | 126 | --- a/hw/vfio/container-base.c |
127 | +++ b/hw/vfio/container-base.c | 127 | +++ b/hw/vfio/container-base.c |
128 | @@ -XXX,XX +XXX,XX @@ | 128 | @@ -XXX,XX +XXX,XX @@ |
129 | #include "qemu/error-report.h" | 129 | #include "qapi/error.h" |
130 | #include "qemu/error-report.h" | ||
131 | #include "hw/vfio/vfio-container-base.h" | ||
132 | -#include "hw/vfio/vfio-common.h" /* vfio_reset_handler */ | ||
133 | +#include "hw/vfio/vfio-device.h" /* vfio_reset_handler */ | ||
130 | #include "system/reset.h" | 134 | #include "system/reset.h" |
131 | #include "hw/vfio/vfio-container-base.h" | 135 | #include "vfio-helpers.h" |
132 | -#include "hw/vfio/vfio-common.h" /* for vfio_device_list */ | 136 | |
133 | +#include "hw/vfio/vfio-device.h" /* for vfio_device_list */ | ||
134 | #include "trace.h" | ||
135 | |||
136 | static QLIST_HEAD(, VFIOAddressSpace) vfio_address_spaces = | ||
137 | diff --git a/hw/vfio/container.c b/hw/vfio/container.c | 137 | diff --git a/hw/vfio/container.c b/hw/vfio/container.c |
138 | index XXXXXXX..XXXXXXX 100644 | 138 | index XXXXXXX..XXXXXXX 100644 |
139 | --- a/hw/vfio/container.c | 139 | --- a/hw/vfio/container.c |
140 | +++ b/hw/vfio/container.c | 140 | +++ b/hw/vfio/container.c |
141 | @@ -XXX,XX +XXX,XX @@ | 141 | @@ -XXX,XX +XXX,XX @@ |
... | ... | ||
171 | -#include "hw/vfio/vfio-common.h" | 171 | -#include "hw/vfio/vfio-common.h" |
172 | +#include "hw/vfio/vfio-device.h" | 172 | +#include "hw/vfio/vfio-device.h" |
173 | #include "hw/vfio/pci.h" | 173 | #include "hw/vfio/pci.h" |
174 | #include "hw/hw.h" | 174 | #include "hw/hw.h" |
175 | #include "trace.h" | 175 | #include "trace.h" |
176 | diff --git a/hw/vfio/dirty-tracking.c b/hw/vfio/dirty-tracking.c | ||
177 | index XXXXXXX..XXXXXXX 100644 | ||
178 | --- a/hw/vfio/dirty-tracking.c | ||
179 | +++ b/hw/vfio/dirty-tracking.c | ||
180 | @@ -XXX,XX +XXX,XX @@ | ||
181 | #include <sys/ioctl.h> | ||
182 | #include <linux/vfio.h> | ||
183 | |||
184 | -#include "hw/vfio/vfio-common.h" | ||
185 | +#include "hw/vfio/vfio-device.h" | ||
186 | #include "hw/vfio/pci.h" | ||
187 | #include "exec/memory.h" | ||
188 | #include "exec/ram_addr.h" | ||
189 | diff --git a/hw/vfio/helpers.c b/hw/vfio/helpers.c | 176 | diff --git a/hw/vfio/helpers.c b/hw/vfio/helpers.c |
190 | index XXXXXXX..XXXXXXX 100644 | 177 | index XXXXXXX..XXXXXXX 100644 |
191 | --- a/hw/vfio/helpers.c | 178 | --- a/hw/vfio/helpers.c |
192 | +++ b/hw/vfio/helpers.c | 179 | +++ b/hw/vfio/helpers.c |
193 | @@ -XXX,XX +XXX,XX @@ | 180 | @@ -XXX,XX +XXX,XX @@ |
... | ... | ||
196 | #include "system/kvm.h" | 183 | #include "system/kvm.h" |
197 | -#include "hw/vfio/vfio-common.h" | 184 | -#include "hw/vfio/vfio-common.h" |
198 | +#include "hw/vfio/vfio-device.h" | 185 | +#include "hw/vfio/vfio-device.h" |
199 | #include "hw/hw.h" | 186 | #include "hw/hw.h" |
200 | #include "qapi/error.h" | 187 | #include "qapi/error.h" |
201 | #include "helpers.h" | 188 | #include "vfio-helpers.h" |
202 | diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c | 189 | diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c |
203 | index XXXXXXX..XXXXXXX 100644 | 190 | index XXXXXXX..XXXXXXX 100644 |
204 | --- a/hw/vfio/iommufd.c | 191 | --- a/hw/vfio/iommufd.c |
205 | +++ b/hw/vfio/iommufd.c | 192 | +++ b/hw/vfio/iommufd.c |
206 | @@ -XXX,XX +XXX,XX @@ | 193 | @@ -XXX,XX +XXX,XX @@ |
... | ... | ||
210 | -#include "hw/vfio/vfio-common.h" | 197 | -#include "hw/vfio/vfio-common.h" |
211 | +#include "hw/vfio/vfio-device.h" | 198 | +#include "hw/vfio/vfio-device.h" |
212 | #include "qemu/error-report.h" | 199 | #include "qemu/error-report.h" |
213 | #include "trace.h" | 200 | #include "trace.h" |
214 | #include "qapi/error.h" | 201 | #include "qapi/error.h" |
202 | diff --git a/hw/vfio/listener.c b/hw/vfio/listener.c | ||
203 | index XXXXXXX..XXXXXXX 100644 | ||
204 | --- a/hw/vfio/listener.c | ||
205 | +++ b/hw/vfio/listener.c | ||
206 | @@ -XXX,XX +XXX,XX @@ | ||
207 | #endif | ||
208 | #include <linux/vfio.h> | ||
209 | |||
210 | -#include "hw/vfio/vfio-common.h" | ||
211 | +#include "hw/vfio/vfio-device.h" | ||
212 | #include "hw/vfio/pci.h" | ||
213 | #include "exec/address-spaces.h" | ||
214 | #include "exec/memory.h" | ||
215 | diff --git a/hw/vfio/migration-multifd.c b/hw/vfio/migration-multifd.c | 215 | diff --git a/hw/vfio/migration-multifd.c b/hw/vfio/migration-multifd.c |
216 | index XXXXXXX..XXXXXXX 100644 | 216 | index XXXXXXX..XXXXXXX 100644 |
217 | --- a/hw/vfio/migration-multifd.c | 217 | --- a/hw/vfio/migration-multifd.c |
218 | +++ b/hw/vfio/migration-multifd.c | 218 | +++ b/hw/vfio/migration-multifd.c |
219 | @@ -XXX,XX +XXX,XX @@ | 219 | @@ -XXX,XX +XXX,XX @@ |
... | ... | ||
252 | +#include "hw/vfio/vfio-device.h" | 252 | +#include "hw/vfio/vfio-device.h" |
253 | #include "hw/hw.h" | 253 | #include "hw/hw.h" |
254 | #include "trace.h" | 254 | #include "trace.h" |
255 | #include "qapi/error.h" | 255 | #include "qapi/error.h" |
256 | -- | 256 | -- |
257 | 2.48.1 | 257 | 2.49.0 |
258 | 258 | ||
259 | 259 | diff view generated by jsdifflib |
... | ... | ||
---|---|---|---|
7 | vfio_attach_device -> vfio_device_attach | 7 | vfio_attach_device -> vfio_device_attach |
8 | vfio_detach_device -> vfio_device_detach | 8 | vfio_detach_device -> vfio_device_detach |
9 | vfio_get_region_info -> vfio_device_get_region_info | 9 | vfio_get_region_info -> vfio_device_get_region_info |
10 | vfio_get_dev_region_info -> vfio_device_get_region_info_type | 10 | vfio_get_dev_region_info -> vfio_device_get_region_info_type |
11 | vfio_has_region_cap -> vfio_device_has_region_cap | 11 | vfio_has_region_cap -> vfio_device_has_region_cap |
12 | vfio_reset_handler -> vfio_device_reset_hander | ||
12 | 13 | ||
13 | to better reflect the namespace they belong to. | 14 | to better reflect the namespace they belong to. |
14 | 15 | ||
15 | Signed-off-by: Cédric Le Goater <clg@redhat.com> | 16 | Signed-off-by: Cédric Le Goater <clg@redhat.com> |
16 | --- | 17 | --- |
17 | include/hw/vfio/vfio-device.h | 18 ++++++------- | 18 | include/hw/vfio/vfio-device.h | 20 +++++++-------- |
18 | hw/vfio/ap.c | 8 +++--- | 19 | hw/vfio/ap.c | 8 +++--- |
19 | hw/vfio/ccw.c | 18 ++++++------- | 20 | hw/vfio/ccw.c | 18 ++++++------- |
21 | hw/vfio/container-base.c | 6 ++--- | ||
20 | hw/vfio/container.c | 6 ++--- | 22 | hw/vfio/container.c | 6 ++--- |
21 | hw/vfio/device.c | 24 +++++++++--------- | 23 | hw/vfio/device.c | 28 ++++++++++---------- |
22 | hw/vfio/display.c | 2 +- | 24 | hw/vfio/display.c | 2 +- |
23 | hw/vfio/igd.c | 8 +++--- | 25 | hw/vfio/igd.c | 8 +++--- |
24 | hw/vfio/pci.c | 48 +++++++++++++++++------------------ | 26 | hw/vfio/pci.c | 48 +++++++++++++++++------------------ |
25 | hw/vfio/platform.c | 10 ++++---- | 27 | hw/vfio/platform.c | 10 ++++---- |
26 | hw/vfio/region.c | 2 +- | 28 | hw/vfio/region.c | 2 +- |
27 | hw/vfio/trace-events | 6 ++--- | 29 | hw/vfio/trace-events | 8 +++--- |
28 | 11 files changed, 75 insertions(+), 75 deletions(-) | 30 | 12 files changed, 82 insertions(+), 82 deletions(-) |
29 | 31 | ||
30 | diff --git a/include/hw/vfio/vfio-device.h b/include/hw/vfio/vfio-device.h | 32 | diff --git a/include/hw/vfio/vfio-device.h b/include/hw/vfio/vfio-device.h |
31 | index XXXXXXX..XXXXXXX 100644 | 33 | index XXXXXXX..XXXXXXX 100644 |
32 | --- a/include/hw/vfio/vfio-device.h | 34 | --- a/include/hw/vfio/vfio-device.h |
33 | +++ b/include/hw/vfio/vfio-device.h | 35 | +++ b/include/hw/vfio/vfio-device.h |
... | ... | ||
43 | +void vfio_device_irq_unmask(VFIODevice *vbasedev, int index); | 45 | +void vfio_device_irq_unmask(VFIODevice *vbasedev, int index); |
44 | +void vfio_device_irq_mask(VFIODevice *vbasedev, int index); | 46 | +void vfio_device_irq_mask(VFIODevice *vbasedev, int index); |
45 | +bool vfio_device_irq_set_signaling(VFIODevice *vbasedev, int index, int subindex, | 47 | +bool vfio_device_irq_set_signaling(VFIODevice *vbasedev, int index, int subindex, |
46 | int action, int fd, Error **errp); | 48 | int action, int fd, Error **errp); |
47 | 49 | ||
50 | -void vfio_reset_handler(void *opaque); | ||
51 | +void vfio_device_reset_handler(void *opaque); | ||
48 | bool vfio_device_is_mdev(VFIODevice *vbasedev); | 52 | bool vfio_device_is_mdev(VFIODevice *vbasedev); |
49 | bool vfio_device_hiod_realize(VFIODevice *vbasedev, Error **errp); | 53 | bool vfio_device_hiod_realize(VFIODevice *vbasedev, Error **errp); |
50 | -bool vfio_attach_device(char *name, VFIODevice *vbasedev, | 54 | -bool vfio_attach_device(char *name, VFIODevice *vbasedev, |
51 | +bool vfio_device_attach(char *name, VFIODevice *vbasedev, | 55 | +bool vfio_device_attach(char *name, VFIODevice *vbasedev, |
52 | AddressSpace *as, Error **errp); | 56 | AddressSpace *as, Error **errp); |
... | ... | ||
192 | - vfio_detach_device(&vcdev->vdev); | 196 | - vfio_detach_device(&vcdev->vdev); |
193 | + vfio_device_detach(&vcdev->vdev); | 197 | + vfio_device_detach(&vcdev->vdev); |
194 | g_free(vcdev->vdev.name); | 198 | g_free(vcdev->vdev.name); |
195 | 199 | ||
196 | if (cdc->unrealize) { | 200 | if (cdc->unrealize) { |
201 | diff --git a/hw/vfio/container-base.c b/hw/vfio/container-base.c | ||
202 | index XXXXXXX..XXXXXXX 100644 | ||
203 | --- a/hw/vfio/container-base.c | ||
204 | +++ b/hw/vfio/container-base.c | ||
205 | @@ -XXX,XX +XXX,XX @@ | ||
206 | #include "qapi/error.h" | ||
207 | #include "qemu/error-report.h" | ||
208 | #include "hw/vfio/vfio-container-base.h" | ||
209 | -#include "hw/vfio/vfio-device.h" /* vfio_reset_handler */ | ||
210 | +#include "hw/vfio/vfio-device.h" /* vfio_device_reset_handler */ | ||
211 | #include "system/reset.h" | ||
212 | #include "vfio-helpers.h" | ||
213 | |||
214 | @@ -XXX,XX +XXX,XX @@ VFIOAddressSpace *vfio_address_space_get(AddressSpace *as) | ||
215 | QLIST_INIT(&space->containers); | ||
216 | |||
217 | if (QLIST_EMPTY(&vfio_address_spaces)) { | ||
218 | - qemu_register_reset(vfio_reset_handler, NULL); | ||
219 | + qemu_register_reset(vfio_device_reset_handler, NULL); | ||
220 | } | ||
221 | |||
222 | QLIST_INSERT_HEAD(&vfio_address_spaces, space, list); | ||
223 | @@ -XXX,XX +XXX,XX @@ void vfio_address_space_put(VFIOAddressSpace *space) | ||
224 | g_free(space); | ||
225 | |||
226 | if (QLIST_EMPTY(&vfio_address_spaces)) { | ||
227 | - qemu_unregister_reset(vfio_reset_handler, NULL); | ||
228 | + qemu_unregister_reset(vfio_device_reset_handler, NULL); | ||
229 | } | ||
230 | } | ||
231 | |||
197 | diff --git a/hw/vfio/container.c b/hw/vfio/container.c | 232 | diff --git a/hw/vfio/container.c b/hw/vfio/container.c |
198 | index XXXXXXX..XXXXXXX 100644 | 233 | index XXXXXXX..XXXXXXX 100644 |
199 | --- a/hw/vfio/container.c | 234 | --- a/hw/vfio/container.c |
200 | +++ b/hw/vfio/container.c | 235 | +++ b/hw/vfio/container.c |
201 | @@ -XXX,XX +XXX,XX @@ static int vfio_device_groupid(VFIODevice *vbasedev, Error **errp) | 236 | @@ -XXX,XX +XXX,XX @@ static int vfio_device_groupid(VFIODevice *vbasedev, Error **errp) |
... | ... | ||
228 | diff --git a/hw/vfio/device.c b/hw/vfio/device.c | 263 | diff --git a/hw/vfio/device.c b/hw/vfio/device.c |
229 | index XXXXXXX..XXXXXXX 100644 | 264 | index XXXXXXX..XXXXXXX 100644 |
230 | --- a/hw/vfio/device.c | 265 | --- a/hw/vfio/device.c |
231 | +++ b/hw/vfio/device.c | 266 | +++ b/hw/vfio/device.c |
232 | @@ -XXX,XX +XXX,XX @@ VFIODeviceList vfio_device_list = | 267 | @@ -XXX,XX +XXX,XX @@ VFIODeviceList vfio_device_list = |
268 | * reset for the one in-use devices case, calling _multi() will do | ||
269 | * nothing if a _one() would have been sufficient. | ||
270 | */ | ||
271 | -void vfio_reset_handler(void *opaque) | ||
272 | +void vfio_device_reset_handler(void *opaque) | ||
273 | { | ||
274 | VFIODevice *vbasedev; | ||
275 | |||
276 | - trace_vfio_reset_handler(); | ||
277 | + trace_vfio_device_reset_handler(); | ||
278 | QLIST_FOREACH(vbasedev, &vfio_device_list, global_next) { | ||
279 | if (vbasedev->dev->realized) { | ||
280 | vbasedev->ops->vfio_compute_needs_reset(vbasedev); | ||
281 | @@ -XXX,XX +XXX,XX @@ void vfio_reset_handler(void *opaque) | ||
233 | /* | 282 | /* |
234 | * Common VFIO interrupt disable | 283 | * Common VFIO interrupt disable |
235 | */ | 284 | */ |
236 | -void vfio_disable_irqindex(VFIODevice *vbasedev, int index) | 285 | -void vfio_disable_irqindex(VFIODevice *vbasedev, int index) |
237 | +void vfio_device_irq_disable(VFIODevice *vbasedev, int index) | 286 | +void vfio_device_irq_disable(VFIODevice *vbasedev, int index) |
... | ... | ||
680 | -vfio_attach_device(const char *name, int group_id) " (%s) group %d" | 729 | -vfio_attach_device(const char *name, int group_id) " (%s) group %d" |
681 | -vfio_detach_device(const char *name, int group_id) " (%s) group %d" | 730 | -vfio_detach_device(const char *name, int group_id) " (%s) group %d" |
682 | vfio_mdev(const char *name, bool is_mdev) " (%s) is_mdev %d" | 731 | vfio_mdev(const char *name, bool is_mdev) " (%s) is_mdev %d" |
683 | vfio_add_ext_cap_dropped(const char *name, uint16_t cap, uint16_t offset) "%s 0x%x@0x%x" | 732 | vfio_add_ext_cap_dropped(const char *name, uint16_t cap, uint16_t offset) "%s 0x%x@0x%x" |
684 | vfio_pci_reset(const char *name) " (%s)" | 733 | vfio_pci_reset(const char *name) " (%s)" |
685 | @@ -XXX,XX +XXX,XX @@ iommufd_cdev_pci_hot_reset_dep_devices(int domain, int bus, int slot, int functi | 734 | @@ -XXX,XX +XXX,XX @@ iommufd_cdev_device_info(char *name, int devfd, int num_irqs, int num_regions, i |
686 | vfio_reset_handler(void) "" | 735 | iommufd_cdev_pci_hot_reset_dep_devices(int domain, int bus, int slot, int function, int dev_id) "\t%04x:%02x:%02x.%x devid %d" |
687 | 736 | ||
688 | # device.c | 737 | # device.c |
689 | -vfio_get_dev_region(const char *name, int index, uint32_t type, uint32_t subtype) "%s index %d, %08x/%08x" | 738 | -vfio_get_dev_region(const char *name, int index, uint32_t type, uint32_t subtype) "%s index %d, %08x/%08x" |
739 | -vfio_reset_handler(void) "" | ||
690 | +vfio_device_get_region_info_type(const char *name, int index, uint32_t type, uint32_t subtype) "%s index %d, %08x/%08x" | 740 | +vfio_device_get_region_info_type(const char *name, int index, uint32_t type, uint32_t subtype) "%s index %d, %08x/%08x" |
741 | +vfio_device_reset_handler(void) "" | ||
691 | +vfio_device_attach(const char *name, int group_id) " (%s) group %d" | 742 | +vfio_device_attach(const char *name, int group_id) " (%s) group %d" |
692 | +vfio_device_detach(const char *name, int group_id) " (%s) group %d" | 743 | +vfio_device_detach(const char *name, int group_id) " (%s) group %d" |
693 | -- | 744 | -- |
694 | 2.48.1 | 745 | 2.49.0 |
695 | 746 | ||
696 | 747 | diff view generated by jsdifflib |
... | ... | ||
---|---|---|---|
10 | vfio_connect_container -> vfio_container_connect | 10 | vfio_connect_container -> vfio_container_connect |
11 | vfio_disconnect_container -> vfio_container_disconnect | 11 | vfio_disconnect_container -> vfio_container_disconnect |
12 | 12 | ||
13 | to better reflect the namespace they belong to. | 13 | to better reflect the namespace they belong to. |
14 | 14 | ||
15 | Reviewed-by: John Levon <john.levon@nutanix.com> | ||
16 | Link: https://lore.kernel.org/qemu-devel/20250318095415.670319-30-clg@redhat.com | ||
15 | Signed-off-by: Cédric Le Goater <clg@redhat.com> | 17 | Signed-off-by: Cédric Le Goater <clg@redhat.com> |
16 | --- | 18 | --- |
17 | hw/vfio/container.c | 52 ++++++++++++++++++++++---------------------- | 19 | hw/vfio/container.c | 52 ++++++++++++++++++++++---------------------- |
18 | hw/vfio/trace-events | 10 +++++---- | 20 | hw/vfio/trace-events | 12 +++++----- |
19 | 2 files changed, 32 insertions(+), 30 deletions(-) | 21 | 2 files changed, 33 insertions(+), 31 deletions(-) |
20 | 22 | ||
21 | diff --git a/hw/vfio/container.c b/hw/vfio/container.c | 23 | diff --git a/hw/vfio/container.c b/hw/vfio/container.c |
22 | index XXXXXXX..XXXXXXX 100644 | 24 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/hw/vfio/container.c | 25 | --- a/hw/vfio/container.c |
24 | +++ b/hw/vfio/container.c | 26 | +++ b/hw/vfio/container.c |
... | ... | ||
71 | return true; | 73 | return true; |
72 | listener_release_exit: | 74 | listener_release_exit: |
73 | QLIST_REMOVE(group, container_next); | 75 | QLIST_REMOVE(group, container_next); |
74 | - vfio_kvm_device_del_group(group); | 76 | - vfio_kvm_device_del_group(group); |
75 | + vfio_group_del_kvm_device(group); | 77 | + vfio_group_del_kvm_device(group); |
76 | memory_listener_unregister(&bcontainer->listener); | 78 | vfio_listener_unregister(bcontainer); |
77 | if (vioc->release) { | 79 | if (vioc->release) { |
78 | vioc->release(bcontainer); | 80 | vioc->release(bcontainer); |
79 | @@ -XXX,XX +XXX,XX @@ put_space_exit: | 81 | @@ -XXX,XX +XXX,XX @@ put_space_exit: |
80 | return false; | 82 | return false; |
81 | } | 83 | } |
... | ... | ||
226 | vfio_device_dirty_tracking_start(int nr_ranges, uint64_t min32, uint64_t max32, uint64_t min64, uint64_t max64, uint64_t minpci, uint64_t maxpci) "nr_ranges %d 32:[0x%"PRIx64" - 0x%"PRIx64"], 64:[0x%"PRIx64" - 0x%"PRIx64"], pci64:[0x%"PRIx64" - 0x%"PRIx64"]" | 228 | vfio_device_dirty_tracking_start(int nr_ranges, uint64_t min32, uint64_t max32, uint64_t min64, uint64_t max64, uint64_t minpci, uint64_t maxpci) "nr_ranges %d 32:[0x%"PRIx64" - 0x%"PRIx64"], 64:[0x%"PRIx64" - 0x%"PRIx64"], pci64:[0x%"PRIx64" - 0x%"PRIx64"]" |
227 | -vfio_disconnect_container(int fd) "close container->fd=%d" | 229 | -vfio_disconnect_container(int fd) "close container->fd=%d" |
228 | -vfio_put_group(int fd) "close group->fd=%d" | 230 | -vfio_put_group(int fd) "close group->fd=%d" |
229 | -vfio_get_device(const char * name, unsigned int flags, unsigned int num_regions, unsigned int num_irqs) "Device %s flags: %u, regions: %u, irqs: %u" | 231 | -vfio_get_device(const char * name, unsigned int flags, unsigned int num_regions, unsigned int num_irqs) "Device %s flags: %u, regions: %u, irqs: %u" |
230 | -vfio_put_base_device(int fd) "close vdev->fd=%d" | 232 | -vfio_put_base_device(int fd) "close vdev->fd=%d" |
231 | vfio_legacy_dma_unmap_overflow_workaround(void) "" | 233 | -vfio_legacy_dma_unmap_overflow_workaround(void) "" |
232 | vfio_get_dirty_bitmap(uint64_t iova, uint64_t size, uint64_t bitmap_size, uint64_t start, uint64_t dirty_pages) "iova=0x%"PRIx64" size= 0x%"PRIx64" bitmap_size=0x%"PRIx64" start=0x%"PRIx64" dirty_pages=%"PRIu64 | ||
233 | vfio_iommu_map_dirty_notify(uint64_t iova_start, uint64_t iova_end) "iommu dirty @ 0x%"PRIx64" - 0x%"PRIx64 | 234 | vfio_iommu_map_dirty_notify(uint64_t iova_start, uint64_t iova_end) "iommu dirty @ 0x%"PRIx64" - 0x%"PRIx64 |
234 | @@ -XXX,XX +XXX,XX @@ iommufd_cdev_pci_hot_reset_dep_devices(int domain, int bus, int slot, int functi | 235 | |
235 | # container-base.c | 236 | # container-base.c |
236 | vfio_reset_handler(void) "" | 237 | vfio_container_query_dirty_bitmap(uint64_t iova, uint64_t size, uint64_t bitmap_size, uint64_t start, uint64_t dirty_pages) "iova=0x%"PRIx64" size= 0x%"PRIx64" bitmap_size=0x%"PRIx64" start=0x%"PRIx64" dirty_pages=%"PRIu64 |
237 | 238 | ||
238 | +# container.c | 239 | +# container.c |
239 | +vfio_container_disconnect(int fd) "close container->fd=%d" | 240 | +vfio_container_disconnect(int fd) "close container->fd=%d" |
240 | +vfio_group_put(int fd) "close group->fd=%d" | 241 | +vfio_group_put(int fd) "close group->fd=%d" |
241 | +vfio_device_get(const char * name, unsigned int flags, unsigned int num_regions, unsigned int num_irqs) "Device %s flags: %u, regions: %u, irqs: %u" | 242 | +vfio_device_get(const char * name, unsigned int flags, unsigned int num_regions, unsigned int num_irqs) "Device %s flags: %u, regions: %u, irqs: %u" |
242 | +vfio_device_put(int fd) "close vdev->fd=%d" | 243 | +vfio_device_put(int fd) "close vdev->fd=%d" |
244 | +vfio_legacy_dma_unmap_overflow_workaround(void) "" | ||
243 | + | 245 | + |
244 | # device.c | 246 | # region.c |
245 | vfio_device_get_region_info_type(const char *name, int index, uint32_t type, uint32_t subtype) "%s index %d, %08x/%08x" | 247 | vfio_region_write(const char *name, int index, uint64_t addr, uint64_t data, unsigned size) " (%s:region%d+0x%"PRIx64", 0x%"PRIx64 ", %d)" |
246 | vfio_device_attach(const char *name, int group_id) " (%s) group %d" | 248 | vfio_region_read(char *name, int index, uint64_t addr, unsigned size, uint64_t data) " (%s:region%d+0x%"PRIx64", %d) = 0x%"PRIx64 |
247 | -- | 249 | -- |
248 | 2.48.1 | 250 | 2.49.0 |
249 | 251 | ||
250 | 252 | diff view generated by jsdifflib |