lkml.org 
[lkml]   [2022]   [Nov]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v10 076/108] KVM: TDX: handle vcpu migration over logical processor
On Tue, Nov 15, 2022 at 10:28:20AM +0800,
Binbin Wu <binbin.wu@linux.intel.com> wrote:

>
> On 10/30/2022 2:23 PM, isaku.yamahata@intel.com wrote:
> > From: Isaku Yamahata <isaku.yamahata@intel.com>
> >
> > For vcpu migration, in the case of VMX, VCMS
>
> typo, 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@intel.com>
> > ---
> > arch/x86/kvm/vmx/main.c | 43 +++++++++++--
> > arch/x86/kvm/vmx/tdx.c | 121 +++++++++++++++++++++++++++++++++++++
> > arch/x86/kvm/vmx/tdx.h | 2 +
> > arch/x86/kvm/vmx/x86_ops.h | 6 ++
> > 4 files changed, 168 insertions(+), 4 deletions(-)
> >
> >
> > @@ -176,6 +214,41 @@ static void tdx_reclaim_td_page(struct tdx_td_page *page)
> > }
> > }
> > +static void tdx_flush_vp(void *arg)
> > +{
> > + struct kvm_vcpu *vcpu = arg;
> > + u64 err;
> > +
> > + lockdep_assert_irqs_disabled();
> > +
> > + /* Task migration can race with CPU offlining. */
> > + if (vcpu->cpu != raw_smp_processor_id())
> > + return;
> > +
> > + /*
> > + * No need to do TDH_VP_FLUSH if the vCPU hasn't been initialized. The
> > + * list tracking still needs to be updated so that it's correct if/when
> > + * the vCPU does get initialized.
> > + */
> > + if (is_td_vcpu_created(to_tdx(vcpu))) {
> > + err = tdh_vp_flush(to_tdx(vcpu)->tdvpr.pa);
>
> Need to retry here if tdh.vp.flush fails due to tdx operand busy?
>
> If such failure occurs, the next vp enter will fail after the vCPU migrated
> to another LP, how is it hanlded?


No need to retry. TDX Resources needed for TDH.VP.FLUSH are, TDVPR as exclusive,
TDR as shared, and TDCS as shared.

This vp flush function is called when destructing vcpu/TD or vcpu migration. No
other thread uses TDVPR in those cases.
--
Isaku Yamahata <isaku.yamahata@gmail.com>

\
 
 \ /
  Last update: 2022-11-17 21:25    [W:0.311 / U:0.708 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site