Re: [PATCH 05/14] iommupt: Implement preserve/unpreserve/restore callbacks
From: Jason Gunthorpe
Date: Mon Apr 13 2026 - 18:34:38 EST
On Mon, Apr 13, 2026 at 07:31:22PM +0000, Samiullah Khawaja wrote:
> Yes, we use the collect walker during KHO restore of the preserved pages
> and also during free. But if I understand correctly, the collect walker
> behaviour changes based on some FEAT_ flags (like SIGN_EXTEND). So we
> have to be careful if the previous kernel was using different FEAT flags
> that affect the collect walker. To handle this, we can just preserve the
> u32 features from struct pt_common and deduce everything using that.
It is agressively not stable, and even new kernels might not support
the features old ones were using, so this is a bit dicy.
You probably need some, but I think I'd be very choosey about which
some I preserve and which come from the new driver.
> Thinking about it more, we do preserve the top_level, so that could
> potentially be used to walk over the page tables of these free-only
> domains if we just set up the pts->index and pts->end_index properly by
> initializing the range based on the top_level. Are you thinking of a
> similar approach to walk these free-only domains?
Hmm, even the free walker requires computing the end_index, and that
requires at least vasz. eg ARM will compute the number of items in the
top level based on vasz to support concatenated pages.
I don't think sign_extend is used in the free path though.
So if that is the only purpose then yes you can probably get away with
nothing, but you have to be very careful to contain the restored
domain to only execute free and nothing else by removing the
map/unmap/etc ops.
And add some dedicated self tests (zero pt features and test free) to
simulate it.
Jason