UPSTREAM: arm64: barriers: introduce nops and __nops macros for NOP sequences
authorWill Deacon <will.deacon@arm.com>
Tue, 6 Sep 2016 15:40:23 +0000 (16:40 +0100)
committerAmit Pundir <amit.pundir@linaro.org>
Mon, 16 Jan 2017 09:12:43 +0000 (14:42 +0530)
NOP sequences tend to get used for padding out alternative sections
and uarch-specific pipeline flushes in errata workarounds.

This patch adds macros for generating these sequences as both inline
asm blocks, but also as strings suitable for embedding in other asm
blocks directly.

Signed-off-by: Will Deacon <will.deacon@arm.com>
Bug: 31432001
Change-Id: I7f82b677a065ede302a763d39ffcc3fef83f8fbe
(cherry picked from commit f99a250cb6a3b301b101b4c0f5fcb80593bba6dc)
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
arch/arm64/include/asm/assembler.h
arch/arm64/include/asm/barrier.h

index 9e8ac1e73457f4ec8e92deacec7bb48f14e91331..bacc75b6c78cc2d449487f9a9bf3f23f1317d638 100644 (file)
        dmb     \opt
        .endm
 
+/*
+ * NOP sequence
+ */
+       .macro  nops, num
+       .rept   \num
+       nop
+       .endr
+       .endm
+
 /*
  * Emit an entry into the exception table
  */
index 9622eb48f894db3fdb06db5441339babc2a1fdeb..c5dbc5cb8f10a14a03096004743656532f7d686e 100644 (file)
@@ -20,6 +20,9 @@
 
 #ifndef __ASSEMBLY__
 
+#define __nops(n)      ".rept  " #n "\nnop\n.endr\n"
+#define nops(n)                asm volatile(__nops(n))
+
 #define sev()          asm volatile("sev" : : : "memory")
 #define wfe()          asm volatile("wfe" : : : "memory")
 #define wfi()          asm volatile("wfi" : : : "memory")