Re: [PATCH v3 00/24] KVM: TDX huge page support for private memory

From: Sean Christopherson

Date: Tue Jan 06 2026 - 16:38:41 EST


On Tue, Jan 06, 2026, Ackerley Tng wrote:
> Vishal Annapurve <vannapurve@xxxxxxxxxx> writes:
>
> > On Tue, Jan 6, 2026 at 2:19 AM Yan Zhao <yan.y.zhao@xxxxxxxxx> wrote:
> >>
> >> - EPT mapping size and folio size
> >>
> >> This series is built upon the rule in KVM that the mapping size in the
> >> KVM-managed secondary MMU is no larger than the backend folio size.
> >>
>
> I'm not familiar with this rule and would like to find out more. Why is
> this rule imposed?

Because it's the only sane way to safely map memory into the guest? :-D

> Is this rule there just because traditionally folio sizes also define the
> limit of contiguity, and so the mapping size must not be greater than folio
> size in case the block of memory represented by the folio is not contiguous?

Pre-guest_memfd, KVM didn't care about folios. KVM's mapping size was (and still
is) strictly bound by the host mapping size. That's handles contiguous addresses,
but it _also_ handles contiguous protections (e.g. RWX) and other attributes.

> In guest_memfd's case, even if the folio is split (just for refcount
> tracking purposese on private to shared conversion), the memory is still
> contiguous up to the original folio's size. Will the contiguity address
> the concerns?

Not really? Why would the folio be split if the memory _and its attributes_ are
fully contiguous? If the attributes are mixed, KVM must not create a mapping
spanning mixed ranges, i.e. with multiple folios.