linux-cvs-patches
[Top] [All Lists]

CVS Update@linux-mips.org: linux

To: linux-cvs-patches@linux-mips.org
Subject: CVS Update@linux-mips.org: linux
From: ralf@linux-mips.org
Date: Tue, 01 Mar 2005 19:22:37 +0000
Reply-to: linux-mips@linux-mips.org
Sender: linux-cvs-patches-bounce@linux-mips.org
CVSROOT:        /home/cvs
Module name:    linux
Changes by:     ralf@ftp.linux-mips.org 05/03/01 19:22:29

Modified files:
        include/asm-mips: uaccess.h 

Log message:
        Add sparse annotations for uaccess.h, the hardest part.

diff -urN linux/include/asm-mips/uaccess.h linux/include/asm-mips/uaccess.h
--- linux/include/asm-mips/uaccess.h    2004/12/03 11:30:32     1.40
+++ linux/include/asm-mips/uaccess.h    2005/03/01 19:22:29     1.41
@@ -128,7 +128,8 @@
  *
  * See access_ok() for more details.
  */
-static inline int verify_area(int type, const void * addr, unsigned long size)
+static inline int verify_area(int type, const void __user * addr,
+       unsigned long size)
 {
        return access_ok(type, addr, size) ? 0 : -EFAULT;
 }
@@ -218,31 +219,29 @@
        __get_user_nocheck((x),(ptr),sizeof(*(ptr)))
 
 struct __large_struct { unsigned long buf[100]; };
-#define __m(x) (*(struct __large_struct *)(x))
+#define __m(x) (*(struct __large_struct __user *)(x))
 
 /*
  * Yuck.  We need two variants, one for 64bit operation and one
  * for 32 bit mode and old iron.
  */
 #ifdef __mips64
-#define __GET_USER_DW(__gu_err) __get_user_asm("ld", __gu_err)
+#define __GET_USER_DW(ptr) __get_user_asm("ld", ptr)
 #else
