Re: [PATCH v4 08/17] KVM: TDX: Adjust the topup count of DPAMT page pairs for splitting S-EPT

From: Yan Zhao

Date: Thu Oct 22 2026 - 22:04:41 EST


On Fri, Oct 23, 2026 at 09:56:06AM +0800, Edgecombe, Rick P wrote:
> On Fri, 2026-10-23 at 07:59 +0800, Yan Zhao wrote:
> > > Yes this looks much clearer than even the upstream code. Do you have any
> > > better
> > > ideas than "4KB guest private page" though? Because in the split case it is
> > > actually for 512 guest private pages. We should put an artful comment to
> > > explain
> > > both cases while not making it look like something that has a better
> > > solution.
> > > Because I'm thinking there isn't one.
> >
> > What about a comment like
> > /*
> >          * +1 pair to account for mapping a new 4KB guest page or splitting a
> >          * 2MB guest page into 512 4KB pages.
> >          */
> > ?
>
> Can we mention why we only need one for 512 pages, what about?

But "2MB guest page" should already imply that the physical range is 2MB
aligned. Instead of expanding the details in the comment, would it be better to
put the explanation in the patch changelog?

> /*
> * +1 pair to account for mapping a new 4KB guest page or splitting a
> * 2MB guest page. Since the resulting split 2MB page will be 2MB
> * aligned it will only end up needing one DPAMT page pair to cover all
> * 512 4KB pages.
> */
>
>