Key changes:
Use features=0 in the initial UFFDIO_API call to query supported feature bits, rather than immediately requesting WP support.
Skip the test gracefully if:
- UFFDIO_API fails with EINVAL (e.g. unsupported API version), or
- UFFD_FEATURE_PAGEFAULT_FLAG_WP is not advertised by the kernel.
Close the initial userfaultfd and create a new one before enabling the required feature, since UFFDIO_API can only be called once per fd.
Improve diagnostics by distinguishing between expected and unexpected failures, using strerror() to report errors.
This ensures the test behaves correctly across a wider range of kernel versions and configurations, while preserving the intended behavior on kernels that support UFFD-WP.
Suggestted-by: David Hildenbrand david@redhat.com
Skimming over this once again ... sorry.
Nit:
"Suggested-by:"
Likely Andrew can fix it up ... if the patch is not upstream yet (did not check).