Re: [RFC PATCH v2 14/23] KVM: TDX: Split and inhibit huge mappings if a VMExit carries level info
From: Yan Zhao
Date: Mon Nov 17 2025 - 21:23:19 EST
On Tue, Nov 18, 2025 at 09:04:20AM +0800, Huang, Kai wrote:
> On Fri, 2025-11-14 at 15:22 +0800, Yan Zhao wrote:
> > > Will 'level == PG_LEVEL_4K' in this case? Or will this function return
> > > early right after check the eeq_type?
> > The function will return early right after check the eeq_type.
>
> But for such case the fault handler will still return 2M and KVM will AUG 2M
> page? Then if guest accepts 4K page, a new exit to KVM would happen?
>
> But this time KVM is able to find the info that guest is accepting 4K and KVM
> will split the 2M to 4K pages so we are good to go?
If guest accesses a private memory without first accepting it (like non-Linux
guests), the sequence is:
1. Guest accesses a private memory.
2. KVM finds it can map the GFN at 2MB. So, AUG 2MB pages.
3. Guest accepts the GFN at 4KB.
4. KVM receives a EPT violation with eeq_type of ACCEPT and level 4KB
5. KVM splits the 2MB mapping.
6. Guest accepts successfully and accesses the page.
If guest first accepts a private memory before accessing (like Linux guests),
the sequence is:
1. Guest accepts a private memory at 4KB.
2. KVM receives a EPT violation with eeq_type of ACCEPT and level 4KB.
3. KVM AUG 4KB.
4. Guest accepts successfully and accesses the page.