Re: [RFC PATCH 09/21] KVM: TDX: Enable 2MB mapping size after TD is RUNNABLE
From: Edgecombe, Rick P
Date: Wed Jun 25 2025 - 10:48:35 EST
On Wed, 2025-06-25 at 17:36 +0800, Yan Zhao wrote:
> On Wed, Jun 25, 2025 at 05:28:22PM +0800, Yan Zhao wrote:
> > Write down my understanding to check if it's correct:
> >
> > - when a TD is NOT configured to support KVM_LPAGE_GUEST_INHIBIT TDVMCALL, KVM
> > always maps at 4KB
> >
> > - When a TD is configured to support KVM_LPAGE_GUEST_INHIBIT TDVMCALL,
> Sorry, the two conditions are stale ones. No need any more.
> So it's always
>
> (a)
> 1. guest accepts at 4KB
> 2. TDX sets KVM_LPAGE_GUEST_INHIBIT and try splitting.(with write mmu_lock)
> 3. KVM maps at 4KB (with read mmu_lock)
> 4. guest's 4KB accept succeeds.
Yea.
>
> (b)
> 1. guest accepts at 2MB.
> 2. KVM maps at 4KB due to a certain reason.
I don't follow this part. You mean because it spans a memslot or other?
Basically that KVM won't guarantee the page size at exactly the accept size? I
think this is ok and good. The ABI can be that KVM will guarantee the S-EPT
mapping size <= the accept size.
> 3. guest's accept 2MB fails with TDACCEPT_SIZE_MISMATCH.
> 4. guest accepts at 4KB
> 5. guest's 4KB accept succeeds.
>
In this option accept behavior doesn't need to change, but the
TDACCEPT_SIZE_MISMATCH in step 3 still is a little weird. TDX module could
accept at 4k mapping size. But this is an issue for the guest to deal with, not
KVM.