Kouya Shimura
2008-Feb-21 11:36 UTC
[Xen-devel] [PATCH] privcmd: return value of IOCTL_PRIVCMD_MMAPBATCH
Return value of IOCTL_PRIVCMD_MMAPBATCH is always 0 even if some entries are failed to map. IMHO, ioctl should return any failure code. It becomes a hotbed of bug. Signed-off-by: Kouya Shimura <kouya@jp.fujitsu.com> _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Keir Fraser
2008-Feb-21 11:39 UTC
Re: [Xen-devel] [PATCH] privcmd: return value of IOCTL_PRIVCMD_MMAPBATCH
There''s a helper function in libxc to do this. We can''t change the privcmd interface (although we could add a new command). -- Keir On 21/2/08 11:36, "Kouya Shimura" <kouya@jp.fujitsu.com> wrote:> Return value of IOCTL_PRIVCMD_MMAPBATCH is always 0 > even if some entries are failed to map. > > IMHO, ioctl should return any failure code. > It becomes a hotbed of bug. > > Signed-off-by: Kouya Shimura <kouya@jp.fujitsu.com> > > diff -r 65a419f81336 drivers/xen/privcmd/privcmd.c > --- a/drivers/xen/privcmd/privcmd.c Tue Feb 19 11:22:24 2008 -0700 > +++ b/drivers/xen/privcmd/privcmd.c Thu Feb 21 20:01:32 2008 +0900 > @@ -164,7 +164,7 @@ static long privcmd_ioctl(struct file *f > struct vm_area_struct *vma; > xen_pfn_t __user *p; > unsigned long addr, mfn, nr_pages; > - int i; > + int i, rc; > > if (!is_initial_xendomain()) > return -EPERM; > @@ -187,6 +187,7 @@ static long privcmd_ioctl(struct file *f > return -EINVAL; > } > > + ret = 0; > p = m.arr; > addr = m.addr; > for (i = 0; i < nr_pages; i++, addr += PAGE_SIZE, p++) { > @@ -195,15 +196,16 @@ static long privcmd_ioctl(struct file *f > return -EFAULT; > } > > - ret = direct_remap_pfn_range(vma, addr & PAGE_MASK, > + rc = direct_remap_pfn_range(vma, addr & PAGE_MASK, > mfn, PAGE_SIZE, > vma->vm_page_prot, m.dom); > - if (ret < 0) > - put_user(0xF0000000 | mfn, p); > + if (rc < 0) { > + put_user(~(-1UL>>4) | mfn, p); > + ret = rc; > + } > } > > up_write(&mm->mmap_sem); > - ret = 0; > } > break; > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xensource.com > http://lists.xensource.com/xen-devel_______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel