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

[Xen-devel] [PATCH] do_callback_op()'s second argument can be const



.. allowing the guest to declare these (mostly static) argument
structures 'const' (a Linux patch to that effect will follow).

Instead of introducing a 'const void' guest handle onn each
architecture, the patch moves the common guest handle declarations into
a common place.

(PowerPC part done just based on analogy, not tested.)

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxxxx>

Index: 2008-01-07/xen/arch/ia64/xen/hypercall.c
===================================================================
--- 2008-01-07.orig/xen/arch/ia64/xen/hypercall.c       2007-12-05 
17:13:57.000000000 +0100
+++ 2008-01-07/xen/arch/ia64/xen/hypercall.c    2008-01-07 12:11:43.000000000 
+0100
@@ -34,9 +34,6 @@
 #include <xen/perfc.h>
 #include <public/arch-ia64/debug_op.h>
 
-extern long do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg);
-extern long do_callback_op(int cmd, XEN_GUEST_HANDLE(void) arg);
-
 static IA64FAULT
 xen_hypercall (struct pt_regs *regs)
 {
@@ -457,7 +454,7 @@ static long unregister_guest_callback(st
 /* First time to add callback to xen/ia64, so let's just stick to
  * the newer callback interface.
  */
-long do_callback_op(int cmd, XEN_GUEST_HANDLE(void) arg)
+long do_callback_op(int cmd, XEN_GUEST_HANDLE(cvoid) arg)
 {
     long ret;
 
Index: 2008-01-07/xen/arch/x86/x86_32/traps.c
===================================================================
--- 2008-01-07.orig/xen/arch/x86/x86_32/traps.c 2007-11-26 16:57:03.000000000 
+0100
+++ 2008-01-07/xen/arch/x86/x86_32/traps.c      2008-01-07 12:11:43.000000000 
+0100
@@ -419,7 +419,7 @@ static long unregister_guest_callback(st
 }
 
 
-long do_callback_op(int cmd, XEN_GUEST_HANDLE(void) arg)
+long do_callback_op(int cmd, XEN_GUEST_HANDLE(cvoid) arg)
 {
     long ret;
 
Index: 2008-01-07/xen/arch/x86/x86_64/traps.c
===================================================================
--- 2008-01-07.orig/xen/arch/x86/x86_64/traps.c 2007-11-02 17:25:58.000000000 
+0100
+++ 2008-01-07/xen/arch/x86/x86_64/traps.c      2008-01-07 12:11:43.000000000 
+0100
@@ -470,7 +470,7 @@ static long unregister_guest_callback(st
 }
 
 
-long do_callback_op(int cmd, XEN_GUEST_HANDLE(void) arg)
+long do_callback_op(int cmd, XEN_GUEST_HANDLE(cvoid) arg)
 {
     long ret;
 
Index: 2008-01-07/xen/include/asm-x86/guest_access.h
===================================================================
--- 2008-01-07.orig/xen/include/asm-x86/guest_access.h  2007-12-07 
11:51:50.000000000 +0100
+++ 2008-01-07/xen/include/asm-x86/guest_access.h       2008-01-07 
12:11:43.000000000 +0100
@@ -34,7 +34,8 @@
  */
 #define copy_to_guest_offset(hnd, off, ptr, nr) ({      \
     const typeof(*(ptr)) *_s = (ptr);                   \
-    char (*_d)[sizeof(*_s)] = (void *)(hnd).p;          \
+    void *_p = (hnd).p;                                 \
+    char (*_d)[sizeof(*_s)] = _p;                       \
     ((void)((hnd).p == (ptr)));                         \
     is_hvm_vcpu(current) ?                              \
     copy_to_user_hvm(_d+(off), _s, sizeof(*_s)*(nr)) :  \
@@ -82,7 +83,8 @@
 
 #define __copy_to_guest_offset(hnd, off, ptr, nr) ({    \
     const typeof(*(ptr)) *_s = (ptr);                   \
-    char (*_d)[sizeof(*_s)] = (void *)(hnd).p;          \
+    void *_p = (hnd).p;                                 \
+    char (*_d)[sizeof(*_s)] = _p;                       \
     ((void)((hnd).p == (ptr)));                         \
     is_hvm_vcpu(current) ?                              \
     copy_to_user_hvm(_d+(off), _s, sizeof(*_s)*(nr)) :  \
Index: 2008-01-07/xen/include/public/arch-ia64.h
===================================================================
--- 2008-01-07.orig/xen/include/public/arch-ia64.h      2008-01-07 
12:02:52.000000000 +0100
+++ 2008-01-07/xen/include/public/arch-ia64.h   2008-01-07 12:11:43.000000000 
+0100
@@ -47,18 +47,7 @@
 #endif
 
 #ifndef __ASSEMBLY__
-/* Guest handles for primitive C types. */
-__DEFINE_XEN_GUEST_HANDLE(uchar, unsigned char);
-__DEFINE_XEN_GUEST_HANDLE(uint,  unsigned int);
-__DEFINE_XEN_GUEST_HANDLE(ulong, unsigned long);
-__DEFINE_XEN_GUEST_HANDLE(u64,   unsigned long);
-DEFINE_XEN_GUEST_HANDLE(char);
-DEFINE_XEN_GUEST_HANDLE(int);
-DEFINE_XEN_GUEST_HANDLE(long);
-DEFINE_XEN_GUEST_HANDLE(void);
-
 typedef unsigned long xen_pfn_t;
-DEFINE_XEN_GUEST_HANDLE(xen_pfn_t);
 #define PRI_xen_pfn "lx"
 #endif
 
Index: 2008-01-07/xen/include/public/arch-powerpc.h
===================================================================
--- 2008-01-07.orig/xen/include/public/arch-powerpc.h   2008-01-07 
12:02:52.000000000 +0100
+++ 2008-01-07/xen/include/public/arch-powerpc.h        2008-01-07 
12:11:43.000000000 +0100
@@ -47,17 +47,7 @@
 #endif
 
 #ifndef __ASSEMBLY__
-/* Guest handles for primitive C types. */
-__DEFINE_XEN_GUEST_HANDLE(uchar, unsigned char);
-__DEFINE_XEN_GUEST_HANDLE(uint,  unsigned int);
-__DEFINE_XEN_GUEST_HANDLE(ulong, unsigned long);
-DEFINE_XEN_GUEST_HANDLE(char);
-DEFINE_XEN_GUEST_HANDLE(int);
-DEFINE_XEN_GUEST_HANDLE(long);
-DEFINE_XEN_GUEST_HANDLE(void);
-
 typedef unsigned long long xen_pfn_t;
-DEFINE_XEN_GUEST_HANDLE(xen_pfn_t);
 #define PRI_xen_pfn "llx"
 #endif
 
Index: 2008-01-07/xen/include/public/arch-x86/xen.h
===================================================================
--- 2008-01-07.orig/xen/include/public/arch-x86/xen.h   2008-01-07 
12:02:52.000000000 +0100
+++ 2008-01-07/xen/include/public/arch-x86/xen.h        2008-01-07 
12:11:43.000000000 +0100
@@ -53,17 +53,7 @@
 #endif
 
 #ifndef __ASSEMBLY__
-/* Guest handles for primitive C types. */
-__DEFINE_XEN_GUEST_HANDLE(uchar, unsigned char);
-__DEFINE_XEN_GUEST_HANDLE(uint,  unsigned int);
-__DEFINE_XEN_GUEST_HANDLE(ulong, unsigned long);
-DEFINE_XEN_GUEST_HANDLE(char);
-DEFINE_XEN_GUEST_HANDLE(int);
-DEFINE_XEN_GUEST_HANDLE(long);
-DEFINE_XEN_GUEST_HANDLE(void);
-
 typedef unsigned long xen_pfn_t;
-DEFINE_XEN_GUEST_HANDLE(xen_pfn_t);
 #define PRI_xen_pfn "lx"
 #endif
 
Index: 2008-01-07/xen/include/public/xen.h
===================================================================
--- 2008-01-07.orig/xen/include/public/xen.h    2008-01-07 12:02:52.000000000 
+0100
+++ 2008-01-07/xen/include/public/xen.h 2008-01-07 12:11:43.000000000 +0100
@@ -39,6 +39,20 @@
 #error "Unsupported architecture"
 #endif
 
+#ifndef __ASSEMBLY__
+/* Guest handles for primitive C types. */
+DEFINE_XEN_GUEST_HANDLE(char);
+__DEFINE_XEN_GUEST_HANDLE(uchar, unsigned char);
+DEFINE_XEN_GUEST_HANDLE(int);
+__DEFINE_XEN_GUEST_HANDLE(uint,  unsigned int);
+DEFINE_XEN_GUEST_HANDLE(long);
+__DEFINE_XEN_GUEST_HANDLE(ulong, unsigned long);
+DEFINE_XEN_GUEST_HANDLE(void);
+__DEFINE_XEN_GUEST_HANDLE(cvoid, const void);
+
+DEFINE_XEN_GUEST_HANDLE(xen_pfn_t);
+#endif
+
 /*
  * HYPERCALLS
  */



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


 


Rackspace

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