Suzuki K Poulose <[email protected]> writes: > On 04/11/2026 16:45, Aneesh Kumar K.V (Arm) wrote: >> Confidential-computing guests may require memory shared with the host to >> be aligned and transitioned in units larger than PAGE_SIZE. Several DMA >> users need struct page-backed allocations satisfying these requirements. >> Provide a common allocator instead of requiring each user to open-code >> this sequence. >> >> Add alloc_cc_shared_pages() and its node-aware variant. The allocator >> rounds the requested size to the architecture's shared granule, >> allocates suitably aligned contiguous pages and transitions the >> complete range to shared state. It also preserves the caller's GFP >> policy. >> >> A private-to-shared transition may alter memory contents. Mask >> __GFP_ZERO from the underlying allocation and when requested, clear the >> complete transitioned range after cc_make_shared() succeeds. > > This is not true for pKVM though. It is the other way around. i.e, > pages must be cleared before transition (e.g., from private to shared) > to make sure the contents don't leak into the host. > > Do we need to handle such cases with a pre_conversion and > post_conversion hook ? >
Patch 2 does something similar. -aneesh
