Re: [PATCH 05/14] iommupt: Implement preserve/unpreserve/restore callbacks
From: Samiullah Khawaja
Date: Mon Apr 13 2026 - 19:29:42 EST
On Mon, Apr 13, 2026 at 07:33:18PM -0300, Jason Gunthorpe wrote:
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.
Agreed.
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.
Yes end_index setup using "derived vasz" is exactly what I was referring
to earlier. Basically KHO stores the order of the folio, so we can look
at the order of the top_table and that should give us an idea of vasz?
Even if actual vasz is less than the one drived from the order of the
page in next kernel, rest of the page should be filled with zeroes, so
iterating through it should be fine?
I think to keep the scope of this series limited and also to do it in
the proper way, I can save the vasz. That should give us everything to
free and restore in the next kernel without introducing too much
complexity and ABI right now. We can put in more functionality with
subsequent patch series to handle other usecases. WDYT?
I don't think sign_extend is used in the free path though.
I think it is used in the pt_all_range() during free to calculate the
range to iterate over. Based on the sign_extend it decides the vasz and
that affect last_va and that affects end_index.
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