patch-2.1.34 linux/include/asm-sparc64/uaccess.h

Next file: linux/include/asm-sparc64/unistd.h
Previous file: linux/include/asm-sparc64/termbits.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.33/linux/include/asm-sparc64/uaccess.h linux/include/asm-sparc64/uaccess.h
@@ -1,4 +1,4 @@
-/* $Id: uaccess.h,v 1.8 1997/03/14 21:05:33 jj Exp $ */
+/* $Id: uaccess.h,v 1.12 1997/04/10 23:32:50 davem Exp $ */
 #ifndef _ASM_UACCESS_H
 #define _ASM_UACCESS_H
 
@@ -10,6 +10,9 @@
 #include <linux/sched.h>
 #include <linux/string.h>
 #include <asm/a.out.h>
+#include <asm/asi.h>
+#include <asm/system.h>
+#include <asm/spitfire.h>
 #endif
 
 #ifndef __ASSEMBLY__
@@ -27,21 +30,27 @@
 
 #define get_fs() (current->tss.current_ds)
 #define get_ds() (KERNEL_DS)
-#define set_fs(val) ((current->tss.current_ds) = (val))
+extern __inline__ void set_fs(int val)
+{
+	if (val != current->tss.current_ds) {
+		if (val == KERNEL_DS) {
+			flushw_user ();
+			spitfire_set_secondary_context (0);
+		} else {
+			spitfire_set_secondary_context (current->mm->context);
+		}
+		current->tss.current_ds = val;
+	}
+}
 
-/* We have there a nice not-mapped page at page_offset - PAGE_SIZE, so that this test
- * can be fairly lightweight.
- * No one can read/write anything from userland in the kernel space by setting
- * large size and address near to page_offset - a fault will break his intentions.
- */
-#define __user_ok(addr,size) ((addr) < PAGE_OFFSET)
+#define __user_ok(addr,size) 1
 #define __kernel_ok (get_fs() == KERNEL_DS)
-#define __access_ok(addr,size) (__user_ok(((unsigned long)(addr)) & get_fs(),(size)))
-#define access_ok(type,addr,size) __access_ok((unsigned long)(addr),(size))
+#define __access_ok(addr,size) 1
+#define access_ok(type,addr,size) 1
 
 extern inline int verify_area(int type, const void * addr, unsigned long size)
 {
-	return access_ok(type,addr,size)?0:-EFAULT;
+	return 0;
 }
 
 /*
@@ -87,55 +96,28 @@
  */
 #define put_user(x,ptr) ({ \
 unsigned long __pu_addr = (unsigned long)(ptr); \
-__put_user_check((__typeof__(*(ptr)))(x),__pu_addr,sizeof(*(ptr))); })
+__put_user_nocheck((__typeof__(*(ptr)))(x),__pu_addr,sizeof(*(ptr))); })
 
 #define put_user_ret(x,ptr,retval) ({ \
 unsigned long __pu_addr = (unsigned long)(ptr); \
-__put_user_check_ret((__typeof__(*(ptr)))(x),__pu_addr,sizeof(*(ptr)),retval); })
+__put_user_nocheck_ret((__typeof__(*(ptr)))(x),__pu_addr,sizeof(*(ptr)),retval); })
 
 #define get_user(x,ptr) ({ \
 unsigned long __gu_addr = (unsigned long)(ptr); \
-__get_user_check((x),__gu_addr,sizeof(*(ptr)),__typeof__(*(ptr))); })
+__get_user_nocheck((x),__gu_addr,sizeof(*(ptr)),__typeof__(*(ptr))); })
 
 #define get_user_ret(x,ptr,retval) ({ \
 unsigned long __gu_addr = (unsigned long)(ptr); \
-__get_user_check_ret((x),__gu_addr,sizeof(*(ptr)),__typeof__(*(ptr)),retval); })
+__get_user_nocheck_ret((x),__gu_addr,sizeof(*(ptr)),__typeof__(*(ptr)),retval); })
 
