From: "Jan Beulich" Subject: [PATCH] fix a few compat mode issues Date: Fri, 09 May 2008 10:07:09 +0100 Message-ID: <4824305D.76E4.0078.0@novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Return-path: Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org - 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 Index: 2008-05-08/xen/arch/x86/x86_64/domain.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 2008-05-08.orig/xen/arch/x86/x86_64/domain.c 2007-06-04 = 08:35:35.000000000 +0200 +++ 2008-05-08/xen/arch/x86/x86_64/domain.c 2008-05-08 12:12:17.0000000= 00 +0200 @@ -9,11 +9,23 @@ #include #include =20 +#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 =3D 0; + int rc =3D -ENOSYS; =20 switch ( cmd ) { @@ -51,8 +63,9 @@ arch_compat_vcpu_op( break; } =20 - default: - rc =3D -ENOSYS; + case VCPUOP_register_vcpu_info: + case VCPUOP_get_physid: + rc =3D arch_do_vcpu_op(cmd, v, arg); break; } =20 Index: 2008-05-08/xen/common/compat/domain.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 2008-05-08.orig/xen/common/compat/domain.c 2008-04-16 16:08:05.0000000= 00 +0200 +++ 2008-05-08/xen/common/compat/domain.c 2008-05-08 12:12:17.0000000= 00 +0200 @@ -11,11 +11,15 @@ #include #include =20 +#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 =3D current->domain; struct vcpu *v; - long rc =3D 0; + int rc =3D 0; =20 if ( (vcpuid < 0) || (vcpuid >=3D MAX_VIRT_CPUS) ) return -EINVAL; @@ -57,7 +61,6 @@ int compat_vcpu_op(int cmd, int vcpuid,=20 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 =3D do_vcpu_op(cmd, vcpuid, arg); @@ -77,6 +80,19 @@ int compat_vcpu_op(int cmd, int vcpuid,=20 break; } =20 + 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 =3D (void *)COMPAT_ARG_XLAT_VIRT_START(current->vcpu_id); + XLAT_vcpu_set_singleshot_timer(nat, &cmp); + rc =3D do_vcpu_op(cmd, vcpuid, guest_handle_from_ptr(nat, void)); + break; + } + default: rc =3D arch_compat_vcpu_op(cmd, v, arg); break; Index: 2008-05-08/xen/include/xlat.lst =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 2008-05-08.orig/xen/include/xlat.lst 2008-05-07 12:21:37.0000000= 00 +0200 +++ 2008-05-08/xen/include/xlat.lst 2008-05-08 12:12:17.000000000 = +0200 @@ -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=20 ! 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 Index: 2008-05-08/xen/tools/get-fields.sh =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 2008-05-08.orig/xen/tools/get-fields.sh 2007-11-02 17:25:59.0000000= 00 +0100 +++ 2008-05-08/xen/tools/get-fields.sh 2008-05-08 12:12:17.000000000 = +0200 @@ -310,7 +310,6 @@ build_body () done echo " \\" echo "} while (0)" - echo "" } =20 check_field ()