return false;
}
+ if (getpagesize() != ram_pagesize_summary()) {
+ bool have_hp = false;
+ /* We've got a huge page */
+#ifdef UFFD_FEATURE_MISSING_HUGETLBFS
+ have_hp = api_struct.features & UFFD_FEATURE_MISSING_HUGETLBFS;
+#endif
+ if (!have_hp) {
+ error_report("Userfault on this host does not support huge pages");
+ return false;
+ }
+ }
return true;
}
-/*
- * Check for things that postcopy won't support; returns 0 if the block
- * is fine.
+/* Callback from postcopy_ram_supported_by_host block iterator.
*/
-static int check_range(const char *block_name, void *host_addr,
- ram_addr_t offset, ram_addr_t length, void *opaque)
+static int test_range_shared(const char *block_name, void *host_addr,
+ ram_addr_t offset, ram_addr_t length, void *opaque)
{
- RAMBlock *rb = qemu_ram_block_by_name(block_name);
-
- if (qemu_ram_pagesize(rb) > getpagesize()) {
- error_report("Postcopy doesn't support large page sizes yet (%s)",
+ if (qemu_ram_is_shared(qemu_ram_block_by_name(block_name))) {
+ error_report("Postcopy on shared RAM (%s) is not yet supported",
block_name);
- return -E2BIG;
+ return 1;
}
-
return 0;
}
goto out;
}
- /* Check for anything about the RAMBlocks we don't support */
- if (qemu_ram_foreach_block(check_range, NULL)) {
- /* check_range will have printed its own error */
- goto out;
- }
-
ufd = syscall(__NR_userfaultfd, O_CLOEXEC);
if (ufd == -1) {
error_report("%s: userfaultfd not available: %s", __func__,
goto out;
}
+ /* We don't support postcopy with shared RAM yet */
+ if (qemu_ram_foreach_block(test_range_shared, NULL)) {
+ goto out;
+ }
+
/*
* userfault and mlock don't go together; we'll put it back later if
* it was enabled.
error_report("%s userfault register: %s", __func__, strerror(errno));
return -1;
}
+ if (!(reg_struct.ioctls & ((__u64)1 << _UFFDIO_COPY))) {
+ error_report("%s userfault: Region doesn't support COPY", __func__);
+ return -1;
+ }
return 0;
}