-#define __GET_USER_DW(__gu_err) __get_user_asm_ll32(__gu_err)
+#define __GET_USER_DW(ptr) __get_user_asm_ll32(ptr)
 #endif
 
 #define __get_user_nocheck(x,ptr,size)                                 \
 ({                                                                     \
        __typeof(*(ptr)) __gu_val = 0;                                  \
-       long __gu_addr;                                                 \
        long __gu_err = 0;                                              \
                                                                        \
        might_sleep();                                                  \
-       __gu_addr = (long) (ptr);                                       \
        switch (size) {                                                 \
-       case 1: __get_user_asm("lb", __gu_err); break;                  \
-       case 2: __get_user_asm("lh", __gu_err); break;                  \
-       case 4: __get_user_asm("lw", __gu_err); break;                  \
-       case 8: __GET_USER_DW(__gu_err); break;                         \
+       case 1: __get_user_asm("lb", ptr); break;                       \
+       case 2: __get_user_asm("lh", ptr); break;                       \
+       case 4: __get_user_asm("lw", ptr); break;                       \
+       case 8: __GET_USER_DW(ptr); break;                              \
        default: __get_user_unknown(); break;                           \
        }                                                               \
        x = (__typeof__(*(ptr))) __gu_val;                              \
@@ -251,20 +250,19 @@
 
 #define __get_user_check(x,ptr,size)                                   \
 ({                                                                     \
+       const __typeof__(*(ptr)) __user * __gu_addr = (ptr);            \
        __typeof__(*(ptr)) __gu_val = 0;                                \
-       long __gu_addr;                                                 \
        long __gu_err;                                                  \
                                                                        \
        might_sleep();                                                  \
-       __gu_addr = (long) (ptr);                                       \
-       __gu_err = verify_area(VERIFY_READ, (void *) __gu_addr, size);  \
                                                                        \
+       __gu_err = verify_area(VERIFY_READ,  __gu_addr, size);          \
        if (likely(!__gu_err)) {                                        \
                switch (size) {                                         \
-               case 1: __get_user_asm("lb", __gu_err); break;          \
-               case 2: __get_user_asm("lh", __gu_err); break;          \
-               case 4: __get_user_asm("lw", __gu_err); break;          \
-               case 8: __GET_USER_DW(__gu_err); break;                 \
+               case 1: __get_user_asm("lb", __gu_addr); break;         \
+               case 2: __get_user_asm("lh", __gu_addr); break;         \
+               case 4: __get_user_asm("lw", __gu_addr); break;         \
+               case 8: __GET_USER_DW(__gu_addr); break;                \
                default: __get_user_unknown(); break;                   \
                }                                                       \
        }                                                               \
@@ -272,7 +270,7 @@
        __gu_err;                                                       \
 })
 
-#define __get_user_asm(insn,__gu_err)                                  \
+#define __get_user_asm(insn, addr)                                     \
 ({                                                                     \
        __asm__ __volatile__(                                           \
        "1:     " insn "        %1, %3                          \n"     \
@@ -285,20 +283,20 @@
        "       "__UA_ADDR "\t1b, 3b                            \n"     \
        "       .previous                                       \n"     \
        : "=r" (__gu_err), "=r" (__gu_val)                              \
-       : "0" (__gu_err), "o" (__m(__gu_addr)), "i" (-EFAULT));         \
+       : "0" (__gu_err), "o" (__m(addr)), "i" (-EFAULT));              \
 })
 
 /*
  * Get a long long 64 using 32 bit registers.
  */
-#define __get_user_asm_ll32(__gu_err)                                  \
+#define __get_user_asm_ll32(addr)                                      \
 ({                                                                     \
        __asm__ __volatile__(                                           \
-       "1:     lw      %1, %3                                  \n"     \
-       "2:     lw      %D1, %4                                 \n"     \
+       "1:     lw      %1, (%3)                                \n"     \
+       "2:     lw      %D1, 4(%3)                              \n"     \
        "       move    %0, $0                                  \n"     \
        "3:     .section        .fixup,\"ax\"                   \n"     \
-       "4:     li      %0, %5                                  \n"     \
+       "4:     li      %0, %4                                  \n"     \
        "       move    %1, $0                                  \n"     \
        "       move    %D1, $0                                 \n"     \
        "       j       3b                                      \n"     \
@@ -308,8 +306,7 @@
        "       " __UA_ADDR "   2b, 4b                          \n"     \
        "       .previous                                       \n"     \
        : "=r" (__gu_err), "=&r" (__gu_val)                             \
-       : "0" (__gu_err), "o" (__m(__gu_addr)),                         \
-         "o" (__m(__gu_addr + 4)), "i" (-EFAULT));                     \
+       : "0" (__gu_err), "r" (addr), "i" (-EFAULT));                   \
 })
 
 extern void __get_user_unknown(void);
@@ -319,25 +316,23 @@
  * for 32 bit mode and old iron.
  */
 #ifdef __mips64
-#define __PUT_USER_DW(__pu_val) __put_user_asm("sd", __pu_val)
+#define __PUT_USER_DW(ptr) __put_user_asm("sd", ptr)
 #else
