Commit 4968db4b9c4528b097ab4e549c4e0d0420dd1efc

Authored by Markos Chandras
Committed by Ralf Baechle
1 parent c48be43eb5

MIPS: lib: strnlen_user: Add EVA support

In non-EVA mode, a strlen_user* alias is used for the
strlen_kernel* symbols since the code is identical. In EVA
mode, a new strlen_user* symbol is used which uses the EVA
specific instructions to load values from userspace.

Signed-off-by: Markos Chandras <markos.chandras@imgtec.com>

Showing 2 changed files with 24 additions and 0 deletions Side-by-side Diff

arch/mips/kernel/mips_ksyms.c
... ... @@ -22,6 +22,8 @@
22 22 long __len);
23 23 extern long __strlen_user_nocheck_asm(const char *s);
24 24 extern long __strlen_user_asm(const char *s);
  25 +extern long __strnlen_kernel_nocheck_asm(const char *s);
  26 +extern long __strnlen_kernel_asm(const char *s);
25 27 extern long __strnlen_user_nocheck_asm(const char *s);
26 28 extern long __strnlen_user_asm(const char *s);
27 29  
... ... @@ -48,6 +50,8 @@
48 50 EXPORT_SYMBOL(__strncpy_from_user_asm);
49 51 EXPORT_SYMBOL(__strlen_user_nocheck_asm);
50 52 EXPORT_SYMBOL(__strlen_user_asm);
  53 +EXPORT_SYMBOL(__strnlen_kernel_nocheck_asm);
  54 +EXPORT_SYMBOL(__strnlen_kernel_asm);
51 55 EXPORT_SYMBOL(__strnlen_user_nocheck_asm);
52 56 EXPORT_SYMBOL(__strnlen_user_asm);
53 57  
arch/mips/lib/strnlen_user.S
... ... @@ -35,7 +35,11 @@
35 35 move v0, a0
36 36 PTR_ADDU a1, a0 # stop pointer
37 37 1: beq v0, a1, 1f # limit reached?
  38 +.ifeqs "\func", "kernel"
38 39 EX(lb, t0, (v0), .Lfault\@)
  40 +.else
  41 + EX(lbe, t0, (v0), .Lfault\@)
  42 +.endif
39 43 PTR_ADDIU v0, 1
40 44 bnez t0, 1b
41 45 1: PTR_SUBU v0, a0
42 46  
... ... @@ -47,5 +51,21 @@
47 51 jr ra
48 52 .endm
49 53  
  54 +#ifndef CONFIG_EVA
  55 + /* Set aliases */
  56 + .global __strnlen_user_asm
  57 + .global __strnlen_user_nocheck_asm
  58 + .set __strnlen_user_asm, __strnlen_kernel_asm
  59 + .set __strnlen_user_nocheck_asm, __strnlen_kernel_nocheck_asm
  60 +#endif
  61 +
  62 +__BUILD_STRNLEN_ASM kernel
  63 +
  64 +#ifdef CONFIG_EVA
  65 +
  66 + .set push
  67 + .set eva
50 68 __BUILD_STRNLEN_ASM user
  69 + .set pop
  70 +#endif