[PATCH v11 039/113] KVM: x86/mmu: Require TDP MMU for TDX

isaku.yamahata@intel.com posted 113 patches 2 years, 8 months ago
There is a newer version of this series
[PATCH v11 039/113] KVM: x86/mmu: Require TDP MMU for TDX
Posted by isaku.yamahata@intel.com 2 years, 8 months ago
From: Isaku Yamahata <isaku.yamahata@intel.com>

Require the TDP MMU for guest TDs, the so called "shadow" MMU does not
support mapping guest private memory, i.e. does not support Secure-EPT.

Signed-off-by: Isaku Yamahata <isaku.yamahata@intel.com>
---
 arch/x86/kvm/mmu/tdp_mmu.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/arch/x86/kvm/mmu/tdp_mmu.c b/arch/x86/kvm/mmu/tdp_mmu.c
index fdcff390ebc2..6c3ce4121a46 100644
--- a/arch/x86/kvm/mmu/tdp_mmu.c
+++ b/arch/x86/kvm/mmu/tdp_mmu.c
@@ -27,6 +27,13 @@ int kvm_mmu_init_tdp_mmu(struct kvm *kvm)
 	if (kvm->arch.vm_type == KVM_X86_TDX_VM && !enable_mmio_caching)
 		return -EOPNOTSUPP;
 
+	/*
+	 * Because only the TDP MMU supports TDX, require the TDP MMU for guest
+	 * TDs.
+	 */
+	if (kvm->arch.vm_type == KVM_X86_TDX_VM && !tdp_enabled)
+		return -EOPNOTSUPP;
+
 	if (!tdp_enabled || !READ_ONCE(tdp_mmu_enabled))
 		return 0;
 
-- 
2.25.1
Re: [PATCH v11 039/113] KVM: x86/mmu: Require TDP MMU for TDX
Posted by Huang, Kai 2 years, 7 months ago
On Thu, 2023-01-12 at 08:31 -0800, isaku.yamahata@intel.com wrote:
> From: Isaku Yamahata <isaku.yamahata@intel.com>
> 
> Require the TDP MMU for guest TDs, the so called "shadow" MMU does not
> support mapping guest private memory, i.e. does not support Secure-EPT.

It's not accurate.  Legacy MMU using EPT can also support.  We just choose to
not support.  Please revisit.

> 
> Signed-off-by: Isaku Yamahata <isaku.yamahata@intel.com>
> ---
>  arch/x86/kvm/mmu/tdp_mmu.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/arch/x86/kvm/mmu/tdp_mmu.c b/arch/x86/kvm/mmu/tdp_mmu.c
> index fdcff390ebc2..6c3ce4121a46 100644
> --- a/arch/x86/kvm/mmu/tdp_mmu.c
> +++ b/arch/x86/kvm/mmu/tdp_mmu.c
> @@ -27,6 +27,13 @@ int kvm_mmu_init_tdp_mmu(struct kvm *kvm)
>  	if (kvm->arch.vm_type == KVM_X86_TDX_VM && !enable_mmio_caching)
>  		return -EOPNOTSUPP;
>  
> +	/*
> +	 * Because only the TDP MMU supports TDX, require the TDP MMU for guest
> +	 * TDs.
> +	 */
> +	if (kvm->arch.vm_type == KVM_X86_TDX_VM && !tdp_enabled)
> +		return -EOPNOTSUPP;
> +
>  	if (!tdp_enabled || !READ_ONCE(tdp_mmu_enabled))
>  		return 0;
>