133-MIPS-UAPI-Ignore-__arch_swab-16-32-64-when-using-MIP.patch 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. From 71a0a72456b48de972d7ed613b06a22a3aa9057f Mon Sep 17 00:00:00 2001
  2. From: Yousong Zhou <yszhou4tech@gmail.com>
  3. Date: Sat, 26 Sep 2015 13:41:43 +0800
  4. Subject: [PATCH] MIPS: UAPI: Ignore __arch_swab{16,32,64} when using MIPS16
  5. Some GCC versions (e.g. 4.8.3) can incorrectly inline a function with
  6. MIPS32 instructions into another function with MIPS16 code [1], causing
  7. the assembler to genereate incorrect binary code or fail right away
  8. complaining about unrecognized opcode.
  9. In the case of __arch_swab{16,32}, when inlined by the compiler with
  10. flags `-mips32r2 -mips16 -Os', the assembler can fail with the following
  11. error.
  12. {standard input}:79: Error: unrecognized opcode `wsbh $2,$2'
  13. For performance concerns and to workaround the issue already existing in
  14. older compilers, just ignore these 2 functions when compiling with
  15. mips16 enabled.
  16. [1] Inlining nomips16 function into mips16 function can result in
  17. undefined builtins, https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55777
  18. Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
  19. Cc: Maciej W. Rozycki <macro@linux-mips.org>
  20. Cc: linux-mips@linux-mips.org
  21. Patchwork: https://patchwork.linux-mips.org/patch/11241/
  22. Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
  23. ---
  24. arch/mips/include/uapi/asm/swab.h | 7 ++++---
  25. 1 file changed, 4 insertions(+), 3 deletions(-)
  26. --- a/arch/mips/include/uapi/asm/swab.h
  27. +++ b/arch/mips/include/uapi/asm/swab.h
  28. @@ -13,8 +13,9 @@
  29. #define __SWAB_64_THRU_32__
  30. -#if (defined(__mips_isa_rev) && (__mips_isa_rev >= 2)) || \
  31. - defined(_MIPS_ARCH_LOONGSON3A)
  32. +#if !defined(__mips16) && \
  33. + ((defined(__mips_isa_rev) && (__mips_isa_rev >= 2)) || \
  34. + defined(_MIPS_ARCH_LOONGSON3A))
  35. static inline __attribute_const__ __u16 __arch_swab16(__u16 x)
  36. {
  37. @@ -65,5 +66,5 @@ static inline __attribute_const__ __u64
  38. }
  39. #define __arch_swab64 __arch_swab64
  40. #endif /* __mips64 */
  41. -#endif /* MIPS R2 or newer or Loongson 3A */
  42. +#endif /* (not __mips16) and (MIPS R2 or newer or Loongson 3A) */
  43. #endif /* _ASM_SWAB_H */