Re: [RFC PATCH 05/13] iommufd: Serialise persisted iommufds and ioas
From: Jason Gunthorpe
Date: Wed Oct 02 2024 - 14:56:07 EST
On Mon, Sep 16, 2024 at 01:30:54PM +0200, James Gowans wrote:
> Now actually implementing the serialise callback for iommufd.
> On KHO activate, iterate through all persisted domains and write their
> metadata to the device tree format. For now just a few fields are
> serialised to demonstrate the concept. To actually make this useful a
> lot more field and related objects will need to be serialised too.
But isn't that a rather difficult problem? The "a lot more fields"
include things like pointers to the mm struct, the user_struct and
task_struct, then all the pinning accounting as well.
Coming work extends this to memfds and more is coming. I would expect
this KHO stuff to use the memfd-like path to access the physical VM
memory too.
I think expecting to serialize and restore everything like this is
probably much too complicated.
If you could just retain a small portion and then directly reconstruct
the missing parts it seems like it would be more maintainable.
Ie "recover" a HWPT from a KHO on a manually created a IOAS with the
right "memfd" for the backing storage. Then the recovery can just
validate that things are correct and adopt the iommu_domain as the
hwpt.
Eventually you'll want this to work for the viommus as well, and that
seems like a lot more tricky complexity..
Jason