Merge remote-tracking branch 'remotes/powerpc/topic/xive' into kvm-ppc-next
[linux/fpc-iii.git] / arch / um / include / asm / uaccess.h
blob3705620ca298b18f6e2f3a6de492a6912f492196
1 /*
2 * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
3 * Copyright (C) 2015 Richard Weinberger (richard@nod.at)
4 * Licensed under the GPL
5 */
7 #ifndef __UM_UACCESS_H
8 #define __UM_UACCESS_H
10 #include <asm/thread_info.h>
11 #include <asm/elf.h>
13 #define __under_task_size(addr, size) \
14 (((unsigned long) (addr) < TASK_SIZE) && \
15 (((unsigned long) (addr) + (size)) < TASK_SIZE))
17 #define __access_ok_vsyscall(addr, size) \
18 (((unsigned long) (addr) >= FIXADDR_USER_START) && \
19 ((unsigned long) (addr) + (size) <= FIXADDR_USER_END) && \
20 ((unsigned long) (addr) + (size) >= (unsigned long)(addr)))
22 #define __addr_range_nowrap(addr, size) \
23 ((unsigned long) (addr) <= ((unsigned long) (addr) + (size)))
25 extern long __copy_from_user(void *to, const void __user *from, unsigned long n);
26 extern long __copy_to_user(void __user *to, const void *from, unsigned long n);
27 extern long __strncpy_from_user(char *dst, const char __user *src, long count);
28 extern long __strnlen_user(const void __user *str, long len);
29 extern unsigned long __clear_user(void __user *mem, unsigned long len);
30 static inline int __access_ok(unsigned long addr, unsigned long size);
32 /* Teach asm-generic/uaccess.h that we have C functions for these. */
33 #define __access_ok __access_ok
34 #define __clear_user __clear_user
35 #define __copy_to_user __copy_to_user
36 #define __copy_from_user __copy_from_user
37 #define __strnlen_user __strnlen_user
38 #define __strncpy_from_user __strncpy_from_user
39 #define __copy_to_user_inatomic __copy_to_user
40 #define __copy_from_user_inatomic __copy_from_user
42 #include <asm-generic/uaccess.h>
44 static inline int __access_ok(unsigned long addr, unsigned long size)
46 return __addr_range_nowrap(addr, size) &&
47 (__under_task_size(addr, size) ||
48 __access_ok_vsyscall(addr, size) ||
49 segment_eq(get_fs(), KERNEL_DS));
52 #endif