putuser.S 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * linux/arch/arm/lib/putuser.S
  4. *
  5. * Copyright (C) 2001 Russell King
  6. *
  7. * Idea from x86 version, (C) Copyright 1998 Linus Torvalds
  8. *
  9. * These functions have a non-standard call interface to make
  10. * them more efficient, especially as they return an error
  11. * value in addition to the "real" return value.
  12. *
  13. * __put_user_X
  14. *
  15. * Inputs: r0 contains the address
  16. * r1 contains the address limit, which must be preserved
  17. * r2, r3 contains the value
  18. * Outputs: r0 is the error code
  19. * lr corrupted
  20. *
  21. * No other registers must be altered. (see <asm/uaccess.h>
  22. * for specific ASM register usage).
  23. *
  24. * Note that ADDR_LIMIT is either 0 or 0xc0000000
  25. * Note also that it is intended that __put_user_bad is not global.
  26. */
  27. #include <linux/linkage.h>
  28. #include <asm/assembler.h>
  29. #include <asm/errno.h>
  30. #include <asm/domain.h>
  31. ENTRY(__put_user_1)
  32. check_uaccess r0, 1, r1, ip, __put_user_bad
  33. 1: TUSER(strb) r2, [r0]
  34. mov r0, #0
  35. ret lr
  36. ENDPROC(__put_user_1)
  37. ENTRY(__put_user_2)
  38. check_uaccess r0, 2, r1, ip, __put_user_bad
  39. #if __LINUX_ARM_ARCH__ >= 6
  40. 2: TUSER(strh) r2, [r0]
  41. #else
  42. mov ip, r2, lsr #8
  43. #ifndef __ARMEB__
  44. 2: TUSER(strb) r2, [r0], #1
  45. 3: TUSER(strb) ip, [r0]
  46. #else
  47. 2: TUSER(strb) ip, [r0], #1
  48. 3: TUSER(strb) r2, [r0]
  49. #endif
  50. #endif /* __LINUX_ARM_ARCH__ >= 6 */
  51. mov r0, #0
  52. ret lr
  53. ENDPROC(__put_user_2)
  54. ENTRY(__put_user_4)
  55. check_uaccess r0, 4, r1, ip, __put_user_bad
  56. 4: TUSER(str) r2, [r0]
  57. mov r0, #0
  58. ret lr
  59. ENDPROC(__put_user_4)
  60. ENTRY(__put_user_8)
  61. check_uaccess r0, 8, r1, ip, __put_user_bad
  62. #ifdef CONFIG_THUMB2_KERNEL
  63. 5: TUSER(str) r2, [r0]
  64. 6: TUSER(str) r3, [r0, #4]
  65. #else
  66. 5: TUSER(str) r2, [r0], #4
  67. 6: TUSER(str) r3, [r0]
  68. #endif
  69. mov r0, #0
  70. ret lr
  71. ENDPROC(__put_user_8)
  72. __put_user_bad:
  73. mov r0, #-EFAULT
  74. ret lr
  75. ENDPROC(__put_user_bad)
  76. .pushsection __ex_table, "a"
  77. .long 1b, __put_user_bad
  78. .long 2b, __put_user_bad
  79. #if __LINUX_ARM_ARCH__ < 6
  80. .long 3b, __put_user_bad
  81. #endif
  82. .long 4b, __put_user_bad
  83. .long 5b, __put_user_bad
  84. .long 6b, __put_user_bad
  85. .popsection