summaryrefslogtreecommitdiff
path: root/arch/riscv/include/asm/asm.h
diff options
context:
space:
mode:
authorHeiko Stuebner <heiko@sntech.de>2022-06-07 16:30:58 +0200
committerPalmer Dabbelt <palmer@rivosinc.com>2022-07-21 17:17:29 -0700
commitc295bc34ab58e917e2f2f789dd82b66fd2e2e299 (patch)
tree010b56d7116e13d42a6fc622e072167adec493c6 /arch/riscv/include/asm/asm.h
parentf2906aa863381afb0015a9eb7fefad885d4e5a56 (diff)
downloadlwn-c295bc34ab58e917e2f2f789dd82b66fd2e2e299.tar.gz
lwn-c295bc34ab58e917e2f2f789dd82b66fd2e2e299.zip
riscv: introduce nops and __nops macros for NOP sequences
NOP sequences tend to get used for padding out alternative sections This change adds macros for generating these sequences as both inline asm blocks, but also as strings suitable for embedding in other asm blocks directly. It essentially mimics similar functionality from arm64 introduced by Wil Deacon in commit f99a250cb6a3 ("arm64: barriers: introduce nops and __nops macros for NOP sequences"). Signed-off-by: Heiko Stuebner <heiko@sntech.de> Link: https://lore.kernel.org/r/20220607143059.1054074-2-heiko@sntech.de Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
Diffstat (limited to 'arch/riscv/include/asm/asm.h')
-rw-r--r--arch/riscv/include/asm/asm.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/arch/riscv/include/asm/asm.h b/arch/riscv/include/asm/asm.h
index 618d7c5af1a2..1b471ff73178 100644
--- a/arch/riscv/include/asm/asm.h
+++ b/arch/riscv/include/asm/asm.h
@@ -67,4 +67,19 @@
#error "Unexpected __SIZEOF_SHORT__"
#endif
+#ifdef __ASSEMBLY__
+
+/* Common assembly source macros */
+
+/*
+ * NOP sequence
+ */
+.macro nops, num
+ .rept \num
+ nop
+ .endr
+.endm
+
+#endif /* __ASSEMBLY__ */
+
#endif /* _ASM_RISCV_ASM_H */