copy_user.S 775 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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, a2, \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 __copy_user(void *to, const void *from, size_t n)
  22. *
  23. * a0: to
  24. * a1: from
  25. * a2: n
  26. */
  27. SYM_FUNC_START(__copy_user)
  28. beqz a2, 3f
  29. 1: ld.b t0, a1, 0
  30. 2: st.b t0, a0, 0
  31. addi.d a0, a0, 1
  32. addi.d a1, a1, 1
  33. addi.d a2, a2, -1
  34. bgtz a2, 1b
  35. 3: move a0, a2
  36. jr ra
  37. fixup_ex 1, 4, 0, 1
  38. fixup_ex 2, 4, 0, 0
  39. SYM_FUNC_END(__copy_user)
  40. EXPORT_SYMBOL(__copy_user)