Thread (70 messages) flat view 70 messages, 7 authors, 2026-06-25

Re: [PATCH v7 07/42] KVM: guest_memfd: Only prepare folios for private pages

From: Suzuki K Poulose <suzuki.poulose@arm.com>
Date: 2026-06-03 09:00:02
Also in: kvm, linux-coco, linux-doc, linux-kselftest, linux-mm, lkml

On 02/06/2026 23:41, Ackerley Tng wrote:
Suzuki K Poulose [off-list ref] writes:
quoted
[...snip...]
quoted
quoted
@@ -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.
quoted
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

quoted
quoted
[...snip...]
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help