[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] x86: fix a few 32-on-64 compat mode issues



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1210583707 -3600
# Node ID 945394931d9e5cb6094f5117acc0a9f55e1019d9
# Parent  9be45076186d191c3c0e622bab42d6c87ffe0cac
x86: fix a few 32-on-64 compat mode issues

- handle VCPUOP_register_vcpu_info and VCPUOP_get_physid (and add
  respective layout checks)
- add missing structure size check for struct vcpu_info
- add missing layout check for vcpu_set_periodic_timer
- handle VCPUOP_set_singleshot_timer via argument translation as the
  structure sizes differ (due to padding in 64-bits)

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxxxx>
---
 xen/arch/x86/x86_64/domain.c |   19 ++++++++++++++++---
 xen/common/compat/domain.c   |   20 ++++++++++++++++++--
 xen/include/xlat.lst         |    5 +++++
 xen/tools/get-fields.sh      |    1 -
 4 files changed, 39 insertions(+), 6 deletions(-)

diff -r 9be45076186d -r 945394931d9e xen/arch/x86/x86_64/domain.c
--- a/xen/arch/x86/x86_64/domain.c      Mon May 12 10:14:01 2008 +0100
+++ b/xen/arch/x86/x86_64/domain.c      Mon May 12 10:15:07 2008 +0100
@@ -9,11 +9,23 @@
 #include <asm/hypercall.h>
 #include <compat/vcpu.h>
 
+#define xen_vcpu_info vcpu_info
+CHECK_SIZE_(struct, vcpu_info);
+#undef xen_vcpu_info
+
+#define xen_vcpu_register_vcpu_info vcpu_register_vcpu_info
+CHECK_vcpu_register_vcpu_info;
+#undef xen_vcpu_register_vcpu_info
+
+#define xen_vcpu_get_physid vcpu_get_physid
+CHECK_vcpu_get_physid;
+#undef xen_vcpu_get_physid
+
 int
 arch_compat_vcpu_op(
     int cmd, struct vcpu *v, XEN_GUEST_HANDLE(void) arg)
 {
-    long rc = 0;
+    int rc = -ENOSYS;
 
     switch ( cmd )
     {
@@ -51,8 +63,9 @@ arch_compat_vcpu_op(
         break;
     }
 
-    default:
-        rc = -ENOSYS;
+    case VCPUOP_register_vcpu_info:
+    case VCPUOP_get_physid:
+        rc = arch_do_vcpu_op(cmd, v, arg);
         break;
     }
 
diff -r 9be45076186d -r 945394931d9e xen/common/compat/domain.c
--- a/xen/common/compat/domain.c        Mon May 12 10:14:01 2008 +0100
+++ b/xen/common/compat/domain.c        Mon May 12 10:15:07 2008 +0100
@@ -11,11 +11,15 @@
 #include <xen/hypercall.h>
 #include <compat/vcpu.h>
 
+#define xen_vcpu_set_periodic_timer vcpu_set_periodic_timer
+CHECK_vcpu_set_periodic_timer;
+#undef xen_vcpu_set_periodic_timer
+
 int compat_vcpu_op(int cmd, int vcpuid, XEN_GUEST_HANDLE(void) arg)
 {
     struct domain *d = current->domain;
     struct vcpu *v;
-    long rc = 0;
+    int rc = 0;
 
     if ( (vcpuid < 0) || (vcpuid >= MAX_VIRT_CPUS) )
         return -EINVAL;
@@ -57,7 +61,6 @@ int compat_vcpu_op(int cmd, int vcpuid, 
     case VCPUOP_is_up:
     case VCPUOP_set_periodic_timer:
     case VCPUOP_stop_periodic_timer:
-    case VCPUOP_set_singleshot_timer:
     case VCPUOP_stop_singleshot_timer:
     case VCPUOP_send_nmi:
         rc = do_vcpu_op(cmd, vcpuid, arg);
@@ -74,6 +77,19 @@ int compat_vcpu_op(int cmd, int vcpuid, 
         xlat_vcpu_runstate_info(&runstate.nat);
         if ( copy_to_guest(arg, &runstate.cmp, 1) )
             rc = -EFAULT;
+        break;
+    }
+
+    case VCPUOP_set_singleshot_timer:
+    {
+        struct compat_vcpu_set_singleshot_timer cmp;
+        struct vcpu_set_singleshot_timer *nat;
+
+        if ( copy_from_guest(&cmp, arg, 1) )
+            return -EFAULT;
+        nat = (void *)COMPAT_ARG_XLAT_VIRT_START(current->vcpu_id);
+        XLAT_vcpu_set_singleshot_timer(nat, &cmp);
+        rc = do_vcpu_op(cmd, vcpuid, guest_handle_from_ptr(nat, void));
         break;
     }
 
diff -r 9be45076186d -r 945394931d9e xen/include/xlat.lst
--- a/xen/include/xlat.lst      Mon May 12 10:14:01 2008 +0100
+++ b/xen/include/xlat.lst      Mon May 12 10:15:07 2008 +0100
@@ -5,6 +5,7 @@
 ?      mmu_update                      xen.h
 !      mmuext_op                       xen.h
 !      start_info                      xen.h
+?      vcpu_info                       xen.h
 ?      vcpu_time_info                  xen.h
 !      cpu_user_regs                   arch-x86/xen-@arch@.h
 !      trap_info                       arch-x86/xen.h
@@ -41,7 +42,11 @@
 ?      sched_remote_shutdown           sched.h
 ?      sched_shutdown                  sched.h
 ?      t_buf                           trace.h
+?      vcpu_get_physid                 vcpu.h
+?      vcpu_register_vcpu_info         vcpu.h
 !      vcpu_runstate_info              vcpu.h
+?      vcpu_set_periodic_timer         vcpu.h
+!      vcpu_set_singleshot_timer       vcpu.h
 ?      xenoprof_init                   xenoprof.h
 ?      xenoprof_passive                xenoprof.h
 !      power_register                  platform.h
diff -r 9be45076186d -r 945394931d9e xen/tools/get-fields.sh
--- a/xen/tools/get-fields.sh   Mon May 12 10:14:01 2008 +0100
+++ b/xen/tools/get-fields.sh   Mon May 12 10:15:07 2008 +0100
@@ -310,7 +310,6 @@ build_body ()
        done
        echo " \\"
        echo "} while (0)"
-       echo ""
 }
 
 check_field ()

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.