Re: [PATCH v14 072/113] KVM: TDX: handle vcpu migration over logical processor

From: Isaku Yamahata
Date: Mon Jul 17 2023 - 13:13:30 EST


On Wed, Jul 12, 2023 at 02:08:15PM +0800,
"Wen, Qian" <qian.wen@xxxxxxxxx> wrote:

> On 5/29/2023 12:19 PM, isaku.yamahata@xxxxxxxxx wrote:
> > From: Isaku Yamahata <isaku.yamahata@xxxxxxxxx>
> >
> > For vcpu migration, in the case of VMX, VMCS is flushed on the source pcpu,
> > and load it on the target pcpu. There are corresponding TDX SEAMCALL APIs,
> > call them on vcpu migration. The logic is mostly same as VMX except the
> > TDX SEAMCALLs are used.
> >
> > When shutting down the machine, (VMX or TDX) vcpus needs to be shutdown on
> > each pcpu. Do the similar for TDX with TDX SEAMCALL APIs.
> >
> > Signed-off-by: Isaku Yamahata <isaku.yamahata@xxxxxxxxx>
> > ---
> > arch/x86/kvm/vmx/main.c | 32 ++++++-
> > arch/x86/kvm/vmx/tdx.c | 168 +++++++++++++++++++++++++++++++++++++
> > arch/x86/kvm/vmx/tdx.h | 2 +
> > arch/x86/kvm/vmx/x86_ops.h | 4 +
> > 4 files changed, 203 insertions(+), 3 deletions(-)
> >
> > diff --git a/arch/x86/kvm/vmx/main.c b/arch/x86/kvm/vmx/main.c
> > index 17fb1515e56a..29ebd171dbe3 100644
>
> ...
>
> > @@ -455,6 +606,19 @@ void tdx_vcpu_free(struct kvm_vcpu *vcpu)
> > return;
> > }
> >
> > + /*
> > + * kvm_free_vcpus()
> > + * -> kvm_unload_vcpu_mmu()
> > + *
> > + * does vcpu_load() for every vcpu after they already disassociated
> > + * from the per cpu list when tdx_vm_teardown(). So we need to
> > + * disassociate them again, otherwise the freed vcpu data will be
> > + * accessed when do list_{del,add}() on associated_tdvcpus list
> > + * later.
> > + */
>
> Nit: kvm_free_vcpus() and tdx_vm_teardown() are typos? I don't find these functions.

kvm_free_vcpus() => kvm_destroy_vcpus()
tdx_vm_teardown() => tdx_mmu_release_hkid()

Will fix the comment.
--
Isaku Yamahata <isaku.yamahata@xxxxxxxxx>