aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Henderson <william.henderson@nutanix.com>2023-07-31 14:42:42 +0000
committerJohn Levon <john.levon@nutanix.com>2023-09-15 12:59:39 +0100
commit376aec630e7e0481328a255b18af454d0c037aab (patch)
tree11df16e48c78034eba948bbfdc57e6ce0ce8a730
parent75664e54ca374a72ff0595f59c3929e87b1a0003 (diff)
downloadlibvfio-user-376aec630e7e0481328a255b18af454d0c037aab.zip
libvfio-user-376aec630e7e0481328a255b18af454d0c037aab.tar.gz
libvfio-user-376aec630e7e0481328a255b18af454d0c037aab.tar.bz2
fix: don't try to log non-mapped regions
Signed-off-by: William Henderson <william.henderson@nutanix.com>
-rw-r--r--lib/dma.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/lib/dma.c b/lib/dma.c
index a323b4e..0d2fe08 100644
--- a/lib/dma.c
+++ b/lib/dma.c
@@ -401,6 +401,24 @@ dma_feature_set(vfu_ctx_t *vfu_ctx, uint32_t feature, void *buf)
if (region == NULL) {
return ERROR_INT(EINVAL);
}
+
+ if (region->fd == -1) {
+ if (is_all_regions) {
+ /*
+ * DMA regions not mapped by the server are not dirty tracked
+ * (the client must track changes via handling
+ * VFIO_USER_DMA_WRITE). Therefore, we don't enable dirty page
+ * tracking for such regions. See #627.
+ */
+ continue;
+ } else {
+ /*
+ * Explicitly trying to enable dirty page tracking on a
+ * non-mapped region is invalid.
+ */
+ return ERROR_INT(EINVAL);
+ }
+ }
if (dirty_page_logging_start_on_region(region,
req->page_size) < 0) {
@@ -438,7 +456,19 @@ dma_feature_set(vfu_ctx_t *vfu_ctx, uint32_t feature, void *buf)
req->ranges[i].length);
}
- if (region == NULL || region->dirty_bitmap == NULL) {
+ if (region == NULL) {
+ return ERROR_INT(EINVAL);
+ }
+
+ if (region->fd == -1) {
+ if (is_all_regions) {
+ continue;
+ } else {
+ return ERROR_INT(EINVAL);
+ }
+ }
+
+ if (region->dirty_bitmap == NULL) {
return ERROR_INT(EINVAL);
}