Skip to contentSkip to conversation

xen: allows more hypercalls from stubdoms

PATCH In review Stefano Stabellini 3 participants 23 messages Oct 12, 2009 – Oct 14, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen: allows more hypercalls from stubdoms

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

---

xen/arch/x86/irq.c +1 -1
diff -r 65a13cafbbef xen/arch/x86/irq.c
@@ -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 )
xen/arch/x86/physdev.c +15 -8
diff -r 65a13cafbbef xen/arch/x86/physdev.c
@@ -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;
xen/common/domctl.c +25 -3
diff -r 65a13cafbbef xen/common/domctl.c
@@ -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(
#1 lore raw

Hello,

Quoted 2 lines · Stefano Stabellini, le Mon 12 Oct 2009 18:20:09 +0100, a écrit :

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

Tried before, nacked by Keir :)

xen/arch/x86/irq.c line 923

Quoted 12 lines

diff -r 65a13cafbbef xen/arch/x86/irq.c

xen/arch/x86/irq.c +1 -1
@@ -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 )

For instance, here. It's not because a stubdomain has privilege over another domain that it suddendly is allowed to reroute all IRQs of the machine :)

This needs proper accounting: xend should tell the hypervisor which IRQs domains are allowed to use. Same for physdev, pci functions, etc.

Samuel

#2 lore raw
Quoted 7 lines · Samuel Thibault

Hello,

Quoted 2 lines · Stefano Stabellini, le Mon 12 Oct 2009 18:20:09 +0100, a écrit :

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

Tried before, nacked by Keir :)

Last time I spoke with Keir I got the impression that allowing only the hypercalls strictly needed for passthrough was OK.

In any case I would greately appreciate if all the other patches were accepted in any case because I wouldn't want them to bitrot.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#3 lore raw
Quoted 7 lines · Stefano Stabellini
Quoted 6 lines · Samuel Thibault

Hello,

Quoted 2 lines · Stefano Stabellini, le Mon 12 Oct 2009 18:20:09 +0100, a écrit :

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

Quoted 8 lines
Quoted 1 line

Tried before, nacked by Keir :)

Last time I spoke with Keir I got the impression that allowing only the hypercalls strictly needed for passthrough was OK.

In any case I would greately appreciate if all the other patches were accepted in any case because I wouldn't want them to bitrot.

BTW: it cannot be worse than opening /dev/mem O_RDWR in qemu-xen, that is exactly what happens at the moment.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#4 lore raw
Quoted 6 lines · Stefano Stabellini, le Mon 12 Oct 2009 19:14:11 +0100, a écrit :
Quoted 3 lines

In any case I would greately appreciate if all the other patches were accepted in any case because I wouldn't want them to bitrot.

BTW: it cannot be worse than opening /dev/mem O_RDWR in qemu-xen, that is exactly what happens at the moment.

Sure, but the difference is that qemu-xen is known to be run as root in dom0, while allowing things from the hypervisor potentially hides security leaks in its source code.

Samuel

#5 lore raw
Quoted 6 lines · Samuel Thibault
Quoted 2 lines

BTW: it cannot be worse than opening /dev/mem O_RDWR in qemu-xen, that is exactly what happens at the moment.

Sure, but the difference is that qemu-xen is known to be run as root in dom0, while allowing things from the hypervisor potentially hides security leaks in its source code.

Also, one of the advantages of stubdom is supposed to be that it contains qemu's large attack surface within a deprivileged environment.

The hard thing about passthru in a stubdom is that every relevant hypercall really needs to be audited and potentially redesigned so that it all works but according to principle of least privilege.

The alternative is rather undesirable, but perhaps acceptable if we make that choice with our eyes open to it.

-- Keir

#6 lore raw
In reply to Stefano Stabellini
Quoted 9 lines · Stefano Stabellini, le Mon 12 Oct 2009 19:10:54 +0100, a écrit :
Quoted 5 lines · Samuel Thibault
Quoted 2 lines · Stefano Stabellini, le Mon 12 Oct 2009 18:20:09 +0100, a écrit :

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

Tried before, nacked by Keir :)

Last time I spoke with Keir I got the impression that allowing only the hypercalls strictly needed for passthrough was OK.

Ok, but doesn't that open a door to passthrough an IRQ which was not supposed to be passed through? Doesn't it let a stubdom passthrough IRQ0 for instance?

Quoted 2 lines

In any case I would greately appreciate if all the other patches were accepted in any case because I wouldn't want them to bitrot.

I think they can go in, yes.

Samuel

#7 lore raw
In reply to Stefano Stabellini

