diff options
author | James Hogan <james.hogan@imgtec.com> | 2015-08-05 11:41:39 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2015-12-22 05:58:43 -0500 |
commit | d6a428fb583738ad685c91a684748cdee7b2a05f (patch) | |
tree | a0c987da5c8d66400b4cb40628921a775bc99ae8 | |
parent | 6f06a2c45d8d714ea3b11a360b4a7191e52acaa4 (diff) |
MIPS: uaccess: Take EVA into account in [__]clear_user
__clear_user() (and clear_user() which uses it), always access the user
mode address space, which results in EVA store instructions when EVA is
enabled even if the current user address limit is KERNEL_DS.
Fix this by adding a new symbol __bzero_kernel for the normal kernel
address space bzero in EVA mode, and call that from __clear_user() if
eva_kernel_access().
Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: Markos Chandras <markos.chandras@imgtec.com>
Cc: Paul Burton <paul.burton@imgtec.com>
Cc: Leonid Yegoshin <leonid.yegoshin@imgtec.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/10844/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
-rw-r--r-- | arch/mips/include/asm/uaccess.h | 32 | ||||
-rw-r--r-- | arch/mips/kernel/mips_ksyms.c | 2 | ||||
-rw-r--r-- | arch/mips/lib/memset.S | 2 |
3 files changed, 26 insertions, 10 deletions
diff --git a/arch/mips/include/asm/uaccess.h b/arch/mips/include/asm/uaccess.h index 5014e187df23..2e3b3991cf0b 100644 --- a/arch/mips/include/asm/uaccess.h +++ b/arch/mips/include/asm/uaccess.h | |||
@@ -1235,16 +1235,28 @@ __clear_user(void __user *addr, __kernel_size_t size) | |||
1235 | { | 1235 | { |
1236 | __kernel_size_t res; | 1236 | __kernel_size_t res; |
1237 | 1237 | ||
1238 | might_fault(); | 1238 | if (eva_kernel_access()) { |
1239 | __asm__ __volatile__( | 1239 | __asm__ __volatile__( |
1240 | "move\t$4, %1\n\t" | 1240 | "move\t$4, %1\n\t" |
1241 | "move\t$5, $0\n\t" | 1241 | "move\t$5, $0\n\t" |
1242 | "move\t$6, %2\n\t" | 1242 | "move\t$6, %2\n\t" |
1243 | __MODULE_JAL(__bzero) | 1243 | __MODULE_JAL(__bzero_kernel) |
1244 | "move\t%0, $6" | 1244 | "move\t%0, $6" |
1245 | : "=r" (res) | 1245 | : "=r" (res) |
1246 | : "r" (addr), "r" (size) | 1246 | : "r" (addr), "r" (size) |
1247 | : "$4", "$5", "$6", __UA_t0, __UA_t1, "$31"); | 1247 | : "$4", "$5", "$6", __UA_t0, __UA_t1, "$31"); |
1248 | } else { | ||
1249 | might_fault(); | ||
1250 | __asm__ __volatile__( | ||
1251 | "move\t$4, %1\n\t" | ||
1252 | "move\t$5, $0\n\t" | ||
1253 | "move\t$6, %2\n\t" | ||
1254 | __MODULE_JAL(__bzero) | ||
1255 | "move\t%0, $6" | ||
1256 | : "=r" (res) | ||
1257 | : "r" (addr), "r" (size) | ||
1258 | : "$4", "$5", "$6", __UA_t0, __UA_t1, "$31"); | ||
1259 | } | ||
1248 | 1260 | ||
1249 | return res; | 1261 | return res; |
1250 | } | 1262 | } |
diff --git a/arch/mips/kernel/mips_ksyms.c b/arch/mips/kernel/mips_ksyms.c index 291af0b5c482..e2b6ab74643d 100644 --- a/arch/mips/kernel/mips_ksyms.c +++ b/arch/mips/kernel/mips_ksyms.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <asm/fpu.h> | 17 | #include <asm/fpu.h> |
18 | #include <asm/msa.h> | 18 | #include <asm/msa.h> |
19 | 19 | ||
20 | extern void *__bzero_kernel(void *__s, size_t __count); | ||
20 | extern void *__bzero(void *__s, size_t __count); | 21 | extern void *__bzero(void *__s, size_t __count); |
21 | extern long __strncpy_from_kernel_nocheck_asm(char *__to, | 22 | extern long __strncpy_from_kernel_nocheck_asm(char *__to, |
22 | const char *__from, long __len); | 23 | const char *__from, long __len); |
@@ -64,6 +65,7 @@ EXPORT_SYMBOL(__copy_from_user_eva); | |||
64 | EXPORT_SYMBOL(__copy_in_user_eva); | 65 | EXPORT_SYMBOL(__copy_in_user_eva); |
65 | EXPORT_SYMBOL(__copy_to_user_eva); | 66 | EXPORT_SYMBOL(__copy_to_user_eva); |
66 | EXPORT_SYMBOL(__copy_user_inatomic_eva); | 67 | EXPORT_SYMBOL(__copy_user_inatomic_eva); |
68 | EXPORT_SYMBOL(__bzero_kernel); | ||
67 | #endif | 69 | #endif |
68 | EXPORT_SYMBOL(__bzero); | 70 | EXPORT_SYMBOL(__bzero); |
69 | EXPORT_SYMBOL(__strncpy_from_kernel_nocheck_asm); | 71 | EXPORT_SYMBOL(__strncpy_from_kernel_nocheck_asm); |
diff --git a/arch/mips/lib/memset.S b/arch/mips/lib/memset.S index b8e63fd00375..8f0019a2e5c8 100644 --- a/arch/mips/lib/memset.S +++ b/arch/mips/lib/memset.S | |||
@@ -283,6 +283,8 @@ LEAF(memset) | |||
283 | 1: | 283 | 1: |
284 | #ifndef CONFIG_EVA | 284 | #ifndef CONFIG_EVA |
285 | FEXPORT(__bzero) | 285 | FEXPORT(__bzero) |
286 | #else | ||
287 | FEXPORT(__bzero_kernel) | ||
286 | #endif | 288 | #endif |
287 | __BUILD_BZERO LEGACY_MODE | 289 | __BUILD_BZERO LEGACY_MODE |
288 | 290 | ||