public header adjustments
RFC PATCH 1/17 public header adjustments
xen/arch/x86/domain.c +6 -7
@@ -386,15 +386,15 @@ arch_do_vcpu_op(if (copy_from_guest (&area, arg,1 ) )break ; -if ( !access_ok (area.addr.v,sizeof (*area.addr.v)) ) +if ( (unsigned long )area.addr.h.p != area.addr.p || + !guest_handle_okay (area.addr.h,1 ) )break ; rc =0 ; - v->runstate_guest = area.addr.v; + v->runstate_guest = area.addr.h;if ( v == current ) -__copy_to_user (v->runstate_guest, &v->runstate, -sizeof (v->runstate)); +__copy_to_guest (area.addr.h, &v->runstate,1 );break ; }
@@ -749,9 +749,8 @@ void context_switch(struct vcpu *prev, scontext_saved (prev);/* Update per-VCPU guest runstate shared memory area (if registered). */ -if ( next->runstate_guest !=NULL ) -__copy_to_user (next->runstate_guest, &next->runstate, -sizeof (next->runstate)); +if ( !guest_handle_is_null (next->runstate_guest) ) +__copy_to_guest (next->runstate_guest, &next->runstate,1 );schedule_tail (next);BUG ();
xen/arch/x86/mm.c +1 -1
@@ -2072,7 +2072,7 @@ int do_mmuext_op( {unsigned long vmask;cpumask_t pmask; -if (unlikely (get_user (vmask, (unsigned long *)op.arg2.vcpumask)) ) +if (unlikely (copy_from_guest (&vmask, op.arg2.vcpumask,1 )) ) { okay =0 ;break ;
xen/arch/x86/physdev.c +1 -1
@@ -125,7 +125,7 @@ long do_physdev_op(int cmd, XEN_GUEST_HAif (copy_from_guest (&set_iobitmap, arg,1 ) !=0 )break ; ret = -EINVAL ; -if ( !access_ok (set_iobitmap.bitmap,IOBMP_BYTES ) || +if ( !guest_handle_okay (set_iobitmap.bitmap,IOBMP_BYTES ) || (set_iobitmap.nr_ports >65536 ) )break ; ret =0 ;
xen/arch/x86/traps.c +9 -3
@@ -971,7 +971,6 @@ static inline int guest_io_okay( unsigned int port, unsigned int bytes, struct vcpu *v, struct cpu_user_regs *regs) { - u16 x; #if defined(__x86_64__) /* If in user mode, switch to kernel mode just to read I/O bitmap. */ int user_mode = !(v->arch.flags & TF_kernel_mode);
@@ -986,10 +985,17 @@ static inline int guest_io_okay(if ( v->arch.iobmp_limit > (port + bytes) ) { +union {uint8_t bytes[2 ];uint16_t mask; } x; +TOGGLE_MODE (); -__get_user (x, (u16 *)(v->arch.iobmp+(port>>3 ))); +switch (__copy_from_guest_offset (&x.bytes[0 ], v->arch.iobmp, port>>3 ,2 ) ) + { +default : x.bytes[0 ] = ~0 ; +case 1 : x.bytes[1 ] = ~0 ; +case 0 :break ; + }TOGGLE_MODE (); -if ( (x & (((1 <<bytes)-1 ) << (port&7 ))) ==0 ) +if ( (x.mask & (((1 <<bytes)-1 ) << (port&7 ))) ==0 )return 1 ; }
xen/include/asm-x86/domain.h +1 -1
@@ -167,7 +167,7 @@ struct arch_vcpustruct trap_bounce trap_bounce;/* I/O-port access bitmap. */ -u8 *iobmp;/* Guest kernel virtual address of the bitmap. */ +XEN_GUEST_HANDLE (uint8_t ) iobmp;/* Guest kernel virtual address of the bitmap. */ int iobmp_limit;/* Number of ports represented in the bitmap. */ int iopl;/* Current IOPL for this VCPU. */
xen/include/public/physdev.h +6 -0
@@ -2,6 +2,8 @@#ifndef __XEN_PUBLIC_PHYSDEV_H__#define __XEN_PUBLIC_PHYSDEV_H__ +#include "xen.h" +/* * Prototype for this hypercall is: * int physdev_op(int cmd, void *args)
@@ -62,7 +64,11 @@ DEFINE_XEN_GUEST_HANDLE(physdev_set_iopl#define PHYSDEVOP_set_iobitmap 7struct physdev_set_iobitmap {/* IN */ +#ifdef __XEN__ +XEN_GUEST_HANDLE (uint8_t ) bitmap; +#else uint8_t *bitmap; +#endif uint32_t nr_ports; };typedef struct physdev_set_iobitmap physdev_set_iobitmap_t ;
xen/include/public/vcpu.h +7 -0
@@ -9,6 +9,8 @@#ifndef __XEN_PUBLIC_VCPU_H__#define __XEN_PUBLIC_VCPU_H__ +#include "xen.h" +/* * Prototype for this hypercall is: * int vcpu_op(int cmd, int vcpuid, void *extra_args)
@@ -68,6 +70,7 @@ struct vcpu_runstate_info {uint64_t time[4 ]; };typedef struct vcpu_runstate_info vcpu_runstate_info_t ; +DEFINE_XEN_GUEST_HANDLE (vcpu_runstate_info_t);/* VCPU is currently running on a physical CPU. */ #define RUNSTATE_running 0
@@ -102,7 +105,11 @@ typedef struct vcpu_runstate_info vcpu_r#define VCPUOP_register_runstate_memory_area 5struct vcpu_register_runstate_memory_area {union { +#ifdef __XEN__ +XEN_GUEST_HANDLE (vcpu_runstate_info_t) h; +#else struct vcpu_runstate_info *v; +#endif uint64_t p; } addr; };
xen/include/public/xen.h +4 -0
@@ -228,7 +228,11 @@ struct mmuext_op {/* SET_LDT */ unsigned int nr_ents;/* TLB_FLUSH_MULTI, INVLPG_MULTI */ +#ifdef __XEN__ +XEN_GUEST_HANDLE (ulong) vcpumask; +#else void *vcpumask; +#endif } arg2; };typedef struct mmuext_op mmuext_op_t ;
xen/include/xen/sched.h +1 -1
@@ -75,7 +75,7 @@ struct vcpuvoid *sched_priv;/* scheduler-specific data */ struct vcpu_runstate_info runstate; -struct vcpu_runstate_info *runstate_guest;/* guest address */ +XEN_GUEST_HANDLE (vcpu_runstate_info_t) runstate_guest;/* guest address */ unsigned long vcpu_flags;