Re: [PATCH 04/16] KVM: x86/mmu: Add address conversion functions for TDX shared bit of GPA

From: Edgecombe, Rick P
Date: Fri May 17 2024 - 20:25:33 EST


On Thu, 2024-05-16 at 13:52 +0800, Yan Zhao wrote:
> > As said above, I don't see why we need a helper with the "current
> > implementation" (which consults kvm_shared_gfn_mask()) for them.  We can
> > just use fault->gfn + fault->is_private for such purpose.
> What about a name like kvm_is_private_and_mirrored_gpa()?
> Only TDX's private memory is mirrored and the common code needs a way to
> tell that.

In the new changes we are working on in the other thread this helper is moved
into arch/x86/kvm/vmx/common.h for only Intel side use, and renamed:
gpa_on_private_root(). It should address the SNP confusion concerns at least.

On the private and mirrored point, the mixing of private and mirrored in the
current code is definitely confusing. I think changing the names like that
(private_mirror), could make it easier to understand, even if it creates longer
lines.

I tried to create some abstraction where the MMU understood the concept of
general mirroring EPT roots, then checked a helper to see if the vm_type
mirrored "private" memory before calling out to all the private helpers. I
thought it would let us pretend more of this stuff was generic. But it was
turning out a bit silly. So think I will just stick with updating the names for
the next revision.