[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20150529192346.GA11651@potion.brq.redhat.com>
Date: Fri, 29 May 2015 21:23:47 +0200
From: Radim Krčmář <rkrcmar@...hat.com>
To: Paolo Bonzini <pbonzini@...hat.com>
Cc: linux-kernel@...r.kernel.org, kvm@...r.kernel.org,
guangrong.xiao@...ux.intel.com, bdas@...hat.com
Subject: Re: [PATCH v2 07/13] KVM: add vcpu-specific functions to
read/write/translate GFNs
2015-05-27 19:05+0200, Paolo Bonzini:
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> @@ -1616,6 +1727,27 @@ int kvm_write_guest(struct kvm *kvm, gpa_t gpa, const void *data,
| int kvm_write_guest(struct kvm *kvm, 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_write_guest_page(kvm, gfn, data, offset, seg);
| if (ret < 0)
| return ret;
| offset = 0;
| len -= seg;
| data += seg;
| ++gfn;
| }
| return 0;
| }
>
> +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.
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@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists