Hi Jason, Aneesh, On Mon, 16 Nov 2026 14:02:59 +0000, Jason Gunthorpe <[email protected]> wrote: [...] > Just like you are wrapping set_memory_decrypted() in an allocator API > the user that wants to have the no-change sharing needs its own > special API too.
That works. A separate API can cover no-change sharing when a user needs it, so I'm fine with set_memory_decrypted() zeroing. Aneesh, the pKVM hunk does need cache maintenance after the memset(), which I have in the Cc: stable patch I posted earlier today [1]. Cheers, /fuad [1] https://lore.kernel.org/all/[email protected]/ On Mon, 16 Nov 2026 at 14:03, Jason Gunthorpe <[email protected]> wrote: > > On Mon, Nov 16, 2026 at 07:28:42PM +0530, Aneesh Kumar K.V wrote: > > Fuad Tabba <[email protected]> writes: > > > > > Hi Aneesh, > > > > > > On Mon, 16 Nov 2026 at 09:12, Aneesh Kumar K.V (Arm) > > > <[email protected]> wrote: > > > [...] > > >> Keep allocations on platforms without memory encryption on the ordinary > > >> page > > >> allocator path so the original GFP constraints, including __GFP_ZERO, > > >> remain > > >> intact. Remove post-transition memset() calls that are now redundant and > > >> explicitly clear allocations on paths where no transition occurs. > > >> > > >> This intentionally makes every private-to-shared transition destructive; > > >> callers can no longer use set_memory_decrypted() to preserve existing > > >> contents. > > > > > > pKVM shares memory in place, and a guest has to be able to share > > > memory it has already set up, as Vincent pointed out [1]. That was one > > > of the primary reasons for in-place conversion in guest_memfd. > > > > > > Cheers, > > > /fuad > > > > > > [1] https://lore.kernel.org/all/[email protected]/ > > > > > > Thanks for catching this. We discussed it before, but I reached the > > opposite conclusion: > > > > https://lore.kernel.org/all/[email protected] > > > > My mistake. How do you suggest we handle this? We want to avoid zeroing > > pages multiple times with different CoCo configurations. For example, to > > allocate a zeroed page, we currently do: > > > > alloc_pages(__GFP_ZERO) > > set_memory_decrypted() > > memset(0, PAGE_SIZE) > > Just like you are wrapping set_memory_decrypted() in an allocator API > the user that wants to have the no-change sharing needs its own > special API too. > > Then you can bury a special implementation for pkvm there. > > Where is this special user in the kernel anyhow? > > Jason >
