Re: [PATCH 03/21] KVM: x86/mmu: Do not enable page track for TD guest

From: Paolo Bonzini
Date: Mon Sep 09 2024 - 09:57:40 EST


On 9/4/24 05:07, Rick Edgecombe wrote:
From: Yan Zhao <yan.y.zhao@xxxxxxxxx>

TDX does not support write protection and hence page track.
Though !tdp_enabled and kvm_shadow_root_allocated(kvm) are always false
for TD guest, should also return false when external write tracking is
enabled.

Cc: Yuan Yao <yuan.yao@xxxxxxxxxxxxxxx>
Signed-off-by: Yan Zhao <yan.y.zhao@xxxxxxxxx>
Signed-off-by: Rick Edgecombe <rick.p.edgecombe@xxxxxxxxx>
Reviewed-by: Binbin Wu <binbin.wu@xxxxxxxxxxxxxxx>
---
v19:
- drop TDX: from the short log
- Added reviewed-by: BinBin
---
arch/x86/kvm/mmu/page_track.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/arch/x86/kvm/mmu/page_track.c b/arch/x86/kvm/mmu/page_track.c
index 561c331fd6ec..26436113103a 100644
--- a/arch/x86/kvm/mmu/page_track.c
+++ b/arch/x86/kvm/mmu/page_track.c
@@ -35,6 +35,9 @@ static bool kvm_external_write_tracking_enabled(struct kvm *kvm)
bool kvm_page_track_write_tracking_enabled(struct kvm *kvm)
{
+ if (kvm->arch.vm_type == KVM_X86_TDX_VM)
+ return false;
+
return kvm_external_write_tracking_enabled(kvm) ||
kvm_shadow_root_allocated(kvm) || !tdp_enabled;
}

You should instead return an error from kvm_enable_external_write_tracking().

This will cause kvm_page_track_register_notifier() and therefore intel_vgpu_open_device() to fail.

Paolo