Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions
uaccess.h File Reference
#include <linux/errno.h>
#include <linux/prefetch.h>
#include <asm/types.h>
#include <linux/sched.h>

Go to the source code of this file.

Data Structures

struct  exception_table_entry
 

Macros

#define VERIFY_READ   0
 
#define VERIFY_WRITE   1
 
#define KERNEL_DS   ((mm_segment_t) { 0 })
 
#define USER_DS   ((mm_segment_t) { 1 })
 
#define get_ds()   (KERNEL_DS)
 
#define get_fs()   (current->thread.current_ds)
 
#define set_fs(val)   (current->thread.current_ds = (val))
 
#define segment_eq(a, b)   ((a).seg == (b).seg)
 
#define __kernel_ok   (segment_eq(get_fs(), KERNEL_DS))
 
#define __user_ok(addr, size)   (((size) <= TASK_SIZE)&&((addr) <= TASK_SIZE-(size)))
 
#define __access_ok(addr, size)   (__kernel_ok || __user_ok((addr),(size)))
 
#define access_ok(type, addr, size)   __access_ok((unsigned long)(addr),(size))
 
#define put_user(x, ptr)   __put_user_check((x),(ptr),sizeof(*(ptr)))
 
#define get_user(x, ptr)   __get_user_check((x),(ptr),sizeof(*(ptr)))
 
#define __put_user(x, ptr)   __put_user_nocheck((x),(ptr),sizeof(*(ptr)))
 
#define __get_user(x, ptr)   __get_user_nocheck((x),(ptr),sizeof(*(ptr)))
 
#define __put_user_nocheck(x, ptr, size)
 
#define __put_user_check(x, ptr, size)
 
#define __put_user_size(x, ptr, size, retval)
 
#define __check_align_1   ""
 
#define __check_align_2
 
#define __check_align_4
 
#define __put_user_asm(x, addr, err, align, insn, cb)
 
#define __get_user_nocheck(x, ptr, size)
 
#define __get_user_check(x, ptr, size)
 
#define __get_user_size(x, ptr, size, retval)
 
#define __get_user_asm(x, addr, err, align, insn, cb)
 
#define __copy_user(to, from, size)   __xtensa_copy_user(to,from,size)
 
#define copy_to_user(to, from, n)   __generic_copy_to_user((to),(from),(n))
 
#define copy_from_user(to, from, n)   __generic_copy_from_user((to),(from),(n))
 
#define __copy_to_user(to, from, n)   __generic_copy_to_user_nocheck((to),(from),(n))
 
#define __copy_from_user(to, from, n)   __generic_copy_from_user_nocheck((to),(from),(n))
 
#define __copy_to_user_inatomic   __copy_to_user
 
#define __copy_from_user_inatomic   __copy_from_user
 
#define __clear_user   __xtensa_clear_user
 
#define __strncpy_from_user   __strncpy_user
 
#define strlen_user(str)   strnlen_user((str), TASK_SIZE - 1)
 
#define fixup_exception(map_reg, fixup_unit, pc)
 

Functions

long __put_user_bad (void)
 
long __get_user_bad (void)
 
unsigned __xtensa_copy_user (void *to, const void *from, unsigned n)
 
long __strncpy_user (char *, const char *, long)
 
long __strnlen_user (const char *, long)
 
unsigned long search_exception_table (unsigned long addr)
 
void sort_exception_table (void)
 

Macro Definition Documentation

#define __access_ok (   addr,
  size 
)    (__kernel_ok || __user_ok((addr),(size)))

Definition at line 184 of file uaccess.h.

#define __check_align_1   ""

Definition at line 271 of file uaccess.h.

#define __check_align_2
Value:
" _bbci.l %3, 0, 1f \n" \
" movi %0, %4 \n" \
" _j 2f \n"

Definition at line 273 of file uaccess.h.

#define __check_align_4
Value:
" _bbsi.l %3, 0, 0f \n" \
" _bbci.l %3, 1, 1f \n" \
"0: movi %0, %4 \n" \
" _j 2f \n"

Definition at line 278 of file uaccess.h.

#define __clear_user   __xtensa_clear_user

