]> xenbits.xensource.com Git - people/vhanquez/xen.git/commitdiff
Allow VMs to query their own grant table version.
authorPaul Durrant <paul.durrant@citrix.com>
Sun, 18 Dec 2011 14:47:23 +0000 (14:47 +0000)
committerPaul Durrant <paul.durrant@citrix.com>
Sun, 18 Dec 2011 14:47:23 +0000 (14:47 +0000)
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Committed-by: Keir Fraser <keir@xen.org>
xen-unstable changeset:   24427:931bf1105730
xen-unstable date:        Sun Dec 18 14:38:32 2011 +0000

xen/arch/x86/hvm/hvm.c
xen/common/grant_table.c

index be023646731bbb080305e1cc6775fa1f75b91aad..4c9b874c2cf8d1e7f1666f67790c27faa5531506 100644 (file)
@@ -2523,6 +2523,7 @@ static int grant_table_op_is_allowed(unsigned int cmd)
     case GNTTABOP_query_size:
     case GNTTABOP_setup_table:
     case GNTTABOP_set_version:
+    case GNTTABOP_get_version:
     case GNTTABOP_copy:
     case GNTTABOP_map_grant_ref:
     case GNTTABOP_unmap_grant_ref:
index 092e6c3bfd6239a6fa2251c716950ac086411300..f97ad438e09afafe3e6a2b2f956e84f6d1aec2db 100644 (file)
@@ -2227,17 +2227,15 @@ gnttab_get_version(XEN_GUEST_HANDLE(gnttab_get_version_t uop))
 {
     gnttab_get_version_t op;
     struct domain *d;
+    int rc;
 
     if ( copy_from_guest(&op, uop, 1) )
         return -EFAULT;
-    d = rcu_lock_domain_by_id(op.dom);
-    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(op.dom, &d);
+    if ( rc < 0 )
+        return rc;
+
     spin_lock(&d->grant_table->lock);
     op.version = d->grant_table->gt_version;
     spin_unlock(&d->grant_table->lock);