-/*
- * The "__xxx" versions do not do address space checking, useful when
- * doing multiple accesses to the same area (the user has to do the
- * checks by hand with "access_ok()")
- */
-#define __put_user(x,ptr) __put_user_nocheck((x),(ptr),sizeof(*(ptr)))
-#define __put_user_ret(x,ptr,retval) __put_user_nocheck_ret((x),(ptr),sizeof(*(ptr)),retval)
-#define __get_user(x,ptr) __get_user_nocheck((x),(ptr),sizeof(*(ptr)),__typeof__(*(ptr)))
-#define __get_user_ret(x,ptr,retval) __get_user_nocheck_ret((x),(ptr),sizeof(*(ptr)),__typeof__(*(ptr)),retval)
+#define __put_user(x,ptr) put_user(x,ptr)
+#define __put_user_ret(x,ptr,retval) put_user_ret(x,ptr,retval)
+#define __get_user(x,ptr) get_user(x,ptr)
+#define __get_user_ret(x,ptr,retval) get_user_ret(x,ptr,retval)
 
 struct __large_struct { unsigned long buf[100]; };
 #define __m(x) ((struct __large_struct *)(x))
 
-#define __put_user_check(data,addr,size) ({ \
-register int __pu_ret; \
-if (__access_ok(addr,size)) { \
-switch (size) { \
-case 1: __put_user_asm(data,b,addr,__pu_ret); break; \
-case 2: __put_user_asm(data,h,addr,__pu_ret); break; \
-case 4: __put_user_asm(data,w,addr,__pu_ret); break; \
-case 8: __put_user_asm(data,x,addr,__pu_ret); break; \
-default: __pu_ret = __put_user_bad(); break; \
-} } else { __pu_ret = -EFAULT; } __pu_ret; })
-
-#define __put_user_check_ret(data,addr,size,retval) ({ \
-register int __foo __asm__ ("l1"); \
-if (__access_ok(addr,size)) { \
-switch (size) { \
-case 1: __put_user_asm_ret(data,b,addr,retval,__foo); break; \
-case 2: __put_user_asm_ret(data,h,addr,retval,__foo); break; \
-case 4: __put_user_asm_ret(data,w,addr,retval,__foo); break; \
-case 8: __put_user_asm_ret(data,x,addr,retval,__foo); break; \
-default: if (__put_user_bad()) return retval; break; \
-} } else return retval; })
-
 #define __put_user_nocheck(data,addr,size) ({ \
 register int __pu_ret; \
 switch (size) { \
@@ -159,7 +141,7 @@
 #define __put_user_asm(x,size,addr,ret)					\
 __asm__ __volatile__(							\
 	"/* Put user asm, inline. */\n"					\
-"1:\t"	"st"#size " %1, [%2]\n\t"					\
+"1:\t"	"st"#size "a %1, [%2] %4\n\t"					\
 	"clr	%0\n"							\
 "2:\n\n\t"								\
 	".section .fixup,#alloc,#execinstr\n\t"				\
@@ -172,23 +154,23 @@
 	".align	4\n\t"							\
 	".word	1b, 3b\n\t"						\
 	".previous\n\n\t"						\
-       : "=&r" (ret) : "r" (x), "r" (__m(addr)),			\
-	 "i" (-EFAULT))
+       : "=r" (ret) : "r" (x), "r" (__m(addr)),				\
+	 "i" (-EFAULT), "i" (ASI_S))
 
 #define __put_user_asm_ret(x,size,addr,ret,foo)				\
 if (__builtin_constant_p(ret) && ret == -EFAULT)			\
 __asm__ __volatile__(							\
 	"/* Put user asm ret, inline. */\n"				\
-"1:\t"	"st"#size " %1, [%2]\n\n\t"					\
+"1:\t"	"st"#size "a %1, [%2] %3\n\n\t"					\
 	".section __ex_table,#alloc\n\t"				\
 	".align	4\n\t"							\
 	".word	1b, __ret_efault\n\n\t"					\
 	".previous\n\n\t"						\
-       : "=r" (foo) : "r" (x), "r" (__m(addr)));			\
+       : "=r" (foo) : "r" (x), "r" (__m(addr)), "i" (ASI_S));		\
 else									\
 __asm__ __volatile(							\
 	"/* Put user asm ret, inline. */\n"				\
-"1:\t"	"st"#size " %1, [%2]\n\n\t"					\
+"1:\t"	"st"#size "a %1, [%2] %4\n\n\t"					\
 	".section .fixup,#alloc,#execinstr\n\t"				\
 	".align	4\n"							\
 "3:\n\t"								\
@@ -199,33 +181,11 @@
 	".align	4\n\t"							\
 	".word	1b, 3b\n\n\t"						\
 	".previous\n\n\t"						\
-       : "=r" (foo) : "r" (x), "r" (__m(addr)), "i" (ret))
+       : "=r" (foo) : "r" (x), "r" (__m(addr)),				\
+         "i" (ret), "i" (ASI_S))
 
 extern int __put_user_bad(void);
 
