Re: [PATCH 14/21] KVM: TDX: Implement hooks to propagate changes of TDP MMU mirror page table

From: Yan Zhao
Date: Mon Sep 09 2024 - 21:54:38 EST


On Tue, Sep 10, 2024 at 05:03:57AM +0800, Edgecombe, Rick P wrote:
> On Fri, 2024-09-06 at 14:10 +1200, Huang, Kai wrote:
...
> > > +        * which causes gmem invalidation to zap all spte.
> > > +        * Population is only allowed after KVM_TDX_INIT_VM.
> > > +        */
> >
> > What does the second sentence ("Population ...")  meaning?  Why is it
> > relevant here?
> >
> How about:
> /*
> * HKID is released after all private pages have been removed,
> * and set before any might be populated. Warn if zapping is
> * attempted when there can't be anything populated in the private
> * EPT.
> */
>
> But actually, I wonder if we need to remove the KVM_BUG_ON(). I think if you did
> a KVM_PRE_FAULT_MEMORY and then deleted the memslot you could hit it?
If we disallow vCPU creation before TD initialization, as discussed in [1],
the BUG_ON should not be hit.

[1] https://lore.kernel.org/all/ZtAU7FIV2Xkw+L3O@xxxxxxxxxxxxxxxxxxxxxxxxx/