TDX VMs need to issue the KVM_TDX_INIT_VM ioctl after VM creation to initialize the TD. This ioctl also sets the cpuids and attributes for the VM.
Signed-off-by: Sagi Shahar sagis@google.com --- tools/testing/selftests/kvm/lib/x86/processor.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/tools/testing/selftests/kvm/lib/x86/processor.c b/tools/testing/selftests/kvm/lib/x86/processor.c index 623168ea9a44..c255fe1951be 100644 --- a/tools/testing/selftests/kvm/lib/x86/processor.c +++ b/tools/testing/selftests/kvm/lib/x86/processor.c @@ -641,6 +641,9 @@ void kvm_arch_vm_post_create(struct kvm_vm *vm) vm_sev_ioctl(vm, KVM_SEV_INIT2, &init); }
+ if (is_tdx_vm(vm)) + vm_tdx_init_vm(vm, 0); + r = __vm_ioctl(vm, KVM_GET_TSC_KHZ, NULL); TEST_ASSERT(r > 0, "KVM_GET_TSC_KHZ did not provide a valid TSC frequency."); guest_tsc_khz = r;