commandProcessing.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*
  2. * arch/arm/include/asm/uaccess.h
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. */
  8. #ifndef _ASMARM_UACCESS_H
  9. #define _ASMARM_UACCESS_H
  10. /*
  11. * User space memory access functions
  12. */
  13. #include <linux/string.h>
  14. #include <linux/thread_info.h>
  15. #include <asm/errno.h>
  16. #include <asm/memory.h>
  17. #include <asm/domain.h>
  18. #include <asm/unified.h>
  19. #include <asm/compiler.h>
  20. #define VERIFY_READ 0
  21. #define VERIFY_WRITE 1
  22. /*
  23. * The exception table consists of pairs of addresses: the first is the
  24. * address of an instruction that is allowed to fault, and the second is
  25. * the address at which the program should continue. No registers are
  26. * modified, so it is entirely up to the continuation code to figure out
  27. * what to do.
  28. *
  29. * All the routines below use bits of fixup code that are out of line
  30. * with the main instruction path. This means when everything is well,
  31. * we don't even have to jump over them. Further, they do not intrude
  32. * on our cache or tlb entries.
  33. */
  34. struct exception_table_entry
  35. {
  36. unsigned long insn, fixup;
  37. };
  38. extern int fixup_exception(struct pt_regs *regs);
  39. /*
  40. * These two are intentionally not defined anywhere - if the kernel
  41. * code generates any references to them, that's a bug.
  42. */
  43. extern int __get_user_bad(void);
  44. extern int __put_user_bad(void);
  45. /*
  46. * Note that this is actually 0x1,0000,0000
  47. */
  48. #define KERNEL_DS 0x00000000
  49. #define get_ds() (KERNEL_DS)
  50. #ifdef CONFIG_MMU
  51. #define USER_DS TASK_SIZE
  52. #define get_fs() (current_thread_info()->addr_limit)
  53. static inline void set_fs(mm_segment_t fs)
  54. {
  55. current_thread_info()->addr_limit = fs;
  56. modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_CLIENT : DOMAIN_MANAGER);
  57. }
  58. #define segment_eq(a,b) ((a) == (b))
  59. #define __addr_ok(addr) ({ \
  60. unsigned long flag; \
  61. __asm__("cmp %2, %0; movlo %0, #0" \
  62. : "=&r" (flag) \
  63. : "0" (current_thread_info()->addr_limit), "r" (addr) \
  64. : "cc"); \
  65. (flag == 0); })
  66. /* We use 33-bit arithmetic here... */
  67. #define __range_ok(addr,size) ({ \
  68. unsigned long flag, roksum; \
  69. __chk_user_ptr(addr); \
  70. __asm__("adds %1, %2, %3; sbcccs %1, %1, %0; movcc %0, #0" \
  71. : "=&r" (flag), "=&r" (roksum) \
  72. : "r" (addr), "Ir" (size), "0" (current_thread_info()->addr_limit) \
  73. : "cc"); \
  74. flag; })
  75. /*
  76. * Single-value transfer routines. They automatically use the right
  77. * size if we just have the right pointer type. Note that the functions
  78. * which read from user space (*get_*) need to take care not to leak
  79. * kernel data even if the calling code is buggy and fails to check
  80. * the return value. This means zeroing out the destination variable
  81. * or buffer on error. Normally this is done out of line by the
  82. * fixup code, but there are a few places where it intrudes on the
  83. * main code path. When we only write to user space, there is no
  84. * problem.
  85. */
  86. extern int __get_user_1(void *);
  87. extern int __get_user_2(void *);
  88. extern int __get_user_4(void *);
  89. #define __GUP_CLOBBER_1 "lr", "cc"
  90. #ifdef CONFIG_CPU_USE_DOMAINS
  91. #define __GUP_CLOBBER_2 "ip", "lr", "cc"
  92. #else
  93. #define __GUP_CLOBBER_2 "lr", "cc"
  94. #endif
  95. #define __GUP_CLOBBER_4 "lr", "cc"
  96. #define __get_user_x(__r2,__p,__e,__l,__s) \
  97. __asm__ __volatile__ ( \
  98. __asmeq("%0", "r0") __asmeq("%1", "r2") \
  99. __asmeq("%3", "r1") \