patch-2.1.77 linux/include/asm-i386/uaccess.h
Next file: linux/include/linux/baycom.h
Previous file: linux/include/asm-i386/processor.h
Back to the patch index
Back to the overall index
- Lines: 72
- Date:
Fri Jan 2 14:01:29 1998
- Orig file:
v2.1.76/linux/include/asm-i386/uaccess.h
- Orig date:
Sun Dec 21 22:36:16 1997
diff -u --recursive --new-file v2.1.76/linux/include/asm-i386/uaccess.h linux/include/asm-i386/uaccess.h
@@ -18,49 +18,42 @@
*/
#define MAKE_MM_SEG(s) ((mm_segment_t) { (s) })
-#define KERNEL_DS MAKE_MM_SEG(0)
-#define USER_DS MAKE_MM_SEG(3)
+
+
+#define KERNEL_DS MAKE_MM_SEG(0xFFFFFFFF)
+#define USER_DS MAKE_MM_SEG(0xC0000000)
#define get_ds() (KERNEL_DS)
-#define get_fs() (current->tss.segment)
-#define set_fs(x) (current->tss.segment = (x))
+#define get_fs() (current->addr_limit)
+#define set_fs(x) (current->addr_limit = (x))
#define segment_eq(a,b) ((a).seg == (b).seg)
+extern int __verify_write(const void *, unsigned long);
+
+#define __addr_ok(addr) ((unsigned long)(addr) < (current->addr_limit.seg))
/*
- * Address Ok:
- *
- * segment
- * 00 (kernel) 11 (user)
- *
- * high 00 1 1
- * two 01 1 1
- * bits of 10 1 1
- * address 11 1 0
+ * Uhhuh, this needs 33-bit arithmetic. We have a carry..
*/
-#define __addr_ok(x) \
- ((((unsigned long)(x)>>30)&get_fs().seg) != 3)
+#define __range_ok(addr,size) ({ \
+ unsigned long flag,sum; \
+ asm("addl %3,%1 ; sbbl %0,%0; cmpl %1,%4; sbbl $0,%0" \
+ :"=&r" (flag), "=r" (sum) \
+ :"1" (addr),"g" (size),"g" (current->addr_limit.seg)); \
+ flag; })
-#define __user_ok(addr,size) \
- ((size <= 0xC0000000UL) && (addr <= 0xC0000000UL - size))
-#define __kernel_ok \
- (!get_fs().seg)
+#if CPU > 386
-extern int __verify_write(const void *, unsigned long);
+#define access_ok(type,addr,size) (__range_ok(addr,size) == 0)
-#if CPU > 386
-#define __access_ok(type,addr,size) \
- (__kernel_ok || __user_ok(addr,size))
#else
-#define __access_ok(type,addr,size) \
- (__kernel_ok || (__user_ok(addr,size) && \
+
+#define access_ok(type,addr,size) ( (__range_ok(addr,size) == 0) && \
((type) == VERIFY_READ || boot_cpu_data.wp_works_ok || \
- __verify_write((void *)(addr),(size)))))
-#endif /* CPU */
+ __verify_write((void *)(addr),(size))))
-#define access_ok(type,addr,size) \
- __access_ok((type),(unsigned long)(addr),(size))
+#endif /* CPU */
extern inline int verify_area(int type, const void * addr, unsigned long size)
{
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov