ia64/xen-unstable

changeset 14194:8939727a9d93

Merge
author Tim Deegan <Tim.Deegan@xensource.com>
date Thu Mar 01 11:04:45 2007 +0000 (2007-03-01)
parents 1966270d89d7 09a9b6d6c356
children 3fb02f56c19f
files
line diff
     1.1 --- a/tools/ioemu/hw/ide.c	Thu Mar 01 11:04:23 2007 +0000
     1.2 +++ b/tools/ioemu/hw/ide.c	Thu Mar 01 11:04:45 2007 +0000
     1.3 @@ -504,7 +504,7 @@ static inline void
     1.4  buffered_pio_write(IDEState *s, uint32_t addr, int size)
     1.5  {
     1.6      struct pio_buffer *piobuf = piobuf_by_addr(addr);
     1.7 -    uint32_t data_end;
     1.8 +    int data_end;
     1.9  
    1.10      if (!piobuf)
    1.11          return;
    1.12 @@ -523,7 +523,7 @@ static inline void
    1.13  buffered_pio_read(IDEState *s, uint32_t addr, int size)
    1.14  {
    1.15      struct pio_buffer *piobuf = piobuf_by_addr(addr);
    1.16 -    uint32_t data_end;
    1.17 +    int data_end;
    1.18  
    1.19      if (!piobuf)
    1.20          return;
     2.1 --- a/xen/acm/acm_core.c	Thu Mar 01 11:04:23 2007 +0000
     2.2 +++ b/xen/acm/acm_core.c	Thu Mar 01 11:04:45 2007 +0000
     2.3 @@ -260,7 +260,7 @@ int
     2.4  acm_init_domain_ssid(domid_t id, ssidref_t ssidref)
     2.5  {
     2.6      struct acm_ssid_domain *ssid;
     2.7 -    struct domain *subj = get_domain_by_id(id);
     2.8 +    struct domain *subj = rcu_lock_domain_by_id(id);
     2.9      int ret1, ret2;
    2.10   
    2.11      if (subj == NULL)
    2.12 @@ -270,7 +270,7 @@ acm_init_domain_ssid(domid_t id, ssidref
    2.13      }
    2.14      if ((ssid = xmalloc(struct acm_ssid_domain)) == NULL)
    2.15      {
    2.16 -        put_domain(subj);
    2.17 +        rcu_unlock_domain(subj);
    2.18          return ACM_INIT_SSID_ERROR;
    2.19      }
    2.20  
    2.21 @@ -302,12 +302,12 @@ acm_init_domain_ssid(domid_t id, ssidref
    2.22          printk("%s: ERROR instantiating individual ssids for domain 0x%02x.\n",
    2.23                 __func__, subj->domain_id);
    2.24          acm_free_domain_ssid(ssid);
    2.25 -        put_domain(subj);
    2.26 +        rcu_unlock_domain(subj);
    2.27          return ACM_INIT_SSID_ERROR;
    2.28      }
    2.29      printkd("%s: assigned domain %x the ssidref=%x.\n",
    2.30             __func__, id, ssid->ssidref);
    2.31 -    put_domain(subj);
    2.32 +    rcu_unlock_domain(subj);
    2.33      return ACM_OK;
    2.34  }
    2.35  
     3.1 --- a/xen/acm/acm_simple_type_enforcement_hooks.c	Thu Mar 01 11:04:23 2007 +0000
     3.2 +++ b/xen/acm/acm_simple_type_enforcement_hooks.c	Thu Mar 01 11:04:45 2007 +0000
     3.3 @@ -230,7 +230,7 @@ ste_init_state(struct acm_ste_policy_buf
     3.4                          __func__, d->domain_id, i, sha_copy.flags, sha_copy.domid, 
     3.5                          (unsigned long)sha_copy.frame);
     3.6                  rdomid = sha_copy.domid;
     3.7 -                if ((rdom = get_domain_by_id(rdomid)) == NULL) {
     3.8 +                if ((rdom = rcu_lock_domain_by_id(rdomid)) == NULL) {
     3.9                      spin_unlock(&d->grant_table->lock);
    3.10                      printkd("%s: domain not found ERROR!\n", __func__);
    3.11                      goto out;
    3.12 @@ -239,7 +239,7 @@ ste_init_state(struct acm_ste_policy_buf
    3.13                  ste_rssid = GET_SSIDP(ACM_SIMPLE_TYPE_ENFORCEMENT_POLICY, 
    3.14                                        (struct acm_ssid_domain *)(rdom->ssid));
    3.15                  ste_rssidref = ste_rssid->ste_ssidref;
    3.16 -                put_domain(rdom);
    3.17 +                rcu_unlock_domain(rdom);
    3.18                  if (!have_common_type(ste_ssidref, ste_rssidref)) {
    3.19                      spin_unlock(&d->grant_table->lock);
    3.20                      printkd("%s: Policy violation in grant table sharing domain %x -> domain %x.\n",
    3.21 @@ -494,8 +494,8 @@ ste_pre_eventchannel_unbound(domid_t id1
    3.22      if (id1 == DOMID_SELF) id1 = current->domain->domain_id;
    3.23      if (id2 == DOMID_SELF) id2 = current->domain->domain_id;
    3.24  
    3.25 -    subj = get_domain_by_id(id1);
    3.26 -    obj  = get_domain_by_id(id2);
    3.27 +    subj = rcu_lock_domain_by_id(id1);
    3.28 +    obj  = rcu_lock_domain_by_id(id2);
    3.29      if ((subj == NULL) || (obj == NULL)) {
    3.30          ret = ACM_ACCESS_DENIED;
    3.31          goto out;
    3.32 @@ -517,9 +517,9 @@ ste_pre_eventchannel_unbound(domid_t id1
    3.33      }
    3.34    out:
    3.35      if (obj != NULL)
    3.36 -        put_domain(obj);
    3.37 +        rcu_unlock_domain(obj);
    3.38      if (subj != NULL)
    3.39 -        put_domain(subj);
    3.40 +        rcu_unlock_domain(subj);
    3.41      return ret;
    3.42  }
    3.43  
    3.44 @@ -539,7 +539,7 @@ ste_pre_eventchannel_interdomain(domid_t
    3.45      if (id == DOMID_SELF) id = current->domain->domain_id;
    3.46  
    3.47      subj = current->domain;
    3.48 -    obj  = get_domain_by_id(id);
    3.49 +    obj  = rcu_lock_domain_by_id(id);
    3.50      if (obj == NULL) {
    3.51          ret = ACM_ACCESS_DENIED;
    3.52          goto out;
    3.53 @@ -563,7 +563,7 @@ ste_pre_eventchannel_interdomain(domid_t
    3.54      }
    3.55   out:
    3.56      if (obj != NULL)
    3.57 -        put_domain(obj);
    3.58 +        rcu_unlock_domain(obj);
    3.59      return ret;
    3.60  }
    3.61  
    3.62 @@ -582,7 +582,7 @@ ste_pre_grant_map_ref (domid_t id) {
    3.63      }
    3.64      atomic_inc(&ste_bin_pol.gt_eval_count);
    3.65      subj = current->domain;
    3.66 -    obj = get_domain_by_id(id);
    3.67 +    obj = rcu_lock_domain_by_id(id);
    3.68  
    3.69      if (share_common_type(subj, obj)) {
    3.70          cache_result(subj, obj);
    3.71 @@ -593,7 +593,7 @@ ste_pre_grant_map_ref (domid_t id) {
    3.72          ret = ACM_ACCESS_DENIED;
    3.73      }
    3.74      if (obj != NULL)
    3.75 -        put_domain(obj);
    3.76 +        rcu_unlock_domain(obj);
    3.77      return ret;
    3.78  }
    3.79  
    3.80 @@ -620,7 +620,7 @@ ste_pre_grant_setup (domid_t id) {
    3.81      }
    3.82      /* b) check types */
    3.83      subj = current->domain;
    3.84 -    obj = get_domain_by_id(id);
    3.85 +    obj = rcu_lock_domain_by_id(id);
    3.86  
    3.87      if (share_common_type(subj, obj)) {
    3.88          cache_result(subj, obj);
    3.89 @@ -630,7 +630,7 @@ ste_pre_grant_setup (domid_t id) {
    3.90          ret = ACM_ACCESS_DENIED;
    3.91      }
    3.92      if (obj != NULL)
    3.93 -        put_domain(obj);
    3.94 +        rcu_unlock_domain(obj);
    3.95      return ret;
    3.96  }
    3.97  
     4.1 --- a/xen/arch/x86/domain.c	Thu Mar 01 11:04:23 2007 +0000
     4.2 +++ b/xen/arch/x86/domain.c	Thu Mar 01 11:04:45 2007 +0000
     4.3 @@ -501,9 +501,12 @@ int arch_set_info_guest(
     4.4      unsigned long flags;
     4.5      int i, rc = 0, compat;
     4.6  
     4.7 -    /* The context is a compat-mode one if the target domain is compat-mode;
     4.8 -     * we expect the tools to DTRT even in compat-mode callers. */
     4.9 -    compat = IS_COMPAT(d);
    4.10 +    /*
    4.11 +     * HVM domain builder always builds caller-bitsize vcpu context.
    4.12 +     * The PV builder is smarter and builds the appropriate type of context for
    4.13 +     * the target domain. So the compat check here differs in the two cases.
    4.14 +     */
    4.15 +    compat = is_hvm_domain(d) ? IS_COMPAT(current->domain) : IS_COMPAT(d);
    4.16  
    4.17  #ifdef CONFIG_COMPAT
    4.18  #define c(fld) (compat ? (c.cmp->fld) : (c.nat->fld))
     5.1 --- a/xen/arch/x86/domctl.c	Thu Mar 01 11:04:23 2007 +0000
     5.2 +++ b/xen/arch/x86/domctl.c	Thu Mar 01 11:04:45 2007 +0000
     5.3 @@ -39,13 +39,13 @@ long arch_do_domctl(
     5.4      {
     5.5          struct domain *d;
     5.6          ret = -ESRCH;
     5.7 -        d = get_domain_by_id(domctl->domain);
     5.8 +        d = rcu_lock_domain_by_id(domctl->domain);
     5.9          if ( d != NULL )
    5.10          {
    5.11              ret = paging_domctl(d,
    5.12                                  &domctl->u.shadow_op,
    5.13                                  guest_handle_cast(u_domctl, void));
    5.14 -            put_domain(d);
    5.15 +            rcu_unlock_domain(d);
    5.16              copy_to_guest(u_domctl, domctl, 1);
    5.17          } 
    5.18      }
    5.19 @@ -62,7 +62,7 @@ long arch_do_domctl(
    5.20              break;
    5.21  
    5.22          ret = -ESRCH;
    5.23 -        if ( unlikely((d = get_domain_by_id(domctl->domain)) == NULL) )
    5.24 +        if ( unlikely((d = rcu_lock_domain_by_id(domctl->domain)) == NULL) )
    5.25              break;
    5.26  
    5.27          if ( np == 0 )
    5.28 @@ -72,7 +72,7 @@ long arch_do_domctl(
    5.29          else
    5.30              ret = ioports_deny_access(d, fp, fp + np - 1);
    5.31  
    5.32 -        put_domain(d);
    5.33 +        rcu_unlock_domain(d);
    5.34      }
    5.35      break;
    5.36  
    5.37 @@ -86,7 +86,7 @@ long arch_do_domctl(
    5.38          ret = -EINVAL;
    5.39  
    5.40          if ( unlikely(!mfn_valid(mfn)) ||
    5.41 -             unlikely((d = get_domain_by_id(dom)) == NULL) )
    5.42 +             unlikely((d = rcu_lock_domain_by_id(dom)) == NULL) )
    5.43              break;
    5.44  
    5.45          page = mfn_to_page(mfn);
    5.46 @@ -119,7 +119,7 @@ long arch_do_domctl(
    5.47              put_page(page);
    5.48          }
    5.49  
    5.50 -        put_domain(d);
    5.51 +        rcu_unlock_domain(d);
    5.52  
    5.53          copy_to_guest(u_domctl, domctl, 1);
    5.54      }
    5.55 @@ -134,13 +134,13 @@ long arch_do_domctl(
    5.56          uint32_t *arr32;
    5.57          ret = -ESRCH;
    5.58  
    5.59 -        if ( unlikely((d = get_domain_by_id(dom)) == NULL) )
    5.60 +        if ( unlikely((d = rcu_lock_domain_by_id(dom)) == NULL) )
    5.61              break;
    5.62  
    5.63          if ( unlikely(num > 1024) )
    5.64          {
    5.65              ret = -E2BIG;
    5.66 -            put_domain(d);
    5.67 +            rcu_unlock_domain(d);
    5.68              break;
    5.69          }
    5.70  
    5.71 @@ -210,14 +210,14 @@ long arch_do_domctl(
    5.72  
    5.73          free_xenheap_page(arr32);
    5.74  
    5.75 -        put_domain(d);
    5.76 +        rcu_unlock_domain(d);
    5.77      }
    5.78      break;
    5.79  
    5.80      case XEN_DOMCTL_getmemlist:
    5.81      {
    5.82          int i;
    5.83 -        struct domain *d = get_domain_by_id(domctl->domain);
    5.84 +        struct domain *d = rcu_lock_domain_by_id(domctl->domain);
    5.85          unsigned long max_pfns = domctl->u.getmemlist.max_pfns;
    5.86          uint64_t mfn;
    5.87          struct list_head *list_ent;
    5.88 @@ -248,14 +248,14 @@ long arch_do_domctl(
    5.89              domctl->u.getmemlist.num_pfns = i;
    5.90              copy_to_guest(u_domctl, domctl, 1);
    5.91  
    5.92 -            put_domain(d);
    5.93 +            rcu_unlock_domain(d);
    5.94          }
    5.95      }
    5.96      break;
    5.97  
    5.98      case XEN_DOMCTL_hypercall_init:
    5.99      {
   5.100 -        struct domain *d = get_domain_by_id(domctl->domain);
   5.101 +        struct domain *d = rcu_lock_domain_by_id(domctl->domain);
   5.102          unsigned long gmfn = domctl->u.hypercall_init.gmfn;
   5.103          unsigned long mfn;
   5.104          void *hypercall_page;
   5.105 @@ -270,7 +270,7 @@ long arch_do_domctl(
   5.106          if ( !mfn_valid(mfn) ||
   5.107               !get_page_and_type(mfn_to_page(mfn), d, PGT_writable_page) )
   5.108          {
   5.109 -            put_domain(d);
   5.110 +            rcu_unlock_domain(d);
   5.111              break;
   5.112          }
   5.113  
   5.114 @@ -282,7 +282,7 @@ long arch_do_domctl(
   5.115  
   5.116          put_page_and_type(mfn_to_page(mfn));
   5.117  
   5.118 -        put_domain(d);
   5.119 +        rcu_unlock_domain(d);
   5.120      }
   5.121      break;
   5.122  
   5.123 @@ -296,7 +296,7 @@ long arch_do_domctl(
   5.124          c.data = NULL;
   5.125          
   5.126          ret = -ESRCH;
   5.127 -        if ( (d = get_domain_by_id(domctl->domain)) == NULL )
   5.128 +        if ( (d = rcu_lock_domain_by_id(domctl->domain)) == NULL )
   5.129              break;
   5.130  
   5.131          ret = -EINVAL;
   5.132 @@ -317,7 +317,7 @@ long arch_do_domctl(
   5.133          if ( c.data != NULL )
   5.134              xfree(c.data);
   5.135  
   5.136 -        put_domain(d);
   5.137 +        rcu_unlock_domain(d);
   5.138      }
   5.139      break;
   5.140  
   5.141 @@ -327,7 +327,7 @@ long arch_do_domctl(
   5.142          struct domain             *d;
   5.143  
   5.144          ret = -ESRCH;
   5.145 -        if ( (d = get_domain_by_id(domctl->domain)) == NULL )
   5.146 +        if ( (d = rcu_lock_domain_by_id(domctl->domain)) == NULL )
   5.147              break;
   5.148  
   5.149          ret = -EINVAL;
   5.150 @@ -369,7 +369,7 @@ long arch_do_domctl(
   5.151          if ( c.data != NULL )
   5.152              xfree(c.data);
   5.153  
   5.154 -        put_domain(d);
   5.155 +        rcu_unlock_domain(d);
   5.156      }
   5.157      break;
   5.158  
   5.159 @@ -378,7 +378,7 @@ long arch_do_domctl(
   5.160          struct domain *d;
   5.161  
   5.162          ret = -ESRCH;
   5.163 -        if ( (d = get_domain_by_id(domctl->domain)) == NULL )
   5.164 +        if ( (d = rcu_lock_domain_by_id(domctl->domain)) == NULL )
   5.165              break;
   5.166  
   5.167          switch ( domctl->u.address_size.size )
   5.168 @@ -396,7 +396,7 @@ long arch_do_domctl(
   5.169              break;
   5.170          }
   5.171  
   5.172 -        put_domain(d);
   5.173 +        rcu_unlock_domain(d);
   5.174      }
   5.175      break;
   5.176  
   5.177 @@ -405,13 +405,13 @@ long arch_do_domctl(
   5.178          struct domain *d;
   5.179  
   5.180          ret = -ESRCH;
   5.181 -        if ( (d = get_domain_by_id(domctl->domain)) == NULL )
   5.182 +        if ( (d = rcu_lock_domain_by_id(domctl->domain)) == NULL )
   5.183              break;
   5.184  
   5.185          domctl->u.address_size.size = BITS_PER_GUEST_LONG(d);
   5.186  
   5.187          ret = 0;
   5.188 -        put_domain(d);
   5.189 +        rcu_unlock_domain(d);
   5.190  
   5.191          if ( copy_to_guest(u_domctl, domctl, 1) )
   5.192              ret = -EFAULT;
     6.1 --- a/xen/arch/x86/hvm/hvm.c	Thu Mar 01 11:04:23 2007 +0000
     6.2 +++ b/xen/arch/x86/hvm/hvm.c	Thu Mar 01 11:04:45 2007 +0000
     6.3 @@ -711,7 +711,7 @@ static int hvmop_set_pci_intx_level(
     6.4      if ( (op.domain > 0) || (op.bus > 0) || (op.device > 31) || (op.intx > 3) )
     6.5          return -EINVAL;
     6.6  
     6.7 -    d = get_domain_by_id(op.domid);
     6.8 +    d = rcu_lock_domain_by_id(op.domid);
     6.9      if ( d == NULL )
    6.10          return -ESRCH;
    6.11  
    6.12 @@ -734,7 +734,7 @@ static int hvmop_set_pci_intx_level(
    6.13      }
    6.14  
    6.15   out:
    6.16 -    put_domain(d);
    6.17 +    rcu_unlock_domain(d);
    6.18      return rc;
    6.19  }
    6.20  
    6.21 @@ -754,7 +754,7 @@ static int hvmop_set_isa_irq_level(
    6.22      if ( op.isa_irq > 15 )
    6.23          return -EINVAL;
    6.24  
    6.25 -    d = get_domain_by_id(op.domid);
    6.26 +    d = rcu_lock_domain_by_id(op.domid);
    6.27      if ( d == NULL )
    6.28          return -ESRCH;
    6.29  
    6.30 @@ -777,7 +777,7 @@ static int hvmop_set_isa_irq_level(
    6.31      }
    6.32  
    6.33   out:
    6.34 -    put_domain(d);
    6.35 +    rcu_unlock_domain(d);
    6.36      return rc;
    6.37  }
    6.38  
    6.39 @@ -797,7 +797,7 @@ static int hvmop_set_pci_link_route(
    6.40      if ( (op.link > 3) || (op.isa_irq > 15) )
    6.41          return -EINVAL;
    6.42  
    6.43 -    d = get_domain_by_id(op.domid);
    6.44 +    d = rcu_lock_domain_by_id(op.domid);
    6.45      if ( d == NULL )
    6.46          return -ESRCH;
    6.47  
    6.48 @@ -809,7 +809,7 @@ static int hvmop_set_pci_link_route(
    6.49      hvm_set_pci_link_route(d, op.link, op.isa_irq);
    6.50  
    6.51   out:
    6.52 -    put_domain(d);
    6.53 +    rcu_unlock_domain(d);
    6.54      return rc;
    6.55  }
    6.56  
    6.57 @@ -842,7 +842,7 @@ long do_hvm_op(unsigned long op, XEN_GUE
    6.58          }
    6.59          else if ( IS_PRIV(current->domain) )
    6.60          {
    6.61 -            d = get_domain_by_id(a.domid);
    6.62 +            d = rcu_lock_domain_by_id(a.domid);
    6.63              if ( d == NULL )
    6.64                  return -ESRCH;
    6.65          }
    6.66 @@ -899,7 +899,7 @@ long do_hvm_op(unsigned long op, XEN_GUE
    6.67          }
    6.68  
    6.69      param_fail:
    6.70 -        put_domain(d);
    6.71 +        rcu_unlock_domain(d);
    6.72          break;
    6.73      }
    6.74  
     7.1 --- a/xen/arch/x86/mm.c	Thu Mar 01 11:04:23 2007 +0000
     7.2 +++ b/xen/arch/x86/mm.c	Thu Mar 01 11:04:45 2007 +0000
     7.3 @@ -2966,7 +2966,7 @@ long arch_memory_op(int op, XEN_GUEST_HA
     7.4          }
     7.5          else if ( !IS_PRIV(current->domain) )
     7.6              return -EPERM;
     7.7 -        else if ( (d = get_domain_by_id(xatp.domid)) == NULL )
     7.8 +        else if ( (d = rcu_lock_domain_by_id(xatp.domid)) == NULL )
     7.9              return -ESRCH;
    7.10  
    7.11          switch ( xatp.space )
    7.12 @@ -2993,7 +2993,7 @@ long arch_memory_op(int op, XEN_GUEST_HA
    7.13  
    7.14          if ( !paging_mode_translate(d) || (mfn == 0) )
    7.15          {
    7.16 -            put_domain(d);
    7.17 +            rcu_unlock_domain(d);
    7.18              return -EINVAL;
    7.19          }
    7.20  
    7.21 @@ -3021,7 +3021,7 @@ long arch_memory_op(int op, XEN_GUEST_HA
    7.22  
    7.23          UNLOCK_BIGLOCK(d);
    7.24  
    7.25 -        put_domain(d);
    7.26 +        rcu_unlock_domain(d);
    7.27  
    7.28          break;
    7.29      }
    7.30 @@ -3045,14 +3045,14 @@ long arch_memory_op(int op, XEN_GUEST_HA
    7.31          }
    7.32          else if ( !IS_PRIV(current->domain) )
    7.33              return -EPERM;
    7.34 -        else if ( (d = get_domain_by_id(fmap.domid)) == NULL )
    7.35 +        else if ( (d = rcu_lock_domain_by_id(fmap.domid)) == NULL )
    7.36              return -ESRCH;
    7.37  
    7.38          rc = copy_from_guest(&d->arch.e820[0], fmap.map.buffer,
    7.39                               fmap.map.nr_entries) ? -EFAULT : 0;
    7.40          d->arch.nr_e820 = fmap.map.nr_entries;
    7.41  
    7.42 -        put_domain(d);
    7.43 +        rcu_unlock_domain(d);
    7.44          return rc;
    7.45      }
    7.46  
     8.1 --- a/xen/common/acm_ops.c	Thu Mar 01 11:04:23 2007 +0000
     8.2 +++ b/xen/common/acm_ops.c	Thu Mar 01 11:04:45 2007 +0000
     8.3 @@ -115,7 +115,7 @@ ret_t do_acm_op(int cmd, XEN_GUEST_HANDL
     8.4              ssidref = getssid.id.ssidref;
     8.5          else if (getssid.get_ssid_by == ACM_GETBY_domainid)
     8.6          {
     8.7 -            struct domain *subj = get_domain_by_id(getssid.id.domainid);
     8.8 +            struct domain *subj = rcu_lock_domain_by_id(getssid.id.domainid);
     8.9              if (!subj)
    8.10              {
    8.11                  rc = -ESRCH; /* domain not found */
    8.12 @@ -123,12 +123,12 @@ ret_t do_acm_op(int cmd, XEN_GUEST_HANDL
    8.13              }
    8.14              if (subj->ssid == NULL)
    8.15              {
    8.16 -                put_domain(subj);
    8.17 +                rcu_unlock_domain(subj);
    8.18                  rc = -ESRCH;
    8.19                  break;
    8.20              }
    8.21              ssidref = ((struct acm_ssid_domain *)(subj->ssid))->ssidref;
    8.22 -            put_domain(subj);
    8.23 +            rcu_unlock_domain(subj);
    8.24          }
    8.25          else
    8.26          {
    8.27 @@ -152,7 +152,7 @@ ret_t do_acm_op(int cmd, XEN_GUEST_HANDL
    8.28              ssidref1 = getdecision.id1.ssidref;
    8.29          else if (getdecision.get_decision_by1 == ACM_GETBY_domainid)
    8.30          {
    8.31 -            struct domain *subj = get_domain_by_id(getdecision.id1.domainid);
    8.32 +            struct domain *subj = rcu_lock_domain_by_id(getdecision.id1.domainid);
    8.33              if (!subj)
    8.34              {
    8.35                  rc = -ESRCH; /* domain not found */
    8.36 @@ -160,12 +160,12 @@ ret_t do_acm_op(int cmd, XEN_GUEST_HANDL
    8.37              }
    8.38              if (subj->ssid == NULL)
    8.39              {
    8.40 -                put_domain(subj);
    8.41 +                rcu_unlock_domain(subj);
    8.42                  rc = -ESRCH;
    8.43                  break;
    8.44              }
    8.45              ssidref1 = ((struct acm_ssid_domain *)(subj->ssid))->ssidref;
    8.46 -            put_domain(subj);
    8.47 +            rcu_unlock_domain(subj);
    8.48          }
    8.49          else
    8.50          {
    8.51 @@ -176,7 +176,7 @@ ret_t do_acm_op(int cmd, XEN_GUEST_HANDL
    8.52              ssidref2 = getdecision.id2.ssidref;
    8.53          else if (getdecision.get_decision_by2 == ACM_GETBY_domainid)
    8.54          {
    8.55 -            struct domain *subj = get_domain_by_id(getdecision.id2.domainid);
    8.56 +            struct domain *subj = rcu_lock_domain_by_id(getdecision.id2.domainid);
    8.57              if (!subj)
    8.58              {
    8.59                  rc = -ESRCH; /* domain not found */
    8.60 @@ -184,12 +184,12 @@ ret_t do_acm_op(int cmd, XEN_GUEST_HANDL
    8.61              }
    8.62              if (subj->ssid == NULL)
    8.63              {
    8.64 -                put_domain(subj);
    8.65 +                rcu_unlock_domain(subj);
    8.66                  rc = -ESRCH;
    8.67                  break;
    8.68              }
    8.69              ssidref2 = ((struct acm_ssid_domain *)(subj->ssid))->ssidref;
    8.70 -            put_domain(subj);
    8.71 +            rcu_unlock_domain(subj);
    8.72          }
    8.73          else
    8.74          {
     9.1 --- a/xen/common/domain.c	Thu Mar 01 11:04:23 2007 +0000
     9.2 +++ b/xen/common/domain.c	Thu Mar 01 11:04:45 2007 +0000
     9.3 @@ -236,7 +236,7 @@ struct domain *get_domain_by_id(domid_t 
     9.4  }
     9.5  
     9.6  
     9.7 -struct domain *find_domain_rcu_lock(domid_t dom)
     9.8 +struct domain *rcu_lock_domain_by_id(domid_t dom)
     9.9  {
    9.10      struct domain *d;
    9.11  
    10.1 --- a/xen/common/domctl.c	Thu Mar 01 11:04:23 2007 +0000
    10.2 +++ b/xen/common/domctl.c	Thu Mar 01 11:04:45 2007 +0000
    10.3 @@ -74,10 +74,10 @@ static inline int is_free_domid(domid_t 
    10.4      if ( dom >= DOMID_FIRST_RESERVED )
    10.5          return 0;
    10.6  
    10.7 -    if ( (d = get_domain_by_id(dom)) == NULL )
    10.8 +    if ( (d = rcu_lock_domain_by_id(dom)) == NULL )
    10.9          return 1;
   10.10  
   10.11 -    put_domain(d);
   10.12 +    rcu_unlock_domain(d);
   10.13      return 0;
   10.14  }
   10.15  
   10.16 @@ -197,7 +197,7 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
   10.17  
   10.18      case XEN_DOMCTL_setvcpucontext:
   10.19      {
   10.20 -        struct domain *d = get_domain_by_id(op->domain);
   10.21 +        struct domain *d = rcu_lock_domain_by_id(op->domain);
   10.22          vcpu_guest_context_u c = { .nat = NULL };
   10.23          unsigned int vcpu = op->u.vcpucontext.vcpu;
   10.24          struct vcpu *v;
   10.25 @@ -243,13 +243,13 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
   10.26  
   10.27      svc_out:
   10.28          xfree(c.nat);
   10.29 -        put_domain(d);
   10.30 +        rcu_unlock_domain(d);
   10.31      }
   10.32      break;
   10.33  
   10.34      case XEN_DOMCTL_pausedomain:
   10.35      {
   10.36 -        struct domain *d = get_domain_by_id(op->domain);
   10.37 +        struct domain *d = rcu_lock_domain_by_id(op->domain);
   10.38          ret = -ESRCH;
   10.39          if ( d != NULL )
   10.40          {
   10.41 @@ -259,14 +259,14 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
   10.42                  domain_pause_by_systemcontroller(d);
   10.43                  ret = 0;
   10.44              }
   10.45 -            put_domain(d);
   10.46 +            rcu_unlock_domain(d);
   10.47          }
   10.48      }
   10.49      break;
   10.50  
   10.51      case XEN_DOMCTL_unpausedomain:
   10.52      {
   10.53 -        struct domain *d = get_domain_by_id(op->domain);
   10.54 +        struct domain *d = rcu_lock_domain_by_id(op->domain);
   10.55          ret = -ESRCH;
   10.56          if ( d != NULL )
   10.57          {
   10.58 @@ -277,14 +277,14 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
   10.59                  domain_unpause_by_systemcontroller(d);
   10.60                  ret = 0;
   10.61              }
   10.62 -            put_domain(d);
   10.63 +            rcu_unlock_domain(d);
   10.64          }
   10.65      }
   10.66      break;
   10.67  
   10.68      case XEN_DOMCTL_resumedomain:
   10.69      {
   10.70 -        struct domain *d = get_domain_by_id(op->domain);
   10.71 +        struct domain *d = rcu_lock_domain_by_id(op->domain);
   10.72          struct vcpu *v;
   10.73  
   10.74          ret = -ESRCH;
   10.75 @@ -294,7 +294,7 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
   10.76              if ( test_and_clear_bit(_DOMF_shutdown, &d->domain_flags) )
   10.77                  for_each_vcpu ( d, v )
   10.78                      vcpu_wake(v);
   10.79 -            put_domain(d);
   10.80 +            rcu_unlock_domain(d);
   10.81          }
   10.82      }
   10.83      break;
   10.84 @@ -363,7 +363,7 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
   10.85              break;
   10.86  
   10.87          ret = -ESRCH;
   10.88 -        if ( (d = get_domain_by_id(op->domain)) == NULL )
   10.89 +        if ( (d = rcu_lock_domain_by_id(op->domain)) == NULL )
   10.90              break;
   10.91  
   10.92          /* Needed, for example, to ensure writable p.t. state is synced. */
   10.93 @@ -392,13 +392,13 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
   10.94  
   10.95      maxvcpu_out:
   10.96          domain_unpause(d);
   10.97 -        put_domain(d);
   10.98 +        rcu_unlock_domain(d);
   10.99      }
  10.100      break;
  10.101  
  10.102      case XEN_DOMCTL_destroydomain:
  10.103      {
  10.104 -        struct domain *d = get_domain_by_id(op->domain);
  10.105 +        struct domain *d = rcu_lock_domain_by_id(op->domain);
  10.106          ret = -ESRCH;
  10.107          if ( d != NULL )
  10.108          {
  10.109 @@ -408,7 +408,7 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
  10.110                  domain_kill(d);
  10.111                  ret = 0;
  10.112              }
  10.113 -            put_domain(d);
  10.114 +            rcu_unlock_domain(d);
  10.115          }
  10.116      }
  10.117      break;
  10.118 @@ -417,7 +417,7 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
  10.119      case XEN_DOMCTL_getvcpuaffinity:
  10.120      {
  10.121          domid_t dom = op->domain;
  10.122 -        struct domain *d = get_domain_by_id(dom);
  10.123 +        struct domain *d = rcu_lock_domain_by_id(dom);
  10.124          struct vcpu *v;
  10.125          cpumask_t new_affinity;
  10.126  
  10.127 @@ -447,7 +447,7 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
  10.128          }
  10.129  
  10.130      vcpuaffinity_out:
  10.131 -        put_domain(d);
  10.132 +        rcu_unlock_domain(d);
  10.133      }
  10.134      break;
  10.135  
  10.136 @@ -456,14 +456,14 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
  10.137          struct domain *d;
  10.138  
  10.139          ret = -ESRCH;
  10.140 -        if ( (d = get_domain_by_id(op->domain)) == NULL )
  10.141 +        if ( (d = rcu_lock_domain_by_id(op->domain)) == NULL )
  10.142              break;
  10.143  
  10.144          ret = sched_adjust(d, &op->u.scheduler_op);
  10.145          if ( copy_to_guest(u_domctl, op, 1) )
  10.146              ret = -EFAULT;
  10.147  
  10.148 -        put_domain(d);
  10.149 +        rcu_unlock_domain(d);
  10.150      }
  10.151      break;
  10.152  
  10.153 @@ -510,7 +510,7 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
  10.154          struct vcpu         *v;
  10.155  
  10.156          ret = -ESRCH;
  10.157 -        if ( (d = get_domain_by_id(op->domain)) == NULL )
  10.158 +        if ( (d = rcu_lock_domain_by_id(op->domain)) == NULL )
  10.159              break;
  10.160  
  10.161          ret = -EINVAL;
  10.162 @@ -555,7 +555,7 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
  10.163  
  10.164      getvcpucontext_out:
  10.165          xfree(c.nat);
  10.166 -        put_domain(d);
  10.167 +        rcu_unlock_domain(d);
  10.168      }
  10.169      break;
  10.170  
  10.171 @@ -566,7 +566,7 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
  10.172          struct vcpu_runstate_info runstate;
  10.173  
  10.174          ret = -ESRCH;
  10.175 -        if ( (d = get_domain_by_id(op->domain)) == NULL )
  10.176 +        if ( (d = rcu_lock_domain_by_id(op->domain)) == NULL )
  10.177              break;
  10.178  
  10.179          ret = -EINVAL;
  10.180 @@ -590,7 +590,7 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
  10.181              ret = -EFAULT;
  10.182  
  10.183      getvcpuinfo_out:
  10.184 -        put_domain(d);
  10.185 +        rcu_unlock_domain(d);
  10.186      }
  10.187      break;
  10.188  
  10.189 @@ -600,7 +600,7 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
  10.190          unsigned long new_max;
  10.191  
  10.192          ret = -ESRCH;
  10.193 -        d = get_domain_by_id(op->domain);
  10.194 +        d = rcu_lock_domain_by_id(op->domain);
  10.195          if ( d == NULL )
  10.196              break;
  10.197  
  10.198 @@ -615,7 +615,7 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
  10.199          }
  10.200          spin_unlock(&d->page_alloc_lock);
  10.201  
  10.202 -        put_domain(d);
  10.203 +        rcu_unlock_domain(d);
  10.204      }
  10.205      break;
  10.206  
  10.207 @@ -623,12 +623,12 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
  10.208      {
  10.209          struct domain *d;
  10.210          ret = -ESRCH;
  10.211 -        d = get_domain_by_id(op->domain);
  10.212 +        d = rcu_lock_domain_by_id(op->domain);
  10.213          if ( d != NULL )
  10.214          {
  10.215              memcpy(d->handle, op->u.setdomainhandle.handle,
  10.216                     sizeof(xen_domain_handle_t));
  10.217 -            put_domain(d);
  10.218 +            rcu_unlock_domain(d);
  10.219              ret = 0;
  10.220          }
  10.221      }
  10.222 @@ -638,14 +638,14 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
  10.223      {
  10.224          struct domain *d;
  10.225          ret = -ESRCH;
  10.226 -        d = get_domain_by_id(op->domain);
  10.227 +        d = rcu_lock_domain_by_id(op->domain);
  10.228          if ( d != NULL )
  10.229          {
  10.230              if ( op->u.setdebugging.enable )
  10.231                  set_bit(_DOMF_debugging, &d->domain_flags);
  10.232              else
  10.233                  clear_bit(_DOMF_debugging, &d->domain_flags);
  10.234 -            put_domain(d);
  10.235 +            rcu_unlock_domain(d);
  10.236              ret = 0;
  10.237          }
  10.238      }
  10.239 @@ -661,7 +661,7 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
  10.240              break;
  10.241  
  10.242          ret = -ESRCH;
  10.243 -        d = get_domain_by_id(op->domain);
  10.244 +        d = rcu_lock_domain_by_id(op->domain);
  10.245          if ( d == NULL )
  10.246              break;
  10.247  
  10.248 @@ -670,7 +670,7 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
  10.249          else
  10.250              ret = irq_deny_access(d, pirq);
  10.251  
  10.252 -        put_domain(d);
  10.253 +        rcu_unlock_domain(d);
  10.254      }
  10.255      break;
  10.256  
  10.257 @@ -685,7 +685,7 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
  10.258              break;
  10.259  
  10.260          ret = -ESRCH;
  10.261 -        d = get_domain_by_id(op->domain);
  10.262 +        d = rcu_lock_domain_by_id(op->domain);
  10.263          if ( d == NULL )
  10.264              break;
  10.265  
  10.266 @@ -694,7 +694,7 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
  10.267          else
  10.268              ret = iomem_deny_access(d, mfn, mfn + nr_mfns - 1);
  10.269  
  10.270 -        put_domain(d);
  10.271 +        rcu_unlock_domain(d);
  10.272      }
  10.273      break;
  10.274  
  10.275 @@ -703,11 +703,11 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
  10.276          struct domain *d;
  10.277  
  10.278          ret = -ESRCH;
  10.279 -        d = get_domain_by_id(op->domain);
  10.280 +        d = rcu_lock_domain_by_id(op->domain);
  10.281          if ( d != NULL )
  10.282          {
  10.283              d->time_offset_seconds = op->u.settimeoffset.time_offset_seconds;
  10.284 -            put_domain(d);
  10.285 +            rcu_unlock_domain(d);
  10.286              ret = 0;
  10.287          }
  10.288      }
    11.1 --- a/xen/common/event_channel.c	Thu Mar 01 11:04:23 2007 +0000
    11.2 +++ b/xen/common/event_channel.c	Thu Mar 01 11:04:45 2007 +0000
    11.3 @@ -112,7 +112,7 @@ static long evtchn_alloc_unbound(evtchn_
    11.4      else if ( !IS_PRIV(current->domain) )
    11.5          return -EPERM;
    11.6  
    11.7 -    if ( (d = get_domain_by_id(dom)) == NULL )
    11.8 +    if ( (d = rcu_lock_domain_by_id(dom)) == NULL )
    11.9          return -ESRCH;
   11.10  
   11.11      spin_lock(&d->evtchn_lock);
   11.12 @@ -130,7 +130,7 @@ static long evtchn_alloc_unbound(evtchn_
   11.13   out:
   11.14      spin_unlock(&d->evtchn_lock);
   11.15  
   11.16 -    put_domain(d);
   11.17 +    rcu_unlock_domain(d);
   11.18  
   11.19      return rc;
   11.20  }
   11.21 @@ -150,7 +150,7 @@ static long evtchn_bind_interdomain(evtc
   11.22      if ( rdom == DOMID_SELF )
   11.23          rdom = current->domain->domain_id;
   11.24  
   11.25 -    if ( (rd = get_domain_by_id(rdom)) == NULL )
   11.26 +    if ( (rd = rcu_lock_domain_by_id(rdom)) == NULL )
   11.27          return -ESRCH;
   11.28  
   11.29      /* Avoid deadlock by first acquiring lock of domain with smaller id. */
   11.30 @@ -198,7 +198,7 @@ static long evtchn_bind_interdomain(evtc
   11.31      if ( ld != rd )
   11.32          spin_unlock(&rd->evtchn_lock);
   11.33      
   11.34 -    put_domain(rd);
   11.35 +    rcu_unlock_domain(rd);
   11.36  
   11.37      return rc;
   11.38  }
   11.39 @@ -598,7 +598,7 @@ static long evtchn_status(evtchn_status_
   11.40      else if ( !IS_PRIV(current->domain) )
   11.41          return -EPERM;
   11.42  
   11.43 -    if ( (d = get_domain_by_id(dom)) == NULL )
   11.44 +    if ( (d = rcu_lock_domain_by_id(dom)) == NULL )
   11.45          return -ESRCH;
   11.46  
   11.47      spin_lock(&d->evtchn_lock);
   11.48 @@ -645,7 +645,7 @@ static long evtchn_status(evtchn_status_
   11.49  
   11.50   out:
   11.51      spin_unlock(&d->evtchn_lock);
   11.52 -    put_domain(d);
   11.53 +    rcu_unlock_domain(d);
   11.54      return rc;
   11.55  }
   11.56  
   11.57 @@ -746,13 +746,13 @@ static long evtchn_reset(evtchn_reset_t 
   11.58      else if ( !IS_PRIV(current->domain) )
   11.59          return -EPERM;
   11.60  
   11.61 -    if ( (d = get_domain_by_id(dom)) == NULL )
   11.62 +    if ( (d = rcu_lock_domain_by_id(dom)) == NULL )
   11.63          return -ESRCH;
   11.64  
   11.65      for ( i = 0; port_is_valid(d, i); i++ )
   11.66          (void)__evtchn_close(d, i);
   11.67  
   11.68 -    put_domain(d);
   11.69 +    rcu_unlock_domain(d);
   11.70  
   11.71      return 0;
   11.72  }
    12.1 --- a/xen/common/grant_table.c	Thu Mar 01 11:04:23 2007 +0000
    12.2 +++ b/xen/common/grant_table.c	Thu Mar 01 11:04:45 2007 +0000
    12.3 @@ -227,10 +227,8 @@ static void
    12.4          return;
    12.5      }
    12.6  
    12.7 -    if ( unlikely((rd = get_domain_by_id(op->dom)) == NULL) )
    12.8 +    if ( unlikely((rd = rcu_lock_domain_by_id(op->dom)) == NULL) )
    12.9      {
   12.10 -        if ( rd != NULL )
   12.11 -            put_domain(rd);
   12.12          gdprintk(XENLOG_INFO, "Could not find domain %d\n", op->dom);
   12.13          op->status = GNTST_bad_domain;
   12.14          return;
   12.15 @@ -238,7 +236,7 @@ static void
   12.16  
   12.17      if ( unlikely((handle = get_maptrack_handle(ld->grant_table)) == -1) )
   12.18      {
   12.19 -        put_domain(rd);
   12.20 +        rcu_unlock_domain(rd);
   12.21          gdprintk(XENLOG_INFO, "Failed to obtain maptrack handle.\n");
   12.22          op->status = GNTST_no_device_space;
   12.23          return;
   12.24 @@ -368,7 +366,7 @@ static void
   12.25      op->handle       = handle;
   12.26      op->status       = GNTST_okay;
   12.27  
   12.28 -    put_domain(rd);
   12.29 +    rcu_unlock_domain(rd);
   12.30      return;
   12.31  
   12.32   undo_out:
   12.33 @@ -395,7 +393,7 @@ static void
   12.34      spin_unlock(&rd->grant_table->lock);
   12.35      op->status = rc;
   12.36      put_maptrack_handle(ld->grant_table, handle);
   12.37 -    put_domain(rd);
   12.38 +    rcu_unlock_domain(rd);
   12.39  }
   12.40  
   12.41  static long
   12.42 @@ -455,7 +453,7 @@ static void
   12.43      ref   = map->ref;
   12.44      flags = map->flags;
   12.45  
   12.46 -    if ( unlikely((rd = get_domain_by_id(dom)) == NULL) )
   12.47 +    if ( unlikely((rd = rcu_lock_domain_by_id(dom)) == NULL) )
   12.48      {
   12.49          /* This can happen when a grant is implicitly unmapped. */
   12.50          gdprintk(XENLOG_INFO, "Could not find domain %d\n", dom);
   12.51 @@ -536,7 +534,7 @@ static void
   12.52   unmap_out:
   12.53      op->status = rc;
   12.54      spin_unlock(&rd->grant_table->lock);
   12.55 -    put_domain(rd);
   12.56 +    rcu_unlock_domain(rd);
   12.57  }
   12.58  
   12.59  static long
   12.60 @@ -658,7 +656,7 @@ gnttab_setup_table(
   12.61          goto out;
   12.62      }
   12.63  
   12.64 -    if ( unlikely((d = get_domain_by_id(dom)) == NULL) )
   12.65 +    if ( unlikely((d = rcu_lock_domain_by_id(dom)) == NULL) )
   12.66      {
   12.67          gdprintk(XENLOG_INFO, "Bad domid %d.\n", dom);
   12.68          op.status = GNTST_bad_domain;
   12.69 @@ -689,7 +687,7 @@ gnttab_setup_table(
   12.70   setup_unlock_out:
   12.71      spin_unlock(&d->grant_table->lock);
   12.72  
   12.73 -    put_domain(d);
   12.74 +    rcu_unlock_domain(d);
   12.75  
   12.76   out:
   12.77      if ( unlikely(copy_to_guest(uop, &op, 1)) )
   12.78 @@ -726,7 +724,7 @@ gnttab_query_size(
   12.79          goto query_out;
   12.80      }
   12.81  
   12.82 -    if ( unlikely((d = get_domain_by_id(dom)) == NULL) )
   12.83 +    if ( unlikely((d = rcu_lock_domain_by_id(dom)) == NULL) )
   12.84      {
   12.85          gdprintk(XENLOG_INFO, "Bad domid %d.\n", dom);
   12.86          op.status = GNTST_bad_domain;
   12.87 @@ -741,7 +739,7 @@ gnttab_query_size(
   12.88  
   12.89      spin_unlock(&d->grant_table->lock);
   12.90  
   12.91 -    put_domain(d);
   12.92 +    rcu_unlock_domain(d);
   12.93  
   12.94   query_out:
   12.95      if ( unlikely(copy_to_guest(uop, &op, 1)) )
   12.96 @@ -869,7 +867,7 @@ gnttab_transfer(
   12.97          }
   12.98  
   12.99          /* Find the target domain. */
  12.100 -        if ( unlikely((e = get_domain_by_id(gop.domid)) == NULL) )
  12.101 +        if ( unlikely((e = rcu_lock_domain_by_id(gop.domid)) == NULL) )
  12.102          {
  12.103              gdprintk(XENLOG_INFO, "gnttab_transfer: can't find domain %d\n",
  12.104                      gop.domid);
  12.105 @@ -897,7 +895,7 @@ gnttab_transfer(
  12.106                          "or is dying (%lx)\n",
  12.107                          e->tot_pages, e->max_pages, gop.ref, e->domain_flags);
  12.108              spin_unlock(&e->page_alloc_lock);
  12.109 -            put_domain(e);
  12.110 +            rcu_unlock_domain(e);
  12.111              page->count_info &= ~(PGC_count_mask|PGC_allocated);
  12.112              free_domheap_page(page);
  12.113              gop.status = GNTST_general_error;
  12.114 @@ -925,7 +923,7 @@ gnttab_transfer(
  12.115  
  12.116          spin_unlock(&e->grant_table->lock);
  12.117  
  12.118 -        put_domain(e);
  12.119 +        rcu_unlock_domain(e);
  12.120  
  12.121          gop.status = GNTST_okay;
  12.122  
  12.123 @@ -1092,7 +1090,7 @@ static void
  12.124          sd = current->domain;
  12.125          get_knownalive_domain(sd);
  12.126      }
  12.127 -    else if ( (sd = get_domain_by_id(op->source.domid)) == NULL )
  12.128 +    else if ( (sd = rcu_lock_domain_by_id(op->source.domid)) == NULL )
  12.129      {
  12.130          PIN_FAIL(error_out, GNTST_bad_domain,
  12.131                   "couldn't find %d\n", op->source.domid);
  12.132 @@ -1103,7 +1101,7 @@ static void
  12.133          dd = current->domain;
  12.134          get_knownalive_domain(dd);
  12.135      }
  12.136 -    else if ( (dd = get_domain_by_id(op->dest.domid)) == NULL )
  12.137 +    else if ( (dd = rcu_lock_domain_by_id(op->dest.domid)) == NULL )
  12.138      {
  12.139          PIN_FAIL(error_out, GNTST_bad_domain,
  12.140                   "couldn't find %d\n", op->dest.domid);
  12.141 @@ -1173,9 +1171,9 @@ static void
  12.142      if ( have_d_grant )
  12.143          __release_grant_for_copy(dd, op->dest.u.ref, 0);
  12.144      if ( sd )
  12.145 -        put_domain(sd);
  12.146 +        rcu_unlock_domain(sd);
  12.147      if ( dd )
  12.148 -        put_domain(dd);
  12.149 +        rcu_unlock_domain(dd);
  12.150      op->status = rc;
  12.151  }
  12.152  
  12.153 @@ -1397,7 +1395,7 @@ gnttab_release_mappings(
  12.154                  "flags:(%x) dom:(%hu)\n",
  12.155                  handle, ref, map->flags, map->domid);
  12.156  
  12.157 -        rd = get_domain_by_id(map->domid);
  12.158 +        rd = rcu_lock_domain_by_id(map->domid);
  12.159          if ( rd == NULL )
  12.160          {
  12.161              /* Nothing to clear up... */
  12.162 @@ -1453,7 +1451,7 @@ gnttab_release_mappings(
  12.163  
  12.164          spin_unlock(&rd->grant_table->lock);
  12.165  
  12.166 -        put_domain(rd);
  12.167 +        rcu_unlock_domain(rd);
  12.168  
  12.169          map->flags = 0;
  12.170      }
    13.1 --- a/xen/common/memory.c	Thu Mar 01 11:04:23 2007 +0000
    13.2 +++ b/xen/common/memory.c	Thu Mar 01 11:04:45 2007 +0000
    13.3 @@ -244,12 +244,12 @@ static long translate_gpfn_list(
    13.4      else if ( !IS_PRIV(current->domain) )
    13.5          return -EPERM;
    13.6  
    13.7 -    if ( (d = get_domain_by_id(op.domid)) == NULL )
    13.8 +    if ( (d = rcu_lock_domain_by_id(op.domid)) == NULL )
    13.9          return -ESRCH;
   13.10  
   13.11      if ( !shadow_mode_translate(d) )
   13.12      {
   13.13 -        put_domain(d);
   13.14 +        rcu_unlock_domain(d);
   13.15          return -EINVAL;
   13.16      }
   13.17  
   13.18 @@ -257,14 +257,14 @@ static long translate_gpfn_list(
   13.19      {
   13.20          if ( hypercall_preempt_check() )
   13.21          {
   13.22 -            put_domain(d);
   13.23 +            rcu_unlock_domain(d);
   13.24              *progress = i;
   13.25              return -EAGAIN;
   13.26          }
   13.27  
   13.28          if ( unlikely(__copy_from_guest_offset(&gpfn, op.gpfn_list, i, 1)) )
   13.29          {
   13.30 -            put_domain(d);
   13.31 +            rcu_unlock_domain(d);
   13.32              return -EFAULT;
   13.33          }
   13.34  
   13.35 @@ -272,12 +272,12 @@ static long translate_gpfn_list(
   13.36  
   13.37          if ( unlikely(__copy_to_guest_offset(op.mfn_list, i, &mfn, 1)) )
   13.38          {
   13.39 -            put_domain(d);
   13.40 +            rcu_unlock_domain(d);
   13.41              return -EFAULT;
   13.42          }
   13.43      }
   13.44  
   13.45 -    put_domain(d);
   13.46 +    rcu_unlock_domain(d);
   13.47      return 0;
   13.48  }
   13.49  
   13.50 @@ -545,7 +545,7 @@ long do_memory_op(unsigned long cmd, XEN
   13.51          if ( likely(reservation.domid == DOMID_SELF) )
   13.52              d = current->domain;
   13.53          else if ( !IS_PRIV(current->domain) ||
   13.54 -                  ((d = get_domain_by_id(reservation.domid)) == NULL) )
   13.55 +                  ((d = rcu_lock_domain_by_id(reservation.domid)) == NULL) )
   13.56              return start_extent;
   13.57          args.domain = d;
   13.58  
   13.59 @@ -563,7 +563,7 @@ long do_memory_op(unsigned long cmd, XEN
   13.60          }
   13.61  
   13.62          if ( unlikely(reservation.domid != DOMID_SELF) )
   13.63 -            put_domain(d);
   13.64 +            rcu_unlock_domain(d);
   13.65  
   13.66          rc = args.nr_done;
   13.67  
   13.68 @@ -591,13 +591,13 @@ long do_memory_op(unsigned long cmd, XEN
   13.69              d = current->domain;
   13.70          else if ( !IS_PRIV(current->domain) )
   13.71              return -EPERM;
   13.72 -        else if ( (d = get_domain_by_id(domid)) == NULL )
   13.73 +        else if ( (d = rcu_lock_domain_by_id(domid)) == NULL )
   13.74              return -ESRCH;
   13.75  
   13.76          rc = (op == XENMEM_current_reservation) ? d->tot_pages : d->max_pages;
   13.77  
   13.78          if ( unlikely(domid != DOMID_SELF) )
   13.79 -            put_domain(d);
   13.80 +            rcu_unlock_domain(d);
   13.81  
   13.82          break;
   13.83  
    14.1 --- a/xen/include/acm/acm_hooks.h	Thu Mar 01 11:04:23 2007 +0000
    14.2 +++ b/xen/include/acm/acm_hooks.h	Thu Mar 01 11:04:45 2007 +0000
    14.3 @@ -241,18 +241,18 @@ static inline int acm_pre_domctl(struct 
    14.4                      __func__);
    14.5              return -EACCES;
    14.6          }
    14.7 -        d = get_domain_by_id(op->domain);
    14.8 +        d = rcu_lock_domain_by_id(op->domain);
    14.9          if (d != NULL) {
   14.10              *ssid = d->ssid; /* save for post destroy when d is gone */
   14.11              if (*ssid == NULL) {
   14.12                  printk("%s: Warning. Destroying domain without ssid pointer.\n", 
   14.13                         __func__);
   14.14 -                put_domain(d);
   14.15 +                domain_rcu_lock(d);
   14.16                  return -EACCES;
   14.17              }
   14.18              d->ssid = NULL; /* make sure it's not used any more */
   14.19               /* no policy-specific hook */
   14.20 -            put_domain(d);
   14.21 +            domain_rcu_lock(d);
   14.22              ret = 0;
   14.23          }
   14.24          break;
    15.1 --- a/xen/include/xen/sched.h	Thu Mar 01 11:04:23 2007 +0000
    15.2 +++ b/xen/include/xen/sched.h	Thu Mar 01 11:04:45 2007 +0000
    15.3 @@ -270,16 +270,16 @@ int construct_dom0(
    15.4      char *cmdline);
    15.5  
    15.6  /*
    15.7 - * find_domain_rcu_lock() is more efficient than get_domain_by_id().
    15.8 + * rcu_lock_domain_by_id() is more efficient than get_domain_by_id().
    15.9   * This is the preferred function if the returned domain reference
   15.10   * is short lived,  but it cannot be used if the domain reference needs 
   15.11   * to be kept beyond the current scope (e.g., across a softirq).
   15.12 - * The returned domain reference must be discarded using domain_rcu_unlock().
   15.13 + * The returned domain reference must be discarded using rcu_unlock_domain().
   15.14   */
   15.15 -struct domain *find_domain_rcu_lock(domid_t dom);
   15.16 +struct domain *rcu_lock_domain_by_id(domid_t dom);
   15.17  
   15.18 -/* Finish a RCU critical region started by find_domain_rcu_lock(). */
   15.19 -static inline void domain_rcu_unlock(struct domain *d)
   15.20 +/* Finish a RCU critical region started by rcu_lock_domain_by_id(). */
   15.21 +static inline void rcu_unlock_domain(struct domain *d)
   15.22  {
   15.23      rcu_read_unlock(&domlist_read_lock);
   15.24  }