All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 3 of 7] xen: allows more hypercalls from stubdoms
@ 2009-10-12 17:20 Stefano Stabellini
  2009-10-12 17:33 ` Samuel Thibault
  2009-10-12 18:56 ` Keir Fraser
  0 siblings, 2 replies; 23+ messages in thread
From: Stefano Stabellini @ 2009-10-12 17:20 UTC (permalink / raw)
  To: xen-devel

Stubdoms need to be able to make all the passthrough related hypercalls
on behalf of the guest.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>

---

diff -r 65a13cafbbef xen/arch/x86/irq.c
--- a/xen/arch/x86/irq.c	Wed Jul 22 15:59:44 2009 +0100
+++ b/xen/arch/x86/irq.c	Wed Jul 22 16:15:14 2009 +0100
@@ -917,7 +917,7 @@
     ASSERT(spin_is_locked(&pcidevs_lock));
     ASSERT(spin_is_locked(&d->event_lock));
 
-    if ( !IS_PRIV(current->domain) )
+    if ( !IS_PRIV_FOR(current->domain, d) )
         return -EPERM;
 
     if ( pirq < 0 || pirq >= d->nr_pirqs || vector < 0 || vector >= NR_VECTORS )
diff -r 65a13cafbbef xen/arch/x86/physdev.c
--- a/xen/arch/x86/physdev.c	Wed Jul 22 15:59:44 2009 +0100
+++ b/xen/arch/x86/physdev.c	Wed Jul 22 16:15:14 2009 +0100
@@ -34,9 +34,6 @@
     struct msi_info _msi;
     void *map_data = NULL;
 
-    if ( !IS_PRIV(current->domain) )
-        return -EPERM;
-
     if ( !map )
         return -EINVAL;
 
@@ -48,6 +45,12 @@
     if ( d == NULL )
     {
         ret = -ESRCH;
+        goto free_domain;
+    }
+
+    if ( !IS_PRIV_FOR(current->domain, d) )
+    {
+        ret = -EPERM;
         goto free_domain;
     }
 
@@ -158,10 +161,7 @@
 static int physdev_unmap_pirq(struct physdev_unmap_pirq *unmap)
 {
     struct domain *d;
-    int ret;
-
-    if ( !IS_PRIV(current->domain) )
-        return -EPERM;
+    int ret = -ESRCH;
 
     if ( unmap->domid == DOMID_SELF )
         d = rcu_lock_domain(current->domain);
@@ -169,7 +169,13 @@
         d = rcu_lock_domain_by_id(unmap->domid);
 
     if ( d == NULL )
-        return -ESRCH;
+        goto free_domain;
+
+    if ( !IS_PRIV_FOR(current->domain, d) )
+    {
+        ret = -EPERM;
+        goto free_domain;
+    }
 
     spin_lock(&pcidevs_lock);
     spin_lock(&d->event_lock);
@@ -177,6 +183,7 @@
     spin_unlock(&d->event_lock);
     spin_unlock(&pcidevs_lock);
 
+free_domain:
     rcu_unlock_domain(d);
 
     return ret;
diff -r 65a13cafbbef xen/common/domctl.c
--- a/xen/common/domctl.c	Wed Jul 22 15:59:44 2009 +0100
+++ b/xen/common/domctl.c	Wed Jul 22 16:15:14 2009 +0100
@@ -220,14 +220,36 @@
     long ret = 0;
     struct xen_domctl curop, *op = &curop;
 
-    if ( !IS_PRIV(current->domain) )
-        return -EPERM;
-
     if ( copy_from_guest(op, u_domctl, 1) )
         return -EFAULT;
 
     if ( op->interface_version != XEN_DOMCTL_INTERFACE_VERSION )
         return -EACCES;
+
+    switch ( op->cmd )
+    {
+        case XEN_DOMCTL_ioport_mapping:
+        case XEN_DOMCTL_memory_mapping:
+        case XEN_DOMCTL_bind_pt_irq:
+        case XEN_DOMCTL_unbind_pt_irq:
+        case XEN_DOMCTL_assign_device:
+        case XEN_DOMCTL_deassign_device:
+            {
+                struct domain *d = get_domain_by_id(op->domain);
+                if ( !IS_PRIV_FOR(current->domain, d) )
+                {
+                    put_domain(d);
+                    return -EPERM;
+                }
+                put_domain(d);
+            }
+            break;
+        default:
+            if ( !IS_PRIV(current->domain) )
+                return -EPERM;
+            break;
+    }
+
 
     if ( !domctl_lock_acquire() )
         return hypercall_create_continuation(

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2009-10-14  7:53 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-12 17:20 [PATCH 3 of 7] xen: allows more hypercalls from stubdoms Stefano Stabellini
2009-10-12 17:33 ` Samuel Thibault
2009-10-12 18:10   ` Stefano Stabellini
2009-10-12 18:14     ` Stefano Stabellini
2009-10-12 18:19       ` Samuel Thibault
2009-10-12 18:50         ` Keir Fraser
2009-10-12 18:17     ` Samuel Thibault
2009-10-12 18:56 ` Keir Fraser
2009-10-13 12:00   ` Stefano Stabellini
2009-10-13 12:05     ` Samuel Thibault
2009-10-13 12:10       ` Stefano Stabellini
2009-10-13 12:15         ` Samuel Thibault
2009-10-13 12:18           ` Stefano Stabellini
2009-10-13 12:25             ` Samuel Thibault
2009-10-13 12:32     ` Keir Fraser
2009-10-13 12:42       ` Samuel Thibault
2009-10-13 14:24       ` Stefano Stabellini
2009-10-13 14:36         ` Samuel Thibault
2009-10-13 14:40           ` Stefano Stabellini
2009-10-13 14:42             ` Samuel Thibault
2009-10-13 14:50               ` Samuel Thibault
2009-10-13 15:51           ` Keir Fraser
2009-10-14  7:53         ` Keir Fraser

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.