Thanks to visit codestin.com
Credit goes to github.com

Skip to content

vmm: fix UFFDIO_WAKE and UFFD_FEATURE_MISSING_HUGETLBFS - #8016

Merged
rbradford merged 1 commit into
cloud-hypervisor:mainfrom
virt-pvm:junchuan/fix-uffd
Apr 14, 2026
Merged

rbradford merged 1 commit into
cloud-hypervisor:mainfrom
virt-pvm:junchuan/fix-uffd

Conversation

@joy-allen

Copy link
Copy Markdown
Contributor

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.

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]>
@joy-allen
joy-allen requested a review from a team as a code owner April 14, 2026 06:43

@rbradford rbradford left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shayonj Would you be able to take a look?

@phip1611 phip1611 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I verified it and seems about right - thanks for your contribution!

Comment thread vmm/src/userfaultfd.rs
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;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread vmm/src/userfaultfd.rs
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)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also seems about right - I verified it! thanks!

@rbradford
rbradford enabled auto-merge April 14, 2026 06:55
@rbradford
rbradford added this pull request to the merge queue Apr 14, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Apr 14, 2026
@phip1611

This comment was marked as outdated.

@rbradford
rbradford added this pull request to the merge queue Apr 14, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Apr 14, 2026
@phip1611

Copy link
Copy Markdown
Member

@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 shayonj left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@shayonj

shayonj commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

Proposed #8019. We can see the CI catching this now for future proofing. Can rebase once this PR lands

@rbradford
rbradford added this pull request to the merge queue Apr 14, 2026
Merged via the queue into cloud-hypervisor:main with commit df58e81 Apr 14, 2026
38 checks passed
@rbradford rbradford moved this to ✅ Done in Cloud Hypervisor Roadmap Apr 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

4 participants