forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-09-20 a36159eec6ca17402b0e146b86efaf76568dc353
kernel/arch/mips/include/asm/futex.h
....@@ -16,26 +16,27 @@
1616 #include <asm/barrier.h>
1717 #include <asm/compiler.h>
1818 #include <asm/errno.h>
19
+#include <asm/sync.h>
1920 #include <asm/war.h>
2021
2122 #define __futex_atomic_op(insn, ret, oldval, uaddr, oparg) \
2223 { \
23
- if (cpu_has_llsc && R10000_LLSC_WAR) { \
24
+ if (cpu_has_llsc && IS_ENABLED(CONFIG_WAR_R10000_LLSC)) { \
2425 __asm__ __volatile__( \
2526 " .set push \n" \
2627 " .set noat \n" \
28
+ " .set push \n" \
2729 " .set arch=r4000 \n" \
2830 "1: ll %1, %4 # __futex_atomic_op \n" \
29
- " .set mips0 \n" \
31
+ " .set pop \n" \
3032 " " insn " \n" \
3133 " .set arch=r4000 \n" \
3234 "2: sc $1, %2 \n" \
3335 " beqzl $1, 1b \n" \
34
- __WEAK_LLSC_MB \
36
+ __stringify(__WEAK_LLSC_MB) " \n" \
3537 "3: \n" \
3638 " .insn \n" \
3739 " .set pop \n" \
38
- " .set mips0 \n" \
3940 " .section .fixup,\"ax\" \n" \
4041 "4: li %0, %6 \n" \
4142 " j 3b \n" \
....@@ -53,18 +54,19 @@
5354 __asm__ __volatile__( \
5455 " .set push \n" \
5556 " .set noat \n" \
57
+ " .set push \n" \
5658 " .set "MIPS_ISA_ARCH_LEVEL" \n" \
59
+ " " __SYNC(full, loongson3_war) " \n" \
5760 "1: "user_ll("%1", "%4")" # __futex_atomic_op\n" \
58
- " .set mips0 \n" \
61
+ " .set pop \n" \
5962 " " insn " \n" \
6063 " .set "MIPS_ISA_ARCH_LEVEL" \n" \
6164 "2: "user_sc("$1", "%2")" \n" \
6265 " beqz $1, 1b \n" \
63
- __WEAK_LLSC_MB \
66
+ __stringify(__WEAK_LLSC_MB) " \n" \
6467 "3: \n" \
6568 " .insn \n" \
6669 " .set pop \n" \
67
- " .set mips0 \n" \
6870 " .section .fixup,\"ax\" \n" \
6971 "4: li %0, %6 \n" \
7072 " j 3b \n" \
....@@ -87,7 +89,8 @@
8789 {
8890 int oldval = 0, ret;
8991
90
- pagefault_disable();
92
+ if (!access_ok(uaddr, sizeof(u32)))
93
+ return -EFAULT;
9194
9295 switch (op) {
9396 case FUTEX_OP_SET:
....@@ -114,8 +117,6 @@
114117 ret = -ENOSYS;
115118 }
116119
117
- pagefault_enable();
118
-
119120 if (!ret)
120121 *oval = oldval;
121122
....@@ -129,23 +130,24 @@
129130 int ret = 0;
130131 u32 val;
131132
132
- if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
133
+ if (!access_ok(uaddr, sizeof(u32)))
133134 return -EFAULT;
134135
135
- if (cpu_has_llsc && R10000_LLSC_WAR) {
136
+ if (cpu_has_llsc && IS_ENABLED(CONFIG_WAR_R10000_LLSC)) {
136137 __asm__ __volatile__(
137138 "# futex_atomic_cmpxchg_inatomic \n"
138139 " .set push \n"
139140 " .set noat \n"
141
+ " .set push \n"
140142 " .set arch=r4000 \n"
141143 "1: ll %1, %3 \n"
142144 " bne %1, %z4, 3f \n"
143
- " .set mips0 \n"
145
+ " .set pop \n"
144146 " move $1, %z5 \n"
145147 " .set arch=r4000 \n"
146148 "2: sc $1, %2 \n"
147149 " beqzl $1, 1b \n"
148
- __WEAK_LLSC_MB
150
+ __stringify(__WEAK_LLSC_MB) " \n"
149151 "3: \n"
150152 " .insn \n"
151153 " .set pop \n"
....@@ -166,16 +168,17 @@
166168 "# futex_atomic_cmpxchg_inatomic \n"
167169 " .set push \n"
168170 " .set noat \n"
171
+ " .set push \n"
169172 " .set "MIPS_ISA_ARCH_LEVEL" \n"
173
+ " " __SYNC(full, loongson3_war) " \n"
170174 "1: "user_ll("%1", "%3")" \n"
171175 " bne %1, %z4, 3f \n"
172
- " .set mips0 \n"
176
+ " .set pop \n"
173177 " move $1, %z5 \n"
174178 " .set "MIPS_ISA_ARCH_LEVEL" \n"
175179 "2: "user_sc("$1", "%2")" \n"
176180 " beqz $1, 1b \n"
177
- __WEAK_LLSC_MB
178
- "3: \n"
181
+ "3: " __SYNC_ELSE(full, loongson3_war, __WEAK_LLSC_MB) "\n"
179182 " .insn \n"
180183 " .set pop \n"
181184 " .section .fixup,\"ax\" \n"