050-v5.16-01-mips-uasm-Add-workaround-for-Loongson-2F-nop-CPU-err.patch 1.3 KB

12345678910111213141516171819202122232425262728293031
  1. From: Johan Almbladh <[email protected]>
  2. Date: Tue, 5 Oct 2021 18:54:03 +0200
  3. Subject: [PATCH] mips: uasm: Add workaround for Loongson-2F nop CPU errata
  4. This patch implements a workaround for the Loongson-2F nop in generated,
  5. code, if the existing option CONFIG_CPU_NOP_WORKAROUND is set. Before,
  6. the binutils option -mfix-loongson2f-nop was enabled, but no workaround
  7. was done when emitting MIPS code. Now, the nop pseudo instruction is
  8. emitted as "or ax,ax,zero" instead of the default "sll zero,zero,0". This
  9. is consistent with the workaround implemented by binutils.
  10. Link: https://sourceware.org/legacy-ml/binutils/2009-11/msg00387.html
  11. Signed-off-by: Johan Almbladh <[email protected]>
  12. Reviewed-by: Jiaxun Yang <[email protected]>
  13. ---
  14. --- a/arch/mips/include/asm/uasm.h
  15. +++ b/arch/mips/include/asm/uasm.h
  16. @@ -249,7 +249,11 @@ static inline void uasm_l##lb(struct uas
  17. #define uasm_i_bnezl(buf, rs, off) uasm_i_bnel(buf, rs, 0, off)
  18. #define uasm_i_ehb(buf) uasm_i_sll(buf, 0, 0, 3)
  19. #define uasm_i_move(buf, a, b) UASM_i_ADDU(buf, a, 0, b)
  20. +#ifdef CONFIG_CPU_NOP_WORKAROUNDS
  21. +#define uasm_i_nop(buf) uasm_i_or(buf, 1, 1, 0)
  22. +#else
  23. #define uasm_i_nop(buf) uasm_i_sll(buf, 0, 0, 0)
  24. +#endif
  25. #define uasm_i_ssnop(buf) uasm_i_sll(buf, 0, 0, 1)
  26. static inline void uasm_i_drotr_safe(u32 **p, unsigned int a1,