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] Fix SETMAXMEM dom0_op with proper locking.

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] Fix SETMAXMEM dom0_op with proper locking.
From: Xen patchbot -3.0-testing <patchbot-3.0-testing@xxxxxxxxxxxxxxxxxxx>
Date: Sat, 15 Apr 2006 10:36:15 +0000
Delivery-date: Sat, 15 Apr 2006 03:37:13 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
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/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/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 kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID e6ee385e3d9a629579544aa63df69251b8416a87
# Parent  a87dc2a55b0a37ab4de84225dad26ead29ccf5bb
Fix SETMAXMEM dom0_op with proper locking.

Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>

diff -r a87dc2a55b0a -r e6ee385e3d9a xen/common/dom0_ops.c
--- a/xen/common/dom0_ops.c     Sat Apr 15 08:53:27 2006
+++ b/xen/common/dom0_ops.c     Sat Apr 15 08:53:52 2006
@@ -581,27 +581,31 @@
     case DOM0_SETDOMAINMAXMEM:
     {
         struct domain *d; 
+        unsigned long new_max;
+
         ret = -ESRCH;
         d = find_domain_by_id(op->u.setdomainmaxmem.domain);
-        if ( d != NULL )
-        {
-            unsigned long new_max;
-            new_max = op->u.setdomainmaxmem.max_memkb >> (PAGE_SHIFT-10);
-            if (new_max < d->tot_pages) 
-                ret = -EINVAL;
-            else 
-            {  
-                d->max_pages = new_max;
-                ret = 0;
-            }
-            put_domain(d);
-        }
+        if ( d == NULL )
+            break;
+
+        ret = -EINVAL;
+        new_max = op->u.setdomainmaxmem.max_memkb >> (PAGE_SHIFT-10);
+
+        spin_lock(&d->page_alloc_lock);
+        if ( new_max >= d->tot_pages )
+        {
+            d->max_pages = new_max;
+            ret = 0;
+        }
+        spin_unlock(&d->page_alloc_lock);
+
+        put_domain(d);
     }
     break;
 
     case DOM0_SETDOMAINHANDLE:
     {
-        struct domain *d; 
+        struct domain *d;
         ret = -ESRCH;
         d = find_domain_by_id(op->u.setdomainhandle.domain);
         if ( d != NULL )

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

<Prev in Thread] Current Thread [Next in Thread>