ia64/xen-unstable

changeset 17630:945394931d9e

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@novell.com>
author Keir Fraser <keir.fraser@citrix.com>
date Mon May 12 10:15:07 2008 +0100 (2008-05-12)
parents 9be45076186d
children a6e2679b1aad
files xen/arch/x86/x86_64/domain.c xen/common/compat/domain.c xen/include/xlat.lst xen/tools/get-fields.sh
line diff
     1.1 --- a/xen/arch/x86/x86_64/domain.c	Mon May 12 10:14:01 2008 +0100
     1.2 +++ b/xen/arch/x86/x86_64/domain.c	Mon May 12 10:15:07 2008 +0100
     1.3 @@ -9,11 +9,23 @@
     1.4  #include <asm/hypercall.h>
     1.5  #include <compat/vcpu.h>
     1.6  
     1.7 +#define xen_vcpu_info vcpu_info
     1.8 +CHECK_SIZE_(struct, vcpu_info);
     1.9 +#undef xen_vcpu_info
    1.10 +
    1.11 +#define xen_vcpu_register_vcpu_info vcpu_register_vcpu_info
    1.12 +CHECK_vcpu_register_vcpu_info;
    1.13 +#undef xen_vcpu_register_vcpu_info
    1.14 +
    1.15 +#define xen_vcpu_get_physid vcpu_get_physid
    1.16 +CHECK_vcpu_get_physid;
    1.17 +#undef xen_vcpu_get_physid
    1.18 +
    1.19  int
    1.20  arch_compat_vcpu_op(
    1.21      int cmd, struct vcpu *v, XEN_GUEST_HANDLE(void) arg)
    1.22  {
    1.23 -    long rc = 0;
    1.24 +    int rc = -ENOSYS;
    1.25  
    1.26      switch ( cmd )
    1.27      {
    1.28 @@ -51,8 +63,9 @@ arch_compat_vcpu_op(
    1.29          break;
    1.30      }
    1.31  
    1.32 -    default:
    1.33 -        rc = -ENOSYS;
    1.34 +    case VCPUOP_register_vcpu_info:
    1.35 +    case VCPUOP_get_physid:
    1.36 +        rc = arch_do_vcpu_op(cmd, v, arg);
    1.37          break;
    1.38      }
    1.39  
     2.1 --- a/xen/common/compat/domain.c	Mon May 12 10:14:01 2008 +0100
     2.2 +++ b/xen/common/compat/domain.c	Mon May 12 10:15:07 2008 +0100
     2.3 @@ -11,11 +11,15 @@
     2.4  #include <xen/hypercall.h>
     2.5  #include <compat/vcpu.h>
     2.6  
     2.7 +#define xen_vcpu_set_periodic_timer vcpu_set_periodic_timer
     2.8 +CHECK_vcpu_set_periodic_timer;
     2.9 +#undef xen_vcpu_set_periodic_timer
    2.10 +
    2.11  int compat_vcpu_op(int cmd, int vcpuid, XEN_GUEST_HANDLE(void) arg)
    2.12  {
    2.13      struct domain *d = current->domain;
    2.14      struct vcpu *v;
    2.15 -    long rc = 0;
    2.16 +    int rc = 0;
    2.17  
    2.18      if ( (vcpuid < 0) || (vcpuid >= MAX_VIRT_CPUS) )
    2.19          return -EINVAL;
    2.20 @@ -57,7 +61,6 @@ int compat_vcpu_op(int cmd, int vcpuid, 
    2.21      case VCPUOP_is_up:
    2.22      case VCPUOP_set_periodic_timer:
    2.23      case VCPUOP_stop_periodic_timer:
    2.24 -    case VCPUOP_set_singleshot_timer:
    2.25      case VCPUOP_stop_singleshot_timer:
    2.26      case VCPUOP_send_nmi:
    2.27          rc = do_vcpu_op(cmd, vcpuid, arg);
    2.28 @@ -77,6 +80,19 @@ int compat_vcpu_op(int cmd, int vcpuid, 
    2.29          break;
    2.30      }
    2.31  
    2.32 +    case VCPUOP_set_singleshot_timer:
    2.33 +    {
    2.34 +        struct compat_vcpu_set_singleshot_timer cmp;
    2.35 +        struct vcpu_set_singleshot_timer *nat;
    2.36 +
    2.37 +        if ( copy_from_guest(&cmp, arg, 1) )
    2.38 +            return -EFAULT;
    2.39 +        nat = (void *)COMPAT_ARG_XLAT_VIRT_START(current->vcpu_id);
    2.40 +        XLAT_vcpu_set_singleshot_timer(nat, &cmp);
    2.41 +        rc = do_vcpu_op(cmd, vcpuid, guest_handle_from_ptr(nat, void));
    2.42 +        break;
    2.43 +    }
    2.44 +
    2.45      default:
    2.46          rc = arch_compat_vcpu_op(cmd, v, arg);
    2.47          break;
     3.1 --- a/xen/include/xlat.lst	Mon May 12 10:14:01 2008 +0100
     3.2 +++ b/xen/include/xlat.lst	Mon May 12 10:15:07 2008 +0100
     3.3 @@ -5,6 +5,7 @@
     3.4  ?	mmu_update			xen.h
     3.5  !	mmuext_op			xen.h
     3.6  !	start_info			xen.h
     3.7 +?	vcpu_info			xen.h
     3.8  ?	vcpu_time_info			xen.h
     3.9  !	cpu_user_regs			arch-x86/xen-@arch@.h
    3.10  !	trap_info			arch-x86/xen.h
    3.11 @@ -41,7 +42,11 @@
    3.12  ?	sched_remote_shutdown		sched.h
    3.13  ?	sched_shutdown			sched.h
    3.14  ?	t_buf				trace.h
    3.15 +?	vcpu_get_physid			vcpu.h
    3.16 +?	vcpu_register_vcpu_info		vcpu.h
    3.17  !	vcpu_runstate_info		vcpu.h
    3.18 +?	vcpu_set_periodic_timer		vcpu.h
    3.19 +!	vcpu_set_singleshot_timer	vcpu.h
    3.20  ?	xenoprof_init			xenoprof.h
    3.21  ?	xenoprof_passive		xenoprof.h
    3.22  !	power_register			platform.h
     4.1 --- a/xen/tools/get-fields.sh	Mon May 12 10:14:01 2008 +0100
     4.2 +++ b/xen/tools/get-fields.sh	Mon May 12 10:15:07 2008 +0100
     4.3 @@ -310,7 +310,6 @@ build_body ()
     4.4  	done
     4.5  	echo " \\"
     4.6  	echo "} while (0)"
     4.7 -	echo ""
     4.8  }
     4.9  
    4.10  check_field ()