aboutsummaryrefslogtreecommitdiffstats
path: root/xen/common/grant_table.c
diff options
context:
space:
mode:
authorPaul Durrant <paul.durrant@citrix.com>2011-12-18 14:38:32 +0000
committerPaul Durrant <paul.durrant@citrix.com>2011-12-18 14:38:32 +0000
commitb2eb6f8fe9781a8ca75b16e3b885d8ed7ec3192b (patch)
treefdb578b74aad1487b40c6ab8d1b10124361a9df9 /xen/common/grant_table.c
parente628c3b0b888ac4291e8d963eb01f420ffca10ad (diff)
downloadxen-b2eb6f8fe9781a8ca75b16e3b885d8ed7ec3192b.tar.gz
xen-b2eb6f8fe9781a8ca75b16e3b885d8ed7ec3192b.tar.bz2
xen-b2eb6f8fe9781a8ca75b16e3b885d8ed7ec3192b.zip
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>
Diffstat (limited to 'xen/common/grant_table.c')
-rw-r--r--xen/common/grant_table.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/xen/common/grant_table.c b/xen/common/grant_table.c
index fefa8383b2..014734d240 100644
--- a/xen/common/grant_table.c
+++ b/xen/common/grant_table.c
@@ -2253,30 +2253,29 @@ 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;
+
if ( xsm_grant_query_size(current->domain, d) )
{
rcu_unlock_domain(d);
return -EPERM;
}
+
spin_lock(&d->grant_table->lock);
op.version = d->grant_table->gt_version;
spin_unlock(&d->grant_table->lock);
if ( copy_to_guest(uop, &op, 1) )
return -EFAULT;
- else
- return 0;
+
+ return 0;
}
long