[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZiA6H9-0fknDPdFp@google.com>
Date: Wed, 17 Apr 2024 14:07:43 -0700
From: Sean Christopherson <seanjc@...gle.com>
To: Isaku Yamahata <isaku.yamahata@...el.com>
Cc: Paolo Bonzini <pbonzini@...hat.com>, linux-kernel@...r.kernel.org, kvm@...r.kernel.org,
xiaoyao.li@...el.com, binbin.wu@...ux.intel.com, rick.p.edgecombe@...el.com,
isaku.yamahata@...ux.intel.com
Subject: Re: [PATCH 2/7] KVM: Add KVM_MAP_MEMORY vcpu ioctl to pre-populate
guest memory
On Wed, Apr 17, 2024, Isaku Yamahata wrote:
> > + vcpu_load(vcpu);
> > + idx = srcu_read_lock(&vcpu->kvm->srcu);
> > +
> > + r = 0;
> > + full_size = mapping->size;
> > + while (mapping->size) {
Maybe pre-check !mapping->size? E.g. there's no reason to load the vCPU and
acquire SRCU just to do nothing. Then this can be a do-while loop and doesn't
need to explicitly initialize 'r'.
> > + if (signal_pending(current)) {
> > + r = -EINTR;
> > + break;
> > + }
> > +
> > + r = kvm_arch_vcpu_map_memory(vcpu, mapping);
Requiring arch code to address @mapping is cumbersone. If the arch call returns
a long, then can't we do?
if (r < 0)
break;
mapping->size -= r;
mapping->gpa += r;
> > + if (r)
> > + break;
> > +
> > + cond_resched();
> > + }
> > +
> > + srcu_read_unlock(&vcpu->kvm->srcu, idx);
> > + vcpu_put(vcpu);
> > +
> > + /* Return success if at least one page was mapped successfully. */
> > + return full_size == mapping->size ? r : 0;
I just saw Paolo's update that this is intentional, but this strikes me as odd,
as it requires userspace to redo the ioctl() to figure out why the last one failed.
Not a sticking point, just odd to my eyes.
Powered by blists - more mailing lists