From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: [PATCH v2 07/13] KVM: add vcpu-specific functions to read/write/translate GFNs Date: Fri, 05 Jun 2015 12:26:35 +0200 Message-ID: <5571795B.6080204@redhat.com> References: <1432746314-50196-1-git-send-email-pbonzini@redhat.com> <1432746314-50196-8-git-send-email-pbonzini@redhat.com> <20150529192346.GA11651@potion.brq.redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, guangrong.xiao@linux.intel.com, bdas@redhat.com To: =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= Return-path: In-Reply-To: <20150529192346.GA11651@potion.brq.redhat.com> Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org On 29/05/2015 21:23, Radim Kr=C4=8Dm=C3=A1=C5=99 wrote: >> > +int kvm_vcpu_write_guest(struct kvm_vcpu *vcpu, gpa_t gpa, const = void *data, >> > + unsigned long len) >> > +{ >> > + gfn_t gfn =3D gpa >> PAGE_SHIFT; >> > + int seg; >> > + int offset =3D offset_in_page(gpa); >> > + int ret; >> > + >> > + while ((seg =3D next_segment(len, offset)) !=3D 0) { >> > + ret =3D kvm_vcpu_write_guest_page(vcpu, gfn, data, offset, seg)= ; >> > + if (ret < 0) >> > + return ret; >> > + offset =3D 0; >> > + len -=3D seg; >> > + data +=3D seg; >> > + ++gfn; >> > + } >> > + return 0; >> > +} > (There is no need to pass vcpu, and kvm, in this API. How so? A single kvm_vcpu_write_guest can cross multiple slots. Paolo > Extracting memslots early will help to keep more code common. >=20 > I have patches that did a superset of this for the old API, so posti= ng > them after this series is finalized will be simple.)