clear_user.S 704 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
  4. */
  5. #include <asm/asm.h>
  6. #include <asm/asmmacro.h>
  7. #include <asm/export.h>
  8. #include <asm/regdef.h>
  9. .macro fixup_ex from, to, offset, fix
  10. .if \fix
  11. .section .fixup, "ax"
  12. \to: addi.d a0, a1, \offset
  13. jr ra
  14. .previous
  15. .endif
  16. .section __ex_table, "a"
  17. PTR \from\()b, \to\()b
  18. .previous
  19. .endm
  20. /*
  21. * unsigned long __clear_user(void *addr, size_t size)
  22. *
  23. * a0: addr
  24. * a1: size
  25. */
  26. SYM_FUNC_START(__clear_user)
  27. beqz a1, 2f
  28. 1: st.b zero, a0, 0
  29. addi.d a0, a0, 1
  30. addi.d a1, a1, -1
  31. bgtz a1, 1b
  32. 2: move a0, a1
  33. jr ra
  34. fixup_ex 1, 3, 0, 1
  35. SYM_FUNC_END(__clear_user)
  36. EXPORT_SYMBOL(__clear_user)