if ( (op.domain > 0) || (op.bus > 0) || (op.device > 31) || (op.intx > 3) )
return -EINVAL;
- rc = rcu_lock_remote_target_domain_by_id(op.domid, &d);
+ rc = rcu_lock_remote_domain_by_id(op.domid, &d);
if ( rc != 0 )
return rc;
if ( op.isa_irq > 15 )
return -EINVAL;
- rc = rcu_lock_remote_target_domain_by_id(op.domid, &d);
+ rc = rcu_lock_remote_domain_by_id(op.domid, &d);
if ( rc != 0 )
return rc;
if ( (op.link > 3) || (op.isa_irq > 15) )
return -EINVAL;
- rc = rcu_lock_remote_target_domain_by_id(op.domid, &d);
+ rc = rcu_lock_remote_domain_by_id(op.domid, &d);
if ( rc != 0 )
return rc;
if ( copy_from_guest(&op, uop, 1) )
return -EFAULT;
- rc = rcu_lock_remote_target_domain_by_id(op.domid, &d);
+ rc = rcu_lock_remote_domain_by_id(op.domid, &d);
if ( rc != 0 )
return rc;
if ( a.index >= HVM_NR_PARAMS )
return -EINVAL;
- rc = rcu_lock_target_domain_by_id(a.domid, &d);
- if ( rc != 0 )
- return rc;
+ d = rcu_lock_domain_by_any_id(a.domid);
+ if ( d == NULL )
+ return -ESRCH;
rc = -EINVAL;
if ( !is_hvm_domain(d) )
if ( copy_from_guest(&a, arg, 1) )
return -EFAULT;
- rc = rcu_lock_remote_target_domain_by_id(a.domid, &d);
+ rc = rcu_lock_remote_domain_by_id(a.domid, &d);
if ( rc != 0 )
return rc;
if ( copy_from_guest(&a, arg, 1) )
return -EFAULT;
- rc = rcu_lock_remote_target_domain_by_id(a.domid, &d);
+ rc = rcu_lock_remote_domain_by_id(a.domid, &d);
if ( rc != 0 )
return rc;
if ( copy_from_guest(&a, arg, 1) )
return -EFAULT;
- rc = rcu_lock_target_domain_by_id(a.domid, &d);
- if ( rc != 0 )
- return rc;
+ d = rcu_lock_domain_by_any_id(a.domid);
+ if ( d == NULL )
+ return -ESRCH;
rc = xsm_hvm_param(d, op);
if ( rc )
if ( copy_from_guest(&a, arg, 1) )
return -EFAULT;
- rc = rcu_lock_remote_target_domain_by_id(a.domid, &d);
+ rc = rcu_lock_remote_domain_by_id(a.domid, &d);
if ( rc != 0 )
return rc;
if ( copy_from_guest(&a, arg, 1) )
return -EFAULT;
- rc = rcu_lock_remote_target_domain_by_id(a.domid, &d);
+ rc = rcu_lock_remote_domain_by_id(a.domid, &d);
if ( rc != 0 )
return rc;
if ( copy_from_guest(&a, arg, 1) )
return -EFAULT;
- rc = rcu_lock_remote_target_domain_by_id(a.domid, &d);
+ rc = rcu_lock_remote_domain_by_id(a.domid, &d);
if ( rc != 0 )
return rc;
if ( copy_from_guest(&a, arg, 1) )
return -EFAULT;
- rc = rcu_lock_target_domain_by_id(a.domid, &d);
- if ( rc != 0 )
- return rc;
+ d = rcu_lock_domain_by_any_id(a.domid);
+ if ( d == NULL )
+ return -ESRCH;
rc = -EINVAL;
if ( !is_hvm_domain(d) || !paging_mode_shadow(d) )
if ( copy_from_guest(&tr, arg, 1 ) )
return -EFAULT;
- rc = rcu_lock_remote_target_domain_by_id(tr.domid, &d);
+ rc = rcu_lock_remote_domain_by_id(tr.domid, &d);
if ( rc != 0 )
return rc;
if ( copy_from_guest(&xatp, arg, 1) )
return -EFAULT;
- rc = rcu_lock_target_domain_by_id(xatp.domid, &d);
- if ( rc != 0 )
- return rc;
+ d = rcu_lock_domain_by_any_id(xatp.domid);
+ if ( d == NULL )
+ return -ESRCH;
if ( xsm_add_to_physmap(current->domain, d) )
{
if ( fmap.map.nr_entries > E820MAX )
return -EINVAL;
- rc = rcu_lock_target_domain_by_id(fmap.domid, &d);
- if ( rc != 0 )
- return rc;
+ d = rcu_lock_domain_by_any_id(fmap.domid);
+ if ( d == NULL )
+ return -ESRCH;
rc = xsm_domain_memory_map(d);
if ( rc )
struct domain *d;
struct p2m_domain *p2m;
- /* Support DOMID_SELF? */
- if ( !IS_PRIV(current->domain) )
- return -EPERM;
-
if ( copy_from_guest(&target, arg, 1) )
return -EFAULT;
- rc = rcu_lock_target_domain_by_id(target.domid, &d);
- if ( rc != 0 )
- return rc;
+ d = rcu_lock_domain_by_any_id(target.domid);
+ if ( d == NULL )
+ return -ESRCH;
if ( op == XENMEM_set_pod_target )
rc = xsm_set_pod_target(d);
domid_t dom = alloc->dom;
long rc;
- rc = rcu_lock_target_domain_by_id(dom, &d);
- if ( rc )
- return rc;
+ d = rcu_lock_domain_by_any_id(dom);
+ if ( d == NULL )
+ return -ESRCH;
spin_lock(&d->event_lock);
struct evtchn *chn;
long rc = 0;
- rc = rcu_lock_target_domain_by_id(dom, &d);
- if ( rc )
- return rc;
+ d = rcu_lock_domain_by_any_id(dom);
+ if ( d == NULL )
+ return -ESRCH;
spin_lock(&d->event_lock);
struct domain *d;
int i, rc;
- rc = rcu_lock_target_domain_by_id(dom, &d);
- if ( rc )
- return rc;
+ d = rcu_lock_domain_by_any_id(dom);
+ if ( d == NULL )
+ return -ESRCH;
rc = xsm_evtchn_reset(current->domain, d);
if ( rc )
spin_unlock(&rgt->lock);
}
-static struct domain *gt_lock_target_domain_by_id(domid_t dom)
-{
- struct domain *d;
- int rc = GNTST_general_error;
-
- switch ( rcu_lock_target_domain_by_id(dom, &d) )
- {
- case 0:
- return d;
-
- case -ESRCH:
- gdprintk(XENLOG_INFO, "Bad domid %d.\n", dom);
- rc = GNTST_bad_domain;
- break;
-
- case -EPERM:
- rc = GNTST_permission_denied;
- break;
- }
-
- ASSERT(rc < 0 && -rc <= MAX_ERRNO);
- return ERR_PTR(rc);
-}
-
static inline int
__get_maptrack_handle(
struct grant_table *t)
if ( !guest_handle_okay(op.frame_list, op.nr_frames) )
return -EFAULT;
- d = gt_lock_target_domain_by_id(op.dom);
- if ( IS_ERR(d) )
+ d = rcu_lock_domain_by_any_id(op.dom);
+ if ( d == NULL )
{
- op.status = PTR_ERR(d);
- goto out1;
+ gdprintk(XENLOG_INFO, "Bad domid %d.\n", op.dom);
+ op.status = GNTST_bad_domain;
+ goto out2;
}
if ( xsm_grant_setup(current->domain, d) )
return -EFAULT;
}
- d = gt_lock_target_domain_by_id(op.dom);
- if ( IS_ERR(d) )
+ d = rcu_lock_domain_by_any_id(op.dom);
+ if ( d == NULL )
{
- op.status = PTR_ERR(d);
+ gdprintk(XENLOG_INFO, "Bad domid %d.\n", op.dom);
+ op.status = GNTST_bad_domain;
goto query_out;
}
return -EFAULT;
}
- d = gt_lock_target_domain_by_id(op.dom);
- if ( IS_ERR(d) )
+ d = rcu_lock_domain_by_any_id(op.dom);
+ if ( d == NULL )
{
- op.status = PTR_ERR(d);
+ op.status = GNTST_bad_domain;
goto out1;
}
rc = xsm_grant_setup(current->domain, d);
if ( copy_from_guest(&op, uop, 1) )
return -EFAULT;
- rc = rcu_lock_target_domain_by_id(op.dom, &d);
- if ( rc < 0 )
- return rc;
+ d = rcu_lock_domain_by_any_id(op.dom);
+ if ( d == NULL )
+ return -ESRCH;
- if ( xsm_grant_query_size(current->domain, d) )
+ rc = xsm_grant_query_size(current->domain, d);
+ if ( rc )
{
rcu_unlock_domain(d);
- return -EPERM;
+ return rc;
}
op.version = d->grant_table->gt_version;
&& (reservation.mem_flags & XENMEMF_populate_on_demand) )
args.memflags |= MEMF_populate_on_demand;
- if ( unlikely(rcu_lock_target_domain_by_id(reservation.domid, &d)) )
+ d = rcu_lock_domain_by_any_id(reservation.domid);
+ if ( d == NULL )
return start_extent;
args.domain = d;
if ( copy_from_guest(&domid, arg, 1) )
return -EFAULT;
- rc = rcu_lock_target_domain_by_id(domid, &d);
- if ( rc )
- return rc;
+ d = rcu_lock_domain_by_any_id(domid);
+ if ( d == NULL )
+ return -ESRCH;
rc = xsm_memory_stat_reservation(current->domain, d);
if ( rc )
if ( copy_from_guest(&xrfp, arg, 1) )
return -EFAULT;
- rc = rcu_lock_target_domain_by_id(xrfp.domid, &d);
- if ( rc != 0 )
- return rc;
+ d = rcu_lock_domain_by_any_id(xrfp.domid);
+ if ( d == NULL )
+ return -ESRCH;
if ( xsm_remove_from_physmap(current->domain, d) )
{
static XSM_INLINE int xsm_grant_setup(struct domain *d1, struct domain *d2)
{
+ if ( d1 != d2 && !IS_PRIV_FOR(d1, d2) )
+ return -EPERM;
return 0;
}
static XSM_INLINE int xsm_grant_query_size(struct domain *d1, struct domain *d2)
{
+ if ( d1 != d2 && !IS_PRIV_FOR(d1, d2) )
+ return -EPERM;
return 0;
}
static XSM_INLINE int xsm_memory_adjust_reservation(struct domain *d1,
struct domain *d2)
{
+ if ( d1 != d2 && !IS_PRIV_FOR(d1, d2) )
+ return -EPERM;
return 0;
}
static XSM_INLINE int xsm_memory_stat_reservation(struct domain *d1, struct domain *d2)
{
+ if ( d1 != d2 && !IS_PRIV_FOR(d1, d2) )
+ return -EPERM;
return 0;
}
static XSM_INLINE int xsm_evtchn_unbound(struct domain *d, struct evtchn *chn,
domid_t id2)
{
+ if ( current->domain != d && !IS_PRIV_FOR(current->domain, d) )
+ return -EPERM;
return 0;
}
static XSM_INLINE int xsm_evtchn_status(struct domain *d, struct evtchn *chn)
{
+ if ( current->domain != d && !IS_PRIV_FOR(current->domain, d) )
+ return -EPERM;
return 0;
}
static XSM_INLINE int xsm_evtchn_reset(struct domain *d1, struct domain *d2)
{
+ if ( d1 != d2 && !IS_PRIV_FOR(d1, d2) )
+ return -EPERM;
return 0;
}
static XSM_INLINE int xsm_get_pod_target(struct domain *d)
{
+ if ( !IS_PRIV(current->domain) )
+ return -EPERM;
return 0;
}
static XSM_INLINE int xsm_set_pod_target(struct domain *d)
{
+ if ( !IS_PRIV(current->domain) )
+ return -EPERM;
return 0;
}
static XSM_INLINE int xsm_hvm_param(struct domain *d, unsigned long op)
{
+ if ( current->domain != d && !IS_PRIV_FOR(current->domain, d) )
+ return -EPERM;
return 0;
}
static XSM_INLINE int xsm_hvm_set_pci_intx_level(struct domain *d)
{
+ if ( !IS_PRIV_FOR(current->domain, d) )
+ return -EPERM;
return 0;
}
static XSM_INLINE int xsm_hvm_set_isa_irq_level(struct domain *d)
{
+ if ( !IS_PRIV_FOR(current->domain, d) )
+ return -EPERM;
return 0;
}
static XSM_INLINE int xsm_hvm_set_pci_link_route(struct domain *d)
{
+ if ( !IS_PRIV_FOR(current->domain, d) )
+ return -EPERM;
return 0;
}
static XSM_INLINE int xsm_hvm_inject_msi(struct domain *d)
{
+ if ( !IS_PRIV_FOR(current->domain, d) )
+ return -EPERM;
return 0;
}
static XSM_INLINE int xsm_domain_memory_map(struct domain *d)
{
+ if ( current->domain != d && !IS_PRIV_FOR(current->domain, d) )
+ return -EPERM;
return 0;
}
static XSM_INLINE int xsm_add_to_physmap(struct domain *d1, struct domain *d2)
{
+ if ( d1 != d2 && !IS_PRIV_FOR(d1, d2) )
+ return -EPERM;
return 0;
}
static XSM_INLINE int xsm_remove_from_physmap(struct domain *d1, struct domain *d2)
{
+ if ( d1 != d2 && !IS_PRIV_FOR(d1, d2) )
+ return -EPERM;
return 0;
}