1 /**************************************************************************** 2 **************************************************************************** 3 *** 4 *** This header was automatically generated from a Linux kernel header 5 *** of the same name, to make information necessary for userspace to 6 *** call into the kernel available to libc. It contains only constants, 7 *** structures, and macros generated from the original header, and thus, 8 *** contains no copyrightable information. 9 *** 10 *** To edit the content of this header, modify the corresponding 11 *** source file (e.g. under external/kernel-headers/original/) then 12 *** run bionic/libc/kernel/tools/update_all.py 13 *** 14 *** Any manual change here will be lost the next time this script will 15 *** be run. You've been warned! 16 *** 17 **************************************************************************** 18 ****************************************************************************/ 19 #ifndef __i386_UACCESS_H 20 #define __i386_UACCESS_H 21 #include <linux/errno.h> 22 #include <linux/thread_info.h> 23 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 24 #include <linux/prefetch.h> 25 #include <linux/string.h> 26 #include <asm/page.h> 27 #define VERIFY_READ 0 28 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 29 #define VERIFY_WRITE 1 30 #define MAKE_MM_SEG(s) ((mm_segment_t) { (s) }) 31 #define KERNEL_DS MAKE_MM_SEG(0xFFFFFFFFUL) 32 #define USER_DS MAKE_MM_SEG(PAGE_OFFSET) 33 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 34 #define get_ds() (KERNEL_DS) 35 #define get_fs() (current_thread_info()->addr_limit) 36 #define set_fs(x) (current_thread_info()->addr_limit = (x)) 37 #define segment_eq(a,b) ((a).seg == (b).seg) 38 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 39 #define __addr_ok(addr) ((unsigned long __force)(addr) < (current_thread_info()->addr_limit.seg)) 40 #define __range_ok(addr,size) ({ unsigned long flag,roksum; __chk_user_ptr(addr); asm("addl %3,%1 ; sbbl %0,%0; cmpl %1,%4; sbbl $0,%0" :"=&r" (flag), "=r" (roksum) :"1" (addr),"g" ((int)(size)),"rm" (current_thread_info()->addr_limit.seg)); flag; }) 41 #define access_ok(type,addr,size) (likely(__range_ok(addr,size) == 0)) 42 struct exception_table_entry 43 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 44 { 45 unsigned long insn, fixup; 46 }; 47 #define __get_user_x(size,ret,x,ptr) __asm__ __volatile__("call __get_user_" #size :"=a" (ret),"=d" (x) :"0" (ptr)) 48 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 49 #define get_user(x,ptr) ({ int __ret_gu; unsigned long __val_gu; __chk_user_ptr(ptr); switch(sizeof (*(ptr))) { case 1: __get_user_x(1,__ret_gu,__val_gu,ptr); break; case 2: __get_user_x(2,__ret_gu,__val_gu,ptr); break; case 4: __get_user_x(4,__ret_gu,__val_gu,ptr); break; default: __get_user_x(X,__ret_gu,__val_gu,ptr); break; } (x) = (__typeof__(*(ptr)))__val_gu; __ret_gu; }) 50 #define __put_user_1(x, ptr) __asm__ __volatile__("call __put_user_1":"=a" (__ret_pu):"0" ((typeof(*(ptr)))(x)), "c" (ptr)) 51 #define __put_user_2(x, ptr) __asm__ __volatile__("call __put_user_2":"=a" (__ret_pu):"0" ((typeof(*(ptr)))(x)), "c" (ptr)) 52 #define __put_user_4(x, ptr) __asm__ __volatile__("call __put_user_4":"=a" (__ret_pu):"0" ((typeof(*(ptr)))(x)), "c" (ptr)) 53 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 54 #define __put_user_8(x, ptr) __asm__ __volatile__("call __put_user_8":"=a" (__ret_pu):"A" ((typeof(*(ptr)))(x)), "c" (ptr)) 55 #define __put_user_X(x, ptr) __asm__ __volatile__("call __put_user_X":"=a" (__ret_pu):"c" (ptr)) 56 #define put_user(x,ptr) ({ int __ret_pu; __typeof__(*(ptr)) __pus_tmp = x; __ret_pu=0; if(unlikely(__copy_to_user_ll(ptr, &__pus_tmp, sizeof(*(ptr))) != 0)) __ret_pu=-EFAULT; __ret_pu; }) 57 #define __get_user(x,ptr) __get_user_nocheck((x),(ptr),sizeof(*(ptr))) 58 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 59 #define __put_user(x,ptr) __put_user_nocheck((__typeof__(*(ptr)))(x),(ptr),sizeof(*(ptr))) 60 #define __put_user_nocheck(x,ptr,size) ({ long __pu_err; __put_user_size((x),(ptr),(size),__pu_err,-EFAULT); __pu_err; }) 61 #define __put_user_u64(x, addr, err) __asm__ __volatile__( "1: movl %%eax,0(%2)\n" "2: movl %%edx,4(%2)\n" "3:\n" ".section .fixup,\"ax\"\n" "4: movl %3,%0\n" " jmp 3b\n" ".previous\n" ".section __ex_table,\"a\"\n" " .align 4\n" " .long 1b,4b\n" " .long 2b,4b\n" ".previous" : "=r"(err) : "A" (x), "r" (addr), "i"(-EFAULT), "0"(err)) 62 #define __put_user_size(x,ptr,size,retval,errret) do { __typeof__(*(ptr)) __pus_tmp = x; retval = 0; if(unlikely(__copy_to_user_ll(ptr, &__pus_tmp, size) != 0)) retval = errret; } while (0) 63 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 64 struct __large_struct { unsigned long buf[100]; }; 65 #define __m(x) (*(struct __large_struct __user *)(x)) 66 #define __put_user_asm(x, addr, err, itype, rtype, ltype, errret) __asm__ __volatile__( "1: mov"itype" %"rtype"1,%2\n" "2:\n" ".section .fixup,\"ax\"\n" "3: movl %3,%0\n" " jmp 2b\n" ".previous\n" ".section __ex_table,\"a\"\n" " .align 4\n" " .long 1b,3b\n" ".previous" : "=r"(err) : ltype (x), "m"(__m(addr)), "i"(errret), "0"(err)) 67 #define __get_user_nocheck(x,ptr,size) ({ long __gu_err; unsigned long __gu_val; __get_user_size(__gu_val,(ptr),(size),__gu_err,-EFAULT); (x) = (__typeof__(*(ptr)))__gu_val; __gu_err; }) 68 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 69 #define __get_user_size(x,ptr,size,retval,errret) do { retval = 0; __chk_user_ptr(ptr); switch (size) { case 1: __get_user_asm(x,ptr,retval,"b","b","=q",errret);break; case 2: __get_user_asm(x,ptr,retval,"w","w","=r",errret);break; case 4: __get_user_asm(x,ptr,retval,"l","","=r",errret);break; default: (x) = __get_user_bad(); } } while (0) 70 #define __get_user_asm(x, addr, err, itype, rtype, ltype, errret) __asm__ __volatile__( "1: mov"itype" %2,%"rtype"1\n" "2:\n" ".section .fixup,\"ax\"\n" "3: movl %3,%0\n" " xor"itype" %"rtype"1,%"rtype"1\n" " jmp 2b\n" ".previous\n" ".section __ex_table,\"a\"\n" " .align 4\n" " .long 1b,3b\n" ".previous" : "=r"(err), ltype (x) : "m"(__m(addr)), "i"(errret), "0"(err)) 71 #define ARCH_HAS_NOCACHE_UACCESS 72 #define strlen_user(str) strnlen_user(str, LONG_MAX) 73 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 74 #endif 75