uaccess_vector.S 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. #include <linux/linkage.h>
  3. #include <asm/asm.h>
  4. #include <asm/asm-extable.h>
  5. #include <asm/csr.h>
  6. #define pDst a0
  7. #define pSrc a1
  8. #define iNum a2
  9. #define iVL a3
  10. #define ELEM_LMUL_SETTING m8
  11. #define vData v0
  12. .macro fixup op reg addr lbl
  13. 100:
  14. \op \reg, \addr
  15. _asm_extable 100b, \lbl
  16. .endm
  17. SYM_FUNC_START(__asm_vector_usercopy)
  18. /* Enable access to user memory */
  19. li t6, SR_SUM
  20. csrs CSR_STATUS, t6
  21. loop:
  22. vsetvli iVL, iNum, e8, ELEM_LMUL_SETTING, ta, ma
  23. fixup vle8.v vData, (pSrc), 10f
  24. sub iNum, iNum, iVL
  25. add pSrc, pSrc, iVL
  26. fixup vse8.v vData, (pDst), 11f
  27. add pDst, pDst, iVL
  28. bnez iNum, loop
  29. /* Exception fixup for vector load is shared with normal exit */
  30. 10:
  31. /* Disable access to user memory */
  32. csrc CSR_STATUS, t6
  33. mv a0, iNum
  34. ret
  35. /* Exception fixup code for vector store. */
  36. 11:
  37. /* Undo the subtraction after vle8.v */
  38. add iNum, iNum, iVL
  39. /* Make sure the scalar fallback skip already processed bytes */
  40. csrr t2, CSR_VSTART
  41. sub iNum, iNum, t2
  42. j 10b
  43. SYM_FUNC_END(__asm_vector_usercopy)