-#define __get_user_check(data,addr,size,type) ({ \
-register int __gu_ret; \
-register unsigned long __gu_val; \
-if (__access_ok(addr,size)) { \
-switch (size) { \
-case 1: __get_user_asm(__gu_val,ub,addr,__gu_ret); break; \
-case 2: __get_user_asm(__gu_val,uh,addr,__gu_ret); break; \
-case 4: __get_user_asm(__gu_val,uw,addr,__gu_ret); break; \
-case 8: __get_user_asm(__gu_val,x,addr,__gu_ret); break; \
-default: __gu_val = 0; __gu_ret = __get_user_bad(); break; \
-} } else { __gu_val = 0; __gu_ret = -EFAULT; } data = (type) __gu_val; __gu_ret; })
-
-#define __get_user_check_ret(data,addr,size,type,retval) ({ \
-register unsigned long __gu_val __asm__ ("l1"); \
-if (__access_ok(addr,size)) { \
-switch (size) { \
-case 1: __get_user_asm_ret(__gu_val,ub,addr,retval); break; \
-case 2: __get_user_asm_ret(__gu_val,uh,addr,retval); break; \
-case 4: __get_user_asm_ret(__gu_val,uw,addr,retval); break; \
-case 8: __get_user_asm_ret(__gu_val,x,addr,retval); break; \
-default: if (__get_user_bad()) return retval; \
-} data = (type) __gu_val; } else return retval; })
-
 #define __get_user_nocheck(data,addr,size,type) ({ \
 register int __gu_ret; \
 register unsigned long __gu_val; \
@@ -250,7 +210,7 @@
 #define __get_user_asm(x,size,addr,ret)					\
 __asm__ __volatile__(							\
 	"/* Get user asm, inline. */\n"					\
-"1:\t"	"ld"#size " [%2], %1\n\t"					\
+"1:\t"	"ld"#size "a [%2] %4, %1\n\t"					\
 	"clr	%0\n"							\
 "2:\n\n\t"								\
 	".section .fixup,#alloc,#execinstr\n\t"				\
@@ -264,80 +224,63 @@
 	".align	4\n\t"							\
 	".word	1b, 3b\n\n\t"						\
 	".previous\n\t"							\
-       : "=&r" (ret), "=&r" (x) : "r" (__m(addr)),			\
-	 "i" (-EFAULT))
+       : "=r" (ret), "=r" (x) : "r" (__m(addr)),			\
+	 "i" (-EFAULT), "i" (ASI_S))
 
 #define __get_user_asm_ret(x,size,addr,retval)				\
 if (__builtin_constant_p(retval) && retval == -EFAULT)			\
 __asm__ __volatile__(							\
 	"/* Get user asm ret, inline. */\n"				\
-"1:\t"	"ld"#size " [%1], %0\n\n\t"					\
+"1:\t"	"ld"#size "a [%1] %2, %0\n\n\t"					\
 	".section __ex_table,#alloc\n\t"				\
 	".align	4\n\t"							\
 	".word	1b,__ret_efault\n\n\t"					\
 	".previous\n\t"							\
-       : "=&r" (x) : "r" (__m(addr)));					\
+       : "=r" (x) : "r" (__m(addr)), "i" (ASI_S));			\
 else									\
 __asm__ __volatile__(							\
 	"/* Get user asm ret, inline. */\n"				\
-"1:\t"	"ld"#size " [%1], %0\n\n\t"					\
+"1:\t"	"ld"#size "a [%1] %2, %0\n\n\t"					\
 	".section .fixup,#alloc,#execinstr\n\t"				\
 	".align	4\n"							\
 "3:\n\t"								\
 	"ret\n\t"							\
-	" restore %%g0, %2, %%o0\n\n\t"					\
+	" restore %%g0, %3, %%o0\n\n\t"					\
 	".previous\n\t"							\
 	".section __ex_table,#alloc\n\t"				\
 	".align	4\n\t"							\
 	".word	1b, 3b\n\n\t"						\
 	".previous\n\t"							\
-       : "=&r" (x) : "r" (__m(addr)), "i" (retval))
+       : "=r" (x) : "r" (__m(addr)), "i" (retval), "i" (ASI_S))
 
 extern int __get_user_bad(void);
 
-extern __kernel_size_t __copy_user(void *to, void *from, __kernel_size_t size);
+extern __kernel_size_t __copy_to_user(void *to, void *from, __kernel_size_t size);
+extern __kernel_size_t __copy_from_user(void *to, void *from, __kernel_size_t size);
 
