[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <Z0fTaqabmj27OJqe@yzhao56-desk.sh.intel.com>
Date: Thu, 28 Nov 2024 10:20:26 +0800
From: Yan Zhao <yan.y.zhao@...el.com>
To: Nikolay Borisov <nik.borisov@...e.com>
CC: <pbonzini@...hat.com>, <seanjc@...gle.com>, <kvm@...r.kernel.org>,
<dave.hansen@...ux.intel.com>, <rick.p.edgecombe@...el.com>,
<kai.huang@...el.com>, <adrian.hunter@...el.com>,
<reinette.chatre@...el.com>, <xiaoyao.li@...el.com>,
<tony.lindgren@...el.com>, <binbin.wu@...ux.intel.com>,
<dmatlack@...gle.com>, <isaku.yamahata@...el.com>,
<isaku.yamahata@...il.com>, <linux-kernel@...r.kernel.org>, <x86@...nel.org>
Subject: Re: [PATCH v2 21/24] KVM: TDX: Add an ioctl to create initial guest
memory
On Wed, Nov 27, 2024 at 08:08:26PM +0200, Nikolay Borisov wrote:
>
> On 12.11.24 г. 9:38 ч., Yan Zhao wrote:
> > +static int tdx_vcpu_init_mem_region(struct kvm_vcpu *vcpu, struct kvm_tdx_cmd *cmd)
> > +{
> > + struct vcpu_tdx *tdx = to_tdx(vcpu);
> > + struct kvm *kvm = vcpu->kvm;
> > + struct kvm_tdx *kvm_tdx = to_kvm_tdx(kvm);
> > + struct kvm_tdx_init_mem_region region;
> > + struct tdx_gmem_post_populate_arg arg;
> > + long gmem_ret;
> > + int ret;
> > +
> > + if (tdx->state != VCPU_TD_STATE_INITIALIZED)
> > + return -EINVAL;
> > +
> > + guard(mutex)(&kvm->slots_lock);
>
> It seems the scope of this lock can be reduced. It's really needed for the
> kvm_gmem_populate call only, no ?
Strictly speaking, yes.
But this KVM_TDX_INIT_MEM_REGION ioctl is only expected to be executed after
QEMU machine creation done and before any vCPU starts running. So no slot
changes are expected during the ioctl.
Powered by blists - more mailing lists