Re: [PATCH 08/16] KVM: x86/mmu: Bug the VM if kvm_zap_gfn_range() is called for TDX

Edgecombe, Rick P
2024-05-15T20:32:54Z

On Wed, 2024-05-15 at 12:48 -0700, Sean Christopherson wrote:
> > It's just another little quirk in an already complicated solution. They
> > third
> > thing we discussed was somehow rejecting or not supporting non-coherent DMA.
> > This seemed simpler than that.
>
> Again, huh?  This has _nothing_ to do with non-coherent DMA.  Devices can't
> DMA
> into TDX private memory.

Hmm... I'm confused how you are confused... :)

For normal VMs (after that change you linked), guests will honor guest PAT on
newer HW. On older HW it will only honor guest PAT if non-coherent DMA is
attached.

For TDX we can't honor guest PAT for private memory. So we can either have:
1. Have shared honor PAT and private not.
2. Have private and shared both not honor PAT and be consistent. Unless non-
coherent DMA is attached. In that case KVM could zap shared only and switch to
1.

The only benefit of 2 is that in normal conditions the guest will have
consistent cache behavior between private and shared.

FWIW, there was at one time a use for private uncacheable memory proposed. It
was for keeping non-performance sensitive secret data protected from speculative
access. (not for TDX, a general kernel thing). This isn't a real thing today,
but it's an example of how the private/shared split is quirky, when you ask "do
TDs support PAT?".

1 is a little quirky, but 2 is too complex and also quirky. 1 is the best
option.

If it's obvious we can trim down the log. There was a bit of hand wringing on
this one, so seemed relevant to discussion. The other point was to describe why
we don't need to support kvm_zap_gfn_range(). I think that point is worth
review. The KVM_BUG_ON() is not super critical so we could even drop the patch
if its all settled.