Commit f4361718 authored by Palmer Dabbelt's avatar Palmer Dabbelt

riscv: Add macro for multiple nop instructions

Some cases need multiple nop instructions and arm64 already has a
nice helper for not needing to write all of them out but instead
use a helper to add n nops.

So add a similar thing to riscv and convert the T-Head PMA
alternative to use it.

* 'riscv-nops' of git://git.kernel.org/pub/scm/linux/kernel/git/palmer/linux.git:
  riscv: convert the t-head pbmt errata to use the __nops macro
  riscv: introduce nops and __nops macros for NOP sequences
parents 3f190111 9c2ea4a3
...@@ -67,4 +67,19 @@ ...@@ -67,4 +67,19 @@
#error "Unexpected __SIZEOF_SHORT__" #error "Unexpected __SIZEOF_SHORT__"
#endif #endif
#ifdef __ASSEMBLY__
/* Common assembly source macros */
/*
* NOP sequence
*/
.macro nops, num
.rept \num
nop
.endr
.endm
#endif /* __ASSEMBLY__ */
#endif /* _ASM_RISCV_ASM_H */ #endif /* _ASM_RISCV_ASM_H */
...@@ -13,6 +13,8 @@ ...@@ -13,6 +13,8 @@
#ifndef __ASSEMBLY__ #ifndef __ASSEMBLY__
#define nop() __asm__ __volatile__ ("nop") #define nop() __asm__ __volatile__ ("nop")
#define __nops(n) ".rept " #n "\nnop\n.endr\n"
#define nops(n) __asm__ __volatile__ (__nops(n))
#define RISCV_FENCE(p, s) \ #define RISCV_FENCE(p, s) \
__asm__ __volatile__ ("fence " #p "," #s : : : "memory") __asm__ __volatile__ ("fence " #p "," #s : : : "memory")
......
...@@ -68,13 +68,7 @@ asm(ALTERNATIVE_2("li %0, 0\t\nnop", \ ...@@ -68,13 +68,7 @@ asm(ALTERNATIVE_2("li %0, 0\t\nnop", \
*/ */
#define ALT_THEAD_PMA(_val) \ #define ALT_THEAD_PMA(_val) \
asm volatile(ALTERNATIVE( \ asm volatile(ALTERNATIVE( \
"nop\n\t" \ __nops(7), \
"nop\n\t" \
"nop\n\t" \
"nop\n\t" \
"nop\n\t" \
"nop\n\t" \
"nop", \
"li t3, %2\n\t" \ "li t3, %2\n\t" \
"slli t3, t3, %4\n\t" \ "slli t3, t3, %4\n\t" \
"and t3, %0, t3\n\t" \ "and t3, %0, t3\n\t" \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment