clear_user.S 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Based on arch/arm/lib/clear_user.S
  4. *
  5. * Copyright (C) 2012 ARM Ltd.
  6. */
  7. #include <linux/linkage.h>
  8. #include <asm/asm-uaccess.h>
  9. #include <asm/assembler.h>
  10. .text
  11. /* Prototype: int __arch_clear_user(void *addr, size_t sz)
  12. * Purpose : clear some user memory
  13. * Params : addr - user memory address to clear
  14. * : sz - number of bytes to clear
  15. * Returns : number of bytes NOT cleared
  16. *
  17. * Alignment fixed up by hardware.
  18. */
  19. SYM_FUNC_START(__arch_clear_user)
  20. mov x2, x1 // save the size for fixup return
  21. subs x1, x1, #8
  22. b.mi 2f
  23. 1:
  24. uao_user_alternative 9f, str, sttr, xzr, x0, 8
  25. subs x1, x1, #8
  26. b.pl 1b
  27. 2: adds x1, x1, #4
  28. b.mi 3f
  29. uao_user_alternative 9f, str, sttr, wzr, x0, 4
  30. sub x1, x1, #4
  31. 3: adds x1, x1, #2
  32. b.mi 4f
  33. uao_user_alternative 9f, strh, sttrh, wzr, x0, 2
  34. sub x1, x1, #2
  35. 4: adds x1, x1, #1
  36. b.mi 5f
  37. uao_user_alternative 9f, strb, sttrb, wzr, x0, 0
  38. 5: mov x0, #0
  39. ret
  40. SYM_FUNC_END(__arch_clear_user)
  41. EXPORT_SYMBOL(__arch_clear_user)
  42. .section .fixup,"ax"
  43. .align 2
  44. 9: mov x0, x2 // return the original size
  45. ret
  46. .previous