Skip to contentSkip to conversation

s390x: io: declare s390x CPU as big endian

PATCH In review Pierre Morel 3 participants 3 messages Nov 11, 2021 – Nov 12, 2021 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 s390x: io: declare s390x CPU as big endian

To use the swap byte transformations we need to declare the s390x architecture as big endian.

---
 lib/s390x/asm/io.h | 1 +
 1 file changed, 1 insertion(+)
lib/s390x/asm/io.h +1 -0
index 1dc6283b..b5e661cf 100644
@@ -10,6 +10,7 @@
 #define _ASMS390X_IO_H_
 
 #define __iomem
+#define __cpu_is_be() (1)
 
 #include <asm-generic/io.h>
 
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 14 lines · Pierre Morel

To use the swap byte transformations we need to declare the s390x architecture as big endian.

---
  lib/s390x/asm/io.h | 1 +
  1 file changed, 1 insertion(+)
lib/s390x/asm/io.h +0 -0
index 1dc6283b..b5e661cf 100644

lib/s390x/asm/io.h line 16

Quoted 7 lines
lib/s390x/asm/io.h +1 -0
@@ -10,6 +10,7 @@
  #define _ASMS390X_IO_H_
 
  #define __iomem
+#define __cpu_is_be() (1)
 
  #include <asm-generic/io.h>
 

Alternatively, I think you could also move this sequence from lib/ppc64/asm/io.h into lib/asm-generic/io.h:

#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
#define __cpu_is_be() (0)
#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
#define __cpu_is_be() (1)
#else
#error Undefined byte order
#endif

(replacing the hardcoded __cpu_is_be() in the generic code).

Thomas

#2 lore raw
Quoted 36 lines · On Fri, 12 Nov 2021 08:38:38 +0100 Thomas Huth <[email protected]> wrote:
Quoted 14 lines · Pierre Morel

To use the swap byte transformations we need to declare the s390x architecture as big endian.

---
  lib/s390x/asm/io.h | 1 +
  1 file changed, 1 insertion(+)
lib/s390x/asm/io.h +0 -0
index 1dc6283b..b5e661cf 100644

lib/s390x/asm/io.h line 16

Quoted 7 lines
lib/s390x/asm/io.h +1 -0
@@ -10,6 +10,7 @@
  #define _ASMS390X_IO_H_
 
  #define __iomem
+#define __cpu_is_be() (1)
 
  #include <asm-generic/io.h>
 

Alternatively, I think you could also move this sequence from lib/ppc64/asm/io.h into lib/asm-generic/io.h:

#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
#define __cpu_is_be() (0)
#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
#define __cpu_is_be() (1)
#else
#error Undefined byte order
#endif

Quoted 3 lines

(replacing the hardcoded __cpu_is_be() in the generic code).

Thomas

I think this looks cleaner