libibverbs: add ARM64 memory barrier macros

The default generic barriers are not correct for ARM64. This results
in data corruption.  The correct macros are based on the ARM Compiler
Toolchain Assembler Reference documenation.

Signed-off-by: Steve Wise <swise@opengridcomputing.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
diff --git a/include/infiniband/arch.h b/include/infiniband/arch.h
index bc1738a..c31dd0a 100644
--- a/include/infiniband/arch.h
+++ b/include/infiniband/arch.h
@@ -122,6 +122,14 @@
 #define wmb()	mb()					/* for s390x */
 #define wc_wmb() wmb()					/* for s390x */
 
+#elif defined(__aarch64__)
+
+/* Perhaps dmb would be sufficient? Let us be conservative for now. */
+#define mb()	{ asm volatile("dsb sy" ::: "memory"); }
+#define rmb()	{ asm volatile("dsb ld" ::: "memory"); }
+#define wmb()	{ asm volatile("dsb st" ::: "memory"); }
+#define wc_wmb() wmb()
+
 #else
 
 #warning No architecture specific defines found.  Using generic implementation.