xen/common/domctl.c line 236

Quoted 6 lines · Stefano Stabellini
xen/common/domctl.c +6 -0
+        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:

This kind of thing, for example, while we're talking about least privilege... I think it's wrong-headed in the first place for this kind of control-plane activity to be going on in qemu. Surely it belongs in the toolstack? Yes, I know it's a pain in the bum that this means modifying multiple toolstacks! :-)

-- Keir

#8 lore raw
Quoted 10 lines · Keir Fraser

xen/common/domctl.c line 236

Quoted 6 lines · Stefano Stabellini
xen/common/domctl.c +6 -0
+        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:
Quoted 6 lines

This kind of thing, for example, while we're talking about least privilege... I think it's wrong-headed in the first place for this kind of control-plane activity to be going on in qemu. Surely it belongs in the toolstack? Yes, I know it's a pain in the bum that this means modifying multiple toolstacks! :-)

I agree with you that we need to redesign these hypercalls, but I am a fan of "doing one thing at a time" so I think we should decouple this goal from the other one of making passthrough work with stubdom for the moment.
This way we could first let people test it as it is, fix some bugs that probably still affect the code, fix pci coldplug and add MSI-X support, then redesign the hypercalls.

In any case it is just a matter of ordering the items in the todo list, all these things have to happen anyway.

#9 lore raw
Quoted 7 lines · Stefano Stabellini, le Tue 13 Oct 2009 13:00:09 +0100, a écrit :

I agree with you that we need to redesign these hypercalls, but I am a fan of "doing one thing at a time" so I think we should decouple this goal from the other one of making passthrough work with stubdom for the moment.
This way we could first let people test it as it is, fix some bugs that probably still affect the code, fix pci coldplug and add MSI-X support, then redesign the hypercalls.

For that you could just provide testers with this patch along with a strong warning that it's not safe (from a security point of view).

Samuel

#10 lore raw
Quoted 11 lines · Samuel Thibault
Quoted 7 lines · Stefano Stabellini, le Tue 13 Oct 2009 13:00:09 +0100, a écrit :

I agree with you that we need to redesign these hypercalls, but I am a fan of "doing one thing at a time" so I think we should decouple this goal from the other one of making passthrough work with stubdom for the moment.
This way we could first let people test it as it is, fix some bugs that probably still affect the code, fix pci coldplug and add MSI-X support, then redesign the hypercalls.

For that you could just provide testers with this patch along with a strong warning that it's not safe (from a security point of view).

In theory yes, but in practice not so many people read the list compared to the people that actually chase xen-unstable.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#11 lore raw
Quoted 10 lines · Stefano Stabellini, le Tue 13 Oct 2009 13:10:20 +0100, a écrit :
Quoted 9 lines · Samuel Thibault
Quoted 7 lines · Stefano Stabellini, le Tue 13 Oct 2009 13:00:09 +0100, a écrit :

I agree with you that we need to redesign these hypercalls, but I am a fan of "doing one thing at a time" so I think we should decouple this goal from the other one of making passthrough work with stubdom for the moment.
This way we could first let people test it as it is, fix some bugs that probably still affect the code, fix pci coldplug and add MSI-X support, then redesign the hypercalls.

Quoted 5 lines
Quoted 2 lines

For that you could just provide testers with this patch along with a strong warning that it's not safe (from a security point of view).

In theory yes, but in practice not so many people read the list compared to the people that actually chase xen-unstable.

Would the latter report bugs they encounter?

Samuel

#12 lore raw
Quoted 11 lines · Samuel Thibault
Quoted 10 lines · Stefano Stabellini, le Tue 13 Oct 2009 13:10:20 +0100, a écrit :
Quoted 9 lines · Samuel Thibault
Quoted 7 lines · Stefano Stabellini, le Tue 13 Oct 2009 13:00:09 +0100, a écrit :

I agree with you that we need to redesign these hypercalls, but I am a fan of "doing one thing at a time" so I think we should decouple this goal from the other one of making passthrough work with stubdom for the moment.
This way we could first let people test it as it is, fix some bugs that probably still affect the code, fix pci coldplug and add MSI-X support, then redesign the hypercalls.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

For that you could just provide testers with this patch along with a strong warning that it's not safe (from a security point of view).

In theory yes, but in practice not so many people read the list compared to the people that actually chase xen-unstable.

Would the latter report bugs they encounter?

I hope so, at least on xen-users.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#13 lore raw
Quoted 15 lines · Stefano Stabellini, le Tue 13 Oct 2009 13:18:50 +0100, a écrit :
Quoted 14 lines · Samuel Thibault
Quoted 13 lines · Stefano Stabellini, le Tue 13 Oct 2009 13:10:20 +0100, a écrit :
Quoted 11 lines · Samuel Thibault
Quoted 7 lines · Stefano Stabellini, le Tue 13 Oct 2009 13:00:09 +0100, a écrit :

I agree with you that we need to redesign these hypercalls, but I am a fan of "doing one thing at a time" so I think we should decouple this goal from the other one of making passthrough work with stubdom for the moment.
This way we could first let people test it as it is, fix some bugs that probably still affect the code, fix pci coldplug and add MSI-X support, then redesign the hypercalls.

For that you could just provide testers with this patch along with a strong warning that it's not safe (from a security point of view).

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

In theory yes, but in practice not so many people read the list compared to the people that actually chase xen-unstable.

Would the latter report bugs they encounter?

I hope so, at least on xen-users.

Well, I'd tend to think that if they're not following either, they're probably not building from the hg repository. Anyway, I let it to Keir whether he's keen on opening a temporary security breach to allow testing :)

Samuel

#14 lore raw
In reply to Stefano Stabellini
Quoted 7 lines · Stefano Stabellini
Quoted 6 lines

This kind of thing, for example, while we're talking about least privilege... I think it's wrong-headed in the first place for this kind of control-plane activity to be going on in qemu. Surely it belongs in the toolstack? Yes, I know it's a pain in the bum that this means modifying multiple toolstacks! :-)

Quoted 7 lines

I agree with you that we need to redesign these hypercalls, but I am a fan of "doing one thing at a time" so I think we should decouple this goal from the other one of making passthrough work with stubdom for the moment.
This way we could first let people test it as it is, fix some bugs that probably still affect the code, fix pci coldplug and add MSI-X support, then redesign the hypercalls.

Perhaps acceptable then if the changes are placed in clear ifdef'ed regions. This ifdef would be default-disabled for a stable release, if the hypercalls are not redone by then.

-- Keir

#15 lore raw
Quoted 3 lines · Keir Fraser, le Tue 13 Oct 2009 13:32:32 +0100, a écrit :

Perhaps acceptable then if the changes are placed in clear ifdef'ed regions. This ifdef would be default-disabled for a stable release, if the hypercalls are not redone by then.

Can be a solution yes.

Samuel

#16 lore raw
In reply to Keir Fraser
Quoted 18 lines · Keir Fraser
Quoted 7 lines · Stefano Stabellini
Quoted 6 lines

This kind of thing, for example, while we're talking about least privilege... I think it's wrong-headed in the first place for this kind of control-plane activity to be going on in qemu. Surely it belongs in the toolstack? Yes, I know it's a pain in the bum that this means modifying multiple toolstacks! :-)

Quoted 7 lines

I agree with you that we need to redesign these hypercalls, but I am a fan of "doing one thing at a time" so I think we should decouple this goal from the other one of making passthrough work with stubdom for the moment.
This way we could first let people test it as it is, fix some bugs that probably still affect the code, fix pci coldplug and add MSI-X support, then redesign the hypercalls.

Quoted 4 lines

Perhaps acceptable then if the changes are placed in clear ifdef'ed regions. This ifdef would be default-disabled for a stable release, if the hypercalls are not redone by then.

This is the updated version of the patch, with all the controversial changes ifdef'ed.

---

Config.mk +8 -0
diff -r 0035117b3a88 Config.mk
@@ -2,6 +2,10 @@
 
 # A debug build of Xen and tools?
 debug ?= y
+
+# Allow some delicate passthrough related hypercalls to be made from a
+# stubdom
+privileged_stubdoms ?= y
 
 XEN_COMPILE_ARCH    ?= $(shell uname -m | sed -e s/i.86/x86_32/ \
                          -e s/i86pc/x86_32/ -e s/amd64/x86_64/)
@@ -114,6 +118,10 @@
 CFLAGS += -g
 endif
 
+ifeq ($(privileged_stubdoms),y)
+CFLAGS += -DPRIVILEGED_STUBDOMS
+endif
+
 CFLAGS += -fno-strict-aliasing
 
 CFLAGS += -std=gnu99
xen/arch/x86/irq.c +4 -0
diff -r 0035117b3a88 xen/arch/x86/irq.c
@@ -1340,7 +1340,11 @@
     ASSERT(spin_is_locked(&pcidevs_lock));
     ASSERT(spin_is_locked(&d->event_lock));
 
