Re: [RFC PATCH v4 11/36] i386/tdx: Initialize TDX before creating TD vcpus

2022-06-07 Thread Xiaoyao Li
On 6/7/2022 7:16 PM, Gerd Hoffmann wrote: Hi, I guess it could be helpful for the discussion when you can outine the 'big picture' for tdx initialization. How does kvm accel setup look like without TDX, and what additional actions are needed for TDX? What ordering requirements and other

Re: [RFC PATCH v4 11/36] i386/tdx: Initialize TDX before creating TD vcpus

2022-06-07 Thread Gerd Hoffmann
Hi, > > I guess it could be helpful for the discussion when you can outine the > > 'big picture' for tdx initialization. How does kvm accel setup look > > like without TDX, and what additional actions are needed for TDX? What > > ordering requirements and other constrains exist? > > To boot

Re: [RFC PATCH v4 11/36] i386/tdx: Initialize TDX before creating TD vcpus

2022-06-01 Thread Xiaoyao Li
On 6/1/2022 3:54 PM, Gerd Hoffmann wrote: On Wed, Jun 01, 2022 at 03:20:46PM +0800, Xiaoyao Li wrote: On 5/24/2022 2:57 PM, Gerd Hoffmann wrote: Hi, Maybe it's a bit more work to add VM-scope initialization support to qemu. If just introducing VM-scope initialization to QEMU, it would be

Re: [RFC PATCH v4 11/36] i386/tdx: Initialize TDX before creating TD vcpus

2022-06-01 Thread Gerd Hoffmann
On Wed, Jun 01, 2022 at 03:20:46PM +0800, Xiaoyao Li wrote: > On 5/24/2022 2:57 PM, Gerd Hoffmann wrote: > >Hi, > > Maybe it's a bit more work to add VM-scope initialization support to > > qemu. > > If just introducing VM-scope initialization to QEMU, it would be easy. What > matters is what

Re: [RFC PATCH v4 11/36] i386/tdx: Initialize TDX before creating TD vcpus

2022-06-01 Thread Xiaoyao Li
On 5/24/2022 2:57 PM, Gerd Hoffmann wrote: Hi, Hmm, hooking *vm* initialization into *vcpu* creation looks wrong to me. That's because for TDX, it has to do VM-scope (feature) initialization before creating vcpu. This is new to KVM and QEMU, that every feature is vcpu-scope and configured

Re: [RFC PATCH v4 11/36] i386/tdx: Initialize TDX before creating TD vcpus

2022-05-24 Thread Gerd Hoffmann
Hi, > > Hmm, hooking *vm* initialization into *vcpu* creation looks wrong to me. > > That's because for TDX, it has to do VM-scope (feature) initialization > before creating vcpu. This is new to KVM and QEMU, that every feature is > vcpu-scope and configured per-vcpu before. > > To minimize

Re: [RFC PATCH v4 11/36] i386/tdx: Initialize TDX before creating TD vcpus

2022-05-23 Thread Xiaoyao Li
On 5/23/2022 5:20 PM, Gerd Hoffmann wrote: +int tdx_pre_create_vcpu(CPUState *cpu) +{ +MachineState *ms = MACHINE(qdev_get_machine()); +X86CPU *x86cpu = X86_CPU(cpu); +CPUX86State *env = >env; +struct kvm_tdx_init_vm init_vm; +int r = 0; + +qemu_mutex_lock(_guest->lock);

Re: [RFC PATCH v4 11/36] i386/tdx: Initialize TDX before creating TD vcpus

2022-05-23 Thread Gerd Hoffmann
> +int tdx_pre_create_vcpu(CPUState *cpu) > +{ > +MachineState *ms = MACHINE(qdev_get_machine()); > +X86CPU *x86cpu = X86_CPU(cpu); > +CPUX86State *env = >env; > +struct kvm_tdx_init_vm init_vm; > +int r = 0; > + > +qemu_mutex_lock(_guest->lock); > +if

[RFC PATCH v4 11/36] i386/tdx: Initialize TDX before creating TD vcpus

2022-05-11 Thread Xiaoyao Li
Invoke KVM_TDX_INIT in kvm_arch_pre_create_vcpu() that KVM_TDX_INIT configures global TD state, 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 and tie x86cpu->enable_pmu with TD's attributes. Note,