📄 uaccess.h
字号:
"13: addq 4,%2\n" \ " clear.d [%0+]\n", \ TENTRY \ " .dword 12b,13b\n")#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+],$acr\n" \ "2: move.b $acr,[%0+]\n", \ "3: jump 1b\n" \ " 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, \ COPY \ " move.w [%1+],$acr\n" \ "2: move.w $acr,[%0+]\n", \ FIXUP \ "3: jump 1b\n" \ " addq 2,%2\n", \ TENTRY \ " .dword 2b,3b\n")#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+],$acr\n" \ "4: move.b $acr,[%0+]\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, \ COPY \ " move.d [%1+],$acr\n" \ "2: move.d $acr,[%0+]\n", \ FIXUP \ "3: jump 1b\n" \ " addq 4,%2\n", \ TENTRY \ " .dword 2b,3b\n")#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+],$acr\n" \ "4: move.b $acr,[%0+]\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, \ COPY \ " move.w [%1+],$acr\n" \ "4: move.w $acr,[%0+]\n", \ FIXUP \ "5: addq 2,%2\n", \ TENTRY \ " .dword 4b,5b\n")#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+],$acr\n" \ "6: move.b $acr,[%0+]\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, \ COPY \ " move.d [%1+],$acr\n" \ "4: move.d $acr,[%0+]\n", \ FIXUP \ "5: addq 4,%2\n", \ TENTRY \ " .dword 4b,5b\n")#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+],$acr\n" \ "6: move.b $acr,[%0+]\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, \ COPY \ " move.w [%1+],$acr\n" \ "6: move.w $acr,[%0+]\n", \ FIXUP \ "7: addq 2,%2\n", \ TENTRY \ " .dword 6b,7b\n")#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+],$acr\n" \ "8: move.b $acr,[%0+]\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, \ COPY \ " move.d [%1+],$acr\n" \ "6: move.d $acr,[%0+]\n", \ FIXUP \ "7: addq 4,%2\n", \ TENTRY \ " .dword 6b,7b\n")#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+],$acr\n" \ "8: move.b $acr,[%0+]\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, \ COPY \ " move.w [%1+],$acr\n" \ "8: move.w $acr,[%0+]\n", \ FIXUP \ "9: addq 2,%2\n", \ TENTRY \ " .dword 8b,9b\n")#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+],$acr\n" \ "10: move.b $acr,[%0+]\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, \ COPY \ " move.d [%1+],$acr\n" \ "8: move.d $acr,[%0+]\n", \ FIXUP \ "9: addq 4,%2\n", \ TENTRY \ " .dword 8b,9b\n")#define __asm_copy_to_user_16(to, from, ret) \ __asm_copy_to_user_16x_cont(to, from, ret, "", "", "")#define __asm_copy_to_user_20x_cont(to, from, ret, COPY, FIXUP, TENTRY) \ __asm_copy_to_user_16x_cont(to, from, ret, \ COPY \ " move.d [%1+],$acr\n" \ "10: move.d $acr,[%0+]\n", \ FIXUP \ "11: addq 4,%2\n", \ TENTRY \ " .dword 10b,11b\n")#define __asm_copy_to_user_20(to, from, ret) \ __asm_copy_to_user_20x_cont(to, from, ret, "", "", "")#define __asm_copy_to_user_24x_cont(to, from, ret, COPY, FIXUP, TENTRY) \ __asm_copy_to_user_20x_cont(to, from, ret, \ COPY \ " move.d [%1+],$acr\n" \ "12: move.d $acr,[%0+]\n", \ FIXUP \ "13: addq 4,%2\n", \ TENTRY \ " .dword 12b,13b\n")#define __asm_copy_to_user_24(to, from, ret) \ __asm_copy_to_user_24x_cont(to, from, ret, "", "", "")/* Define a few clearing asms with exception handlers. *//* This frame-asm is like the __asm_copy_user_cont one, but has one less input. */#define __asm_clear(to, ret, CLEAR, FIXUP, TENTRY) \ __asm__ __volatile__ ( \ CLEAR \ "1:\n" \ " .section .fixup,\"ax\"\n" \ FIXUP \ " .previous\n" \ " .section __ex_table,\"a\"\n" \ TENTRY \ " .previous" \ : "=b" (to), "=r" (ret) \ : "0" (to), "1" (ret) \ : "memory")#define __asm_clear_1(to, ret) \ __asm_clear(to, ret, \ "2: clear.b [%0+]\n", \ "3: jump 1b\n" \ " addq 1,%1\n", \ " .dword 2b,3b\n")#define __asm_clear_2(to, ret) \ __asm_clear(to, ret, \ "2: clear.w [%0+]\n", \ "3: jump 1b\n" \ " addq 2,%1\n", \ " .dword 2b,3b\n")#define __asm_clear_3(to, ret) \ __asm_clear(to, ret, \ "2: clear.w [%0+]\n" \ "3: clear.b [%0+]\n", \ "4: addq 2,%1\n" \ "5: jump 1b\n" \ " addq 1,%1\n", \ " .dword 2b,4b\n" \ " .dword 3b,5b\n")#define __asm_clear_4x_cont(to, ret, CLEAR, FIXUP, TENTRY) \ __asm_clear(to, ret, \ CLEAR \ "2: clear.d [%0+]\n", \ FIXUP \ "3: jump 1b\n" \ " addq 4,%1\n", \ TENTRY \ " .dword 2b,3b\n")#define __asm_clear_4(to, ret) \ __asm_clear_4x_cont(to, ret, "", "", "")#define __asm_clear_8x_cont(to, ret, CLEAR, FIXUP, TENTRY) \ __asm_clear_4x_cont(to, ret, \ CLEAR \ "4: clear.d [%0+]\n", \ FIXUP \ "5: addq 4,%1\n", \ TENTRY \ " .dword 4b,5b\n")#define __asm_clear_8(to, ret) \ __asm_clear_8x_cont(to, ret, "", "", "")#define __asm_clear_12x_cont(to, ret, CLEAR, FIXUP, TENTRY) \ __asm_clear_8x_cont(to, ret, \ CLEAR \ "6: clear.d [%0+]\n", \ FIXUP \ "7: addq 4,%1\n", \ TENTRY \ " .dword 6b,7b\n")#define __asm_clear_12(to, ret) \ __asm_clear_12x_cont(to, ret, "", "", "")#define __asm_clear_16x_cont(to, ret, CLEAR, FIXUP, TENTRY) \ __asm_clear_12x_cont(to, ret, \ CLEAR \ "8: clear.d [%0+]\n", \ FIXUP \ "9: addq 4,%1\n", \ TENTRY \ " .dword 8b,9b\n")#define __asm_clear_16(to, ret) \ __asm_clear_16x_cont(to, ret, "", "", "")#define __asm_clear_20x_cont(to, ret, CLEAR, FIXUP, TENTRY) \ __asm_clear_16x_cont(to, ret, \ CLEAR \ "10: clear.d [%0+]\n", \ FIXUP \ "11: addq 4,%1\n", \ TENTRY \ " .dword 10b,11b\n")#define __asm_clear_20(to, ret) \ __asm_clear_20x_cont(to, ret, "", "", "")#define __asm_clear_24x_cont(to, ret, CLEAR, FIXUP, TENTRY) \ __asm_clear_20x_cont(to, ret, \ CLEAR \ "12: clear.d [%0+]\n", \ FIXUP \ "13: addq 4,%1\n", \ TENTRY \ " .dword 12b,13b\n")#define __asm_clear_24(to, ret) \ __asm_clear_24x_cont(to, ret, "", "", "")/* * Return the size of a string (including the ending 0) * * Return length of string in userspace including terminating 0 * or 0 for error. Return a value greater than N if too long. */static inline longstrnlen_user(const char *s, long n){ long res, tmp1; if (!access_ok(VERIFY_READ, s, 0)) return 0; /* * This code is deduced from: * * tmp1 = n; * while (tmp1-- > 0 && *s++) * ; * * res = n - tmp1; * * (with tweaks). */ __asm__ __volatile__ ( " move.d %1,$acr\n" " cmpq 0,$acr\n" "0:\n" " ble 1f\n" " subq 1,$acr\n" "4: test.b [%0+]\n" " bne 0b\n" " cmpq 0,$acr\n" "1:\n" " move.d %1,%0\n" " sub.d $acr,%0\n" "2:\n" " .section .fixup,\"ax\"\n" "3: jump 2b\n" " clear.d %0\n" " .previous\n" " .section __ex_table,\"a\"\n" " .dword 4b,3b\n" " .previous\n" : "=r" (res), "=r" (tmp1) : "0" (s), "1" (n) : "acr"); return res;}#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -