Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754374AbbFEK0n (ORCPT ); Fri, 5 Jun 2015 06:26:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45451 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751483AbbFEK0k (ORCPT ); Fri, 5 Jun 2015 06:26:40 -0400 Message-ID: <5571795B.6080204@redhat.com> Date: Fri, 05 Jun 2015 12:26:35 +0200 From: Paolo Bonzini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= CC: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, guangrong.xiao@linux.intel.com, bdas@redhat.com Subject: Re: [PATCH v2 07/13] KVM: add vcpu-specific functions to read/write/translate GFNs 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> In-Reply-To: <20150529192346.GA11651@potion.brq.redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1143 Lines: 37 On 29/05/2015 21:23, Radim Krčmář wrote: >> > +int kvm_vcpu_write_guest(struct kvm_vcpu *vcpu, gpa_t gpa, const void *data, >> > + unsigned long len) >> > +{ >> > + gfn_t gfn = gpa >> PAGE_SHIFT; >> > + int seg; >> > + int offset = offset_in_page(gpa); >> > + int ret; >> > + >> > + while ((seg = next_segment(len, offset)) != 0) { >> > + ret = kvm_vcpu_write_guest_page(vcpu, gfn, data, offset, seg); >> > + if (ret < 0) >> > + return ret; >> > + offset = 0; >> > + len -= seg; >> > + data += 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. > > I have patches that did a superset of this for the old API, so posting > them after this series is finalized will be simple.) -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/