Re: [PATCH RFC v2 31/50] KVM: guest_memfd: Support getting PFNs for stage 2 from providers
From: Fred Griffoul
Date: Fri Oct 23 2026 - 13:42:48 EST
> + if (kvm_gmem_is_pfn_mode(gi)) {
> + r = gmem_provider_get_pfn(gi, index, pfn, max_order);
> + if (r)
> + return ERR_PTR(r);
> + return NULL;
> + }
The order goes from the provider to the fault handler unchecked. MPS
reports 0, but a provider with contiguous memory won't, and then a
fault can map a block that the gfn and pfn aren't aligned to, one that
mixes shared and private pages, or one that covers a page being revoked
or converted at the same time: only that page's gfn is marked as being
invalidated, so the fault doesn't retry.
Clamping the order in kvm_gmem_get_pfn() to an aligned block of uniform
attributes, and widening invalidations to the surrounding blocks, would
cover it.
Fred