Unverified Commit c295bc34 authored by Heiko Stuebner's avatar Heiko Stuebner Committed by Palmer Dabbelt
Browse files

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 f99a250c ("arm64: barriers: introduce nops
and __nops macros for NOP sequences").

Signed-off-by: default avatarHeiko Stuebner <heiko@sntech.de>
Link: https://lore.kernel.org/r/20220607143059.1054074-2-heiko@sntech.de


Signed-off-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
parent f2906aa8
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -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 */
+2 −0
Original line number Diff line number Diff line
@@ -13,6 +13,8 @@
#ifndef __ASSEMBLY__

#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) \
	__asm__ __volatile__ ("fence " #p "," #s : : : "memory")