Re: [RFC PATCH 09/21] KVM: TDX: Enable 2MB mapping size after TD is RUNNABLE

From: Xiaoyao Li
Date: Fri Jun 13 2025 - 02:08:39 EST


On 6/13/2025 1:35 PM, Yan Zhao wrote:
To avoid confusion, here's the full new design:

1.when an EPT violation carries an ACCEPT level info
(This occurs when TD performs ACCEPT before it accesses memory),
KVM maps the page at map level <= the specified level.
Guest's ACCEPT will succeed or return PAGE_SIZE_MATCH if map level < the
specified level.

2.when an EPT violation does not carry ACCEPT level info
(This occurs when TD accesses memory before invoking ACCEPT),

1) if the TD is configured to always accept VMM's map level,
KVM allows to map at 2MB.
TD's later 4KB ACCEPT will return PAGE_SIZE_MATCH.
TD can either retry with 2MB ACCEPT or explictly invoke a TDVMCALL for
demotion.
2) if the TD is not configured to always accept VMM's map level,
KVM always maps at 4KB.

Is it the decision derived from the discussion of this series to make the design simple and avoid the demotion on ACCEPT?

It looks like KVM's own design preference that if the TD doesn't opt-in the proposed new feature "always accept VMM's map level', the only way it can get the page mapped by EPT as hugepage is always trying to accept the page before first access and trying accept starting from biggest page size.

I'm OK with it.

TD's 2MB ACCEPT will return PAGE_SIZE_MATCH.

Please let me know if anything does not look right.