On 20.05.25 12:28, Chenyi Qiang wrote:
A new state_change() helper is introduced for RamBlockAttribute
to efficiently notify all registered RamDiscardListeners, including
VFIO listeners, about memory conversion events in guest_memfd. The VFIO
listener can dynamically DMA map/unmap shared pages based on conversion
types:
- For conversions from shared to private, the VFIO system ensures the
discarding of shared mapping from the IOMMU.
- For conversions from private to shared, it triggers the population of
the shared mapping into the IOMMU.
Currently, memory conversion failures cause QEMU to quit instead of
resuming the guest or retrying the operation. It would be a future work
to add more error handling or rollback mechanisms once conversion
failures are allowed. For example, in-place conversion of guest_memfd
could retry the unmap operation during the conversion from shared to
private. However, for now, keep the complex error handling out of the
picture as it is not required:
- If a conversion request is made for a page already in the desired
state, the helper simply returns success.
- For requests involving a range partially in the desired state, there
is no such scenario in practice at present. Simply return error.
- If a conversion request is declined by other systems, such as a
failure from VFIO during notify_to_populated(), the failure is
returned directly. As for notify_to_discard(), VFIO cannot fail
unmap/unpin, so no error is returned.
Note that the bitmap status is updated before callbacks, allowing
listeners to handle memory based on the latest status.
Signed-off-by: Chenyi Qiang <chenyi.qi...@intel.com>
---
I think this should be squashed into the previous patch: I fail to see
why the split makes sense.
--
Cheers,
David / dhildenb