[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-ia64-devel] [PATCH] make use of rcu_lock_target_domain_by_id()
This is the ia64 counter part of xen-unstable.hg 18566:9a7b46546e05. [IA64] make use of rcu_lock_target_domain_by_id() reduce code duplication by using rcu_lock_target_domain_by_id() Signed-off-by: Isaku Yamahata <yamahata@xxxxxxxxxxxxx> diff -r 9b1545b22c9e xen/arch/ia64/vmx/vmx_hypercall.c --- a/xen/arch/ia64/vmx/vmx_hypercall.c Thu Oct 02 17:59:42 2008 +0900 +++ b/xen/arch/ia64/vmx/vmx_hypercall.c Thu Oct 02 18:26:55 2008 +0900 @@ -50,16 +50,9 @@ if ( op.isa_irq > 15 ) return -EINVAL; - if ( op.domid == DOMID_SELF ) - op.domid = current->domain->domain_id; - - d = rcu_lock_domain_by_id(op.domid); - if ( d == NULL ) - return -ESRCH; - - rc = -EPERM; - if ( !IS_PRIV_FOR(current->domain, d) && d != current->domain ) - goto out; + rc = rcu_lock_target_domain_by_id(op.domid, &d); + if ( rc != 0 ) + return rc; rc = -EINVAL; if ( !is_hvm_domain(d) ) @@ -86,16 +79,9 @@ if ( (op.domain > 0) || (op.bus > 0) || (op.device > 31) || (op.intx > 3) ) return -EINVAL; - if ( op.domid == DOMID_SELF ) - op.domid = current->domain->domain_id; - - d = rcu_lock_domain_by_id(op.domid); - if ( d == NULL ) - return -ESRCH; - - rc = -EPERM; - if ( !IS_PRIV_FOR(current->domain, d) && d != current->domain ) - goto out; + rc = rcu_lock_target_domain_by_id(op.domid, &d); + if ( rc != 0 ) + return rc; rc = -EINVAL; if ( !is_hvm_domain(d) ) @@ -129,18 +115,9 @@ if (a.index >= HVM_NR_PARAMS) return -EINVAL; - if (a.domid == DOMID_SELF) { - d = rcu_lock_current_domain(); - } - else { - d = rcu_lock_domain_by_id(a.domid); - if (d == NULL) - return -ESRCH; - if (!IS_PRIV_FOR(current->domain, d)) { - rcu_unlock_domain(d); - return -EPERM; - } - } + rc = rcu_lock_target_domain_by_id(a.domid, &d); + if (rc != 0) + return rc; if (op == HVMOP_set_param) { struct vmx_ioreq_page *iorp; @@ -213,20 +190,9 @@ if ( copy_from_guest(&a, arg, 1) ) return -EFAULT; - if ( a.domid == DOMID_SELF ) - { - d = rcu_lock_current_domain(); - } - else - { - if ( (d = rcu_lock_domain_by_id(a.domid)) == NULL ) - return -ESRCH; - if ( !IS_PRIV_FOR(current->domain, d) ) - { - rc = -EPERM; - goto param_fail3; - } - } + rc = rcu_lock_target_domain_by_id(a.domid, &d); + if ( rc != 0 ) + break; rc = -EINVAL; if ( !is_hvm_domain(d) ) diff -r 9b1545b22c9e xen/arch/ia64/xen/mm.c --- a/xen/arch/ia64/xen/mm.c Thu Oct 02 17:59:42 2008 +0900 +++ b/xen/arch/ia64/xen/mm.c Thu Oct 02 18:26:55 2008 +0900 @@ -3224,6 +3224,7 @@ arch_memory_op(int op, XEN_GUEST_HANDLE(void) arg) { struct page_info *page = NULL; + long rc; switch (op) { case XENMEM_add_to_physmap: @@ -3235,16 +3236,9 @@ if (copy_from_guest(&xatp, arg, 1)) return -EFAULT; - if (xatp.domid == DOMID_SELF) - d = rcu_lock_current_domain(); - else { - if ((d = rcu_lock_domain_by_id(xatp.domid)) == NULL) - return -ESRCH; - if (!IS_PRIV_FOR(current->domain,d)) { - rcu_lock_domain(d); - return -EPERM; - } - } + rc = rcu_lock_target_domain_by_id(xatp.domid, &d); + if (rc) + return rc; /* This hypercall is used for VT-i domain only */ if (!is_hvm_domain(d)) { @@ -3362,20 +3356,9 @@ if ( copy_from_guest(&xrfp, arg, 1) ) return -EFAULT; - if ( xrfp.domid == DOMID_SELF ) - { - d = rcu_lock_current_domain(); - } - else - { - if ( (d = rcu_lock_domain_by_id(xrfp.domid)) == NULL ) - return -ESRCH; - if ( !IS_PRIV_FOR(current->domain, d) ) - { - rcu_unlock_domain(d); - return -EPERM; - } - } + rc = rcu_lock_target_domain_by_id(xrfp.domid, &d); + if ( rc != 0 ) + return rc; domain_lock(d); -- yamahata _______________________________________________ Xen-ia64-devel mailing list Xen-ia64-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-ia64-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |