lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240506190248.GD13783@ls.amr.corp.intel.com>
Date: Mon, 6 May 2024 12:02:48 -0700
From: Isaku Yamahata <isaku.yamahata@...el.com>
To: Binbin Wu <binbin.wu@...ux.intel.com>
Cc: Reinette Chatre <reinette.chatre@...el.com>, isaku.yamahata@...el.com,
	kvm@...r.kernel.org, linux-kernel@...r.kernel.org,
	isaku.yamahata@...il.com, Paolo Bonzini <pbonzini@...hat.com>,
	erdemaktas@...gle.com, Sean Christopherson <seanjc@...gle.com>,
	Sagi Shahar <sagis@...gle.com>, Kai Huang <kai.huang@...el.com>,
	chen.bo@...el.com, hang.yuan@...el.com, tina.zhang@...el.com,
	isaku.yamahata@...ux.intel.com
Subject: Re: [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@...ux.intel.com> wrote:

> On 4/13/2024 12:15 AM, Reinette Chatre wrote:
> > Hi Isaku,
> > 
> > On 2/26/2024 12:26 AM, isaku.yamahata@...el.com wrote:
> > > From: Isaku Yamahata <isaku.yamahata@...el.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@...el.com>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