Commit 937f6593 authored by Weihao Li's avatar Weihao Li Committed by Huacai Chen

LoongArch: Adjust {copy, clear}_user exception handler behavior

The {copy, clear}_user function should returns number of bytes that
could not be {copied, cleared}. So, try to {copy, clear} byte by byte
when ld.{d,w,h} and st.{d,w,h} trapped into an exception.
Reviewed-by: default avatarWANG Rui <wangrui@loongson.cn>
Signed-off-by: default avatarWeihao Li <liweihao@loongson.cn>
Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
parent 0921af6c
...@@ -11,19 +11,6 @@ ...@@ -11,19 +11,6 @@
#include <asm/cpu.h> #include <asm/cpu.h>
#include <asm/regdef.h> #include <asm/regdef.h>
.irp to, 0, 1, 2, 3, 4, 5, 6, 7
.L_fixup_handle_\to\():
sub.d a0, a2, a0
addi.d a0, a0, (\to) * (-8)
jr ra
.endr
.irp to, 0, 2, 4
.L_fixup_handle_s\to\():
addi.d a0, a1, -\to
jr ra
.endr
SYM_FUNC_START(__clear_user) SYM_FUNC_START(__clear_user)
/* /*
* Some CPUs support hardware unaligned access * Some CPUs support hardware unaligned access
...@@ -51,7 +38,7 @@ SYM_FUNC_START(__clear_user_generic) ...@@ -51,7 +38,7 @@ SYM_FUNC_START(__clear_user_generic)
2: move a0, a1 2: move a0, a1
jr ra jr ra
_asm_extable 1b, .L_fixup_handle_s0 _asm_extable 1b, 2b
SYM_FUNC_END(__clear_user_generic) SYM_FUNC_END(__clear_user_generic)
/* /*
...@@ -173,33 +160,47 @@ SYM_FUNC_START(__clear_user_fast) ...@@ -173,33 +160,47 @@ SYM_FUNC_START(__clear_user_fast)
jr ra jr ra
/* fixup and ex_table */ /* fixup and ex_table */
_asm_extable 0b, .L_fixup_handle_0 .Llarge_fixup:
_asm_extable 1b, .L_fixup_handle_0 sub.d a1, a2, a0
_asm_extable 2b, .L_fixup_handle_1
_asm_extable 3b, .L_fixup_handle_2 .Lsmall_fixup:
_asm_extable 4b, .L_fixup_handle_3 29: st.b zero, a0, 0
_asm_extable 5b, .L_fixup_handle_4 addi.d a0, a0, 1
_asm_extable 6b, .L_fixup_handle_5 addi.d a1, a1, -1
_asm_extable 7b, .L_fixup_handle_6 bgt a1, zero, 29b
_asm_extable 8b, .L_fixup_handle_7
_asm_extable 9b, .L_fixup_handle_0 .Lexit:
_asm_extable 10b, .L_fixup_handle_1 move a0, a1
_asm_extable 11b, .L_fixup_handle_2 jr ra
_asm_extable 12b, .L_fixup_handle_3
_asm_extable 13b, .L_fixup_handle_0 _asm_extable 0b, .Lsmall_fixup
_asm_extable 14b, .L_fixup_handle_1 _asm_extable 1b, .Llarge_fixup
_asm_extable 15b, .L_fixup_handle_0 _asm_extable 2b, .Llarge_fixup
_asm_extable 16b, .L_fixup_handle_0 _asm_extable 3b, .Llarge_fixup
_asm_extable 17b, .L_fixup_handle_s0 _asm_extable 4b, .Llarge_fixup
_asm_extable 18b, .L_fixup_handle_s0 _asm_extable 5b, .Llarge_fixup
_asm_extable 19b, .L_fixup_handle_s0 _asm_extable 6b, .Llarge_fixup
_asm_extable 20b, .L_fixup_handle_s2 _asm_extable 7b, .Llarge_fixup
_asm_extable 21b, .L_fixup_handle_s0 _asm_extable 8b, .Llarge_fixup
_asm_extable 22b, .L_fixup_handle_s0 _asm_extable 9b, .Llarge_fixup
_asm_extable 23b, .L_fixup_handle_s4 _asm_extable 10b, .Llarge_fixup
_asm_extable 24b, .L_fixup_handle_s0 _asm_extable 11b, .Llarge_fixup
_asm_extable 25b, .L_fixup_handle_s4 _asm_extable 12b, .Llarge_fixup
_asm_extable 26b, .L_fixup_handle_s0 _asm_extable 13b, .Llarge_fixup
_asm_extable 27b, .L_fixup_handle_s4 _asm_extable 14b, .Llarge_fixup
_asm_extable 28b, .L_fixup_handle_s0 _asm_extable 15b, .Llarge_fixup
_asm_extable 16b, .Llarge_fixup
_asm_extable 17b, .Lexit
_asm_extable 18b, .Lsmall_fixup
_asm_extable 19b, .Lsmall_fixup
_asm_extable 20b, .Lsmall_fixup
_asm_extable 21b, .Lsmall_fixup
_asm_extable 22b, .Lsmall_fixup
_asm_extable 23b, .Lsmall_fixup
_asm_extable 24b, .Lsmall_fixup
_asm_extable 25b, .Lsmall_fixup
_asm_extable 26b, .Lsmall_fixup
_asm_extable 27b, .Lsmall_fixup
_asm_extable 28b, .Lsmall_fixup
_asm_extable 29b, .Lexit
SYM_FUNC_END(__clear_user_fast) SYM_FUNC_END(__clear_user_fast)
...@@ -11,19 +11,6 @@ ...@@ -11,19 +11,6 @@
#include <asm/cpu.h> #include <asm/cpu.h>
#include <asm/regdef.h> #include <asm/regdef.h>
.irp to, 0, 1, 2, 3, 4, 5, 6, 7
.L_fixup_handle_\to\():
sub.d a0, a2, a0
addi.d a0, a0, (\to) * (-8)
jr ra
.endr
.irp to, 0, 2, 4
.L_fixup_handle_s\to\():
addi.d a0, a2, -\to
jr ra
.endr
SYM_FUNC_START(__copy_user) SYM_FUNC_START(__copy_user)
/* /*
* Some CPUs support hardware unaligned access * Some CPUs support hardware unaligned access
...@@ -54,8 +41,8 @@ SYM_FUNC_START(__copy_user_generic) ...@@ -54,8 +41,8 @@ SYM_FUNC_START(__copy_user_generic)
3: move a0, a2 3: move a0, a2
jr ra jr ra
_asm_extable 1b, .L_fixup_handle_s0 _asm_extable 1b, 3b
_asm_extable 2b, .L_fixup_handle_s0 _asm_extable 2b, 3b
SYM_FUNC_END(__copy_user_generic) SYM_FUNC_END(__copy_user_generic)
/* /*
...@@ -69,10 +56,10 @@ SYM_FUNC_START(__copy_user_fast) ...@@ -69,10 +56,10 @@ SYM_FUNC_START(__copy_user_fast)
sltui t0, a2, 9 sltui t0, a2, 9
bnez t0, .Lsmall bnez t0, .Lsmall
add.d a3, a1, a2
add.d a2, a0, a2
0: ld.d t0, a1, 0 0: ld.d t0, a1, 0
1: st.d t0, a0, 0 1: st.d t0, a0, 0
add.d a3, a1, a2
add.d a2, a0, a2
/* align up destination address */ /* align up destination address */
andi t1, a0, 7 andi t1, a0, 7
...@@ -94,7 +81,6 @@ SYM_FUNC_START(__copy_user_fast) ...@@ -94,7 +81,6 @@ SYM_FUNC_START(__copy_user_fast)
7: ld.d t5, a1, 40 7: ld.d t5, a1, 40
8: ld.d t6, a1, 48 8: ld.d t6, a1, 48
9: ld.d t7, a1, 56 9: ld.d t7, a1, 56
addi.d a1, a1, 64
10: st.d t0, a0, 0 10: st.d t0, a0, 0
11: st.d t1, a0, 8 11: st.d t1, a0, 8
12: st.d t2, a0, 16 12: st.d t2, a0, 16
...@@ -103,6 +89,7 @@ SYM_FUNC_START(__copy_user_fast) ...@@ -103,6 +89,7 @@ SYM_FUNC_START(__copy_user_fast)
15: st.d t5, a0, 40 15: st.d t5, a0, 40
16: st.d t6, a0, 48 16: st.d t6, a0, 48
17: st.d t7, a0, 56 17: st.d t7, a0, 56
addi.d a1, a1, 64
addi.d a0, a0, 64 addi.d a0, a0, 64
bltu a1, a4, .Lloop64 bltu a1, a4, .Lloop64
...@@ -114,11 +101,11 @@ SYM_FUNC_START(__copy_user_fast) ...@@ -114,11 +101,11 @@ SYM_FUNC_START(__copy_user_fast)
19: ld.d t1, a1, 8 19: ld.d t1, a1, 8
20: ld.d t2, a1, 16 20: ld.d t2, a1, 16
21: ld.d t3, a1, 24 21: ld.d t3, a1, 24
addi.d a1, a1, 32
22: st.d t0, a0, 0 22: st.d t0, a0, 0
23: st.d t1, a0, 8 23: st.d t1, a0, 8
24: st.d t2, a0, 16 24: st.d t2, a0, 16
25: st.d t3, a0, 24 25: st.d t3, a0, 24
addi.d a1, a1, 32
addi.d a0, a0, 32 addi.d a0, a0, 32
.Llt32: .Llt32:
...@@ -126,9 +113,9 @@ SYM_FUNC_START(__copy_user_fast) ...@@ -126,9 +113,9 @@ SYM_FUNC_START(__copy_user_fast)
bgeu a1, a4, .Llt16 bgeu a1, a4, .Llt16
26: ld.d t0, a1, 0 26: ld.d t0, a1, 0
27: ld.d t1, a1, 8 27: ld.d t1, a1, 8
addi.d a1, a1, 16
28: st.d t0, a0, 0 28: st.d t0, a0, 0
29: st.d t1, a0, 8 29: st.d t1, a0, 8
addi.d a1, a1, 16
addi.d a0, a0, 16 addi.d a0, a0, 16
.Llt16: .Llt16:
...@@ -136,6 +123,7 @@ SYM_FUNC_START(__copy_user_fast) ...@@ -136,6 +123,7 @@ SYM_FUNC_START(__copy_user_fast)
bgeu a1, a4, .Llt8 bgeu a1, a4, .Llt8
30: ld.d t0, a1, 0 30: ld.d t0, a1, 0
31: st.d t0, a0, 0 31: st.d t0, a0, 0
addi.d a1, a1, 8
addi.d a0, a0, 8 addi.d a0, a0, 8
.Llt8: .Llt8:
...@@ -214,62 +202,79 @@ SYM_FUNC_START(__copy_user_fast) ...@@ -214,62 +202,79 @@ SYM_FUNC_START(__copy_user_fast)
jr ra jr ra
/* fixup and ex_table */ /* fixup and ex_table */
_asm_extable 0b, .L_fixup_handle_0 .Llarge_fixup:
_asm_extable 1b, .L_fixup_handle_0 sub.d a2, a2, a0
_asm_extable 2b, .L_fixup_handle_0
_asm_extable 3b, .L_fixup_handle_0 .Lsmall_fixup:
_asm_extable 4b, .L_fixup_handle_0 58: ld.b t0, a1, 0
_asm_extable 5b, .L_fixup_handle_0 59: st.b t0, a0, 0
_asm_extable 6b, .L_fixup_handle_0 addi.d a0, a0, 1
_asm_extable 7b, .L_fixup_handle_0 addi.d a1, a1, 1
_asm_extable 8b, .L_fixup_handle_0 addi.d a2, a2, -1
_asm_extable 9b, .L_fixup_handle_0 bgt a2, zero, 58b
_asm_extable 10b, .L_fixup_handle_0
_asm_extable 11b, .L_fixup_handle_1 .Lexit:
_asm_extable 12b, .L_fixup_handle_2 move a0, a2
_asm_extable 13b, .L_fixup_handle_3 jr ra
_asm_extable 14b, .L_fixup_handle_4
_asm_extable 15b, .L_fixup_handle_5 _asm_extable 0b, .Lsmall_fixup
_asm_extable 16b, .L_fixup_handle_6 _asm_extable 1b, .Lsmall_fixup
_asm_extable 17b, .L_fixup_handle_7 _asm_extable 2b, .Llarge_fixup
_asm_extable 18b, .L_fixup_handle_0 _asm_extable 3b, .Llarge_fixup
_asm_extable 19b, .L_fixup_handle_0 _asm_extable 4b, .Llarge_fixup
_asm_extable 20b, .L_fixup_handle_0 _asm_extable 5b, .Llarge_fixup
_asm_extable 21b, .L_fixup_handle_0 _asm_extable 6b, .Llarge_fixup
_asm_extable 22b, .L_fixup_handle_0 _asm_extable 7b, .Llarge_fixup
_asm_extable 23b, .L_fixup_handle_1 _asm_extable 8b, .Llarge_fixup
_asm_extable 24b, .L_fixup_handle_2 _asm_extable 9b, .Llarge_fixup
_asm_extable 25b, .L_fixup_handle_3 _asm_extable 10b, .Llarge_fixup
_asm_extable 26b, .L_fixup_handle_0 _asm_extable 11b, .Llarge_fixup
_asm_extable 27b, .L_fixup_handle_0 _asm_extable 12b, .Llarge_fixup
_asm_extable 28b, .L_fixup_handle_0 _asm_extable 13b, .Llarge_fixup
_asm_extable 29b, .L_fixup_handle_1 _asm_extable 14b, .Llarge_fixup
_asm_extable 30b, .L_fixup_handle_0 _asm_extable 15b, .Llarge_fixup
_asm_extable 31b, .L_fixup_handle_0 _asm_extable 16b, .Llarge_fixup
_asm_extable 32b, .L_fixup_handle_0 _asm_extable 17b, .Llarge_fixup
_asm_extable 33b, .L_fixup_handle_0 _asm_extable 18b, .Llarge_fixup
_asm_extable 34b, .L_fixup_handle_s0 _asm_extable 19b, .Llarge_fixup
_asm_extable 35b, .L_fixup_handle_s0 _asm_extable 20b, .Llarge_fixup
_asm_extable 36b, .L_fixup_handle_s0 _asm_extable 21b, .Llarge_fixup
_asm_extable 37b, .L_fixup_handle_s0 _asm_extable 22b, .Llarge_fixup
_asm_extable 38b, .L_fixup_handle_s0 _asm_extable 23b, .Llarge_fixup
_asm_extable 39b, .L_fixup_handle_s0 _asm_extable 24b, .Llarge_fixup
_asm_extable 40b, .L_fixup_handle_s0 _asm_extable 25b, .Llarge_fixup
_asm_extable 41b, .L_fixup_handle_s2 _asm_extable 26b, .Llarge_fixup
_asm_extable 42b, .L_fixup_handle_s0 _asm_extable 27b, .Llarge_fixup
_asm_extable 43b, .L_fixup_handle_s0 _asm_extable 28b, .Llarge_fixup
_asm_extable 44b, .L_fixup_handle_s0 _asm_extable 29b, .Llarge_fixup
_asm_extable 45b, .L_fixup_handle_s0 _asm_extable 30b, .Llarge_fixup
_asm_extable 46b, .L_fixup_handle_s0 _asm_extable 31b, .Llarge_fixup
_asm_extable 47b, .L_fixup_handle_s4 _asm_extable 32b, .Llarge_fixup
_asm_extable 48b, .L_fixup_handle_s0 _asm_extable 33b, .Llarge_fixup
_asm_extable 49b, .L_fixup_handle_s0 _asm_extable 34b, .Lexit
_asm_extable 50b, .L_fixup_handle_s0 _asm_extable 35b, .Lexit
_asm_extable 51b, .L_fixup_handle_s4 _asm_extable 36b, .Lsmall_fixup
_asm_extable 52b, .L_fixup_handle_s0 _asm_extable 37b, .Lsmall_fixup
_asm_extable 53b, .L_fixup_handle_s0 _asm_extable 38b, .Lsmall_fixup
_asm_extable 54b, .L_fixup_handle_s0 _asm_extable 39b, .Lsmall_fixup
_asm_extable 55b, .L_fixup_handle_s4 _asm_extable 40b, .Lsmall_fixup
_asm_extable 56b, .L_fixup_handle_s0 _asm_extable 41b, .Lsmall_fixup
_asm_extable 57b, .L_fixup_handle_s0 _asm_extable 42b, .Lsmall_fixup
_asm_extable 43b, .Lsmall_fixup
_asm_extable 44b, .Lsmall_fixup
_asm_extable 45b, .Lsmall_fixup
_asm_extable 46b, .Lsmall_fixup
_asm_extable 47b, .Lsmall_fixup
_asm_extable 48b, .Lsmall_fixup
_asm_extable 49b, .Lsmall_fixup
_asm_extable 50b, .Lsmall_fixup
_asm_extable 51b, .Lsmall_fixup
_asm_extable 52b, .Lsmall_fixup
_asm_extable 53b, .Lsmall_fixup
_asm_extable 54b, .Lsmall_fixup
_asm_extable 55b, .Lsmall_fixup
_asm_extable 56b, .Lsmall_fixup
_asm_extable 57b, .Lsmall_fixup
_asm_extable 58b, .Lexit
_asm_extable 59b, .Lexit
SYM_FUNC_END(__copy_user_fast) SYM_FUNC_END(__copy_user_fast)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment