On 02/06/2026 23:41, Ackerley Tng wrote:
Suzuki K Poulose <[email protected]> writes:


[...snip...]

@@ -914,7 +916,8 @@ int kvm_gmem_get_pfn(struct kvm *kvm, struct
kvm_memory_slot *slot,
           folio_mark_uptodate(folio);
       }
-    r = kvm_gmem_prepare_folio(kvm, slot, gfn, folio);
+    if (kvm_gmem_is_private_mem(inode, index))

Don't we need to make sure the entire folio is private ? Not just the
page at the index ?
      if (kvm_gmem_range_is_private(, index, folio_nr_pages(folio)) ?

I was thinking to fix this when I do huge pages, for now guest_memfd is
always just PAGE_SIZE, so just looking up index is fine.

Is that okay?

Thats fine, but would be good to enforce that here, so that we don't miss out when we add support for multi page folios.



Or rather, we should go through the individual pages and apply the
prepare for ones that are private ?

Suzuki


IIRC the plan was to make kvm_gmem_prepare_folio() idempotent, as in, if
a page is already private, just skip. Currently sev_gmem_prepare() does
a pr_debug(), which I guess is technically still idempotent.

I'm thinking that the information tha needs tracking to make
.gmem_prepare() idempotent should be tracked by arch code.

Does this work for ARM CCA?

We don't hook into the prepare yet, but have plans to do that. We should
be able to handle the pages that are already private. (For CCA context,
RMI_GRANULE_DELEGATE_RANGE can skip over already REALM pages). So this
should be fine.

My point is, in a given folio, there may be pages that are shared.
Like you said, this could be dealt with when we support hugepages.

Suzuki




[...snip...]



Reply via email to