Skip to contentSkip to conversation

libibverbs: add ARM64 memory barrier macros

PATCH In review Steve Wise 3 participants 6 messages May 18, 2016 – May 20, 2016 3 messages not in the archive InfiniBand

lore
Share & tools
lore

Steve Wise

author
#0 lore raw

PATCH 1/1 libibverbs: add ARM64 memory barrier macros

The default generic barriers are not correct for ARM64. This results in data corruption. The correct macros are lifted from the linux kernel.

---

Changes since RFC:

no change to the patch - just productive discussion about these barrier implementations. I propose we proceed to add this patch since it resolves a data corruption bug.

---
 include/infiniband/arch.h |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
include/infiniband/arch.h +9 -0
index bc1738a..71f02f8 100644
@@ -122,6 +122,15 @@ static inline uint64_t ntohll(uint64_t x) { return x; }
 #define wmb()	mb()					/* for s390x */
 #define wc_wmb() wmb()					/* for s390x */
 
+#elif defined(__aarch64__)
+
+#define dsb(opt)	asm volatile("dsb " #opt : : : "memory")
+
+#define mb()	dsb(sy)
+#define rmb()	dsb(ld)
+#define wmb()	dsb(st)
+#define wc_wmb() wmb()
+
 #else
 
 #warning No architecture specific defines found.  Using generic implementation.
Signature · 6 lines
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 20160520163207.B99DCE0B9D-/[email protected]

#2 lore raw
Quoted 1 line

The default generic barriers are not correct for ARM64. This results in data corruption. The correct macros are lifted from the linux kernel.

Does this mean that the code you want to add to libibverbs will be tainted with GPL since they come from the Linux kernel. I know that there are a lot of people that will not use a GPL library, since it could taint their applications with GPL if they link to that library. I thought that is why LGPL was invented to prevent such tainting.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 9C6B67F36DCAFC479B1CF6A967258A8C7DDBB201-8oqHQFITsIFqS6EAlXoojrfspsVTdybXVpNB7YpNyf8@public.gmane.org

author
#4 lore raw
Quoted 4 lines
Quoted 1 line

The default generic barriers are not correct for ARM64. This results in data

corruption. The correct macros are lifted from the linux kernel.

Does this mean that the code you want to add to libibverbs will be tainted

with GPL

Quoted 1 line

since they come from the Linux kernel.

I guess so.

Quoted 1 line

I know that there are a lot of people that will not use a GPL library, since

it could

Quoted 2 lines

taint their applications with GPL if they
link to that library. I thought that is why LGPL was invented to prevent such

tainting.

I could utilize the code from FreeBSD. Does that allow me to submit this to libibverbs under the dual GPL/BSD license?

/*
* Options for DMB and DSB:

 *      oshld   Outer Shareable, load
 *      oshst   Outer Shareable, store
 *      osh     Outer Shareable, all
 *      nshld   Non-shareable, load
 *      nshst   Non-shareable, store
 *      nsh     Non-shareable, all
 *      ishld   Inner Shareable, load
 *      ishst   Inner Shareable, store
 *      ish     Inner Shareable, all
 *      ld      Full system, load
 *      st      Full system, store
 *      sy      Full system, all

*/
#define dsb(opt) __asm __volatile("dsb " __STRING(opt) : : : "memory")
#define dmb(opt) __asm __volatile("dmb " __STRING(opt) : : : "memory")

#define mb()    dmb(sy) /* Full system memory barrier all */
#define wmb()   dmb(st) /* Full system memory barrier store */
#define rmb()   dmb(ld) /* Full system memory barrier load */

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

author
#5 lore raw
Quoted 10 lines
Quoted 1 line

Does this mean that the code you want to add to libibverbs will be tainted

with GPL

Quoted 1 line

since they come from the Linux kernel.

I guess so.

Quoted 1 line

I know that there are a lot of people that will not use a GPL library, since

it could

Quoted 2 lines

taint their applications with GPL if they
link to that library. I thought that is why LGPL was invented to prevent

such

Quoted 5 lines

tainting.

I could utilize the code from FreeBSD. Does that allow me to submit this to libibverbs under the dual GPL/BSD license?

I think I can just re-implement these services myself based published works describing the memory barrier assembly for ARM (like the document Jason referenced earlier). That will avoid any tainting.

Doug: Will that work?

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#6 lore raw
Quoted 17 lines · Steve Wise
Quoted 10 lines
Quoted 1 line

Does this mean that the code you want to add to libibverbs will be tainted

with GPL

Quoted 1 line

since they come from the Linux kernel.

I guess so.

Quoted 1 line

I know that there are a lot of people that will not use a GPL library, since

it could

Quoted 2 lines

taint their applications with GPL if they
link to that library. I thought that is why LGPL was invented to prevent

such

Quoted 5 lines

tainting.

I could utilize the code from FreeBSD. Does that allow me to submit this to libibverbs under the dual GPL/BSD license?

Quoted 5 lines

I think I can just re-implement these services myself based published works describing the memory barrier assembly for ARM (like the document Jason referenced earlier). That will avoid any tainting.

Doug: Will that work?

Either way works actually. IANAL, but I've been told this multiple times and will relay my possibly flawed memory of the legal issue. The original patch, even though lifted from the linux kernel, is likely to fall under the scope of "operationally defined" code. In other words, the specific patch you wrote and the thing it implemented is so rigidly defined by what it does, that there really is little to no room for any different expression of the code. When there is no room for different expressions, the code is not copyrightable.

Signature · 2 lines
Doug Ledford <[email protected]>
              GPG KeyID: 0E572FDD

A message that is not in the archive (sent off-list or not yet received): 2dc25c9c-748c-098c-f7a1-5d6e59504308-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

author
#8 lore raw
Quoted 1 line
Quoted 1 line
Quoted 1 line

I could utilize the code from FreeBSD. Does that allow me to submit this

to

Quoted 9 lines
Quoted 8 lines
Quoted 2 lines

libibverbs under the dual GPL/BSD license?

I think I can just re-implement these services myself based published works describing the memory barrier assembly for ARM (like the document Jason referenced earlier). That will avoid any tainting.

Doug: Will that work?

Quoted 9 lines

Either way works actually. IANAL, but I've been told this multiple times and will relay my possibly flawed memory of the legal issue. The original patch, even though lifted from the linux kernel, is likely to fall under the scope of "operationally defined" code. In other words, the specific patch you wrote and the thing it implemented is so rigidly defined by what it does, that there really is little to no room for any different expression of the code. When there is no room for different expressions, the code is not copyrightable.

That makes too much sense... ;)

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html