-#define __PUT_USER_DW(__pu_val) __put_user_asm_ll32(__pu_val)
+#define __PUT_USER_DW(ptr) __put_user_asm_ll32(ptr)
 #endif
 
 #define __put_user_nocheck(x,ptr,size)                                 \
 ({                                                                     \
        __typeof__(*(ptr)) __pu_val;                                    \
-       long __pu_addr;                                                 \
        long __pu_err = 0;                                              \
                                                                        \
        might_sleep();                                                  \
        __pu_val = (x);                                                 \
-       __pu_addr = (long) (ptr);                                       \
        switch (size) {                                                 \
-       case 1: __put_user_asm("sb", __pu_val); break;                  \
-       case 2: __put_user_asm("sh", __pu_val); break;                  \
-       case 4: __put_user_asm("sw", __pu_val); break;                  \
-       case 8: __PUT_USER_DW(__pu_val); break;                         \
+       case 1: __put_user_asm("sb", ptr); break;                       \
+       case 2: __put_user_asm("sh", ptr); break;                       \
+       case 4: __put_user_asm("sw", ptr); break;                       \
+       case 8: __PUT_USER_DW(ptr); break;                              \
        default: __put_user_unknown(); break;                           \
        }                                                               \
        __pu_err;                                                       \
@@ -345,28 +340,26 @@
 
 #define __put_user_check(x,ptr,size)                                   \
 ({                                                                     \
-       __typeof__(*(ptr)) __pu_val;                                    \
-       long __pu_addr;                                                 \
+       __typeof__(*(ptr)) __user *__pu_addr = (ptr);                   \
+       __typeof__(*(ptr)) __pu_val = (x);                              \
        long __pu_err;                                                  \
                                                                        \
        might_sleep();                                                  \
-       __pu_val = (x);                                                 \
-       __pu_addr = (long) (ptr);                                       \
-       __pu_err = verify_area(VERIFY_WRITE, (void *) __pu_addr, size); \
                                                                        \
+       __pu_err = verify_area(VERIFY_WRITE, __pu_addr, size);          \
        if (likely(!__pu_err)) {                                        \
                switch (size) {                                         \
-               case 1: __put_user_asm("sb", __pu_val); break;          \
-               case 2: __put_user_asm("sh", __pu_val); break;          \
-               case 4: __put_user_asm("sw", __pu_val); break;          \
-               case 8: __PUT_USER_DW(__pu_val); break;                 \
+               case 1: __put_user_asm("sb", __pu_addr); break;         \
+               case 2: __put_user_asm("sh", __pu_addr); break;         \
+               case 4: __put_user_asm("sw", __pu_addr); break;         \
+               case 8: __PUT_USER_DW(__pu_addr); break;                \
                default: __put_user_unknown(); break;                   \
                }                                                       \
        }                                                               \
        __pu_err;                                                       \
 })
 
-#define __put_user_asm(insn, __pu_val)                                 \
+#define __put_user_asm(insn, ptr)                                      \
 ({                                                                     \
        __asm__ __volatile__(                                           \
        "1:     " insn "        %z2, %3         # __put_user_asm\n"     \
@@ -379,18 +372,18 @@
        "       " __UA_ADDR "   1b, 3b                          \n"     \
        "       .previous                                       \n"     \
        : "=r" (__pu_err)                                               \
-       : "0" (__pu_err), "Jr" (__pu_val), "o" (__m(__pu_addr)),        \
+       : "0" (__pu_err), "Jr" (__pu_val), "o" (__m(ptr)),              \
          "i" (-EFAULT));                                               \
 })
 
-#define __put_user_asm_ll32(__pu_val)                                  \
+#define __put_user_asm_ll32(ptr)                                       \
 ({                                                                     \
        __asm__ __volatile__(                                           \
-       "1:     sw      %2, %3          # __put_user_asm_ll32   \n"     \
-       "2:     sw      %D2, %4                                 \n"     \
+       "1:     sw      %2, (%3)        # __put_user_asm_ll32   \n"     \
+       "2:     sw      %D2, 4(%3)                              \n"     \
        "3:                                                     \n"     \
        "       .section        .fixup,\"ax\"                   \n"     \
-       "4:     li      %0, %5                                  \n"     \
+       "4:     li      %0, %4                                  \n"     \
        "       j       3b                                      \n"     \
        "       .previous                                       \n"     \
        "       .section        __ex_table,\"a\"                \n"     \
@@ -398,8 +391,8 @@
        "       " __UA_ADDR "   2b, 4b                          \n"     \
        "       .previous"                                              \
        : "=r" (__pu_err)                                               \
-       : "0" (__pu_err), "r" (__pu_val), "o" (__m(__pu_addr)),         \
-         "o" (__m(__pu_addr + 4)), "i" (-EFAULT));                     \
+       : "0" (__pu_err), "r" (__pu_val), "r" (ptr),                    \
+         "i" (-EFAULT));                                               \
 })
 
 extern void __put_user_unknown(void);
@@ -423,7 +416,7 @@
 
 #define __invoke_copy_to_user(to,from,n)                               \
 ({                                                                     \
-       register void *__cu_to_r __asm__ ("$4");                        \
+       register void __user *__cu_to_r __asm__ ("$4");                 \
        register const void *__cu_from_r __asm__ ("$5");                \
        register long __cu_len_r __asm__ ("$6");                        \
                                                                        \
@@ -455,7 +448,7 @@
  */
 #define __copy_to_user(to,from,n)                                      \
 ({                                                                     \
-       void *__cu_to;                                                  \
+       void __user __user *__cu_to;                                    \
        const void *__cu_from;                                          \
        long __cu_len;                                                  \
                                                                        \
@@ -485,7 +478,7 @@
  */
 #define copy_to_user(to,from,n)                                                
\
 ({                                                                     \
-       void *__cu_to;                                                  \
+       void __user *__cu_to;                                           \
        const void *__cu_from;                                          \
        long __cu_len;                                                  \
                                                                        \
@@ -502,7 +495,7 @@
 #define __invoke_copy_from_user(to,from,n)                             \
 ({                                                                     \
        register void *__cu_to_r __asm__ ("$4");                        \
-       register const void *__cu_from_r __asm__ ("$5");                \
+       register const void __user *__cu_from_r __asm__ ("$5");         \
        register long __cu_len_r __asm__ ("$6");                        \
                                                                        \
        __cu_to_r = (to);                                               \
@@ -541,7 +534,7 @@
 #define __copy_from_user(to,from,n)                                    \
 ({                                                                     \
        void *__cu_to;                                                  \
-       const void *__cu_from;                                          \
+       const void __user *__cu_from;                                   \
        long __cu_len;                                                  \
                                                                        \
        might_sleep();                                                  \
@@ -572,7 +565,7 @@
 #define copy_from_user(to,from,n)                                      \
 ({                                                                     \
        void *__cu_to;                                                  \
-       const void *__cu_from;                                          \
+       const void __user *__cu_from;                                   \
        long __cu_len;                                                  \
                                                                        \
        might_sleep();                                                  \
@@ -589,8 +582,8 @@
 
 #define copy_in_user(to,from,n)                                                
\
 ({                                                                     \
-       void *__cu_to;                                                  \
-       const void *__cu_from;                                          \
+       void __user *__cu_to;                                           \
+       const void __user *__cu_from;                                   \
        long __cu_len;                                                  \
                                                                        \
        might_sleep();                                                  \
@@ -616,7 +609,7 @@
  * On success, this will be zero.
  */
 static inline __kernel_size_t
-__clear_user(void *addr, __kernel_size_t size)
+__clear_user(void __user *addr, __kernel_size_t size)
 {
        __kernel_size_t res;
 
@@ -665,7 +658,7 @@
  * and returns @count.
  */
 static inline long
-__strncpy_from_user(char *__to, const char *__from, long __len)
+__strncpy_from_user(char *__to, const char __user *__from, long __len)
 {
        long res;
 
@@ -702,7 +695,7 @@
  * and returns @count.
  */
 static inline long
-strncpy_from_user(char *__to, const char *__from, long __len)
+strncpy_from_user(char *__to, const char __user *__from, long __len)
 {
        long res;
 
@@ -721,7 +714,7 @@
 }
 
 /* Returns: 0 if bad, string length+1 (memory size) of string if ok */
-static inline long __strlen_user(const char *s)
+static inline long __strlen_user(const char __user *s)
 {
        long res;
 
@@ -751,7 +744,7 @@
  * If there is a limit on the length of a valid string, you may wish to
  * consider using strnlen_user() instead.
  */
-static inline long strlen_user(const char *s)
+static inline long strlen_user(const char __user *s)
 {
        long res;
 
@@ -768,7 +761,7 @@
 }
 
 /* Returns: 0 if bad, string length+1 (memory size) of string if ok */
-static inline long __strnlen_user(const char *s, long n)
+static inline long __strnlen_user(const char __user *s, long n)
 {
        long res;
 
@@ -799,7 +792,7 @@
  * If there is a limit on the length of a valid string, you may wish to
  * consider using strnlen_user() instead.
  */
-static inline long strnlen_user(const char *s, long n)
+static inline long strnlen_user(const char __user *s, long n)
 {
        long res;
 

<Prev in Thread] Current Thread [Next in Thread>