copy_in_user.S 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. * Copy from user space to user space
  3. *
  4. * Copyright (C) 2012 ARM Ltd.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #include <linux/linkage.h>
  19. #include <asm/alternative.h>
  20. #include <asm/assembler.h>
  21. #include <asm/cache.h>
  22. #include <asm/cpufeature.h>
  23. #include <asm/sysreg.h>
  24. /*
  25. * Copy from user space to user space (alignment handled by the hardware)
  26. *
  27. * Parameters:
  28. * x0 - to
  29. * x1 - from
  30. * x2 - n
  31. * Returns:
  32. * x0 - bytes not copied
  33. */
  34. .macro ldrb1 ptr, regB, val
  35. uao_user_alternative 9998f, ldrb, ldtrb, \ptr, \regB, \val
  36. .endm
  37. .macro strb1 ptr, regB, val
  38. uao_user_alternative 9998f, strb, sttrb, \ptr, \regB, \val
  39. .endm
  40. .macro ldrh1 ptr, regB, val
  41. uao_user_alternative 9998f, ldrh, ldtrh, \ptr, \regB, \val
  42. .endm
  43. .macro strh1 ptr, regB, val
  44. uao_user_alternative 9998f, strh, sttrh, \ptr, \regB, \val
  45. .endm
  46. .macro ldr1 ptr, regB, val
  47. uao_user_alternative 9998f, ldr, ldtr, \ptr, \regB, \val
  48. .endm
  49. .macro str1 ptr, regB, val
  50. uao_user_alternative 9998f, str, sttr, \ptr, \regB, \val
  51. .endm
  52. .macro ldp1 ptr, regB, regC, val
  53. uao_ldp 9998f, \ptr, \regB, \regC, \val
  54. .endm
  55. .macro stp1 ptr, regB, regC, val
  56. uao_stp 9998f, \ptr, \regB, \regC, \val
  57. .endm
  58. end .req x5
  59. ENTRY(__arch_copy_in_user)
  60. ALTERNATIVE("nop", __stringify(SET_PSTATE_PAN(0)), ARM64_ALT_PAN_NOT_UAO, \
  61. CONFIG_ARM64_PAN)
  62. add end, x0, x2
  63. #include "copy_template.S"
  64. ALTERNATIVE("nop", __stringify(SET_PSTATE_PAN(1)), ARM64_ALT_PAN_NOT_UAO, \
  65. CONFIG_ARM64_PAN)
  66. mov x0, #0
  67. ret
  68. ENDPROC(__arch_copy_in_user)
  69. .section .fixup,"ax"
  70. .align 2
  71. 9998: sub x0, end, dst // bytes not copied
  72. ret
  73. .previous