lkml.org 
[lkml]   [2024]   [Apr]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH 2/7] KVM: Add KVM_MAP_MEMORY vcpu ioctl to pre-populate guest memory
From
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.

\
 
 \ /
  Last update: 2024-04-17 23:07    [W:0.048 / U:0.336 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site