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-changelog

[Xen-changelog] [xen-4.0-testing] domctl: Fix cpumap/cpumask conversion

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-4.0-testing] domctl: Fix cpumap/cpumask conversion functions to return an error code.
From: "Xen patchbot-4.0-testing" <patchbot-4.0-testing@xxxxxxxxxxxxxxxxxxx>
Date: Fri, 14 May 2010 00:41:50 -0700
Delivery-date: Fri, 14 May 2010 00:48:41 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1273742204 -3600
# Node ID 760c8ec816adad5253ef563bc816cd93a384f3d0
# Parent  372d4093ea59559c3193c514c8f141e13f4c94ae
domctl: Fix cpumap/cpumask conversion functions to return an error code.

Signed-off-by: Keir Fraser <keir.fraser@xxxxxxxxxx>
xen-unstable changeset:   21350:e50afc6ecc48
xen-unstable date:        Wed May 12 08:42:30 2010 +0100
---
 xen/arch/x86/platform_hypercall.c |    7 +++++--
 xen/common/domctl.c               |   31 ++++++++++++++++---------------
 xen/common/trace.c                |    2 +-
 xen/include/xen/cpumask.h         |    4 ++--
 4 files changed, 24 insertions(+), 20 deletions(-)

diff -r 372d4093ea59 -r 760c8ec816ad xen/arch/x86/platform_hypercall.c
--- a/xen/arch/x86/platform_hypercall.c Thu May 13 10:14:54 2010 +0100
+++ b/xen/arch/x86/platform_hypercall.c Thu May 13 10:16:44 2010 +0100
@@ -340,7 +340,8 @@ ret_t do_platform_op(XEN_GUEST_HANDLE(xe
         guest_from_compat_handle(cpumap_bitmap,
                                  op->u.getidletime.cpumap_bitmap);
         ctlmap.bitmap.p = cpumap_bitmap.p; /* handle -> handle_64 conversion */
-        xenctl_cpumap_to_cpumask(&cpumap, &ctlmap);
+        if ( (ret = xenctl_cpumap_to_cpumask(&cpumap, &ctlmap)) != 0 )
+            goto out;
         guest_from_compat_handle(idletimes, op->u.getidletime.idletime);
 
         for_each_cpu_mask ( cpu, cpumap )
@@ -355,7 +356,9 @@ ret_t do_platform_op(XEN_GUEST_HANDLE(xe
         }
 
         op->u.getidletime.now = now;
-        cpumask_to_xenctl_cpumap(&ctlmap, &cpumap);
+        if ( (ret = cpumask_to_xenctl_cpumap(&ctlmap, &cpumap)) != 0 )
+            goto out;
+
         ret = copy_to_guest(u_xenpf_op, op, 1) ? -EFAULT : 0;
     }
     break;
diff -r 372d4093ea59 -r 760c8ec816ad xen/common/domctl.c
--- a/xen/common/domctl.c       Thu May 13 10:14:54 2010 +0100
+++ b/xen/common/domctl.c       Thu May 13 10:16:44 2010 +0100
@@ -30,37 +30,35 @@ extern long arch_do_domctl(
 extern long arch_do_domctl(
     struct xen_domctl *op, XEN_GUEST_HANDLE(xen_domctl_t) u_domctl);
 
-void cpumask_to_xenctl_cpumap(
+int cpumask_to_xenctl_cpumap(
     struct xenctl_cpumap *xenctl_cpumap, cpumask_t *cpumask)
 {
     unsigned int guest_bytes, copy_bytes, i;
     uint8_t zero = 0;
     uint8_t bytemap[(NR_CPUS + 7) / 8];
 
-    if ( guest_handle_is_null(xenctl_cpumap->bitmap) )
-        return;
-
     guest_bytes = (xenctl_cpumap->nr_cpus + 7) / 8;
     copy_bytes  = min_t(unsigned int, guest_bytes, sizeof(bytemap));
 
     bitmap_long_to_byte(bytemap, cpus_addr(*cpumask), NR_CPUS);
 
     if ( copy_bytes != 0 )
-        copy_to_guest(xenctl_cpumap->bitmap, bytemap, copy_bytes);
+        if ( copy_to_guest(xenctl_cpumap->bitmap, bytemap, copy_bytes) )
+            return -EFAULT;
 
     for ( i = copy_bytes; i < guest_bytes; i++ )
-        copy_to_guest_offset(xenctl_cpumap->bitmap, i, &zero, 1);
+        if ( copy_to_guest_offset(xenctl_cpumap->bitmap, i, &zero, 1) )
+            return -EFAULT;
+
+    return 0;
 }
 
-void xenctl_cpumap_to_cpumask(
+int xenctl_cpumap_to_cpumask(
     cpumask_t *cpumask, struct xenctl_cpumap *xenctl_cpumap)
 {
     unsigned int guest_bytes, copy_bytes;
     uint8_t bytemap[(NR_CPUS + 7) / 8];
 
-    if ( guest_handle_is_null(xenctl_cpumap->bitmap) )
-        return;
-
     guest_bytes = (xenctl_cpumap->nr_cpus + 7) / 8;
     copy_bytes  = min_t(unsigned int, guest_bytes, sizeof(bytemap));
 
@@ -68,12 +66,15 @@ void xenctl_cpumap_to_cpumask(
 
     if ( copy_bytes != 0 )
     {
-        copy_from_guest(bytemap, xenctl_cpumap->bitmap, copy_bytes);
+        if ( copy_from_guest(bytemap, xenctl_cpumap->bitmap, copy_bytes) )
+            return -EFAULT;
         if ( (xenctl_cpumap->nr_cpus & 7) && (guest_bytes <= sizeof(bytemap)) )
             bytemap[guest_bytes-1] &= ~(0xff << (xenctl_cpumap->nr_cpus & 7));
     }
 
     bitmap_byte_to_long(cpus_addr(*cpumask), bytemap, NR_CPUS);
+
+    return 0;
 }
 
 static inline int is_free_domid(domid_t dom)
@@ -574,15 +575,15 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
 
         if ( op->cmd == XEN_DOMCTL_setvcpuaffinity )
         {
-            xenctl_cpumap_to_cpumask(
+            ret = xenctl_cpumap_to_cpumask(
                 &new_affinity, &op->u.vcpuaffinity.cpumap);
-            ret = vcpu_set_affinity(v, &new_affinity);
+            if ( !ret )
+                ret = vcpu_set_affinity(v, &new_affinity);
         }
         else
         {
-            cpumask_to_xenctl_cpumap(
+            ret = cpumask_to_xenctl_cpumap(
                 &op->u.vcpuaffinity.cpumap, &v->cpu_affinity);
-            ret = 0;
         }
 
     vcpuaffinity_out:
diff -r 372d4093ea59 -r 760c8ec816ad xen/common/trace.c
--- a/xen/common/trace.c        Thu May 13 10:14:54 2010 +0100
+++ b/xen/common/trace.c        Thu May 13 10:16:44 2010 +0100
@@ -343,7 +343,7 @@ int tb_control(xen_sysctl_tbuf_op_t *tbc
         tbc->size = T_INFO_PAGES * PAGE_SIZE;
         break;
     case XEN_SYSCTL_TBUFOP_set_cpu_mask:
-        xenctl_cpumap_to_cpumask(&tb_cpu_mask, &tbc->cpu_mask);
+        rc = xenctl_cpumap_to_cpumask(&tb_cpu_mask, &tbc->cpu_mask);
         break;
     case XEN_SYSCTL_TBUFOP_set_evt_mask:
         tb_event_mask = tbc->evt_mask;
diff -r 372d4093ea59 -r 760c8ec816ad xen/include/xen/cpumask.h
--- a/xen/include/xen/cpumask.h Thu May 13 10:14:54 2010 +0100
+++ b/xen/include/xen/cpumask.h Thu May 13 10:16:44 2010 +0100
@@ -424,9 +424,9 @@ extern cpumask_t cpu_present_map;
 
 /* Copy to/from cpumap provided by control tools. */
 struct xenctl_cpumap;
-void cpumask_to_xenctl_cpumap(
+int cpumask_to_xenctl_cpumap(
     struct xenctl_cpumap *enctl_cpumap, cpumask_t *cpumask);
-void xenctl_cpumap_to_cpumask(
+int xenctl_cpumap_to_cpumask(
     cpumask_t *cpumask, struct xenctl_cpumap *enctl_cpumap);
 
 #endif /* __XEN_CPUMASK_H */

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-4.0-testing] domctl: Fix cpumap/cpumask conversion functions to return an error code., Xen patchbot-4.0-testing <=