Skip to content

Commit d6a428f

Browse files
James Hoganralfbaechle
authored andcommitted
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>
1 parent 6f06a2c commit d6a428f

File tree

3 files changed

+26
-10
lines changed

3 files changed

+26
-10
lines changed

arch/mips/include/asm/uaccess.h

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,16 +1235,28 @@ __clear_user(void __user *addr, __kernel_size_t size)
12351235
{
12361236
__kernel_size_t res;
12371237

1238-
might_fault();
1239-
__asm__ __volatile__(
1240-
"move\t$4, %1\n\t"
1241-
"move\t$5, $0\n\t"
1242-
"move\t$6, %2\n\t"
1243-
__MODULE_JAL(__bzero)
1244-
"move\t%0, $6"
1245-
: "=r" (res)
1246-
: "r" (addr), "r" (size)
1247-
: "$4", "$5", "$6", __UA_t0, __UA_t1, "$31");
1238+
if (eva_kernel_access()) {
1239+
__asm__ __volatile__(
1240+
"move\t$4, %1\n\t"
1241+
"move\t$5, $0\n\t"
1242+
"move\t$6, %2\n\t"
1243+
__MODULE_JAL(__bzero_kernel)
1244+
"move\t%0, $6"
1245+
: "=r" (res)
1246+
: "r" (addr), "r" (size)
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+
}
12481260

12491261
return res;
12501262
}

arch/mips/kernel/mips_ksyms.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <asm/fpu.h>
1818
#include <asm/msa.h>
1919

20+
extern void *__bzero_kernel(void *__s, size_t __count);
2021
extern void *__bzero(void *__s, size_t __count);
2122
extern long __strncpy_from_kernel_nocheck_asm(char *__to,
2223
const char *__from, long __len);
@@ -64,6 +65,7 @@ EXPORT_SYMBOL(__copy_from_user_eva);
6465
EXPORT_SYMBOL(__copy_in_user_eva);
6566
EXPORT_SYMBOL(__copy_to_user_eva);
6667
EXPORT_SYMBOL(__copy_user_inatomic_eva);
68+
EXPORT_SYMBOL(__bzero_kernel);
6769
#endif
6870
EXPORT_SYMBOL(__bzero);
6971
EXPORT_SYMBOL(__strncpy_from_kernel_nocheck_asm);

arch/mips/lib/memset.S

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,8 @@ LEAF(memset)
283283
1:
284284
#ifndef CONFIG_EVA
285285
FEXPORT(__bzero)
286+
#else
287+
FEXPORT(__bzero_kernel)
286288
#endif
287289
__BUILD_BZERO LEGACY_MODE
288290

0 commit comments

Comments
 (0)