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