ia64/xen-unstable

changeset 14192:09a9b6d6c356

xen: Use RCU-based domain-locking functions where appropriate.
Signed-off-by: Jose Renato Santos <jsantos@hpl.hp.com>
author kfraser@localhost.localdomain
date Thu Mar 01 10:44:40 2007 +0000 (2007-03-01)
parents a5b5279d2ba3
children 8939727a9d93
files xen/acm/acm_core.c xen/acm/acm_simple_type_enforcement_hooks.c xen/arch/x86/domctl.c xen/arch/x86/hvm/hvm.c xen/arch/x86/mm.c xen/common/acm_ops.c xen/common/domctl.c xen/common/event_channel.c xen/common/grant_table.c xen/common/memory.c xen/include/acm/acm_hooks.h
line diff
     1.1 --- a/xen/acm/acm_core.c	Thu Mar 01 10:32:52 2007 +0000
     1.2 +++ b/xen/acm/acm_core.c	Thu Mar 01 10:44:40 2007 +0000
     1.3 @@ -260,7 +260,7 @@ int
     1.4  acm_init_domain_ssid(domid_t id, ssidref_t ssidref)
     1.5  {
     1.6      struct acm_ssid_domain *ssid;
     1.7 -    struct domain *subj = get_domain_by_id(id);
     1.8 +    struct domain *subj = rcu_lock_domain_by_id(id);
     1.9      int ret1, ret2;
    1.10   
    1.11      if (subj == NULL)
    1.12 @@ -270,7 +270,7 @@ acm_init_domain_ssid(domid_t id, ssidref
    1.13      }
    1.14      if ((ssid = xmalloc(struct acm_ssid_domain)) == NULL)
    1.15      {
    1.16 -        put_domain(subj);
    1.17 +        rcu_unlock_domain(subj);
    1.18          return ACM_INIT_SSID_ERROR;
    1.19      }
    1.20  
    1.21 @@ -302,12 +302,12 @@ acm_init_domain_ssid(domid_t id, ssidref
    1.22          printk("%s: ERROR instantiating individual ssids for domain 0x%02x.\n",
    1.23                 __func__, subj->domain_id);
    1.24          acm_free_domain_ssid(ssid);
    1.25 -        put_domain(subj);
    1.26 +        rcu_unlock_domain(subj);
    1.27          return ACM_INIT_SSID_ERROR;
    1.28      }
    1.29      printkd("%s: assigned domain %x the ssidref=%x.\n",
    1.30             __func__, id, ssid->ssidref);
    1.31 -    put_domain(subj);
    1.32 +    rcu_unlock_domain(subj);
    1.33      return ACM_OK;
    1.34  }
    1.35  
     2.1 --- a/xen/acm/acm_simple_type_enforcement_hooks.c	Thu Mar 01 10:32:52 2007 +0000
     2.2 +++ b/xen/acm/acm_simple_type_enforcement_hooks.c	Thu Mar 01 10:44:40 2007 +0000
     2.3 @@ -230,7 +230,7 @@ ste_init_state(struct acm_ste_policy_buf
     2.4                          __func__, d->domain_id, i, sha_copy.flags, sha_copy.domid, 
     2.5                          (unsigned long)sha_copy.frame);
     2.6                  rdomid = sha_copy.domid;
     2.7 -                if ((rdom = get_domain_by_id(rdomid)) == NULL) {
     2.8 +                if ((rdom = rcu_lock_domain_by_id(rdomid)) == NULL) {
     2.9                      spin_unlock(&d->grant_table->lock);
    2.10                      printkd("%s: domain not found ERROR!\n", __func__);
    2.11                      goto out;
    2.12 @@ -239,7 +239,7 @@ ste_init_state(struct acm_ste_policy_buf
    2.13                  ste_rssid = GET_SSIDP(ACM_SIMPLE_TYPE_ENFORCEMENT_POLICY, 
    2.14                                        (struct acm_ssid_domain *)(rdom->ssid));
    2.15                  ste_rssidref = ste_rssid->ste_ssidref;
    2.16 -                put_domain(rdom);
    2.17 +                rcu_unlock_domain(rdom);
    2.18                  if (!have_common_type(ste_ssidref, ste_rssidref)) {
    2.19                      spin_unlock(&d->grant_table->lock);
    2.20                      printkd("%s: Policy violation in grant table sharing domain %x -> domain %x.\n",
    2.21 @@ -494,8 +494,8 @@ ste_pre_eventchannel_unbound(domid_t id1
    2.22      if (id1 == DOMID_SELF) id1 = current->domain->domain_id;
    2.23      if (id2 == DOMID_SELF) id2 = current->domain->domain_id;
    2.24  
    2.25 -    subj = get_domain_by_id(id1);
    2.26 -    obj  = get_domain_by_id(id2);
    2.27 +    subj = rcu_lock_domain_by_id(id1);
    2.28 +    obj  = rcu_lock_domain_by_id(id2);
    2.29      if ((subj == NULL) || (obj == NULL)) {
    2.30          ret = ACM_ACCESS_DENIED;
    2.31          goto out;
    2.32 @@ -517,9 +517,9 @@ ste_pre_eventchannel_unbound(domid_t id1
    2.33      }
    2.34    out:
    2.35      if (obj != NULL)
    2.36 -        put_domain(obj);
    2.37 +        rcu_unlock_domain(obj);
    2.38      if (subj != NULL)
    2.39 -        put_domain(subj);
    2.40 +        rcu_unlock_domain(subj);
    2.41      return ret;
    2.42  }
    2.43  
    2.44 @@ -539,7 +539,7 @@ ste_pre_eventchannel_interdomain(domid_t
    2.45      if (id == DOMID_SELF) id = current->domain->domain_id;
    2.46  
    2.47      subj = current->domain;
    2.48 -    obj  = get_domain_by_id(id);
    2.49 +    obj  = rcu_lock_domain_by_id(id);
    2.50      if (obj == NULL) {
    2.51          ret = ACM_ACCESS_DENIED;
    2.52          goto out;
    2.53 @@ -563,7 +563,7 @@ ste_pre_eventchannel_interdomain(domid_t
    2.54      }
    2.55   out:
    2.56      if (obj != NULL)
    2.57 -        put_domain(obj);
    2.58 +        rcu_unlock_domain(obj);
    2.59      return ret;
    2.60  }
    2.61  
    2.62 @@ -582,7 +582,7 @@ ste_pre_grant_map_ref (domid_t id) {
    2.63      }
    2.64      atomic_inc(&ste_bin_pol.gt_eval_count);
    2.65      subj = current->domain;
    2.66 -    obj = get_domain_by_id(id);
    2.67 +    obj = rcu_lock_domain_by_id(id);
    2.68  
    2.69      if (share_common_type(subj, obj)) {
    2.70          cache_result(subj, obj);
    2.71 @@ -593,7 +593,7 @@ ste_pre_grant_map_ref (domid_t id) {
    2.72          ret = ACM_ACCESS_DENIED;
    2.73      }
    2.74      if (obj != NULL)
    2.75 -        put_domain(obj);
    2.76 +        rcu_unlock_domain(obj);
    2.77      return ret;
    2.78  }
    2.79  
    2.80 @@ -620,7 +620,7 @@ ste_pre_grant_setup (domid_t id) {
    2.81      }
    2.82      /* b) check types */
    2.83      subj = current->domain;
    2.84 -    obj = get_domain_by_id(id);
    2.85 +    obj = rcu_lock_domain_by_id(id);
    2.86  
    2.87      if (share_common_type(subj, obj)) {
    2.88          cache_result(subj, obj);
    2.89 @@ -630,7 +630,7 @@ ste_pre_grant_setup (domid_t id) {
    2.90          ret = ACM_ACCESS_DENIED;
    2.91      }
    2.92      if (obj != NULL)
    2.93 -        put_domain(obj);
    2.94 +        rcu_unlock_domain(obj);
    2.95      return ret;
    2.96  }
    2.97  
     3.1 --- a/xen/arch/x86/domctl.c	Thu Mar 01 10:32:52 2007 +0000
     3.2 +++ b/xen/arch/x86/domctl.c	Thu Mar 01 10:44:40 2007 +0000
     3.3 @@ -39,13 +39,13 @@ long arch_do_domctl(
     3.4      {
     3.5          struct domain *d;
     3.6          ret = -ESRCH;
     3.7 -        d = get_domain_by_id(domctl->domain);
     3.8 +        d = rcu_lock_domain_by_id(domctl->domain);
     3.9          if ( d != NULL )
    3.10          {
    3.11              ret = paging_domctl(d,
    3.12                                  &domctl->u.shadow_op,
    3.13                                  guest_handle_cast(u_domctl, void));
    3.14 -            put_domain(d);
    3.15 +            rcu_unlock_domain(d);
    3.16              copy_to_guest(u_domctl, domctl, 1);
    3.17          } 
    3.18      }
    3.19 @@ -62,7 +62,7 @@ long arch_do_domctl(
    3.20              break;
    3.21  
    3.22          ret = -ESRCH;
    3.23 -        if ( unlikely((d = get_domain_by_id(domctl->domain)) == NULL) )
    3.24 +        if ( unlikely((d = rcu_lock_domain_by_id(domctl->domain)) == NULL) )
    3.25              break;
    3.26  
    3.27          if ( np == 0 )
    3.28 @@ -72,7 +72,7 @@ long arch_do_domctl(
    3.29          else
    3.30              ret = ioports_deny_access(d, fp, fp + np - 1);
    3.31  
    3.32 -        put_domain(d);
    3.33 +        rcu_unlock_domain(d);
    3.34      }
    3.35      break;
    3.36  
    3.37 @@ -86,7 +86,7 @@ long arch_do_domctl(
    3.38          ret = -EINVAL;
    3.39  
    3.40          if ( unlikely(!mfn_valid(mfn)) ||
    3.41 -             unlikely((d = get_domain_by_id(dom)) == NULL) )
    3.42 +             unlikely((d = rcu_lock_domain_by_id(dom)) == NULL) )
    3.43              break;
    3.44  
    3.45          page = mfn_to_page(mfn);
    3.46 @@ -119,7 +119,7 @@ long arch_do_domctl(
    3.47              put_page(page);
    3.48          }
    3.49  
    3.50 -        put_domain(d);
    3.51 +        rcu_unlock_domain(d);
    3.52  
    3.53          copy_to_guest(u_domctl, domctl, 1);
    3.54      }
    3.55 @@ -134,13 +134,13 @@ long arch_do_domctl(
    3.56          uint32_t *arr32;
    3.57          ret = -ESRCH;
    3.58  
    3.59 -        if ( unlikely((d = get_domain_by_id(dom)) == NULL) )
    3.60 +        if ( unlikely((d = rcu_lock_domain_by_id(dom)) == NULL) )
    3.61              break;
    3.62  
    3.63          if ( unlikely(num > 1024) )
    3.64          {
    3.65              ret = -E2BIG;
    3.66 -            put_domain(d);
    3.67 +            rcu_unlock_domain(d);
    3.68              break;
    3.69          }
    3.70  
    3.71 @@ -210,14 +210,14 @@ long arch_do_domctl(
    3.72  
    3.73          free_xenheap_page(arr32);
    3.74  
    3.75 -        put_domain(d);
    3.76 +        rcu_unlock_domain(d);
    3.77      }
    3.78      break;
    3.79  
    3.80      case XEN_DOMCTL_getmemlist:
    3.81      {
    3.82          int i;
    3.83 -        struct domain *d = get_domain_by_id(domctl->domain);
    3.84 +        struct domain *d = rcu_lock_domain_by_id(domctl->domain);
    3.85          unsigned long max_pfns = domctl->u.getmemlist.max_pfns;
    3.86          uint64_t mfn;
    3.87          struct list_head *list_ent;
    3.88 @@ -248,14 +248,14 @@ long arch_do_domctl(
    3.89              domctl->u.getmemlist.num_pfns = i;
    3.90              copy_to_guest(u_domctl, domctl, 1);
    3.91  
    3.92 -            put_domain(d);
    3.93 +            rcu_unlock_domain(d);
    3.94          }
    3.95      }
    3.96      break;
    3.97  
    3.98      case XEN_DOMCTL_hypercall_init:
    3.99      {
   3.100 -        struct domain *d = get_domain_by_id(domctl->domain);
   3.101 +        struct domain *d = rcu_lock_domain_by_id(domctl->domain);
   3.102          unsigned long gmfn = domctl->u.hypercall_init.gmfn;
   3.103          unsigned long mfn;
   3.104          void *hypercall_page;
   3.105 @@ -270,7 +270,7 @@ long arch_do_domctl(
   3.106          if ( !mfn_valid(mfn) ||
   3.107               !get_page_and_type(mfn_to_page(mfn), d, PGT_writable_page) )
   3.108          {
   3.109 -            put_domain(d);
   3.110 +            rcu_unlock_domain(d);
   3.111              break;
   3.112          }
   3.113  
   3.114 @@ -282,7 +282,7 @@ long arch_do_domctl(
   3.115  
   3.116          put_page_and_type(mfn_to_page(mfn));
   3.117  
   3.118 -        put_domain(d);
   3.119 +        rcu_unlock_domain(d);
   3.120      }
   3.121      break;
   3.122  
   3.123 @@ -296,7 +296,7 @@ long arch_do_domctl(
   3.124          c.data = NULL;
   3.125          
   3.126          ret = -ESRCH;
   3.127 -        if ( (d = get_domain_by_id(domctl->domain)) == NULL )
   3.128 +        if ( (d = rcu_lock_domain_by_id(domctl->domain)) == NULL )
   3.129              break;
   3.130  
   3.131          ret = -EINVAL;
   3.132 @@ -317,7 +317,7 @@ long arch_do_domctl(
   3.133          if ( c.data != NULL )
   3.134              xfree(c.data);
   3.135  
   3.136 -        put_domain(d);
   3.137 +        rcu_unlock_domain(d);
   3.138      }
   3.139      break;
   3.140  
   3.141 @@ -327,7 +327,7 @@ long arch_do_domctl(
   3.142          struct domain             *d;
   3.143  
   3.144          ret = -ESRCH;
   3.145 -        if ( (d = get_domain_by_id(domctl->domain)) == NULL )
   3.146 +        if ( (d = rcu_lock_domain_by_id(domctl->domain)) == NULL )
   3.147              break;
   3.148  
   3.149          ret = -EINVAL;
   3.150 @@ -369,7 +369,7 @@ long arch_do_domctl(
   3.151          if ( c.data != NULL )
   3.152              xfree(c.data);
   3.153  
   3.154 -        put_domain(d);
   3.155 +        rcu_unlock_domain(d);
   3.156      }
   3.157      break;
   3.158  
   3.159 @@ -378,7 +378,7 @@ long arch_do_domctl(
   3.160          struct domain *d;
   3.161  
   3.162          ret = -ESRCH;
   3.163 -        if ( (d = get_domain_by_id(domctl->domain)) == NULL )
   3.164 +        if ( (d = rcu_lock_domain_by_id(domctl->domain)) == NULL )
   3.165              break;
   3.166  
   3.167          switch ( domctl->u.address_size.size )
   3.168 @@ -396,7 +396,7 @@ long arch_do_domctl(
   3.169              break;
   3.170          }
   3.171  
   3.172 -        put_domain(d);
   3.173 +        rcu_unlock_domain(d);
   3.174      }
   3.175      break;
   3.176  
   3.177 @@ -405,13 +405,13 @@ long arch_do_domctl(
   3.178          struct domain *d;
   3.179  
   3.180          ret = -ESRCH;
   3.181 -        if ( (d = get_domain_by_id(domctl->domain)) == NULL )
   3.182 +        if ( (d = rcu_lock_domain_by_id(domctl->domain)) == NULL )
   3.183              break;
   3.184  
   3.185          domctl->u.address_size.size = BITS_PER_GUEST_LONG(d);
   3.186  
   3.187          ret = 0;
   3.188 -        put_domain(d);
   3.189 +        rcu_unlock_domain(d);
   3.190  
   3.191          if ( copy_to_guest(u_domctl, domctl, 1) )
   3.192              ret = -EFAULT;
     4.1 --- a/xen/arch/x86/hvm/hvm.c	Thu Mar 01 10:32:52 2007 +0000
     4.2 +++ b/xen/arch/x86/hvm/hvm.c	Thu Mar 01 10:44:40 2007 +0000
     4.3 @@ -711,7 +711,7 @@ static int hvmop_set_pci_intx_level(
     4.4      if ( (op.domain > 0) || (op.bus > 0) || (op.device > 31) || (op.intx > 3) )
     4.5          return -EINVAL;
     4.6  
     4.7 -    d = get_domain_by_id(op.domid);
     4.8 +    d = rcu_lock_domain_by_id(op.domid);
     4.9      if ( d == NULL )
    4.10          return -ESRCH;
    4.11  
    4.12 @@ -734,7 +734,7 @@ static int hvmop_set_pci_intx_level(
    4.13      }
    4.14  
    4.15   out:
    4.16 -    put_domain(d);
    4.17 +    rcu_unlock_domain(d);
    4.18      return rc;
    4.19  }
    4.20  
    4.21 @@ -754,7 +754,7 @@ static int hvmop_set_isa_irq_level(
    4.22      if ( op.isa_irq > 15 )
    4.23          return -EINVAL;
    4.24  
    4.25 -    d = get_domain_by_id(op.domid);
    4.26 +    d = rcu_lock_domain_by_id(op.domid);
    4.27      if ( d == NULL )
    4.28          return -ESRCH;
    4.29  
    4.30 @@ -777,7 +777,7 @@ static int hvmop_set_isa_irq_level(
    4.31      }
    4.32  
    4.33   out:
    4.34 -    put_domain(d);
    4.35 +    rcu_unlock_domain(d);
    4.36      return rc;
    4.37  }
    4.38  
    4.39 @@ -797,7 +797,7 @@ static int hvmop_set_pci_link_route(
    4.40      if ( (op.link > 3) || (op.isa_irq > 15) )
    4.41          return -EINVAL;
    4.42  
    4.43 -    d = get_domain_by_id(op.domid);
    4.44 +    d = rcu_lock_domain_by_id(op.domid);
    4.45      if ( d == NULL )
    4.46          return -ESRCH;
    4.47  
    4.48 @@ -809,7 +809,7 @@ static int hvmop_set_pci_link_route(
    4.49      hvm_set_pci_link_route(d, op.link, op.isa_irq);
    4.50  
    4.51   out:
    4.52 -    put_domain(d);
    4.53 +    rcu_unlock_domain(d);
    4.54      return rc;
    4.55  }
    4.56  
    4.57 @@ -842,7 +842,7 @@ long do_hvm_op(unsigned long op, XEN_GUE
    4.58          }
    4.59          else if ( IS_PRIV(current->domain) )
    4.60          {
    4.61 -            d = get_domain_by_id(a.domid);
    4.62 +            d = rcu_lock_domain_by_id(a.domid);
    4.63              if ( d == NULL )
    4.64                  return -ESRCH;
    4.65          }
    4.66 @@ -899,7 +899,7 @@ long do_hvm_op(unsigned long op, XEN_GUE
    4.67          }
    4.68  
    4.69      param_fail:
    4.70 -        put_domain(d);
    4.71 +        rcu_unlock_domain(d);
    4.72          break;
    4.73      }
    4.74  
     5.1 --- a/xen/arch/x86/mm.c	Thu Mar 01 10:32:52 2007 +0000
     5.2 +++ b/xen/arch/x86/mm.c	Thu Mar 01 10:44:40 2007 +0000
     5.3 @@ -2966,7 +2966,7 @@ long arch_memory_op(int op, XEN_GUEST_HA
     5.4          }
     5.5          else if ( !IS_PRIV(current->domain) )
     5.6              return -EPERM;
     5.7 -        else if ( (d = get_domain_by_id(xatp.domid)) == NULL )
     5.8 +        else if ( (d = rcu_lock_domain_by_id(xatp.domid)) == NULL )
     5.9              return -ESRCH;
    5.10  
    5.11          switch ( xatp.space )
    5.12 @@ -2993,7 +2993,7 @@ long arch_memory_op(int op, XEN_GUEST_HA
    5.13  
    5.14          if ( !paging_mode_translate(d) || (mfn == 0) )
    5.15          {
    5.16 -            put_domain(d);
    5.17 +            rcu_unlock_domain(d);
    5.18              return -EINVAL;
    5.19          }
    5.20  
    5.21 @@ -3021,7 +3021,7 @@ long arch_memory_op(int op, XEN_GUEST_HA
    5.22  
    5.23          UNLOCK_BIGLOCK(d);
    5.24  
    5.25 -        put_domain(d);
    5.26 +        rcu_unlock_domain(d);
    5.27  
    5.28          break;
    5.29      }
    5.30 @@ -3045,14 +3045,14 @@ long arch_memory_op(int op, XEN_GUEST_HA
    5.31          }
    5.32          else if ( !IS_PRIV(current->domain) )
    5.33              return -EPERM;
    5.34 -        else if ( (d = get_domain_by_id(fmap.domid)) == NULL )
    5.35 +        else if ( (d = rcu_lock_domain_by_id(fmap.domid)) == NULL )
    5.36              return -ESRCH;
    5.37  
    5.38          rc = copy_from_guest(&d->arch.e820[0], fmap.map.buffer,
    5.39                               fmap.map.nr_entries) ? -EFAULT : 0;
    5.40          d->arch.nr_e820 = fmap.map.nr_entries;
    5.41  
    5.42 -        put_domain(d);
    5.43 +        rcu_unlock_domain(d);
    5.44          return rc;
    5.45      }
    5.46  
     6.1 --- a/xen/common/acm_ops.c	Thu Mar 01 10:32:52 2007 +0000
     6.2 +++ b/xen/common/acm_ops.c	Thu Mar 01 10:44:40 2007 +0000
     6.3 @@ -115,7 +115,7 @@ ret_t do_acm_op(int cmd, XEN_GUEST_HANDL
     6.4              ssidref = getssid.id.ssidref;
     6.5          else if (getssid.get_ssid_by == ACM_GETBY_domainid)
     6.6          {
     6.7 -            struct domain *subj = get_domain_by_id(getssid.id.domainid);
     6.8 +            struct domain *subj = rcu_lock_domain_by_id(getssid.id.domainid);
     6.9              if (!subj)
    6.10              {
    6.11                  rc = -ESRCH; /* domain not found */
    6.12 @@ -123,12 +123,12 @@ ret_t do_acm_op(int cmd, XEN_GUEST_HANDL
    6.13              }
    6.14              if (subj->ssid == NULL)
    6.15              {
    6.16 -                put_domain(subj);
    6.17 +                rcu_unlock_domain(subj);
    6.18                  rc = -ESRCH;
    6.19                  break;
    6.20              }
    6.21              ssidref = ((struct acm_ssid_domain *)(subj->ssid))->ssidref;
    6.22 -            put_domain(subj);
    6.23 +            rcu_unlock_domain(subj);
    6.24          }
    6.25          else
    6.26          {
    6.27 @@ -152,7 +152,7 @@ ret_t do_acm_op(int cmd, XEN_GUEST_HANDL
    6.28              ssidref1 = getdecision.id1.ssidref;
    6.29          else if (getdecision.get_decision_by1 == ACM_GETBY_domainid)
    6.30          {
    6.31 -            struct domain *subj = get_domain_by_id(getdecision.id1.domainid);
    6.32 +            struct domain *subj = rcu_lock_domain_by_id(getdecision.id1.domainid);
    6.33              if (!subj)
    6.34              {
    6.35                  rc = -ESRCH; /* domain not found */
    6.36 @@ -160,12 +160,12 @@ ret_t do_acm_op(int cmd, XEN_GUEST_HANDL
    6.37              }
    6.38              if (subj->ssid == NULL)
    6.39              {
    6.40 -                put_domain(subj);
    6.41 +                rcu_unlock_domain(subj);
    6.42                  rc = -ESRCH;
    6.43                  break;
    6.44              }
    6.45              ssidref1 = ((struct acm_ssid_domain *)(subj->ssid))->ssidref;
    6.46 -            put_domain(subj);
    6.47 +            rcu_unlock_domain(subj);
    6.48          }
    6.49          else
    6.50          {
    6.51 @@ -176,7 +176,7 @@ ret_t do_acm_op(int cmd, XEN_GUEST_HANDL
    6.52              ssidref2 = getdecision.id2.ssidref;
    6.53          else if (getdecision.get_decision_by2 == ACM_GETBY_domainid)
    6.54          {
    6.55 -            struct domain *subj = get_domain_by_id(getdecision.id2.domainid);
    6.56 +            struct domain *subj = rcu_lock_domain_by_id(getdecision.id2.domainid);
    6.57              if (!subj)
    6.58              {
    6.59                  rc = -ESRCH; /* domain not found */
    6.60 @@ -184,12 +184,12 @@ ret_t do_acm_op(int cmd, XEN_GUEST_HANDL
    6.61              }
    6.62              if (subj->ssid == NULL)
    6.63              {
    6.64 -                put_domain(subj);
    6.65 +                rcu_unlock_domain(subj);
    6.66                  rc = -ESRCH;
    6.67                  break;
    6.68              }
    6.69              ssidref2 = ((struct acm_ssid_domain *)(subj->ssid))->ssidref;
    6.70 -            put_domain(subj);
    6.71 +            rcu_unlock_domain(subj);
    6.72          }
    6.73          else
    6.74          {
     7.1 --- a/xen/common/domctl.c	Thu Mar 01 10:32:52 2007 +0000
     7.2 +++ b/xen/common/domctl.c	Thu Mar 01 10:44:40 2007 +0000
     7.3 @@ -74,10 +74,10 @@ static inline int is_free_domid(domid_t 
     7.4      if ( dom >= DOMID_FIRST_RESERVED )
     7.5          return 0;
     7.6  
     7.7 -    if ( (d = get_domain_by_id(dom)) == NULL )
     7.8 +    if ( (d = rcu_lock_domain_by_id(dom)) == NULL )
     7.9          return 1;
    7.10  
    7.11 -    put_domain(d);
    7.12 +    rcu_unlock_domain(d);
    7.13      return 0;
    7.14  }
    7.15  
    7.16 @@ -197,7 +197,7 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
    7.17  
    7.18      case XEN_DOMCTL_setvcpucontext:
    7.19      {
    7.20 -        struct domain *d = get_domain_by_id(op->domain);
    7.21 +        struct domain *d = rcu_lock_domain_by_id(op->domain);
    7.22          vcpu_guest_context_u c = { .nat = NULL };
    7.23          unsigned int vcpu = op->u.vcpucontext.vcpu;
    7.24          struct vcpu *v;
    7.25 @@ -243,13 +243,13 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
    7.26  
    7.27      svc_out:
    7.28          xfree(c.nat);
    7.29 -        put_domain(d);
    7.30 +        rcu_unlock_domain(d);
    7.31      }
    7.32      break;
    7.33  
    7.34      case XEN_DOMCTL_pausedomain:
    7.35      {
    7.36 -        struct domain *d = get_domain_by_id(op->domain);
    7.37 +        struct domain *d = rcu_lock_domain_by_id(op->domain);
    7.38          ret = -ESRCH;
    7.39          if ( d != NULL )
    7.40          {
    7.41 @@ -259,14 +259,14 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
    7.42                  domain_pause_by_systemcontroller(d);
    7.43                  ret = 0;
    7.44              }
    7.45 -            put_domain(d);
    7.46 +            rcu_unlock_domain(d);
    7.47          }
    7.48      }
    7.49      break;
    7.50  
    7.51      case XEN_DOMCTL_unpausedomain:
    7.52      {
    7.53 -        struct domain *d = get_domain_by_id(op->domain);
    7.54 +        struct domain *d = rcu_lock_domain_by_id(op->domain);
    7.55          ret = -ESRCH;
    7.56          if ( d != NULL )
    7.57          {
    7.58 @@ -277,14 +277,14 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
    7.59                  domain_unpause_by_systemcontroller(d);
    7.60                  ret = 0;
    7.61              }
    7.62 -            put_domain(d);
    7.63 +            rcu_unlock_domain(d);
    7.64          }
    7.65      }
    7.66      break;
    7.67  
    7.68      case XEN_DOMCTL_resumedomain:
    7.69      {
    7.70 -        struct domain *d = get_domain_by_id(op->domain);
    7.71 +        struct domain *d = rcu_lock_domain_by_id(op->domain);
    7.72          struct vcpu *v;
    7.73  
    7.74          ret = -ESRCH;
    7.75 @@ -294,7 +294,7 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
    7.76              if ( test_and_clear_bit(_DOMF_shutdown, &d->domain_flags) )
    7.77                  for_each_vcpu ( d, v )
    7.78                      vcpu_wake(v);
    7.79 -            put_domain(d);
    7.80 +            rcu_unlock_domain(d);
    7.81          }
    7.82      }
    7.83      break;
    7.84 @@ -363,7 +363,7 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
    7.85              break;
    7.86  
    7.87          ret = -ESRCH;
    7.88 -        if ( (d = get_domain_by_id(op->domain)) == NULL )
    7.89 +        if ( (d = rcu_lock_domain_by_id(op->domain)) == NULL )
    7.90              break;
    7.91  
    7.92          /* Needed, for example, to ensure writable p.t. state is synced. */
    7.93 @@ -392,13 +392,13 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
    7.94  
    7.95      maxvcpu_out:
    7.96          domain_unpause(d);
    7.97 -        put_domain(d);
    7.98 +        rcu_unlock_domain(d);
    7.99      }
   7.100      break;
   7.101  
   7.102      case XEN_DOMCTL_destroydomain:
   7.103      {
   7.104 -        struct domain *d = get_domain_by_id(op->domain);
   7.105 +        struct domain *d = rcu_lock_domain_by_id(op->domain);
   7.106          ret = -ESRCH;
   7.107          if ( d != NULL )
   7.108          {
   7.109 @@ -408,7 +408,7 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
   7.110                  domain_kill(d);
   7.111                  ret = 0;
   7.112              }
   7.113 -            put_domain(d);
   7.114 +            rcu_unlock_domain(d);
   7.115          }
   7.116      }
   7.117      break;
   7.118 @@ -417,7 +417,7 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
   7.119      case XEN_DOMCTL_getvcpuaffinity:
   7.120      {
   7.121          domid_t dom = op->domain;
   7.122 -        struct domain *d = get_domain_by_id(dom);
   7.123 +        struct domain *d = rcu_lock_domain_by_id(dom);
   7.124          struct vcpu *v;
   7.125          cpumask_t new_affinity;
   7.126  
   7.127 @@ -447,7 +447,7 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
   7.128          }
   7.129  
   7.130      vcpuaffinity_out:
   7.131 -        put_domain(d);
   7.132 +        rcu_unlock_domain(d);
   7.133      }
   7.134      break;
   7.135  
   7.136 @@ -456,14 +456,14 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
   7.137          struct domain *d;
   7.138  
   7.139          ret = -ESRCH;
   7.140 -        if ( (d = get_domain_by_id(op->domain)) == NULL )
   7.141 +        if ( (d = rcu_lock_domain_by_id(op->domain)) == NULL )
   7.142              break;
   7.143  
   7.144          ret = sched_adjust(d, &op->u.scheduler_op);
   7.145          if ( copy_to_guest(u_domctl, op, 1) )
   7.146              ret = -EFAULT;
   7.147  
   7.148 -        put_domain(d);
   7.149 +        rcu_unlock_domain(d);
   7.150      }
   7.151      break;
   7.152  
   7.153 @@ -510,7 +510,7 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
   7.154          struct vcpu         *v;
   7.155  
   7.156          ret = -ESRCH;
   7.157 -        if ( (d = get_domain_by_id(op->domain)) == NULL )
   7.158 +        if ( (d = rcu_lock_domain_by_id(op->domain)) == NULL )
   7.159              break;
   7.160  
   7.161          ret = -EINVAL;
   7.162 @@ -555,7 +555,7 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
   7.163  
   7.164      getvcpucontext_out:
   7.165          xfree(c.nat);
   7.166 -        put_domain(d);
   7.167 +        rcu_unlock_domain(d);
   7.168      }
   7.169      break;
   7.170  
   7.171 @@ -566,7 +566,7 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
   7.172          struct vcpu_runstate_info runstate;
   7.173  
   7.174          ret = -ESRCH;
   7.175 -        if ( (d = get_domain_by_id(op->domain)) == NULL )
   7.176 +        if ( (d = rcu_lock_domain_by_id(op->domain)) == NULL )
   7.177              break;
   7.178  
   7.179          ret = -EINVAL;
   7.180 @@ -590,7 +590,7 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
   7.181              ret = -EFAULT;
   7.182  
   7.183      getvcpuinfo_out:
   7.184 -        put_domain(d);
   7.185 +        rcu_unlock_domain(d);
   7.186      }
   7.187      break;
   7.188  
   7.189 @@ -600,7 +600,7 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
   7.190          unsigned long new_max;
   7.191  
   7.192          ret = -ESRCH;
   7.193 -        d = get_domain_by_id(op->domain);
   7.194 +        d = rcu_lock_domain_by_id(op->domain);
   7.195          if ( d == NULL )
   7.196              break;
   7.197  
   7.198 @@ -615,7 +615,7 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
   7.199          }
   7.200          spin_unlock(&d->page_alloc_lock);
   7.201  
   7.202 -        put_domain(d);
   7.203 +        rcu_unlock_domain(d);
   7.204      }
   7.205      break;
   7.206  
   7.207 @@ -623,12 +623,12 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
   7.208      {
   7.209          struct domain *d;
   7.210          ret = -ESRCH;
   7.211 -        d = get_domain_by_id(op->domain);
   7.212 +        d = rcu_lock_domain_by_id(op->domain);
   7.213          if ( d != NULL )
   7.214          {
   7.215              memcpy(d->handle, op->u.setdomainhandle.handle,
   7.216                     sizeof(xen_domain_handle_t));
   7.217 -            put_domain(d);
   7.218 +            rcu_unlock_domain(d);
   7.219              ret = 0;
   7.220          }
   7.221      }
   7.222 @@ -638,14 +638,14 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
   7.223      {
   7.224          struct domain *d;
   7.225          ret = -ESRCH;
   7.226 -        d = get_domain_by_id(op->domain);
   7.227 +        d = rcu_lock_domain_by_id(op->domain);
   7.228          if ( d != NULL )
   7.229          {
   7.230              if ( op->u.setdebugging.enable )
   7.231                  set_bit(_DOMF_debugging, &d->domain_flags);
   7.232              else
   7.233                  clear_bit(_DOMF_debugging, &d->domain_flags);
   7.234 -            put_domain(d);
   7.235 +            rcu_unlock_domain(d);
   7.236              ret = 0;
   7.237          }
   7.238      }
   7.239 @@ -661,7 +661,7 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
   7.240              break;
   7.241  
   7.242          ret = -ESRCH;
   7.243 -        d = get_domain_by_id(op->domain);
   7.244 +        d = rcu_lock_domain_by_id(op->domain);
   7.245          if ( d == NULL )
   7.246              break;
   7.247  
   7.248 @@ -670,7 +670,7 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
   7.249          else
   7.250              ret = irq_deny_access(d, pirq);
   7.251  
   7.252 -        put_domain(d);
   7.253 +        rcu_unlock_domain(d);
   7.254      }
   7.255      break;
   7.256  
   7.257 @@ -685,7 +685,7 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
   7.258              break;
   7.259  
   7.260          ret = -ESRCH;
   7.261 -        d = get_domain_by_id(op->domain);
   7.262 +        d = rcu_lock_domain_by_id(op->domain);
   7.263          if ( d == NULL )
   7.264              break;
   7.265  
   7.266 @@ -694,7 +694,7 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
   7.267          else
   7.268              ret = iomem_deny_access(d, mfn, mfn + nr_mfns - 1);
   7.269  
   7.270 -        put_domain(d);
   7.271 +        rcu_unlock_domain(d);
   7.272      }
   7.273      break;
   7.274  
   7.275 @@ -703,11 +703,11 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
   7.276          struct domain *d;
   7.277  
   7.278          ret = -ESRCH;
   7.279 -        d = get_domain_by_id(op->domain);
   7.280 +        d = rcu_lock_domain_by_id(op->domain);
   7.281          if ( d != NULL )
   7.282          {
   7.283              d->time_offset_seconds = op->u.settimeoffset.time_offset_seconds;
   7.284 -            put_domain(d);
   7.285 +            rcu_unlock_domain(d);
   7.286              ret = 0;
   7.287          }
   7.288      }
     8.1 --- a/xen/common/event_channel.c	Thu Mar 01 10:32:52 2007 +0000
     8.2 +++ b/xen/common/event_channel.c	Thu Mar 01 10:44:40 2007 +0000
     8.3 @@ -112,7 +112,7 @@ static long evtchn_alloc_unbound(evtchn_
     8.4      else if ( !IS_PRIV(current->domain) )
     8.5          return -EPERM;
     8.6  
     8.7 -    if ( (d = get_domain_by_id(dom)) == NULL )
     8.8 +    if ( (d = rcu_lock_domain_by_id(dom)) == NULL )
     8.9          return -ESRCH;
    8.10  
    8.11      spin_lock(&d->evtchn_lock);
    8.12 @@ -130,7 +130,7 @@ static long evtchn_alloc_unbound(evtchn_
    8.13   out:
    8.14      spin_unlock(&d->evtchn_lock);
    8.15  
    8.16 -    put_domain(d);
    8.17 +    rcu_unlock_domain(d);
    8.18  
    8.19      return rc;
    8.20  }
    8.21 @@ -150,7 +150,7 @@ static long evtchn_bind_interdomain(evtc
    8.22      if ( rdom == DOMID_SELF )
    8.23          rdom = current->domain->domain_id;
    8.24  
    8.25 -    if ( (rd = get_domain_by_id(rdom)) == NULL )
    8.26 +    if ( (rd = rcu_lock_domain_by_id(rdom)) == NULL )
    8.27          return -ESRCH;
    8.28  
    8.29      /* Avoid deadlock by first acquiring lock of domain with smaller id. */
    8.30 @@ -198,7 +198,7 @@ static long evtchn_bind_interdomain(evtc
    8.31      if ( ld != rd )
    8.32          spin_unlock(&rd->evtchn_lock);
    8.33      
    8.34 -    put_domain(rd);
    8.35 +    rcu_unlock_domain(rd);
    8.36  
    8.37      return rc;
    8.38  }
    8.39 @@ -598,7 +598,7 @@ static long evtchn_status(evtchn_status_
    8.40      else if ( !IS_PRIV(current->domain) )
    8.41          return -EPERM;
    8.42  
    8.43 -    if ( (d = get_domain_by_id(dom)) == NULL )
    8.44 +    if ( (d = rcu_lock_domain_by_id(dom)) == NULL )
    8.45          return -ESRCH;
    8.46  
    8.47      spin_lock(&d->evtchn_lock);
    8.48 @@ -645,7 +645,7 @@ static long evtchn_status(evtchn_status_
    8.49  
    8.50   out:
    8.51      spin_unlock(&d->evtchn_lock);
    8.52 -    put_domain(d);
    8.53 +    rcu_unlock_domain(d);
    8.54      return rc;
    8.55  }
    8.56  
    8.57 @@ -746,13 +746,13 @@ static long evtchn_reset(evtchn_reset_t 
    8.58      else if ( !IS_PRIV(current->domain) )
    8.59          return -EPERM;
    8.60  
    8.61 -    if ( (d = get_domain_by_id(dom)) == NULL )
    8.62 +    if ( (d = rcu_lock_domain_by_id(dom)) == NULL )
    8.63          return -ESRCH;
    8.64  
    8.65      for ( i = 0; port_is_valid(d, i); i++ )
    8.66          (void)__evtchn_close(d, i);
    8.67  
    8.68 -    put_domain(d);
    8.69 +    rcu_unlock_domain(d);
    8.70  
    8.71      return 0;
    8.72  }
     9.1 --- a/xen/common/grant_table.c	Thu Mar 01 10:32:52 2007 +0000
     9.2 +++ b/xen/common/grant_table.c	Thu Mar 01 10:44:40 2007 +0000
     9.3 @@ -227,10 +227,8 @@ static void
     9.4          return;
     9.5      }
     9.6  
     9.7 -    if ( unlikely((rd = get_domain_by_id(op->dom)) == NULL) )
     9.8 +    if ( unlikely((rd = rcu_lock_domain_by_id(op->dom)) == NULL) )
     9.9      {
    9.10 -        if ( rd != NULL )
    9.11 -            put_domain(rd);
    9.12          gdprintk(XENLOG_INFO, "Could not find domain %d\n", op->dom);
    9.13          op->status = GNTST_bad_domain;
    9.14          return;
    9.15 @@ -238,7 +236,7 @@ static void
    9.16  
    9.17      if ( unlikely((handle = get_maptrack_handle(ld->grant_table)) == -1) )
    9.18      {
    9.19 -        put_domain(rd);
    9.20 +        rcu_unlock_domain(rd);
    9.21          gdprintk(XENLOG_INFO, "Failed to obtain maptrack handle.\n");
    9.22          op->status = GNTST_no_device_space;
    9.23          return;
    9.24 @@ -368,7 +366,7 @@ static void
    9.25      op->handle       = handle;
    9.26      op->status       = GNTST_okay;
    9.27  
    9.28 -    put_domain(rd);
    9.29 +    rcu_unlock_domain(rd);
    9.30      return;
    9.31  
    9.32   undo_out:
    9.33 @@ -395,7 +393,7 @@ static void
    9.34      spin_unlock(&rd->grant_table->lock);
    9.35      op->status = rc;
    9.36      put_maptrack_handle(ld->grant_table, handle);
    9.37 -    put_domain(rd);
    9.38 +    rcu_unlock_domain(rd);
    9.39  }
    9.40  
    9.41  static long
    9.42 @@ -455,7 +453,7 @@ static void
    9.43      ref   = map->ref;
    9.44      flags = map->flags;
    9.45  
    9.46 -    if ( unlikely((rd = get_domain_by_id(dom)) == NULL) )
    9.47 +    if ( unlikely((rd = rcu_lock_domain_by_id(dom)) == NULL) )
    9.48      {
    9.49          /* This can happen when a grant is implicitly unmapped. */
    9.50          gdprintk(XENLOG_INFO, "Could not find domain %d\n", dom);
    9.51 @@ -536,7 +534,7 @@ static void
    9.52   unmap_out:
    9.53      op->status = rc;
    9.54      spin_unlock(&rd->grant_table->lock);
    9.55 -    put_domain(rd);
    9.56 +    rcu_unlock_domain(rd);
    9.57  }
    9.58  
    9.59  static long
    9.60 @@ -658,7 +656,7 @@ gnttab_setup_table(
    9.61          goto out;
    9.62      }
    9.63  
    9.64 -    if ( unlikely((d = get_domain_by_id(dom)) == NULL) )
    9.65 +    if ( unlikely((d = rcu_lock_domain_by_id(dom)) == NULL) )
    9.66      {
    9.67          gdprintk(XENLOG_INFO, "Bad domid %d.\n", dom);
    9.68          op.status = GNTST_bad_domain;
    9.69 @@ -689,7 +687,7 @@ gnttab_setup_table(
    9.70   setup_unlock_out:
    9.71      spin_unlock(&d->grant_table->lock);
    9.72  
    9.73 -    put_domain(d);
    9.74 +    rcu_unlock_domain(d);
    9.75  
    9.76   out:
    9.77      if ( unlikely(copy_to_guest(uop, &op, 1)) )
    9.78 @@ -726,7 +724,7 @@ gnttab_query_size(
    9.79          goto query_out;
    9.80      }
    9.81  
    9.82 -    if ( unlikely((d = get_domain_by_id(dom)) == NULL) )
    9.83 +    if ( unlikely((d = rcu_lock_domain_by_id(dom)) == NULL) )
    9.84      {
    9.85          gdprintk(XENLOG_INFO, "Bad domid %d.\n", dom);
    9.86          op.status = GNTST_bad_domain;
    9.87 @@ -741,7 +739,7 @@ gnttab_query_size(
    9.88  
    9.89      spin_unlock(&d->grant_table->lock);
    9.90  
    9.91 -    put_domain(d);
    9.92 +    rcu_unlock_domain(d);
    9.93  
    9.94   query_out:
    9.95      if ( unlikely(copy_to_guest(uop, &op, 1)) )
    9.96 @@ -869,7 +867,7 @@ gnttab_transfer(
    9.97          }
    9.98  
    9.99          /* Find the target domain. */
   9.100 -        if ( unlikely((e = get_domain_by_id(gop.domid)) == NULL) )
   9.101 +        if ( unlikely((e = rcu_lock_domain_by_id(gop.domid)) == NULL) )
   9.102          {
   9.103              gdprintk(XENLOG_INFO, "gnttab_transfer: can't find domain %d\n",
   9.104                      gop.domid);
   9.105 @@ -897,7 +895,7 @@ gnttab_transfer(
   9.106                          "or is dying (%lx)\n",
   9.107                          e->tot_pages, e->max_pages, gop.ref, e->domain_flags);
   9.108              spin_unlock(&e->page_alloc_lock);
   9.109 -            put_domain(e);
   9.110 +            rcu_unlock_domain(e);
   9.111              page->count_info &= ~(PGC_count_mask|PGC_allocated);
   9.112              free_domheap_page(page);
   9.113              gop.status = GNTST_general_error;
   9.114 @@ -925,7 +923,7 @@ gnttab_transfer(
   9.115  
   9.116          spin_unlock(&e->grant_table->lock);
   9.117  
   9.118 -        put_domain(e);
   9.119 +        rcu_unlock_domain(e);
   9.120  
   9.121          gop.status = GNTST_okay;
   9.122  
   9.123 @@ -1092,7 +1090,7 @@ static void
   9.124          sd = current->domain;
   9.125          get_knownalive_domain(sd);
   9.126      }
   9.127 -    else if ( (sd = get_domain_by_id(op->source.domid)) == NULL )
   9.128 +    else if ( (sd = rcu_lock_domain_by_id(op->source.domid)) == NULL )
   9.129      {
   9.130          PIN_FAIL(error_out, GNTST_bad_domain,
   9.131                   "couldn't find %d\n", op->source.domid);
   9.132 @@ -1103,7 +1101,7 @@ static void
   9.133          dd = current->domain;
   9.134          get_knownalive_domain(dd);
   9.135      }
   9.136 -    else if ( (dd = get_domain_by_id(op->dest.domid)) == NULL )
   9.137 +    else if ( (dd = rcu_lock_domain_by_id(op->dest.domid)) == NULL )
   9.138      {
   9.139          PIN_FAIL(error_out, GNTST_bad_domain,
   9.140                   "couldn't find %d\n", op->dest.domid);
   9.141 @@ -1173,9 +1171,9 @@ static void
   9.142      if ( have_d_grant )
   9.143          __release_grant_for_copy(dd, op->dest.u.ref, 0);
   9.144      if ( sd )
   9.145 -        put_domain(sd);
   9.146 +        rcu_unlock_domain(sd);
   9.147      if ( dd )
   9.148 -        put_domain(dd);
   9.149 +        rcu_unlock_domain(dd);
   9.150      op->status = rc;
   9.151  }
   9.152  
   9.153 @@ -1397,7 +1395,7 @@ gnttab_release_mappings(
   9.154                  "flags:(%x) dom:(%hu)\n",
   9.155                  handle, ref, map->flags, map->domid);
   9.156  
   9.157 -        rd = get_domain_by_id(map->domid);
   9.158 +        rd = rcu_lock_domain_by_id(map->domid);
   9.159          if ( rd == NULL )
   9.160          {
   9.161              /* Nothing to clear up... */
   9.162 @@ -1453,7 +1451,7 @@ gnttab_release_mappings(
   9.163  
   9.164          spin_unlock(&rd->grant_table->lock);
   9.165  
   9.166 -        put_domain(rd);
   9.167 +        rcu_unlock_domain(rd);
   9.168  
   9.169          map->flags = 0;
   9.170      }
    10.1 --- a/xen/common/memory.c	Thu Mar 01 10:32:52 2007 +0000
    10.2 +++ b/xen/common/memory.c	Thu Mar 01 10:44:40 2007 +0000
    10.3 @@ -244,12 +244,12 @@ static long translate_gpfn_list(
    10.4      else if ( !IS_PRIV(current->domain) )
    10.5          return -EPERM;
    10.6  
    10.7 -    if ( (d = get_domain_by_id(op.domid)) == NULL )
    10.8 +    if ( (d = rcu_lock_domain_by_id(op.domid)) == NULL )
    10.9          return -ESRCH;
   10.10  
   10.11      if ( !shadow_mode_translate(d) )
   10.12      {
   10.13 -        put_domain(d);
   10.14 +        rcu_unlock_domain(d);
   10.15          return -EINVAL;
   10.16      }
   10.17  
   10.18 @@ -257,14 +257,14 @@ static long translate_gpfn_list(
   10.19      {
   10.20          if ( hypercall_preempt_check() )
   10.21          {
   10.22 -            put_domain(d);
   10.23 +            rcu_unlock_domain(d);
   10.24              *progress = i;
   10.25              return -EAGAIN;
   10.26          }
   10.27  
   10.28          if ( unlikely(__copy_from_guest_offset(&gpfn, op.gpfn_list, i, 1)) )
   10.29          {
   10.30 -            put_domain(d);
   10.31 +            rcu_unlock_domain(d);
   10.32              return -EFAULT;
   10.33          }
   10.34  
   10.35 @@ -272,12 +272,12 @@ static long translate_gpfn_list(
   10.36  
   10.37          if ( unlikely(__copy_to_guest_offset(op.mfn_list, i, &mfn, 1)) )
   10.38          {
   10.39 -            put_domain(d);
   10.40 +            rcu_unlock_domain(d);
   10.41              return -EFAULT;
   10.42          }
   10.43      }
   10.44  
   10.45 -    put_domain(d);
   10.46 +    rcu_unlock_domain(d);
   10.47      return 0;
   10.48  }
   10.49  
   10.50 @@ -545,7 +545,7 @@ long do_memory_op(unsigned long cmd, XEN
   10.51          if ( likely(reservation.domid == DOMID_SELF) )
   10.52              d = current->domain;
   10.53          else if ( !IS_PRIV(current->domain) ||
   10.54 -                  ((d = get_domain_by_id(reservation.domid)) == NULL) )
   10.55 +                  ((d = rcu_lock_domain_by_id(reservation.domid)) == NULL) )
   10.56              return start_extent;
   10.57          args.domain = d;
   10.58  
   10.59 @@ -563,7 +563,7 @@ long do_memory_op(unsigned long cmd, XEN
   10.60          }
   10.61  
   10.62          if ( unlikely(reservation.domid != DOMID_SELF) )
   10.63 -            put_domain(d);
   10.64 +            rcu_unlock_domain(d);
   10.65  
   10.66          rc = args.nr_done;
   10.67  
   10.68 @@ -591,13 +591,13 @@ long do_memory_op(unsigned long cmd, XEN
   10.69              d = current->domain;
   10.70          else if ( !IS_PRIV(current->domain) )
   10.71              return -EPERM;
   10.72 -        else if ( (d = get_domain_by_id(domid)) == NULL )
   10.73 +        else if ( (d = rcu_lock_domain_by_id(domid)) == NULL )
   10.74              return -ESRCH;
   10.75  
   10.76          rc = (op == XENMEM_current_reservation) ? d->tot_pages : d->max_pages;
   10.77  
   10.78          if ( unlikely(domid != DOMID_SELF) )
   10.79 -            put_domain(d);
   10.80 +            rcu_unlock_domain(d);
   10.81  
   10.82          break;
   10.83  
    11.1 --- a/xen/include/acm/acm_hooks.h	Thu Mar 01 10:32:52 2007 +0000
    11.2 +++ b/xen/include/acm/acm_hooks.h	Thu Mar 01 10:44:40 2007 +0000
    11.3 @@ -241,18 +241,18 @@ static inline int acm_pre_domctl(struct 
    11.4                      __func__);
    11.5              return -EACCES;
    11.6          }
    11.7 -        d = get_domain_by_id(op->domain);
    11.8 +        d = rcu_lock_domain_by_id(op->domain);
    11.9          if (d != NULL) {
   11.10              *ssid = d->ssid; /* save for post destroy when d is gone */
   11.11              if (*ssid == NULL) {
   11.12                  printk("%s: Warning. Destroying domain without ssid pointer.\n", 
   11.13                         __func__);
   11.14 -                put_domain(d);
   11.15 +                domain_rcu_lock(d);
   11.16                  return -EACCES;
   11.17              }
   11.18              d->ssid = NULL; /* make sure it's not used any more */
   11.19               /* no policy-specific hook */
   11.20 -            put_domain(d);
   11.21 +            domain_rcu_lock(d);
   11.22              ret = 0;
   11.23          }
   11.24          break;