-#define copy_to_user(to,from,n) ({ \
-void *__copy_to = (void *) (to); \
-__kernel_size_t __copy_size = (__kernel_size_t) (n); \
-__kernel_size_t __copy_res; \
-if(__copy_size && __access_ok(__copy_to, __copy_size)) { \
-__copy_res = __copy_user(__copy_to, (void *) (from), __copy_size); \
-} else __copy_res = __copy_size; \
-__copy_res; })
+#define copy_to_user(to,from,n) \
+	__copy_to_user((void *)(to), \
+	(void *) (from), (__kernel_size_t)(n))
 
 #define copy_to_user_ret(to,from,n,retval) ({ \
 if (copy_to_user(to,from,n)) \
 	return retval; \
 })
 
-#define __copy_to_user(to,from,n)		\
-	__copy_user((void *)(to),	\
-		    (void *)(from), n)
-
 #define __copy_to_user_ret(to,from,n,retval) ({ \
 if (__copy_to_user(to,from,n)) \
 	return retval; \
 })
 
-#define copy_from_user(to,from,n) ({ \
-void *__copy_from = (void *) (from); \
-__kernel_size_t __copy_size = (__kernel_size_t) (n); \
-__kernel_size_t __copy_res; \
-if(__copy_size && __access_ok(__copy_from, __copy_size)) { \
-__copy_res = __copy_user((void *) (to), __copy_from, __copy_size); \
-} else __copy_res = __copy_size; \
-__copy_res; })
+#define copy_from_user(to,from,n)		\
+	__copy_from_user((void *)(to),	\
+		    (void *)(from), (__kernel_size_t)(n))
 
 #define copy_from_user_ret(to,from,n,retval) ({ \
 if (copy_from_user(to,from,n)) \
 	return retval; \
 })
 
-#define __copy_from_user(to,from,n)		\
-	__copy_user((void *)(to),	\
-		    (void *)(from), n)
-
 #define __copy_from_user_ret(to,from,n,retval) ({ \
 if (__copy_from_user(to,from,n)) \
 	return retval; \
@@ -352,23 +295,18 @@
 	.word 1f,3
 	.previous
 1:
+	wr %%g0, %3, %%asi
 	mov %2, %%o1
-	call __bzero
+	call __bzero_noasi
 	 mov %1, %%o0
 	mov %%o0, %0
-	" : "=r" (ret) : "r" (addr), "r" (size) :
-	"o0", "o1", "o2", "o3", "o4", "o5", "o7", "g1", "g2", "g3", "g5", "g7");
+	" : "=r" (ret) : "r" (addr), "r" (size), "i" (ASI_S) :
+	"cc", "o0", "o1", "o2", "o3", "o4", "o5", "o7", "g1", "g2", "g3", "g5", "g7");
   return ret;
 }
 
-#define clear_user(addr,n) ({ \
-void *__clear_addr = (void *) (addr); \
-__kernel_size_t __clear_size = (__kernel_size_t) (n); \
-__kernel_size_t __clear_res; \
-if(__clear_size && __access_ok(__clear_addr, __clear_size)) { \
-__clear_res = __clear_user(__clear_addr, __clear_size); \
-} else __clear_res = __clear_size; \
-__clear_res; })
+#define clear_user(addr,n) \
+	__clear_user((void *)(addr), (__kernel_size_t)(n))
 
 #define clear_user_ret(addr,size,retval) ({ \
 if (clear_user(addr,size)) \
@@ -377,23 +315,12 @@
 
 extern int __strncpy_from_user(unsigned long dest, unsigned long src, int count);
 
-#define strncpy_from_user(dest,src,count) ({ \
-unsigned long __sfu_src = (unsigned long) (src); \
-int __sfu_count = (int) (count); \
-long __sfu_res = -EFAULT; \
-if(__access_ok(__sfu_src, __sfu_count)) { \
-__sfu_res = __strncpy_from_user((unsigned long) (dest), __sfu_src, __sfu_count); \
-} __sfu_res; })
+#define strncpy_from_user(dest,src,count) \
+	__strncpy_from_user((unsigned long)(dest), (unsigned long)(src), (int)(count))
 
 extern int __strlen_user(const char *);
 
-extern __inline__ int strlen_user(const char *str)
-{
-	if(!access_ok(VERIFY_READ, str, 0))
-		return 0;
-	else
-		return __strlen_user(str);
-}
+#define strlen_user __strlen_user
 
 #endif  /* __ASSEMBLY__ */
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov