Skip to contentSkip to conversation

use compat_*() for all 32-bit hypercalls.

PATCH In review Tim Deegan 3 participants 3 messages May 10, 2011 1 message not in the archive

lore
Share & tools
lore

Tim Deegan

author
#0 lore raw

PATCH 1/1 use compat_*() for all 32-bit hypercalls.

The attached patch switches the handling of sched_op, get_xen_version and set_timer_op hypercalls from 32-bit HVM guests to use the compat versions of the handlers. As far as I can see this is correcting an
oversight: other hypercalls are already redirected to the compat versions and having a mix of translated and untranslated seems like the worst option.

The only one of these three that's likely to cause trouble is schedop (poll) which almost always happens to work if you call the wrong version. However the interlock against concurrent event arrival doesn't work, which was leading to lockups in the HVMloader xenbus code.

Cc'ing various people who I know are responsible for HVM PV drivers just in case any ofthem have hardcoded this broken interface into client code.

Cheers,

Tim.

Signature · 3 lines
Tim Deegan <[email protected]>
Principal Software Engineer, Xen Platform Team
Citrix Systems UK Ltd.  (Company #02937203, SL9 0BG)

# HG changeset patch
# User Tim Deegan <[email protected]>
# Date 1305031692 -3600
# Node ID fd865a27f38a93cc63ab8b96ad2f98b29a30d7b5
# Parent 19452acd23045f40c4e18437f0a60f016757e5bd
x86: use compat hypercall handlers for calls from 32-bit HVM guests

On 64-bit Xen, hypercalls from 32-bit HVM guests are handled as a special case, but not all the hypercalls are corrently redirected to their compat-mode wrappers. Use compat_* for xen_version, sched_op and set_timer_op for consistency.

xen/arch/x86/hvm/hvm.c +6 -3
diff -r 19452acd2304 -r fd865a27f38a xen/arch/x86/hvm/hvm.c
@@ -2911,15 +2911,18 @@ static hvm_hypercall_t *hvm_hypercall64_
     HYPERCALL(tmem_op)
 };
 
+#define COMPAT_CALL(x)                                        \
+    [ __HYPERVISOR_ ## x ] = (hvm_hypercall_t *) compat_ ## x
+
 static hvm_hypercall_t *hvm_hypercall32_table[NR_hypercalls] = {
     [ __HYPERVISOR_memory_op ] = (hvm_hypercall_t *)hvm_memory_op_compat32,
     [ __HYPERVISOR_grant_table_op ] = (hvm_hypercall_t *)hvm_grant_table_op_compat32,
     [ __HYPERVISOR_vcpu_op ] = (hvm_hypercall_t *)hvm_vcpu_op_compat32,
     [ __HYPERVISOR_physdev_op ] = (hvm_hypercall_t *)hvm_physdev_op_compat32,
-    HYPERCALL(xen_version),
+    COMPAT_CALL(xen_version),
     HYPERCALL(event_channel_op),
-    HYPERCALL(sched_op),
-    HYPERCALL(set_timer_op),
+    COMPAT_CALL(sched_op),
+    COMPAT_CALL(set_timer_op),
     HYPERCALL(hvm_op),
     HYPERCALL(sysctl),
     HYPERCALL(tmem_op)
xen/include/xen/hypercall.h +14 -0
diff -r 19452acd2304 -r fd865a27f38a xen/include/xen/hypercall.h
@@ -146,6 +146,20 @@ compat_vcpu_op(
 extern int
 compat_xenoprof_op(int op, XEN_GUEST_HANDLE(void) arg);
 
+extern int
+compat_xen_version(
+    int cmd,
+    XEN_GUEST_HANDLE(void) arg);
+
+extern int
+compat_sched_op(
+    int cmd,
+    XEN_GUEST_HANDLE(void) arg);
+
+extern int
+compat_set_timer_op(
+    s_time_t timeout);
+
 #endif
 
 #endif /* __XEN_HYPERCALL_H__ */

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

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw

PATCH 1/1 use compat_*() for all 32-bit hypercalls.

Is this a problem for 4.1 as well, or are the lockups in HVMloader xenbus in code that's been introduced since then?

 -George

Quoted 31 lines · Tim Deegan

The attached patch switches the handling of sched_op, get_xen_version and set_timer_op hypercalls from 32-bit HVM guests to use the compat versions of the handlers.  As far as I can see this is correcting an
oversight: other hypercalls are already redirected to the compat versions and having a mix of translated and untranslated seems like the worst option.

The only one of these three that's likely to cause trouble is schedop (poll) which almost always happens to work if you call the wrong version.  However the interlock against concurrent event arrival doesn't work, which was leading to lockups in the HVMloader xenbus code.

Cc'ing various people who I know are responsible for HVM PV drivers just in case any ofthem have hardcoded this broken interface into client code.

Cheers,

Tim.

--
Tim Deegan <[email protected]>
Principal Software Engineer, Xen Platform Team Citrix Systems UK Ltd.  (Company #02937203, SL9 0BG)

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

#3 lore raw
In reply to a message not in the archive
Quoted 2 lines · George Dunlap

Is this a problem for 4.1 as well, or are the lockups in HVMloader xenbus in code that's been introduced since then?

This affects all hvmloaders that use xenbus, which I think includes 4.1

Tim.

Quoted 32 lines · Tim Deegan
Quoted 31 lines

The attached patch switches the handling of sched_op, get_xen_version and set_timer_op hypercalls from 32-bit HVM guests to use the compat versions of the handlers.  As far as I can see this is correcting an
oversight: other hypercalls are already redirected to the compat versions and having a mix of translated and untranslated seems like the worst option.

The only one of these three that's likely to cause trouble is schedop (poll) which almost always happens to work if you call the wrong version.  However the interlock against concurrent event arrival doesn't work, which was leading to lockups in the HVMloader xenbus code.

Cc'ing various people who I know are responsible for HVM PV drivers just in case any ofthem have hardcoded this broken interface into client code.

Cheers,

Tim.

--
Tim Deegan <[email protected]>
Principal Software Engineer, Xen Platform Team Citrix Systems UK Ltd.  (Company #02937203, SL9 0BG)

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

Signature · 3 lines
Tim Deegan <[email protected]>
Principal Software Engineer, Xen Platform Team
Citrix Systems UK Ltd.  (Company #02937203, SL9 0BG)