Re: [PATCH 10/21] KVM: TDX: Require TDP MMU and mmio caching for TDX

From: Huang, Kai
Date: Wed Sep 11 2024 - 20:16:04 EST




On 4/09/2024 3:07 pm, Edgecombe, Rick P wrote:
From: Isaku Yamahata <isaku.yamahata@xxxxxxxxx>

Disable TDX support when TDP MMU or mmio caching aren't supported.

As TDP MMU is becoming main stream than the legacy MMU, the legacy MMU
support for TDX isn't implemented.

Nitpickings:

I suppose we should use imperative mode since this is part of what this patch does?

Like:

TDX needs extensive MMU code change to make it work. As TDP MMU is becoming main stream than the legacy MMU, for simplicity only support TDX for TDP MMU for now.


TDX requires KVM mmio caching. Without mmio caching, KVM will go to MMIO
emulation without installing SPTEs for MMIOs. However, TDX guest is
protected and KVM would meet errors when trying to emulate MMIOs for TDX
guest during instruction decoding. So, TDX guest relies on SPTEs being
installed for MMIOs, which are with no RWX bits and with VE suppress bit
unset, to inject VE to TDX guest. The TDX guest would then issue TDVMCALL
in the VE handler to perform instruction decoding and have host do MMIO
emulation.

AFAICT the above two paragraphs are talking about two different things that one thing doens't have hard dependency to the other.

Should we separate this into two patches: one patch to change 'checking enable_ept' to 'checking tdp_mmu_enabled' (which justifies the first paragraph), and the other to add MMIO caching checking.

The final code after the two patches could still end up with ...

[...]

+ if (!tdp_mmu_enabled || !enable_mmio_caching)
+ return -EOPNOTSUPP;
+

... this though.

But feel free to ignore (since nitpickings).