[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] RE: [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
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |