vmm: fix UFFDIO_WAKE and UFFD_FEATURE_MISSING_HUGETLBFS - #8016
Conversation
UFFDIO_WAKE was 0x4010_aa02 (_IOW) but should be 0x8010_aa02, causing every wake call to silently fail with -EINVAL. UFFD_FEATURE_MISSING_HUGETLBFS was (1<<6) but should be (1<<4), colliding with UFFD_FEATURE_EVENT_UNMAP. Signed-off-by: Zhiheng Tao <[email protected]>
phip1611
left a comment
There was a problem hiding this comment.
I verified it and seems about right - thanks for your contribution!
| pub const UFFD_API: u64 = 0xAA; | ||
| pub const UFFDIO_REGISTER_MODE_MISSING: u64 = 1; | ||
| pub const UFFD_EVENT_PAGEFAULT: u8 = 0x12; | ||
| pub const UFFD_FEATURE_MISSING_HUGETLBFS: u64 = 1 << 4; |
There was a problem hiding this comment.
yup. correct.
source: https://elixir.bootlin.com/linux/v7.0/source/include/uapi/linux/userfaultfd.h#L238
| pub const UFFDIO_REGISTER: u64 = 0xc020_aa00; // _IOWR(0xAA, 0x00, struct uffdio_register) | ||
| pub const UFFDIO_COPY: u64 = 0xc028_aa03; // _IOWR(0xAA, 0x03, struct uffdio_copy) | ||
| pub const UFFDIO_WAKE: u64 = 0x4010_aa02; // _IOW(0xAA, 0x02, struct uffdio_range) | ||
| pub const UFFDIO_WAKE: u64 = 0x8010_aa02; // _IOR(0xAA, 0x02, struct uffdio_range) |
There was a problem hiding this comment.
Also seems about right - I verified it! thanks!
This comment was marked as outdated.
This comment was marked as outdated.
|
@rbradford I think I have a patch for that failure commit 29ed4622ac4a10ce05b5c5cbe6c687fb5d0f41b2
Author: Philipp Schuster <[email protected]>
Date: Tue Apr 14 10:30:26 2026 +0200
tests: make VFIO memory hotplug more robust
After memory hotplug, it may happen that it takes a few seconds until a
VFIO device is available again (IOMMU/DMA mappings need update).
On-behalf-of: SAP [email protected]
Signed-off-by: Philipp Schuster <[email protected]>
diff --git a/cloud-hypervisor/tests/integration.rs b/cloud-hypervisor/tests/integration.rs
index 82c24a4f8..1c4a49478 100644
--- a/cloud-hypervisor/tests/integration.rs
+++ b/cloud-hypervisor/tests/integration.rs
@@ -8385,8 +8385,10 @@ mod vfio {
}));
assert!(guest.get_total_memory().unwrap_or_default() > 5_760_000);
- // Check the VFIO device works when RAM is increased to 6GiB
- assert!(guest.check_nvidia_gpu());
+ // Check the VFIO device works when RAM is increased to 6GiB.
+ // After guest memory hotplug, the VMM must refresh VFIO/iommufd DMA
+ // mappings for the passthrough GPU.
+ assert!(wait_until(Duration::from_secs(10), || guest.check_nvidia_gpu()));
});
let _ = child.kill();WDYT? |
shayonj
left a comment
There was a problem hiding this comment.
Good catch, thank you for the fix! Verified here as well - https://github.com/torvalds/linux/blob/d60bc140158342716e13ff0f8aa65642f43ba053/include/uapi/linux/userfaultfd.h#L21
On the side, I will see if a compile-time ioctl encoding validation possible to have these caught early in CI
|
Proposed #8019. We can see the CI catching this now for future proofing. Can rebase once this PR lands |
UFFDIO_WAKE was 0x4010_aa02 (_IOW) but should be 0x8010_aa02, causing every wake call to silently fail with -EINVAL.
UFFD_FEATURE_MISSING_HUGETLBFS was (1<<6) but should be (1<<4), colliding with UFFD_FEATURE_EVENT_UNMAP.
This PR fix these const values.