WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] privcmd: return value of IOCTL_PRIVCMD_MMAPBATCH

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] privcmd: return value of IOCTL_PRIVCMD_MMAPBATCH
From: Kouya Shimura <kouya@xxxxxxxxxxxxxx>
Date: Thu, 21 Feb 2008 20:36:34 +0900
Delivery-date: Thu, 21 Feb 2008 03:37:09 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
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
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@xxxxxxxxxxxxxx>

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@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>