WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH,RFC 1/17] public header adjustments

To: <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH,RFC 1/17] public header adjustments
From: "Jan Beulich" <jbeulich@xxxxxxxxxx>
Date: Wed, 04 Oct 2006 17:27:01 +0200
Delivery-date: Wed, 04 Oct 2006 08:25:58 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Index: 2006-10-04/xen/arch/x86/domain.c
===================================================================
--- 2006-10-04.orig/xen/arch/x86/domain.c       2006-09-21 13:26:07.000000000 
+0200
+++ 2006-10-04/xen/arch/x86/domain.c    2006-10-04 09:27:29.000000000 +0200
@@ -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, s
     context_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();
Index: 2006-10-04/xen/arch/x86/mm.c
===================================================================
--- 2006-10-04.orig/xen/arch/x86/mm.c   2006-10-04 08:49:30.000000000 +0200
+++ 2006-10-04/xen/arch/x86/mm.c        2006-10-04 09:27:53.000000000 +0200
@@ -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;
Index: 2006-10-04/xen/arch/x86/physdev.c
===================================================================
--- 2006-10-04.orig/xen/arch/x86/physdev.c      2006-08-31 15:26:11.000000000 
+0200
+++ 2006-10-04/xen/arch/x86/physdev.c   2006-09-21 11:09:00.000000000 +0200
@@ -125,7 +125,7 @@ long do_physdev_op(int cmd, XEN_GUEST_HA
         if ( 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;
Index: 2006-10-04/xen/arch/x86/traps.c
===================================================================
--- 2006-10-04.orig/xen/arch/x86/traps.c        2006-09-20 15:53:06.000000000 
+0200
+++ 2006-10-04/xen/arch/x86/traps.c     2006-10-04 09:28:00.000000000 +0200
@@ -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;
     }
 
Index: 2006-10-04/xen/include/asm-x86/domain.h
===================================================================
--- 2006-10-04.orig/xen/include/asm-x86/domain.h        2006-10-04 
08:49:31.000000000 +0200
+++ 2006-10-04/xen/include/asm-x86/domain.h     2006-09-21 11:09:00.000000000 
+0200
@@ -167,7 +167,7 @@ struct arch_vcpu
     struct 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. */
 
Index: 2006-10-04/xen/include/public/physdev.h
===================================================================
--- 2006-10-04.orig/xen/include/public/physdev.h        2006-06-09 
08:30:05.000000000 +0200
+++ 2006-10-04/xen/include/public/physdev.h     2006-09-21 11:09:00.000000000 
+0200
@@ -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           7
 struct 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;
Index: 2006-10-04/xen/include/public/vcpu.h
===================================================================
--- 2006-10-04.orig/xen/include/public/vcpu.h   2006-05-22 12:18:55.000000000 
+0200
+++ 2006-10-04/xen/include/public/vcpu.h        2006-09-21 11:09:00.000000000 
+0200
@@ -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 5
 struct 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;
 };
Index: 2006-10-04/xen/include/public/xen.h
===================================================================
--- 2006-10-04.orig/xen/include/public/xen.h    2006-09-20 13:19:25.000000000 
+0200
+++ 2006-10-04/xen/include/public/xen.h 2006-09-21 11:09:00.000000000 +0200
@@ -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;
Index: 2006-10-04/xen/include/xen/sched.h
===================================================================
--- 2006-10-04.orig/xen/include/xen/sched.h     2006-10-04 08:49:32.000000000 
+0200
+++ 2006-10-04/xen/include/xen/sched.h  2006-09-21 11:09:00.000000000 +0200
@@ -75,7 +75,7 @@ struct vcpu 
     void            *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;
 


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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH,RFC 1/17] public header adjustments, Jan Beulich <=