lkml.org 
[lkml]   [2024]   [May]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v19 087/130] KVM: TDX: handle vcpu migration over logical processor
On Tue, Apr 23, 2024 at 08:13:25PM +0800,
Binbin Wu <binbin.wu@linux.intel.com> wrote:

> On 4/13/2024 12:15 AM, Reinette Chatre wrote:
> > Hi Isaku,
> >
> > On 2/26/2024 12:26 AM, isaku.yamahata@intel.com wrote:
> > > From: Isaku Yamahata <isaku.yamahata@intel.com>
> > ...
> >
> > > @@ -218,6 +257,87 @@ static void tdx_reclaim_control_page(unsigned long td_page_pa)
> > > free_page((unsigned long)__va(td_page_pa));
> > > }
> > > +struct tdx_flush_vp_arg {
> > > + struct kvm_vcpu *vcpu;
> > > + u64 err;
> > > +};
> > > +
> > > +static void tdx_flush_vp(void *arg_)
> > > +{
> > > + struct tdx_flush_vp_arg *arg = arg_;
> > > + struct kvm_vcpu *vcpu = arg->vcpu;
> > > + u64 err;
> > > +
> > > + arg->err = 0;
> > > + lockdep_assert_irqs_disabled();
> > > +
> > > + /* Task migration can race with CPU offlining. */
> > > + if (unlikely(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))) {
> > > + /*
> > > + * 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.
> > > + */
> Is it possible that other thread uses TDR or TDCS as exclusive?

Exclusive lock is taken only when the guest creation or destruction.
TDH.MNG.{ADDCX, CREATE, INIT, KEY.CONFIG, KEY.FREEID, FLUSHDONE}()
TDH.MR.{EXTEND, FINALIZE}()
TDH.MEM.PAGE.ADD()
TDH.VP.{CREATE, INIT, ADDCX, FLUSH}()

During run time (while vcpu can run), they are locked as shared.
--
Isaku Yamahata <isaku.yamahata@intel.com>

\
 
 \ /
  Last update: 2024-05-27 18:17    [W:0.249 / U:0.260 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site