ia64/xen-unstable

changeset 17866:ac745ad5f018

32-on-64: Fix compat-access macros to use correct underlying HVM accessors.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Fri Jun 13 16:10:50 2008 +0100 (2008-06-13)
parents a88e19526770
children 049a42108c65
files xen/include/asm-x86/guest_access.h xen/include/xen/compat.h
line diff
     1.1 --- a/xen/include/asm-x86/guest_access.h	Fri Jun 13 15:31:35 2008 +0100
     1.2 +++ b/xen/include/asm-x86/guest_access.h	Fri Jun 13 16:10:50 2008 +0100
     1.3 @@ -12,6 +12,24 @@
     1.4  #include <asm/hvm/support.h>
     1.5  #include <asm/hvm/guest_access.h>
     1.6  
     1.7 +/* Raw access functions: no type checking. */
     1.8 +#define raw_copy_to_guest(dst, src, len)        \
     1.9 +    (is_hvm_vcpu(current) ?                     \
    1.10 +     copy_to_user_hvm((dst), (src), (len)) :    \
    1.11 +     copy_to_user((dst), (src), (len)))
    1.12 +#define raw_copy_from_guest(dst, src, len)      \
    1.13 +    (is_hvm_vcpu(current) ?                     \
    1.14 +     copy_from_user_hvm((dst), (src), (len)) :  \
    1.15 +     copy_from_user((dst), (src), (len)))
    1.16 +#define __raw_copy_to_guest(dst, src, len)      \
    1.17 +    (is_hvm_vcpu(current) ?                     \
    1.18 +     copy_to_user_hvm((dst), (src), (len)) :    \
    1.19 +     __copy_to_user((dst), (src), (len)))
    1.20 +#define __raw_copy_from_guest(dst, src, len)    \
    1.21 +    (is_hvm_vcpu(current) ?                     \
    1.22 +     copy_from_user_hvm((dst), (src), (len)) :  \
    1.23 +     __copy_from_user((dst), (src), (len)))
    1.24 +
    1.25  /* Is the guest handle a NULL reference? */
    1.26  #define guest_handle_is_null(hnd)        ((hnd).p == NULL)
    1.27  
    1.28 @@ -36,9 +54,7 @@
    1.29      const typeof(*(ptr)) *_s = (ptr);                   \
    1.30      char (*_d)[sizeof(*_s)] = (void *)(hnd).p;          \
    1.31      ((void)((hnd).p == (ptr)));                         \
    1.32 -    is_hvm_vcpu(current) ?                              \
    1.33 -    copy_to_user_hvm(_d+(off), _s, sizeof(*_s)*(nr)) :  \
    1.34 -    copy_to_user(_d+(off), _s, sizeof(*_s)*(nr));       \
    1.35 +    raw_copy_to_guest(_d+(off), _s, sizeof(*_s)*(nr));  \
    1.36  })
    1.37  
    1.38  /*
    1.39 @@ -48,9 +64,7 @@
    1.40  #define copy_from_guest_offset(ptr, hnd, off, nr) ({    \
    1.41      const typeof(*(ptr)) *_s = (hnd).p;                 \
    1.42      typeof(*(ptr)) *_d = (ptr);                         \
    1.43 -    is_hvm_vcpu(current) ?                              \
    1.44 -    copy_from_user_hvm(_d, _s+(off), sizeof(*_d)*(nr)) :\
    1.45 -    copy_from_user(_d, _s+(off), sizeof(*_d)*(nr));     \
    1.46 +    raw_copy_from_guest(_d, _s+(off), sizeof(*_d)*(nr));\
    1.47  })
    1.48  
    1.49  /* Copy sub-field of a structure to guest context via a guest handle. */
    1.50 @@ -58,18 +72,14 @@
    1.51      const typeof(&(ptr)->field) _s = &(ptr)->field;     \
    1.52      void *_d = &(hnd).p->field;                         \
    1.53      ((void)(&(hnd).p->field == &(ptr)->field));         \
    1.54 -    is_hvm_vcpu(current) ?                              \
    1.55 -    copy_to_user_hvm(_d, _s, sizeof(*_s)) :             \
    1.56 -    copy_to_user(_d, _s, sizeof(*_s));                  \
    1.57 +    raw_copy_to_guest(_d, _s, sizeof(*_s));             \
    1.58  })
    1.59  
    1.60  /* Copy sub-field of a structure from guest context via a guest handle. */
    1.61  #define copy_field_from_guest(ptr, hnd, field) ({       \
    1.62      const typeof(&(ptr)->field) _s = &(hnd).p->field;   \
    1.63      typeof(&(ptr)->field) _d = &(ptr)->field;           \
    1.64 -    is_hvm_vcpu(current) ?                              \
    1.65 -    copy_from_user_hvm(_d, _s, sizeof(*_d)) :           \
    1.66 -    copy_from_user(_d, _s, sizeof(*_d));                \
    1.67 +    raw_copy_from_guest(_d, _s, sizeof(*_d));           \
    1.68  })
    1.69  
    1.70  /*
    1.71 @@ -89,34 +99,26 @@
    1.72      const typeof(*(ptr)) *_s = (ptr);                   \
    1.73      char (*_d)[sizeof(*_s)] = (void *)(hnd).p;          \
    1.74      ((void)((hnd).p == (ptr)));                         \
    1.75 -    is_hvm_vcpu(current) ?                              \
    1.76 -    copy_to_user_hvm(_d+(off), _s, sizeof(*_s)*(nr)) :  \
    1.77 -    __copy_to_user(_d+(off), _s, sizeof(*_s)*(nr));     \
    1.78 +    __raw_copy_to_guest(_d+(off), _s, sizeof(*_s)*(nr));\
    1.79  })
    1.80  
    1.81  #define __copy_from_guest_offset(ptr, hnd, off, nr) ({  \
    1.82      const typeof(*(ptr)) *_s = (hnd).p;                 \
    1.83      typeof(*(ptr)) *_d = (ptr);                         \
    1.84 -    is_hvm_vcpu(current) ?                              \
    1.85 -    copy_from_user_hvm(_d, _s+(off), sizeof(*_d)*(nr)) :\
    1.86 -    __copy_from_user(_d, _s+(off), sizeof(*_d)*(nr));   \
    1.87 +    __raw_copy_from_guest(_d, _s+(off), sizeof(*_d)*(nr));\
    1.88  })
    1.89  
    1.90  #define __copy_field_to_guest(hnd, ptr, field) ({       \
    1.91      const typeof(&(ptr)->field) _s = &(ptr)->field;     \
    1.92      void *_d = &(hnd).p->field;                         \
    1.93      ((void)(&(hnd).p->field == &(ptr)->field));         \
    1.94 -    is_hvm_vcpu(current) ?                              \
    1.95 -    copy_to_user_hvm(_d, _s, sizeof(*_s)) :             \
    1.96 -    __copy_to_user(_d, _s, sizeof(*_s));                \
    1.97 +    __raw_copy_to_guest(_d, _s, sizeof(*_s));           \
    1.98  })
    1.99  
   1.100  #define __copy_field_from_guest(ptr, hnd, field) ({     \
   1.101      const typeof(&(ptr)->field) _s = &(hnd).p->field;   \
   1.102      typeof(&(ptr)->field) _d = &(ptr)->field;           \
   1.103 -    is_hvm_vcpu(current) ?                              \
   1.104 -    copy_from_user_hvm(_d, _s, sizeof(*_d)) :           \
   1.105 -    __copy_from_user(_d, _s, sizeof(*_d));              \
   1.106 +    __raw_copy_from_guest(_d, _s, sizeof(*_d));         \
   1.107  })
   1.108  
   1.109  #endif /* __ASM_X86_GUEST_ACCESS_H__ */
     2.1 --- a/xen/include/xen/compat.h	Fri Jun 13 15:31:35 2008 +0100
     2.2 +++ b/xen/include/xen/compat.h	Fri Jun 13 16:10:50 2008 +0100
     2.3 @@ -47,7 +47,7 @@
     2.4      const typeof(*(ptr)) *_s = (ptr);                                \
     2.5      char (*_d)[sizeof(*_s)] = (void *)(full_ptr_t)(hnd).c;           \
     2.6      ((void)((typeof(**(hnd)._) *)(full_ptr_t)(hnd).c == (ptr)));     \
     2.7 -    copy_to_user(_d + (off), _s, sizeof(*_s) * (nr));                \
     2.8 +    raw_copy_to_guest(_d + (off), _s, sizeof(*_s) * (nr));           \
     2.9  })
    2.10  
    2.11  /*
    2.12 @@ -57,7 +57,7 @@
    2.13  #define copy_from_compat_offset(ptr, hnd, off, nr) ({                \
    2.14      const typeof(*(ptr)) *_s = (typeof(**(hnd)._) *)(full_ptr_t)(hnd).c; \
    2.15      typeof(*(ptr)) *_d = (ptr);                                      \
    2.16 -    copy_from_user(_d, _s + (off), sizeof(*_d) * (nr));              \
    2.17 +    raw_copy_from_guest(_d, _s + (off), sizeof(*_d) * (nr));         \
    2.18  })
    2.19  
    2.20  #define copy_to_compat(hnd, ptr, nr)                                 \
    2.21 @@ -72,7 +72,7 @@
    2.22      void *_d = &((typeof(**(hnd)._) *)(full_ptr_t)(hnd).c)->field;   \
    2.23      ((void)(&((typeof(**(hnd)._) *)(full_ptr_t)(hnd).c)->field ==    \
    2.24              &(ptr)->field));                                         \
    2.25 -    copy_to_user(_d, _s, sizeof(*_s));                               \
    2.26 +    raw_copy_to_guest(_d, _s, sizeof(*_s));                          \
    2.27  })
    2.28  
    2.29  /* Copy sub-field of a structure from guest context via a compat handle. */
    2.30 @@ -80,7 +80,7 @@
    2.31      const typeof(&(ptr)->field) _s =                                 \
    2.32          &((typeof(**(hnd)._) *)(full_ptr_t)(hnd).c)->field;          \
    2.33      typeof(&(ptr)->field) _d = &(ptr)->field;                        \
    2.34 -    copy_from_user(_d, _s, sizeof(*_d));                             \
    2.35 +    raw_copy_from_guest(_d, _s, sizeof(*_d));                        \
    2.36  })
    2.37  
    2.38  /*
    2.39 @@ -95,13 +95,13 @@
    2.40      const typeof(*(ptr)) *_s = (ptr);                                \
    2.41      char (*_d)[sizeof(*_s)] = (void *)(full_ptr_t)(hnd).c;           \
    2.42      ((void)((typeof(**(hnd)._) *)(full_ptr_t)(hnd).c == (ptr)));     \
    2.43 -    __copy_to_user(_d + (off), _s, sizeof(*_s) * (nr));              \
    2.44 +    __raw_copy_to_guest(_d + (off), _s, sizeof(*_s) * (nr));         \
    2.45  })
    2.46  
    2.47  #define __copy_from_compat_offset(ptr, hnd, off, nr) ({              \
    2.48      const typeof(*(ptr)) *_s = (typeof(**(hnd)._) *)(full_ptr_t)(hnd).c; \
    2.49      typeof(*(ptr)) *_d = (ptr);                                      \
    2.50 -    __copy_from_user(_d, _s + (off), sizeof(*_d) * (nr));            \
    2.51 +    __raw_copy_from_guest(_d, _s + (off), sizeof(*_d) * (nr));       \
    2.52  })
    2.53  
    2.54  #define __copy_to_compat(hnd, ptr, nr)                               \
    2.55 @@ -115,14 +115,14 @@
    2.56      void *_d = &((typeof(**(hnd)._) *)(full_ptr_t)(hnd).c)->field;   \
    2.57      ((void)(&((typeof(**(hnd)._) *)(full_ptr_t)(hnd).c)->field ==    \
    2.58              &(ptr)->field));                                         \
    2.59 -    __copy_to_user(_d, _s, sizeof(*_s));                             \
    2.60 +    __raw_copy_to_guest(_d, _s, sizeof(*_s));                        \
    2.61  })
    2.62  
    2.63  #define __copy_field_from_compat(ptr, hnd, field) ({                 \
    2.64      const typeof(&(ptr)->field) _s =                                 \
    2.65          &((typeof(**(hnd)._) *)(full_ptr_t)(hnd).c)->field;          \
    2.66      typeof(&(ptr)->field) _d = &(ptr)->field;                        \
    2.67 -    __copy_from_user(_d, _s, sizeof(*_d));                           \
    2.68 +    __raw_copy_from_guest(_d, _s, sizeof(*_d));                      \
    2.69  })
    2.70  
    2.71