clear_user.S 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * linux/arch/arm/lib/clear_user.S
  4. *
  5. * Copyright (C) 1995, 1996,1997,1998 Russell King
  6. */
  7. #include <linux/linkage.h>
  8. #include <asm/assembler.h>
  9. #include <asm/unwind.h>
  10. .text
  11. /* Prototype: unsigned long arm_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. ENTRY(__clear_user_std)
  18. WEAK(arm_clear_user)
  19. UNWIND(.fnstart)
  20. UNWIND(.save {r1, lr})
  21. stmfd sp!, {r1, lr}
  22. mov r2, #0
  23. cmp r1, #4
  24. blt 2f
  25. ands ip, r0, #3
  26. beq 1f
  27. cmp ip, #2
  28. strusr r2, r0, 1
  29. strusr r2, r0, 1, le
  30. strusr r2, r0, 1, lt
  31. rsb ip, ip, #4
  32. sub r1, r1, ip @ 7 6 5 4 3 2 1
  33. 1: subs r1, r1, #8 @ -1 -2 -3 -4 -5 -6 -7
  34. strusr r2, r0, 4, pl, rept=2
  35. bpl 1b
  36. adds r1, r1, #4 @ 3 2 1 0 -1 -2 -3
  37. strusr r2, r0, 4, pl
  38. 2: tst r1, #2 @ 1x 1x 0x 0x 1x 1x 0x
  39. strusr r2, r0, 1, ne, rept=2
  40. tst r1, #1 @ x1 x0 x1 x0 x1 x0 x1
  41. it ne @ explicit IT needed for the label
  42. USER( strbtne r2, [r0])
  43. mov r0, #0
  44. ldmfd sp!, {r1, pc}
  45. UNWIND(.fnend)
  46. ENDPROC(arm_clear_user)
  47. ENDPROC(__clear_user_std)
  48. .pushsection .text.fixup,"ax"
  49. .align 0
  50. 9001: ldmfd sp!, {r0, pc}
  51. .popsection