+#ifdef PRIVILEGED_STUBDOMS
+    if ( !IS_PRIV_FOR(current->domain, d) )
+#else
     if ( !IS_PRIV(current->domain) )
+#endif
         return -EPERM;
 
     if ( pirq < 0 || pirq >= d->nr_pirqs || irq < 0 || irq >= nr_irqs )
xen/arch/x86/physdev.c +23 -8
diff -r 0035117b3a88 xen/arch/x86/physdev.c
@@ -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,16 @@
     if ( d == NULL )
     {
         ret = -ESRCH;
+        goto free_domain;
+    }
+
+#ifdef PRIVILEGED_STUBDOMS
+    if ( !IS_PRIV_FOR(current->domain, d) )
+#else
+    if ( !IS_PRIV(current->domain) )
+#endif
+    {
+        ret = -EPERM;
         goto free_domain;
     }
 
@@ -158,10 +165,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 +173,17 @@
         d = rcu_lock_domain_by_id(unmap->domid);
 
     if ( d == NULL )
-        return -ESRCH;
+        goto free_domain;
+
+#ifdef PRIVILEGED_STUBDOMS
+    if ( !IS_PRIV_FOR(current->domain, d) )
+#else
+    if ( !IS_PRIV(current->domain) )
+#endif
+    {
+        ret = -EPERM;
+        goto free_domain;
+    }
 
     spin_lock(&pcidevs_lock);
     spin_lock(&d->event_lock);
@@ -177,6 +191,7 @@
     spin_unlock(&d->event_lock);
     spin_unlock(&pcidevs_lock);
 
+free_domain:
     rcu_unlock_domain(d);
 
     return ret;
xen/common/domctl.c +27 -3
diff -r 0035117b3a88 xen/common/domctl.c
@@ -220,14 +220,38 @@
     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:
+#ifdef PRIVILEGED_STUBDOMS
+            {
+                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;
+#endif
+        default:
+            if ( !IS_PRIV(current->domain) )
+                return -EPERM;
+            break;
+    }
+
 
     if ( !domctl_lock_acquire() )
         return hypercall_create_continuation(
#17 lore raw
Quoted 28 lines · Stefano Stabellini, le Tue 13 Oct 2009 15:24:31 +0100, a écrit :
xen/common/domctl.c +19 -3
-    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:
+#ifdef PRIVILEGED_STUBDOMS
+            {
+                struct domain *d = get_domain_by_id(op->domain);
+                if ( !IS_PRIV_FOR(current->domain, d) )
+                {
+                    put_domain(d);
+                    return -EPERM;
+                }
+                put_domain(d);
+            }

xen/common/domctl.c line 256

Quoted 10 lines
xen/common/domctl.c +8 -0
+            break;
+#endif
+        default:
+            if ( !IS_PRIV(current->domain) )
+                return -EPERM;
+            break;
+    }
+
 
     if ( !domctl_lock_acquire() )

The cases should be inside the #ifdef, or there should be a #else.

Samuel

#18 lore raw
Quoted 2 lines · Samuel Thibault

The cases should be inside the #ifdef, or there should be a #else.

Why? Just for aesthetic?

#19 lore raw
Quoted 4 lines · Stefano Stabellini, le Tue 13 Oct 2009 15:40:23 +0100, a écrit :
Quoted 1 line · Samuel Thibault

The cases should be inside the #ifdef, or there should be a #else.

Why? Just for aesthetic?

Ah, sorry, I missed that it was exactly along break; This shows that yes, at least for readability it'd be useful.

Samuel

#20 lore raw
Quoted 7 lines · Samuel Thibault, le Tue 13 Oct 2009 16:42:36 +0200, a écrit :
Quoted 4 lines · Stefano Stabellini, le Tue 13 Oct 2009 15:40:23 +0100, a écrit :
Quoted 1 line · Samuel Thibault

The cases should be inside the #ifdef, or there should be a #else.

Why? Just for aesthetic?

Ah, sorry, I missed that it was exactly along break;

Along default: I meant.

Quoted 9 lines

This shows that yes, at least for readability it'd be useful.

Samuel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

Signature · 2 lines
Samuel
"c'est pas nous qui sommes à la rue, c'est la rue qui est à nous"
#22 lore raw
In reply to Stefano Stabellini
Quoted 6 lines · Stefano Stabellini
Quoted 3 lines

Perhaps acceptable then if the changes are placed in clear ifdef'ed regions. This ifdef would be default-disabled for a stable release, if the hypercalls are not redone by then.

This is the updated version of the patch, with all the controversial changes ifdef'ed.

Fixed and reworked and applied.

K.