Definition at line 453 of file uaccess.h.

#define __copy_from_user (   to,
  from,
  n 
)    __generic_copy_from_user_nocheck((to),(from),(n))

Definition at line 425 of file uaccess.h.

#define __copy_from_user_inatomic   __copy_from_user

Definition at line 427 of file uaccess.h.

#define __copy_to_user (   to,
  from,
  n 
)    __generic_copy_to_user_nocheck((to),(from),(n))

Definition at line 424 of file uaccess.h.

#define __copy_to_user_inatomic   __copy_to_user

Definition at line 426 of file uaccess.h.

#define __copy_user (   to,
  from,
  size 
)    __xtensa_copy_user(to,from,size)

Definition at line 387 of file uaccess.h.

#define __get_user (   x,
  ptr 
)    __get_user_nocheck((x),(ptr),sizeof(*(ptr)))

Definition at line 211 of file uaccess.h.

#define __get_user_asm (   x,
  addr,
  err,
  align,
  insn,
  cb 
)
Value:
__asm__ __volatile__( \
__check_align_##align \
"1: "insn" %2, %3, 0 \n" \
"2: \n" \
" .section .fixup,\"ax\" \n" \
" .align 4 \n" \
"4: \n" \
" .long 2b \n" \
"5: \n" \
" l32r %1, 4b \n" \
" movi %2, 0 \n" \
" movi %0, %4 \n" \
" jx %1 \n" \
" .previous \n" \
" .section __ex_table,\"a\" \n" \
" .long 1b, 5b \n" \
" .previous" \
:"=r" (err), "=r" (cb), "=r" (x) \
:"r" (addr), "i" (-EFAULT), "0" (err))

Definition at line 351 of file uaccess.h.

#define __get_user_check (   x,
  ptr,
  size 
)
Value:
({ \
long __gu_err = -EFAULT, __gu_val = 0; \
const __typeof__(*(ptr)) *__gu_addr = (ptr); \
if (access_ok(VERIFY_READ,__gu_addr,size)) \
__get_user_size(__gu_val,__gu_addr,(size),__gu_err); \
(x) = (__typeof__(*(ptr)))__gu_val; \
__gu_err; \
})

Definition at line 321 of file uaccess.h.

#define __get_user_nocheck (   x,
  ptr,
  size 
)
Value:
({ \
long __gu_err, __gu_val; \
__get_user_size(__gu_val,(ptr),(size),__gu_err); \
(x) = (__typeof__(*(ptr)))__gu_val; \
__gu_err; \
})

Definition at line 313 of file uaccess.h.

#define __get_user_size (   x,
  ptr,
  size,
  retval 
)
Value:
do { \
int __cb; \
retval = 0; \
switch (size) { \
case 1: __get_user_asm(x,ptr,retval,1,"l8ui",__cb); break; \
case 2: __get_user_asm(x,ptr,retval,2,"l16ui",__cb); break; \
case 4: __get_user_asm(x,ptr,retval,4,"l32i",__cb); break; \
case 8: retval = __copy_from_user(&x,ptr,8); break; \
default: (x) = __get_user_bad(); \
} \
} while (0)

Definition at line 333 of file uaccess.h.

#define __kernel_ok   (segment_eq(get_fs(), KERNEL_DS))

Definition at line 182 of file uaccess.h.

#define __put_user (   x,
  ptr 
)    __put_user_nocheck((x),(ptr),sizeof(*(ptr)))

Definition at line 210 of file uaccess.h.

#define __put_user_asm (   x,
  addr,
  err,
  align,
  insn,
  cb 
)
Value:
__asm__ __volatile__( \
__check_align_##align \
"1: "insn" %2, %3, 0 \n" \
"2: \n" \
" .section .fixup,\"ax\" \n" \
" .align 4 \n" \
"4: \n" \
" .long 2b \n" \
"5: \n" \
" l32r %1, 4b \n" \
" movi %0, %4 \n" \
" jx %1 \n" \
" .previous \n" \
" .section __ex_table,\"a\" \n" \
" .long 1b, 5b \n" \
" .previous" \
:"=r" (err), "=r" (cb) \
:"r" ((int)(x)), "r" (addr), "i" (-EFAULT), "0" (err))

