Repository navigation
feat(vfio-user): implement VFIO_USER_DEVICE_GET_REGION_IO_FDS - #521
Merged
Merged
Conversation
KvmIoeventFdRegistry has to remember every registration in a per-VM
HashMap keyed by the raw fd, because deregister() only receives the
notifier while KVM_IOEVENTFD needs {addr, len, datamatch, flags} to
deassign an entry. That map also breaks for any caller registering one
notifier at several addresses, e.g. a vfio-user device that shares one
eventfd between sub-regions: the second registration overwrites the
bookkeeping of the first, and deregistering then leaves a live KVM
ioeventfd behind.
Hand the registration parameters back to deregister() instead, so the
registry needs no state and makes no assumptions about how callers use
their fds. To let a callback reconstruct them,
MemRegionCallback::unmapped() now receives the address the region is
unmapped from, symmetric with mapped(); both call sites already have it.
Assisted-by: Antigravity:Claude-Opus-5
Signed-off-by: Changyuan Lyu <changyuanl@google.com>
Ask the server which sub-regions of a BAR it wants to watch with a file descriptor, and register them as ioeventfds, so that a doorbell write no longer travels through a VM exit and a REGION_WRITE round trip. Device gains get_region_notifiers(), defaulting to none: kernel VFIO has no equivalent, VFIO_DEVICE_IOEVENTFD goes the other way round and hands an eventfd to the kernel so that it writes a fixed value to the device. VfioPciDev::new() now takes an optional notifier registry, shared by the BAR callbacks, which register the notifiers once the guest programs a BAR address, mirroring what virtio-pci does for its queue notifiers. Only VFIO_USER_IO_FD_TYPE_IOEVENTFD is honored. An ioregionfd needs a KVM feature that is not upstream, and a shadow ioeventfd additionally needs KVM to store the written value in a shared buffer, which upstream cannot do either; libvfio-user documents clients as free to ignore it. Sub-regions with KVM_IOEVENTFD_FLAG_PIO are dropped as well, since NotifierRegistry cannot express port IO, as are sub-regions reaching past the region, which the protocol makes the client's job to check. Note the sub-region layout follows libvfio-user, which sends 48-byte entries carrying the shadow fields whatever the type. The protocol documentation describes 40-byte entries, predating shadow ioeventfds, and computes the entry stride from an argsz that includes the message header, which no implementation does. Assisted-by: Antigravity:Claude-Opus-5 Signed-off-by: Changyuan Lyu <changyuanl@google.com>
Coverage Report for CI Build 37578781737Coverage increased (+0.6%) to 39.652%Details
Uncovered Changes
Coverage Regressions3 previously-covered lines in 2 files lost coverage.
Coverage Stats💛 - Coveralls |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.