📄 uaccess.h
字号:
" .dword 2b,4b\n" " .previous" : "=r" (res), "=r" (dst), "=r" (src), "=r" (count) : "3" (count), "1" (dst), "2" (src), "g" (-EFAULT) : "r9"); return res;}static inline unsigned long__generic_copy_to_user(void *to, const void *from, unsigned long n){ if (access_ok(VERIFY_WRITE, to, n)) return __copy_user(to,from,n); return n;}static inline unsigned long__generic_copy_from_user(void *to, const void *from, unsigned long n){ if (access_ok(VERIFY_READ, from, n)) return __copy_user_zeroing(to,from,n); return n;}static inline unsigned long__generic_clear_user(void *to, unsigned long n){ if (access_ok(VERIFY_WRITE, to, n)) return __do_clear_user(to,n); return n;}static inline long__strncpy_from_user(char *dst, const char *src, long count){ return __do_strncpy_from_user(dst, src, count);}static inline longstrncpy_from_user(char *dst, const char *src, long count){ long res = -EFAULT; if (access_ok(VERIFY_READ, src, 1)) res = __do_strncpy_from_user(dst, src, count); return res;}/* A few copy asms to build up the more complex ones from. Note again, a post-increment is performed regardless of whether a bus fault occurred in that instruction, and PC for a faulted insn is the address *after* the insn. */#define __asm_copy_user_cont(to, from, ret, COPY, FIXUP, TENTRY) \ __asm__ __volatile__ ( \ COPY \ "1:\n" \ " .section .fixup,\"ax\"\n" \ FIXUP \ " jump 1b\n" \ " .previous\n" \ " .section __ex_table,\"a\"\n" \ TENTRY \ " .previous\n" \ : "=r" (to), "=r" (from), "=r" (ret) \ : "0" (to), "1" (from), "2" (ret) \ : "r9", "memory")#define __asm_copy_from_user_1(to, from, ret) \ __asm_copy_user_cont(to, from, ret, \ " move.b [%1+],$r9\n" \ "2: move.b $r9,[%0+]\n", \ "3: addq 1,%2\n" \ " clear.b [%0+]\n", \ " .dword 2b,3b\n")#define __asm_copy_from_user_2x_cont(to, from, ret, COPY, FIXUP, TENTRY) \ __asm_copy_user_cont(to, from, ret, \ " move.w [%1+],$r9\n" \ "2: move.w $r9,[%0+]\n" COPY, \ "3: addq 2,%2\n" \ " clear.w [%0+]\n" FIXUP, \ " .dword 2b,3b\n" TENTRY)#define __asm_copy_from_user_2(to, from, ret) \ __asm_copy_from_user_2x_cont(to, from, ret, "", "", "")#define __asm_copy_from_user_3(to, from, ret) \ __asm_copy_from_user_2x_cont(to, from, ret, \ " move.b [%1+],$r9\n" \ "4: move.b $r9,[%0+]\n", \ "5: addq 1,%2\n" \ " clear.b [%0+]\n", \ " .dword 4b,5b\n")#define __asm_copy_from_user_4x_cont(to, from, ret, COPY, FIXUP, TENTRY) \ __asm_copy_user_cont(to, from, ret, \ " move.d [%1+],$r9\n" \ "2: move.d $r9,[%0+]\n" COPY, \ "3: addq 4,%2\n" \ " clear.d [%0+]\n" FIXUP, \ " .dword 2b,3b\n" TENTRY)#define __asm_copy_from_user_4(to, from, ret) \ __asm_copy_from_user_4x_cont(to, from, ret, "", "", "")#define __asm_copy_from_user_5(to, from, ret) \ __asm_copy_from_user_4x_cont(to, from, ret, \ " move.b [%1+],$r9\n" \ "4: move.b $r9,[%0+]\n", \ "5: addq 1,%2\n" \ " clear.b [%0+]\n", \ " .dword 4b,5b\n")#define __asm_copy_from_user_6x_cont(to, from, ret, COPY, FIXUP, TENTRY) \ __asm_copy_from_user_4x_cont(to, from, ret, \ " move.w [%1+],$r9\n" \ "4: move.w $r9,[%0+]\n" COPY, \ "5: addq 2,%2\n" \ " clear.w [%0+]\n" FIXUP, \ " .dword 4b,5b\n" TENTRY)#define __asm_copy_from_user_6(to, from, ret) \ __asm_copy_from_user_6x_cont(to, from, ret, "", "", "")#define __asm_copy_from_user_7(to, from, ret) \ __asm_copy_from_user_6x_cont(to, from, ret, \ " move.b [%1+],$r9\n" \ "6: move.b $r9,[%0+]\n", \ "7: addq 1,%2\n" \ " clear.b [%0+]\n", \ " .dword 6b,7b\n")#define __asm_copy_from_user_8x_cont(to, from, ret, COPY, FIXUP, TENTRY) \ __asm_copy_from_user_4x_cont(to, from, ret, \ " move.d [%1+],$r9\n" \ "4: move.d $r9,[%0+]\n" COPY, \ "5: addq 4,%2\n" \ " clear.d [%0+]\n" FIXUP, \ " .dword 4b,5b\n" TENTRY)#define __asm_copy_from_user_8(to, from, ret) \ __asm_copy_from_user_8x_cont(to, from, ret, "", "", "")#define __asm_copy_from_user_9(to, from, ret) \ __asm_copy_from_user_8x_cont(to, from, ret, \ " move.b [%1+],$r9\n" \ "6: move.b $r9,[%0+]\n", \ "7: addq 1,%2\n" \ " clear.b [%0+]\n", \ " .dword 6b,7b\n")#define __asm_copy_from_user_10x_cont(to, from, ret, COPY, FIXUP, TENTRY) \ __asm_copy_from_user_8x_cont(to, from, ret, \ " move.w [%1+],$r9\n" \ "6: move.w $r9,[%0+]\n" COPY, \ "7: addq 2,%2\n" \ " clear.w [%0+]\n" FIXUP, \ " .dword 6b,7b\n" TENTRY)#define __asm_copy_from_user_10(to, from, ret) \ __asm_copy_from_user_10x_cont(to, from, ret, "", "", "")#define __asm_copy_from_user_11(to, from, ret) \ __asm_copy_from_user_10x_cont(to, from, ret, \ " move.b [%1+],$r9\n" \ "8: move.b $r9,[%0+]\n", \ "9: addq 1,%2\n" \ " clear.b [%0+]\n", \ " .dword 8b,9b\n")#define __asm_copy_from_user_12x_cont(to, from, ret, COPY, FIXUP, TENTRY) \ __asm_copy_from_user_8x_cont(to, from, ret, \ " move.d [%1+],$r9\n" \ "6: move.d $r9,[%0+]\n" COPY, \ "7: addq 4,%2\n" \ " clear.d [%0+]\n" FIXUP, \ " .dword 6b,7b\n" TENTRY)#define __asm_copy_from_user_12(to, from, ret) \ __asm_copy_from_user_12x_cont(to, from, ret, "", "", "")#define __asm_copy_from_user_13(to, from, ret) \ __asm_copy_from_user_12x_cont(to, from, ret, \ " move.b [%1+],$r9\n" \ "8: move.b $r9,[%0+]\n", \ "9: addq 1,%2\n" \ " clear.b [%0+]\n", \ " .dword 8b,9b\n")#define __asm_copy_from_user_14x_cont(to, from, ret, COPY, FIXUP, TENTRY) \ __asm_copy_from_user_12x_cont(to, from, ret, \ " move.w [%1+],$r9\n" \ "8: move.w $r9,[%0+]\n" COPY, \ "9: addq 2,%2\n" \ " clear.w [%0+]\n" FIXUP, \ " .dword 8b,9b\n" TENTRY)#define __asm_copy_from_user_14(to, from, ret) \ __asm_copy_from_user_14x_cont(to, from, ret, "", "", "")#define __asm_copy_from_user_15(to, from, ret) \ __asm_copy_from_user_14x_cont(to, from, ret, \ " move.b [%1+],$r9\n" \ "10: move.b $r9,[%0+]\n", \ "11: addq 1,%2\n" \ " clear.b [%0+]\n", \ " .dword 10b,11b\n")#define __asm_copy_from_user_16x_cont(to, from, ret, COPY, FIXUP, TENTRY) \ __asm_copy_from_user_12x_cont(to, from, ret, \ " move.d [%1+],$r9\n" \ "8: move.d $r9,[%0+]\n" COPY, \ "9: addq 4,%2\n" \ " clear.d [%0+]\n" FIXUP, \ " .dword 8b,9b\n" TENTRY)#define __asm_copy_from_user_16(to, from, ret) \ __asm_copy_from_user_16x_cont(to, from, ret, "", "", "")#define __asm_copy_from_user_20x_cont(to, from, ret, COPY, FIXUP, TENTRY) \ __asm_copy_from_user_16x_cont(to, from, ret, \ " move.d [%1+],$r9\n" \ "10: move.d $r9,[%0+]\n" COPY, \ "11: addq 4,%2\n" \ " clear.d [%0+]\n" FIXUP, \ " .dword 10b,11b\n" TENTRY)#define __asm_copy_from_user_20(to, from, ret) \ __asm_copy_from_user_20x_cont(to, from, ret, "", "", "")#define __asm_copy_from_user_24x_cont(to, from, ret, COPY, FIXUP, TENTRY) \ __asm_copy_from_user_20x_cont(to, from, ret, \ " move.d [%1+],$r9\n" \ "12: move.d $r9,[%0+]\n" COPY, \ "13: addq 4,%2\n" \ " clear.d [%0+]\n" FIXUP, \ " .dword 12b,13b\n" TENTRY)#define __asm_copy_from_user_24(to, from, ret) \ __asm_copy_from_user_24x_cont(to, from, ret, "", "", "")/* And now, the to-user ones. */#define __asm_copy_to_user_1(to, from, ret) \ __asm_copy_user_cont(to, from, ret, \ " move.b [%1+],$r9\n" \ " move.b $r9,[%0+]\n2:\n", \ "3: addq 1,%2\n", \ " .dword 2b,3b\n")#define __asm_copy_to_user_2x_cont(to, from, ret, COPY, FIXUP, TENTRY) \ __asm_copy_user_cont(to, from, ret, \ " move.w [%1+],$r9\n" \ " move.w $r9,[%0+]\n2:\n" COPY, \ "3: addq 2,%2\n" FIXUP, \ " .dword 2b,3b\n" TENTRY)#define __asm_copy_to_user_2(to, from, ret) \ __asm_copy_to_user_2x_cont(to, from, ret, "", "", "")#define __asm_copy_to_user_3(to, from, ret) \ __asm_copy_to_user_2x_cont(to, from, ret, \ " move.b [%1+],$r9\n" \ " move.b $r9,[%0+]\n4:\n", \ "5: addq 1,%2\n", \ " .dword 4b,5b\n")#define __asm_copy_to_user_4x_cont(to, from, ret, COPY, FIXUP, TENTRY) \ __asm_copy_user_cont(to, from, ret, \ " move.d [%1+],$r9\n" \ " move.d $r9,[%0+]\n2:\n" COPY, \ "3: addq 4,%2\n" FIXUP, \ " .dword 2b,3b\n" TENTRY)#define __asm_copy_to_user_4(to, from, ret) \ __asm_copy_to_user_4x_cont(to, from, ret, "", "", "")#define __asm_copy_to_user_5(to, from, ret) \ __asm_copy_to_user_4x_cont(to, from, ret, \ " move.b [%1+],$r9\n" \ " move.b $r9,[%0+]\n4:\n", \ "5: addq 1,%2\n", \ " .dword 4b,5b\n")#define __asm_copy_to_user_6x_cont(to, from, ret, COPY, FIXUP, TENTRY) \ __asm_copy_to_user_4x_cont(to, from, ret, \ " move.w [%1+],$r9\n" \ " move.w $r9,[%0+]\n4:\n" COPY, \ "5: addq 2,%2\n" FIXUP, \ " .dword 4b,5b\n" TENTRY)#define __asm_copy_to_user_6(to, from, ret) \ __asm_copy_to_user_6x_cont(to, from, ret, "", "", "")#define __asm_copy_to_user_7(to, from, ret) \ __asm_copy_to_user_6x_cont(to, from, ret, \ " move.b [%1+],$r9\n" \ " move.b $r9,[%0+]\n6:\n", \ "7: addq 1,%2\n", \ " .dword 6b,7b\n")#define __asm_copy_to_user_8x_cont(to, from, ret, COPY, FIXUP, TENTRY) \ __asm_copy_to_user_4x_cont(to, from, ret, \ " move.d [%1+],$r9\n" \ " move.d $r9,[%0+]\n4:\n" COPY, \ "5: addq 4,%2\n" FIXUP, \ " .dword 4b,5b\n" TENTRY)#define __asm_copy_to_user_8(to, from, ret) \ __asm_copy_to_user_8x_cont(to, from, ret, "", "", "")#define __asm_copy_to_user_9(to, from, ret) \ __asm_copy_to_user_8x_cont(to, from, ret, \ " move.b [%1+],$r9\n" \ " move.b $r9,[%0+]\n6:\n", \ "7: addq 1,%2\n", \ " .dword 6b,7b\n")#define __asm_copy_to_user_10x_cont(to, from, ret, COPY, FIXUP, TENTRY) \ __asm_copy_to_user_8x_cont(to, from, ret, \ " move.w [%1+],$r9\n" \ " move.w $r9,[%0+]\n6:\n" COPY, \ "7: addq 2,%2\n" FIXUP, \ " .dword 6b,7b\n" TENTRY)#define __asm_copy_to_user_10(to, from, ret) \ __asm_copy_to_user_10x_cont(to, from, ret, "", "", "")#define __asm_copy_to_user_11(to, from, ret) \ __asm_copy_to_user_10x_cont(to, from, ret, \ " move.b [%1+],$r9\n" \ " move.b $r9,[%0+]\n8:\n", \ "9: addq 1,%2\n", \ " .dword 8b,9b\n")#define __asm_copy_to_user_12x_cont(to, from, ret, COPY, FIXUP, TENTRY) \ __asm_copy_to_user_8x_cont(to, from, ret, \ " move.d [%1+],$r9\n" \ " move.d $r9,[%0+]\n6:\n" COPY, \ "7: addq 4,%2\n" FIXUP, \ " .dword 6b,7b\n" TENTRY)#define __asm_copy_to_user_12(to, from, ret) \ __asm_copy_to_user_12x_cont(to, from, ret, "", "", "")#define __asm_copy_to_user_13(to, from, ret) \ __asm_copy_to_user_12x_cont(to, from, ret, \ " move.b [%1+],$r9\n" \ " move.b $r9,[%0+]\n8:\n", \ "9: addq 1,%2\n", \ " .dword 8b,9b\n")#define __asm_copy_to_user_14x_cont(to, from, ret, COPY, FIXUP, TENTRY) \ __asm_copy_to_user_12x_cont(to, from, ret, \ " move.w [%1+],$r9\n" \ " move.w $r9,[%0+]\n8:\n" COPY, \ "9: addq 2,%2\n" FIXUP, \ " .dword 8b,9b\n" TENTRY)#define __asm_copy_to_user_14(to, from, ret) \ __asm_copy_to_user_14x_cont(to, from, ret, "", "", "")#define __asm_copy_to_user_15(to, from, ret) \ __asm_copy_to_user_14x_cont(to, from, ret, \ " move.b [%1+],$r9\n" \ " move.b $r9,[%0+]\n10:\n", \ "11: addq 1,%2\n", \ " .dword 10b,11b\n")#define __asm_copy_to_user_16x_cont(to, from, ret, COPY, FIXUP, TENTRY) \ __asm_copy_to_user_12x_cont(to, from, ret, \ " move.d [%1+],$r9\n" \
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -