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

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



Thanks,

I've found out the reason it page-faulting is because I used malloc() to allocate the output buffer, which turns out to allocate lazily. Therefore the hypervisor page-fault because the memory is still waiting to be mapped by the kernel.Â

I simply touched all the allocated memory, and it works fine now.Â

Cheers.


On 7 November 2014 19:01, Andrew Cooper <andrew.cooper3@xxxxxxxxxx> wrote:
On 07/11/14 10:57, And Dinh wrote:
how does it get page fault? I made sure the output buffer at the user space is properly allocated with the correct Âsize.

When page fault, do I have no choice but abort? It seems calling the hypercall again does not solve it.


And nothing guarentees that your userspace process is in context when Xen is running, or that the kernel hasn't played with the pagetables behind your back.

You must use the hypercall buffer mechanism to avoid issues like this. See the hypercall implementations in libxc. In Xen, you must have a XEN_GUEST_HANDLE() which is an opaque reference to your buffer, and use copy_{to,from}_guest() rather than {to/from}_user(), which is generally only safe for kernel addresses.

~Andrew

_______________________________________________
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®.