WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] [IA64] make use of rcu_lock_target_domain

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] [IA64] make use of rcu_lock_target_domain_by_id()
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Fri, 10 Oct 2008 20:00:44 -0700
Delivery-date: Fri, 10 Oct 2008 20:02:19 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Isaku Yamahata <yamahata@xxxxxxxxxxxxx>
# Date 1223004289 -32400
# Node ID 788ed94f8fe4dc04beac24ff2f9c4145af04efdd
# Parent  591734b38585ef474cda87ca5a6a5b82436e1470
[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>
---
 xen/arch/ia64/vmx/vmx_hypercall.c |   58 +++++++-------------------------------
 xen/arch/ia64/xen/mm.c            |   31 ++++----------------
 2 files changed, 19 insertions(+), 70 deletions(-)

diff -r 591734b38585 -r 788ed94f8fe4 xen/arch/ia64/vmx/vmx_hypercall.c
--- a/xen/arch/ia64/vmx/vmx_hypercall.c Fri Oct 03 11:49:07 2008 +0900
+++ b/xen/arch/ia64/vmx/vmx_hypercall.c Fri Oct 03 12:24:49 2008 +0900
@@ -50,16 +50,9 @@ static int hvmop_set_isa_irq_level(
     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 @@ static int hvmop_set_pci_intx_level(
     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 @@ do_hvm_op(unsigned long op, XEN_GUEST_HA
         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 @@ do_hvm_op(unsigned long op, XEN_GUEST_HA
         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 591734b38585 -r 788ed94f8fe4 xen/arch/ia64/xen/mm.c
--- a/xen/arch/ia64/xen/mm.c    Fri Oct 03 11:49:07 2008 +0900
+++ b/xen/arch/ia64/xen/mm.c    Fri Oct 03 12:24:49 2008 +0900
@@ -2815,6 +2815,7 @@ arch_memory_op(int op, XEN_GUEST_HANDLE(
 arch_memory_op(int op, XEN_GUEST_HANDLE(void) arg)
 {
     struct page_info *page = NULL;
+    long rc;
 
     switch (op) {
     case XENMEM_add_to_physmap:
@@ -2826,16 +2827,9 @@ arch_memory_op(int op, XEN_GUEST_HANDLE(
         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)) {
@@ -2926,20 +2920,9 @@ arch_memory_op(int op, XEN_GUEST_HANDLE(
         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);
 

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] [IA64] make use of rcu_lock_target_domain_by_id(), Xen patchbot-unstable <=