@@ -64,6 +64,7 @@ static bool ufd_version_check(int ufd)
{
struct uffdio_api api_struct;
uint64_t ioctl_mask;
+ uint64_t features = 0;
api_struct.api = UFFD_API;
api_struct.features = 0;
@@ -92,6 +93,27 @@ static bool ufd_version_check(int ufd)
return false;
}
}
+
+#ifdef UFFD_FEATURE_THREAD_ID
+ if (api_struct.features & UFFD_FEATURE_THREAD_ID) {
+ features |= UFFD_FEATURE_THREAD_ID;
+ }
+#endif
+
+ if (features) {
+ /*
+ * If there are new features to be enabled from userspace,
+ * trigger another UFFDIO_API ioctl.
+ */
+ api_struct.api = UFFD_API;
+ api_struct.features = features;
+ if (ioctl(ufd, UFFDIO_API, &api_struct)) {
+ error_report("UFFDIO_API failed to setup features: 0x%"PRIx64,
+ features);
+ return false;
+ }
+ }
+
return true;
}