On Tue, Apr 01, 2025 at 09:01:18AM -0400, Xiaoyao Li wrote: > Date: Tue, 1 Apr 2025 09:01:18 -0400 > From: Xiaoyao Li <xiaoyao...@intel.com> > Subject: [PATCH v8 08/55] i386/tdx: Initialize TDX before creating TD vcpus > X-Mailer: git-send-email 2.34.1 > > Invoke KVM_TDX_INIT_VM in kvm_arch_pre_create_vcpu() that > KVM_TDX_INIT_VM configures global TD configurations, e.g. the canonical > CPUID config, and must be executed prior to creating vCPUs. > > Use kvm_x86_arch_cpuid() to setup the CPUID settings for TDX VM. > > Note, this doesn't address the fact that QEMU may change the CPUID > configuration when creating vCPUs, i.e. punts on refactoring QEMU to > provide a stable CPUID config prior to kvm_arch_init(). > > Signed-off-by: Xiaoyao Li <xiaoyao...@intel.com> > Acked-by: Gerd Hoffmann <kra...@redhat.com> > Acked-by: Markus Armbruster <arm...@redhat.com> > --- > Changes in v8: > - Drop the code that initializes cpu->kvm_state before > kvm_arch_pre_create_vcpu() because it's not needed anymore. > > Changes in v7: > - Add comments to explain why KVM_TDX_INIT_VM should retry on -EAGAIN; > - Add retry limit of 10000 times for -EAGAIN on KVM_TDX_INIT_VM; > > Changes in v6: > - setup xfam explicitly to fit with new uapi; > - use tdx_caps->cpuid to filter the input of cpuids because now KVM only > allows the leafs that reported via KVM_TDX_GET_CAPABILITIES; > > Changes in v4: > - mark init_vm with g_autofree() and use QEMU_LOCK_GUARD() to eliminate > the goto labels; (Daniel) > Changes in v3: > - Pass @errp in tdx_pre_create_vcpu() and pass error info to it. (Daniel) > --- > target/i386/kvm/kvm.c | 16 +++--- > target/i386/kvm/kvm_i386.h | 5 ++ > target/i386/kvm/meson.build | 2 +- > target/i386/kvm/tdx-stub.c | 10 ++++ > target/i386/kvm/tdx.c | 105 ++++++++++++++++++++++++++++++++++++ > target/i386/kvm/tdx.h | 6 +++ > 6 files changed, 137 insertions(+), 7 deletions(-) > create mode 100644 target/i386/kvm/tdx-stub.c
Reviewed-by: Zhao Liu <zhao1....@intel.com>