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;
}
+/* Callback from postcopy_ram_supported_by_host block iterator.
+ */
+static int test_range_shared(const char *block_name, void *host_addr,
+ ram_addr_t offset, ram_addr_t length, void *opaque)
+{
+ 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 1;
+ }
+ return 0;
+}
+
/*
* Note: This has the side effect of munlock'ing all of RAM, that's
* normally fine since if the postcopy succeeds it gets turned back on at the
if (!ufd_version_check(ufd)) {
goto out;
}
- /* TODO: Only allow huge pages if the kernel supports it */
+
+ /* 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
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;
}