ia64/xen-unstable

changeset 9729:1d8b3c85121d

Fix SETMAXMEM dom0_op with proper locking.

Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Sat Apr 15 09:52:32 2006 +0100 (2006-04-15)
parents 5102cd121a36
children 74ee53209cca
files xen/common/dom0_ops.c
line diff
     1.1 --- a/xen/common/dom0_ops.c	Sat Apr 15 09:47:55 2006 +0100
     1.2 +++ b/xen/common/dom0_ops.c	Sat Apr 15 09:52:32 2006 +0100
     1.3 @@ -581,27 +581,31 @@ long do_dom0_op(GUEST_HANDLE(dom0_op_t) 
     1.4      case DOM0_SETDOMAINMAXMEM:
     1.5      {
     1.6          struct domain *d; 
     1.7 +        unsigned long new_max;
     1.8 +
     1.9          ret = -ESRCH;
    1.10          d = find_domain_by_id(op->u.setdomainmaxmem.domain);
    1.11 -        if ( d != NULL )
    1.12 +        if ( d == NULL )
    1.13 +            break;
    1.14 +
    1.15 +        ret = -EINVAL;
    1.16 +        new_max = op->u.setdomainmaxmem.max_memkb >> (PAGE_SHIFT-10);
    1.17 +
    1.18 +        spin_lock(&d->page_alloc_lock);
    1.19 +        if ( new_max >= d->tot_pages )
    1.20          {
    1.21 -            unsigned long new_max;
    1.22 -            new_max = op->u.setdomainmaxmem.max_memkb >> (PAGE_SHIFT-10);
    1.23 -            if (new_max < d->tot_pages) 
    1.24 -                ret = -EINVAL;
    1.25 -            else 
    1.26 -            {  
    1.27 -                d->max_pages = new_max;
    1.28 -                ret = 0;
    1.29 -            }
    1.30 -            put_domain(d);
    1.31 +            d->max_pages = new_max;
    1.32 +            ret = 0;
    1.33          }
    1.34 +        spin_unlock(&d->page_alloc_lock);
    1.35 +
    1.36 +        put_domain(d);
    1.37      }
    1.38      break;
    1.39  
    1.40      case DOM0_SETDOMAINHANDLE:
    1.41      {
    1.42 -        struct domain *d; 
    1.43 +        struct domain *d;
    1.44          ret = -ESRCH;
    1.45          d = find_domain_by_id(op->u.setdomainhandle.domain);
    1.46          if ( d != NULL )