[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] how to deal with copy_to_user returning non zero


  • To: xen-devel@xxxxxxxxxxxxx
  • From: Anh Dinh <ug93tad@xxxxxxxxx>
  • Date: Fri, 7 Nov 2014 18:38:39 +0800
  • Delivery-date: Fri, 07 Nov 2014 10:38:53 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xen.org>

I'm testing out a hypercall that takes in large data (many MB) from the user space and simply copy the data back.Â

For copying in, I call xmalloc_array() for about 4MB at a time and call copy_from_user() successfully for the entire input.Â

The problem is with copy_to_user() which returns non-zero values. I tried to vary the size of the data being copy, but still unable to copy the whole data back.Â

What are the cause of copy_to_user() failure? I checked the source I got quite lost at the code.Â

How could I make sure all data is copy back? Surely it is not a memory limitation problem, because I copy_from_user() succeeds for over 100MB.Â


******
long do_test_copy(long n, unsigned char *in, unsigned char *out){
    unsigned char **tmp;Â
    long ret;
    int m = n/(MAX_ALLOC);Â
    tmp = xmalloc_array(unsigned char*,m);Â

    for (int i=0; i<m; i++){
        tmp[i] = xmalloc_array(unsigned char, MAX_ALLOC);Â
        copy_from_user(tmp[i],in+i*MAX_ALLOC,MAX_ALLOC);Â
    }
   ÂÂ
    for (int i=0; i<m; i++){
        if (tmp[i]){
            ret = copy_to_user(out+i*MAX_ALLOC,tmp[i],MAX_ALLOC);        ÂÂ
            xfree(tmp[i]);Â
        }
    }
    xfree(tmp);
    return 0;   ÂÂ
}
****

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.