|
|
|
|
|
|
|
|
|
|
xen-devel
RE: [Xen-devel] [PATCH] vmx-copy_from_guest.patch
To: |
"Ling, Xiaofeng" <xiaofeng.ling@xxxxxxxxx>, "Leendert van Doorn" <leendert@xxxxxxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxx |
Subject: |
RE: [Xen-devel] [PATCH] vmx-copy_from_guest.patch |
From: |
"Petersson, Mats" <mats.petersson@xxxxxxx> |
Date: |
Tue, 6 Sep 2005 16:48:43 +0200 |
Cc: |
"Sharma, Arun" <arun.sharma@xxxxxxxxx>, Ian Pratt <Ian.Pratt@xxxxxxxxxxxx> |
Delivery-date: |
Tue, 06 Sep 2005 14:55:04 +0000 |
Envelope-to: |
www-data@xxxxxxxxxxxxxxxxxxx |
List-help: |
<mailto:xen-devel-request@lists.xensource.com?subject=help> |
List-id: |
Xen developer discussion <xen-devel.lists.xensource.com> |
List-post: |
<mailto:xen-devel@lists.xensource.com> |
List-subscribe: |
<http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe> |
List-unsubscribe: |
<http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe> |
Sender: |
xen-devel-bounces@xxxxxxxxxxxxxxxxxxx |
Thread-index: |
AcWy8CcefB4sB5PnQUi/ADA536RRywAAjDgw |
Thread-topic: |
[Xen-devel] [PATCH] vmx-copy_from_guest.patch |
This code doesn't work for non-paging situations.
Also, the original inst_copy_from_guest is broken with respect to
page-crossing when in "non-paging" mode, so if that can be fixed in any
new version of code, that would be great.
Having one piece of code that does all the types of copying is probably
a good idea as long as the code isn't hit so often that inlining the
actual memcpy is of importance. But all the other stuff going on in
either of these functions probably doesn't make this very likely for the
cases I've seen so far.
--
Mats
> -----Original Message-----
> From: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
> [mailto:xen-devel-bounces@xxxxxxxxxxxxxxxxxxx] On Behalf Of
> Ling, Xiaofeng
> Sent: 06 September 2005 15:42
> To: Leendert van Doorn; xen-devel@xxxxxxxxxxxxxxxxxxx
> Cc: Sharma, Arun; Ian Pratt
> Subject: RE: [Xen-devel] [PATCH] vmx-copy_from_guest.patch
>
>
> Ling, Xiaofeng <> wrote:
> > seems current vmx_copy can not deal with copy over page boundary?
> > so remove inst_copy_from_guest will cause problem.
> >
> > Leendert van Doorn <> wrote:
> The following code is I used to deal with hypercall parameters in vmx.
> It has no limit with copy length and page boundary.
>
> static inline void* map_domain_vaddr(void * guest_vaddr,
> unsigned long len) {
> unsigned long gpa, mfn;
> void * vstart;
>
> gpa = gva_to_gpa((unsigned long)guest_vaddr);
> mfn = get_mfn_from_pfn(gpa>>PAGE_SHIFT);
> vstart = (void *)map_domain_page(mfn) +
> ((unsigned long)guest_vaddr & (PAGE_SIZE - 1));
>
> return vstart;
> }
>
> unsigned long
> copy_from_guest(void *to, const void __user *from, unsigned long n) {
> void *hfrom;
> unsigned long ncopy;
> int nleft;
> ncopy = (((unsigned long)from + PAGE_SIZE) & PAGE_MASK) -
> (unsigned long)from;
> ncopy = ncopy > n ? n : ncopy;
>
> for(nleft = n; nleft > 0; ncopy = nleft > PAGE_SIZE ?
> PAGE_SIZE : nleft)
> {
> hfrom = map_domain_vaddr((void*)from, ncopy);
> if(hfrom)
> {
> memcpy(to, hfrom, ncopy);
> unmap_domain_page((void*)hfrom);
> }
> else
> {
> printk("error!, copy from guest map error,
> from:%p, ncopy:%ld\n",
> from, ncopy);
> return nleft;
> }
> nleft -= ncopy;
> from += ncopy;
> to += ncopy;
> }
> return nleft;
> }
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@xxxxxxxxxxxxxxxxxxx
> http://lists.xensource.com/xen-devel
>
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|
|
|
|
|