xcp-1.6-updates/xen-4.1.hg

changeset 23204:6ccf1820fb94

Allow VMs to query their own grant table version.

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
author Paul Durrant <paul.durrant@citrix.com>
date Sun Dec 18 14:47:23 2011 +0000 (2011-12-18)
parents c62738ea1bb4
children e2af3c4e4c1d
files xen/arch/x86/hvm/hvm.c xen/common/grant_table.c
line diff
     1.1 --- a/xen/arch/x86/hvm/hvm.c	Sun Dec 18 14:45:44 2011 +0000
     1.2 +++ b/xen/arch/x86/hvm/hvm.c	Sun Dec 18 14:47:23 2011 +0000
     1.3 @@ -2523,6 +2523,7 @@ static int grant_table_op_is_allowed(uns
     1.4      case GNTTABOP_query_size:
     1.5      case GNTTABOP_setup_table:
     1.6      case GNTTABOP_set_version:
     1.7 +    case GNTTABOP_get_version:
     1.8      case GNTTABOP_copy:
     1.9      case GNTTABOP_map_grant_ref:
    1.10      case GNTTABOP_unmap_grant_ref:
     2.1 --- a/xen/common/grant_table.c	Sun Dec 18 14:45:44 2011 +0000
     2.2 +++ b/xen/common/grant_table.c	Sun Dec 18 14:47:23 2011 +0000
     2.3 @@ -2227,17 +2227,15 @@ gnttab_get_version(XEN_GUEST_HANDLE(gntt
     2.4  {
     2.5      gnttab_get_version_t op;
     2.6      struct domain *d;
     2.7 +    int rc;
     2.8  
     2.9      if ( copy_from_guest(&op, uop, 1) )
    2.10          return -EFAULT;
    2.11 -    d = rcu_lock_domain_by_id(op.dom);
    2.12 -    if ( d == NULL )
    2.13 -        return -ESRCH;
    2.14 -    if ( !IS_PRIV_FOR(current->domain, d) )
    2.15 -    {
    2.16 -        rcu_unlock_domain(d);
    2.17 -        return -EPERM;
    2.18 -    }
    2.19 +
    2.20 +    rc = rcu_lock_target_domain_by_id(op.dom, &d);
    2.21 +    if ( rc < 0 )
    2.22 +        return rc;
    2.23 +
    2.24      spin_lock(&d->grant_table->lock);
    2.25      op.version = d->grant_table->gt_version;
    2.26      spin_unlock(&d->grant_table->lock);