Definition at line 293 of file uaccess.h.

#define __put_user_check (   x,
  ptr,
  size 
)
Value:
({ \
long __pu_err = -EFAULT; \
__typeof__(*(ptr)) *__pu_addr = (ptr); \
if (access_ok(VERIFY_WRITE,__pu_addr,size)) \
__put_user_size((x),__pu_addr,(size),__pu_err); \
__pu_err; \
})

Definition at line 223 of file uaccess.h.

#define __put_user_nocheck (   x,
  ptr,
  size 
)
Value:
({ \
long __pu_err; \
__put_user_size((x),(ptr),(size),__pu_err); \
__pu_err; \
})

Definition at line 216 of file uaccess.h.

#define __put_user_size (   x,
  ptr,
  size,
  retval 
)
Value:
do { \
int __cb; \
retval = 0; \
switch (size) { \
case 1: __put_user_asm(x,ptr,retval,1,"s8i",__cb); break; \
case 2: __put_user_asm(x,ptr,retval,2,"s16i",__cb); break; \
case 4: __put_user_asm(x,ptr,retval,4,"s32i",__cb); break; \
case 8: { \
__typeof__(*ptr) __v64 = x; \
retval = __copy_to_user(ptr,&__v64,8); \
break; \
} \
default: __put_user_bad(); \
} \
} while (0)

Definition at line 232 of file uaccess.h.

#define __strncpy_from_user   __strncpy_user

Definition at line 457 of file uaccess.h.

#define __user_ok (   addr,
  size 
)    (((size) <= TASK_SIZE)&&((addr) <= TASK_SIZE-(size)))

Definition at line 183 of file uaccess.h.

#define access_ok (   type,
  addr,
  size 
)    __access_ok((unsigned long)(addr),(size))

Definition at line 185 of file uaccess.h.

#define copy_from_user (   to,
  from,
  n 
)    __generic_copy_from_user((to),(from),(n))

Definition at line 423 of file uaccess.h.

#define copy_to_user (   to,
  from,
  n 
)    __generic_copy_to_user((to),(from),(n))

Definition at line 422 of file uaccess.h.

#define fixup_exception (   map_reg,
  fixup_unit,
  pc 
)
Value:
({ \
fixup_unit; \
})

Definition at line 496 of file uaccess.h.

#define get_ds (   void)    (KERNEL_DS)

Definition at line 176 of file uaccess.h.

#define get_fs (   void)    (current->thread.current_ds)

Definition at line 177 of file uaccess.h.

#define get_user (   x,
  ptr 
)    __get_user_check((x),(ptr),sizeof(*(ptr)))

Definition at line 202 of file uaccess.h.

#define KERNEL_DS   ((mm_segment_t) { 0 })

Definition at line 173 of file uaccess.h.

#define put_user (   x,
  ptr 
)    __put_user_check((x),(ptr),sizeof(*(ptr)))

Definition at line 201 of file uaccess.h.

#define segment_eq (   a,
  b 
)    ((a).seg == (b).seg)

Definition at line 180 of file uaccess.h.

#define set_fs (   val)    (current->thread.current_ds = (val))

Definition at line 178 of file uaccess.h.

#define strlen_user (   str)    strnlen_user((str), TASK_SIZE - 1)

Definition at line 468 of file uaccess.h.

#define USER_DS   ((mm_segment_t) { 1 })

Definition at line 174 of file uaccess.h.

#define VERIFY_READ   0

Definition at line 25 of file uaccess.h.

#define VERIFY_WRITE   1

Definition at line 26 of file uaccess.h.

Function Documentation

long __get_user_bad ( void  )
long __put_user_bad ( void  )
long __strncpy_user ( char ,
const char ,
long   
)
long __strnlen_user ( const char ,
long   
)
unsigned __xtensa_copy_user ( void to,
const void from,
unsigned  n 
)
unsigned long search_exception_table ( unsigned long  addr)

Definition at line 43 of file extable.c.

void sort_exception_table ( void  )