All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v5 00/16] xen: Centralise byteswap infrastructure
@ 2025-03-28 13:44 Andrew Cooper
  2025-03-28 13:44 ` [PATCH v5 01/16] xen/lzo: Remove more remanants of TMEM Andrew Cooper
                   ` (15 more replies)
  0 siblings, 16 replies; 30+ messages in thread
From: Andrew Cooper @ 2025-03-28 13:44 UTC (permalink / raw)
  To: Xen-devel
  Cc: Andrew Cooper, Anthony PERARD, Michal Orzel, Jan Beulich,
	Julien Grall, Roger Pau Monné, Stefano Stabellini,
	Volodymyr Babchuk, Bertrand Marquis, Shawn Anastasio,
	Oleksii Kurochko, Daniel P . Smith, Lin Liu

The diffstat speaks for itself.

This is a follow-up to Lin's years-old series, rebased to account for RISC-V
and PPC, and simplified owing to our new compiler baseline.

Andrew Cooper (8):
  xen/lzo: Remove more remanants of TMEM
  xen: Remove __{BIG,LITTLE}_ENDIAN_BITFIELD
  xsm/flask: Switch {asm -> xen}/byteorder.h
  xen/common: Switch {asm -> xen}/byteorder.h
  arm: Remove asm/byteorder.h
  ppc: Drop asm/byteorder.h
  riscv: Remove asm/byteorder.h
  x86: Drop asm/byteorder.h

Lin Liu (8):
  xen: Implement common byte{order,swap}.h
  xen/lib: Switch to xen/byteorder.h
  xen/device-tree: Remove use of *_to_cpup() helpers
  xen/decompressors: Remove use of *_to_cpup() helpers
  xen/arch: Switch to new byteorder infrastructure
  xen/decompressors: Use new byteorder infrastructure
  xen: Remove old byteorder infrastructure
  crypto/vmac: Switch to xen/byteswap.h

 .../libs/guest/xg_dom_decompress_unsafe_xz.c  |  13 +-
 .../guest/xg_dom_decompress_unsafe_zstd.c     |   3 +-
 xen/arch/arm/alternative.c                    |   6 +-
 xen/arch/arm/arm64/livepatch.c                |   2 +-
 xen/arch/arm/include/asm/arm32/io.h           |   3 +-
 xen/arch/arm/include/asm/arm64/io.h           |   3 +-
 xen/arch/arm/include/asm/byteorder.h          |  16 --
 xen/arch/arm/kernel.c                         |   2 +-
 xen/arch/arm/vgic/vgic-mmio.c                 |   3 +-
 xen/arch/ppc/include/asm/byteorder.h          |  12 --
 xen/arch/ppc/include/asm/page.h               |   4 +-
 xen/arch/ppc/mm-radix.c                       |   2 +-
 xen/arch/riscv/include/asm/byteorder.h        |  16 --
 xen/arch/riscv/include/asm/io.h               |   3 +-
 xen/arch/x86/include/asm/byteorder.h          |  29 ---
 xen/arch/x86/include/asm/msi.h                |   1 -
 xen/common/bitmap.c                           |   5 +-
 xen/common/device-tree/device-tree.c          |  44 ++---
 xen/common/grant_table.c                      |   4 +-
 xen/common/libelf/libelf-private.h            |   9 +-
 xen/common/lz4/defs.h                         |   7 +-
 xen/common/lzo.c                              |  22 ---
 xen/common/unlzo.c                            |   1 -
 xen/common/xz/private.h                       |  13 +-
 xen/crypto/vmac.c                             |  76 +-------
 xen/drivers/char/ehci-dbgp.c                  |   4 +-
 xen/include/xen/bitmap.h                      |   2 +-
 xen/include/xen/byteorder.h                   |  44 +++++
 xen/include/xen/byteorder/big_endian.h        | 102 ----------
 xen/include/xen/byteorder/generic.h           |  68 -------
 xen/include/xen/byteorder/little_endian.h     | 102 ----------
 xen/include/xen/byteorder/swab.h              | 179 ------------------
 xen/include/xen/byteswap.h                    |  15 ++
 xen/include/xen/config.h                      |   6 +
 xen/include/xen/device_tree.h                 |   3 +-
 xen/include/xen/libfdt/libfdt_env.h           |   3 +-
 xen/include/xen/unaligned.h                   |   3 +-
 xen/lib/divmod.c                              |   5 +-
 xen/lib/find-next-bit.c                       |  39 +---
 xen/xsm/flask/ss/avtab.c                      |   4 +-
 xen/xsm/flask/ss/conditional.c                |   9 +-
 xen/xsm/flask/ss/ebitmap.c                    |   9 +-
 xen/xsm/flask/ss/policydb.c                   |   7 +-
 43 files changed, 166 insertions(+), 737 deletions(-)
 delete mode 100644 xen/arch/arm/include/asm/byteorder.h
 delete mode 100644 xen/arch/ppc/include/asm/byteorder.h
 delete mode 100644 xen/arch/riscv/include/asm/byteorder.h
 delete mode 100644 xen/arch/x86/include/asm/byteorder.h
 create mode 100644 xen/include/xen/byteorder.h
 delete mode 100644 xen/include/xen/byteorder/big_endian.h
 delete mode 100644 xen/include/xen/byteorder/generic.h
 delete mode 100644 xen/include/xen/byteorder/little_endian.h
 delete mode 100644 xen/include/xen/byteorder/swab.h
 create mode 100644 xen/include/xen/byteswap.h


base-commit: eecb9f437b2c3e2d22d0af93dc6b1f4d978313a7
-- 
2.39.5



^ permalink raw reply	[flat|nested] 30+ messages in thread

* [PATCH v5 01/16] xen/lzo: Remove more remanants of TMEM
  2025-03-28 13:44 [PATCH v5 00/16] xen: Centralise byteswap infrastructure Andrew Cooper
@ 2025-03-28 13:44 ` Andrew Cooper
  2025-03-31  7:30   ` Jan Beulich
  2025-03-28 13:44 ` [PATCH v5 02/16] xen: Remove __{BIG,LITTLE}_ENDIAN_BITFIELD Andrew Cooper
                   ` (14 subsequent siblings)
  15 siblings, 1 reply; 30+ messages in thread
From: Andrew Cooper @ 2025-03-28 13:44 UTC (permalink / raw)
  To: Xen-devel
  Cc: Andrew Cooper, Anthony PERARD, Michal Orzel, Jan Beulich,
	Julien Grall, Roger Pau Monné, Stefano Stabellini,
	Volodymyr Babchuk, Bertrand Marquis, Shawn Anastasio,
	Oleksii Kurochko, Daniel P . Smith, Lin Liu

This logic was inserted by commit 447f613c5404 ("lzo: update LZO compression
to current upstream version") but was only relevant for the TMEM logic, so
should have been deleted in commit c492e19fdd05 ("xen: remove tmem from
hypervisor")

Fixes: c492e19fdd05 ("xen: remove tmem from hypervisor")
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Anthony PERARD <anthony.perard@vates.tech>
CC: Michal Orzel <michal.orzel@amd.com>
CC: Jan Beulich <jbeulich@suse.com>
CC: Julien Grall <julien@xen.org>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
CC: Bertrand Marquis <bertrand.marquis@arm.com>
CC: Shawn Anastasio <sanastasio@raptorengineering.com>
CC: Oleksii Kurochko <oleksii.kurochko@gmail.com>
CC: Daniel P. Smith <dpsmith@apertussolutions.com>
CC: Lin Liu <lin.liu@citrix.com>

Notably, this also removes the singular case where anything in Xen cares about
the value in __BYTE_ORDER, __LITTLE_ENDIAN and __BIG_ENDIAN, and even then it
was only an adaptation to the MiniOS environment.

v5:
 * New.
---
 xen/common/lzo.c | 21 ---------------------
 1 file changed, 21 deletions(-)

diff --git a/xen/common/lzo.c b/xen/common/lzo.c
index 3454ce4a7e24..07b4017812dc 100644
--- a/xen/common/lzo.c
+++ b/xen/common/lzo.c
@@ -28,27 +28,6 @@
 #define COPY4(dst, src) memcpy(dst, src, 4)
 #define COPY8(dst, src) memcpy(dst, src, 8)
 
-#ifdef __MINIOS__
-# include <lib.h>
-# if __BYTE_ORDER == __LITTLE_ENDIAN
-#  undef __BIG_ENDIAN
-# endif
-# if __BYTE_ORDER == __BIG_ENDIAN
-#  undef __LITTLE_ENDIAN
-# endif
-#endif
-
-#if defined(__BIG_ENDIAN) && defined(__LITTLE_ENDIAN)
-#error "conflicting endian definitions"
-#elif defined(__x86_64__)
-#define LZO_USE_CTZ64    1
-#define LZO_USE_CTZ32    1
-#elif defined(__i386__) || defined(__powerpc__)
-#define LZO_USE_CTZ32    1
-#elif defined(__arm__) && (__LINUX_ARM_ARCH__ >= 5)
-#define LZO_USE_CTZ32    1
-#endif
-
 #define M1_MAX_OFFSET 0x0400
 #define M2_MAX_OFFSET 0x0800
 #define M3_MAX_OFFSET 0x4000

base-commit: eecb9f437b2c3e2d22d0af93dc6b1f4d978313a7
-- 
2.39.5



^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH v5 02/16] xen: Remove __{BIG,LITTLE}_ENDIAN_BITFIELD
  2025-03-28 13:44 [PATCH v5 00/16] xen: Centralise byteswap infrastructure Andrew Cooper
  2025-03-28 13:44 ` [PATCH v5 01/16] xen/lzo: Remove more remanants of TMEM Andrew Cooper
@ 2025-03-28 13:44 ` Andrew Cooper
  2025-03-31  7:42   ` Jan Beulich
  2025-03-28 13:44 ` [PATCH v5 03/16] xen: Implement common byte{order,swap}.h Andrew Cooper
                   ` (13 subsequent siblings)
  15 siblings, 1 reply; 30+ messages in thread
From: Andrew Cooper @ 2025-03-28 13:44 UTC (permalink / raw)
  To: Xen-devel
  Cc: Andrew Cooper, Anthony PERARD, Michal Orzel, Jan Beulich,
	Julien Grall, Roger Pau Monné, Stefano Stabellini,
	Volodymyr Babchuk, Bertrand Marquis, Shawn Anastasio,
	Oleksii Kurochko, Daniel P . Smith, Lin Liu

There is a singular user.  It's unlikely we'll gain a big-endian build of Xen,
but it's far more unlikely that bitfields will differ from main endianness.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Anthony PERARD <anthony.perard@vates.tech>
CC: Michal Orzel <michal.orzel@amd.com>
CC: Jan Beulich <jbeulich@suse.com>
CC: Julien Grall <julien@xen.org>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
CC: Bertrand Marquis <bertrand.marquis@arm.com>
CC: Shawn Anastasio <sanastasio@raptorengineering.com>
CC: Oleksii Kurochko <oleksii.kurochko@gmail.com>
CC: Daniel P. Smith <dpsmith@apertussolutions.com>
CC: Lin Liu <lin.liu@citrix.com>

I'm tempted to simply drop the logic in maptrack_node.  If any big-endian
build of Xen came along, that's probably the least of it's worries.

v5:
 * New.
---
 xen/common/grant_table.c                  | 4 ++--
 xen/include/xen/byteorder/big_endian.h    | 3 ---
 xen/include/xen/byteorder/little_endian.h | 3 ---
 3 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/xen/common/grant_table.c b/xen/common/grant_table.c
index 6c77867f8cdd..d6886ee74847 100644
--- a/xen/common/grant_table.c
+++ b/xen/common/grant_table.c
@@ -979,12 +979,12 @@ static struct active_grant_entry *grant_map_exists(const struct domain *ld,
 union maptrack_node {
     struct {
         /* Radix tree slot pointers use two of the bits. */
-#ifdef __BIG_ENDIAN_BITFIELD
+#ifdef __BIG_ENDIAN
         unsigned long _0 : 2;
 #endif
         unsigned long rd : BITS_PER_LONG / 2 - 1;
         unsigned long wr : BITS_PER_LONG / 2 - 1;
-#ifndef __BIG_ENDIAN_BITFIELD
+#ifndef __BIG_ENDIAN
         unsigned long _0 : 2;
 #endif
     } cnt;
diff --git a/xen/include/xen/byteorder/big_endian.h b/xen/include/xen/byteorder/big_endian.h
index ce395a17f64b..9cfb567d51d5 100644
--- a/xen/include/xen/byteorder/big_endian.h
+++ b/xen/include/xen/byteorder/big_endian.h
@@ -4,9 +4,6 @@
 #ifndef __BIG_ENDIAN
 #define __BIG_ENDIAN 4321
 #endif
-#ifndef __BIG_ENDIAN_BITFIELD
-#define __BIG_ENDIAN_BITFIELD
-#endif
 
 #include <xen/types.h>
 #include <xen/byteorder/swab.h>
diff --git a/xen/include/xen/byteorder/little_endian.h b/xen/include/xen/byteorder/little_endian.h
index 8b118afba5e3..96c80eab2b12 100644
--- a/xen/include/xen/byteorder/little_endian.h
+++ b/xen/include/xen/byteorder/little_endian.h
@@ -4,9 +4,6 @@
 #ifndef __LITTLE_ENDIAN
 #define __LITTLE_ENDIAN 1234
 #endif
-#ifndef __LITTLE_ENDIAN_BITFIELD
-#define __LITTLE_ENDIAN_BITFIELD
-#endif
 
 #include <xen/types.h>
 #include <xen/byteorder/swab.h>
-- 
2.39.5



^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH v5 03/16] xen: Implement common byte{order,swap}.h
  2025-03-28 13:44 [PATCH v5 00/16] xen: Centralise byteswap infrastructure Andrew Cooper
  2025-03-28 13:44 ` [PATCH v5 01/16] xen/lzo: Remove more remanants of TMEM Andrew Cooper
  2025-03-28 13:44 ` [PATCH v5 02/16] xen: Remove __{BIG,LITTLE}_ENDIAN_BITFIELD Andrew Cooper
@ 2025-03-28 13:44 ` Andrew Cooper
  2025-03-31  8:32   ` Jan Beulich
  2025-03-28 13:44 ` [PATCH v5 04/16] xen/lib: Switch to xen/byteorder.h Andrew Cooper
                   ` (12 subsequent siblings)
  15 siblings, 1 reply; 30+ messages in thread
From: Andrew Cooper @ 2025-03-28 13:44 UTC (permalink / raw)
  To: Xen-devel
  Cc: Lin Liu, Andrew Cooper, Anthony PERARD, Michal Orzel, Jan Beulich,
	Julien Grall, Roger Pau Monné, Stefano Stabellini,
	Volodymyr Babchuk, Bertrand Marquis, Shawn Anastasio,
	Oleksii Kurochko, Daniel P . Smith

From: Lin Liu <lin.liu@citrix.com>

The current swab??() infrastructure is unecesserily complicated, and can be
repated entirely with compiler builtins.

All supported compilers provide __BYTE_ORDER__ and __builtin_bswap??().

Nothing in Xen cares about the values of __{BIG,LITTLE}_ENDIAN; just that one
of them is defined.  Therefore, centralise their definitions in xen/config.h

Signed-off-by: Lin Liu <lin.liu@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Anthony PERARD <anthony.perard@vates.tech>
CC: Michal Orzel <michal.orzel@amd.com>
CC: Jan Beulich <jbeulich@suse.com>
CC: Julien Grall <julien@xen.org>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
CC: Bertrand Marquis <bertrand.marquis@arm.com>
CC: Shawn Anastasio <sanastasio@raptorengineering.com>
CC: Oleksii Kurochko <oleksii.kurochko@gmail.com>
CC: Daniel P. Smith <dpsmith@apertussolutions.com>
CC: Lin Liu <lin.liu@citrix.com>

v5:
 * Rebase substantially
 * Drop PASTE().  It doesn't work when BITS_PER_LONG isn't a plain integer
 * Simplify in light of new toolchain baseline
---
 xen/include/xen/byteorder.h               | 44 +++++++++++++++++++++++
 xen/include/xen/byteorder/big_endian.h    |  4 ---
 xen/include/xen/byteorder/little_endian.h |  4 ---
 xen/include/xen/byteswap.h                | 15 ++++++++
 xen/include/xen/config.h                  |  6 ++++
 5 files changed, 65 insertions(+), 8 deletions(-)
 create mode 100644 xen/include/xen/byteorder.h
 create mode 100644 xen/include/xen/byteswap.h

diff --git a/xen/include/xen/byteorder.h b/xen/include/xen/byteorder.h
new file mode 100644
index 000000000000..570a7fe027e5
--- /dev/null
+++ b/xen/include/xen/byteorder.h
@@ -0,0 +1,44 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+#ifndef XEN_BYTEORDER_H
+#define XEN_BYTEORDER_H
+
+#include <xen/byteswap.h>
+#include <xen/types.h>
+
+#if defined(__LITTLE_ENDIAN)
+
+# define cpu_to_le64(x) (uint64_t)(x)
+# define le64_to_cpu(x) (uint64_t)(x)
+# define cpu_to_le32(x) (uint32_t)(x)
+# define le32_to_cpu(x) (uint32_t)(x)
+# define cpu_to_le16(x) (uint16_t)(x)
+# define le16_to_cpu(x) (uint16_t)(x)
+
+# define cpu_to_be64(x) bswap64(x)
+# define be64_to_cpu(x) bswap64(x)
+# define cpu_to_be32(x) bswap32(x)
+# define be32_to_cpu(x) bswap32(x)
+# define cpu_to_be16(x) bswap16(x)
+# define be16_to_cpu(x) bswap16(x)
+
+#elif defined(__BIG_ENDIAN)
+
+# define cpu_to_le64(x) bswap64(x)
+# define le64_to_cpu(x) bswap64(x)
+# define cpu_to_le32(x) bswap32(x)
+# define le32_to_cpu(x) bswap32(x)
+# define cpu_to_le16(x) bswap16(x)
+# define le16_to_cpu(x) bswap16(x)
+
+# define cpu_to_be64(x) (uint64_t)(x)
+# define be64_to_cpu(x) (uint64_t)(x)
+# define cpu_to_be32(x) (uint32_t)(x)
+# define be32_to_cpu(x) (uint32_t)(x)
+# define cpu_to_be16(x) (uint16_t)(x)
+# define be16_to_cpu(x) (uint16_t)(x)
+
+#else
+# error Unknown Endianness
+#endif /* __*_ENDIAN */
+
+#endif /* XEN_BYTEORDER_H */
diff --git a/xen/include/xen/byteorder/big_endian.h b/xen/include/xen/byteorder/big_endian.h
index 9cfb567d51d5..512291c76f1b 100644
--- a/xen/include/xen/byteorder/big_endian.h
+++ b/xen/include/xen/byteorder/big_endian.h
@@ -1,10 +1,6 @@
 #ifndef __XEN_BYTEORDER_BIG_ENDIAN_H__
 #define __XEN_BYTEORDER_BIG_ENDIAN_H__
 
-#ifndef __BIG_ENDIAN
-#define __BIG_ENDIAN 4321
-#endif
-
 #include <xen/types.h>
 #include <xen/byteorder/swab.h>
 
diff --git a/xen/include/xen/byteorder/little_endian.h b/xen/include/xen/byteorder/little_endian.h
index 96c80eab2b12..bd1afc6a67c3 100644
--- a/xen/include/xen/byteorder/little_endian.h
+++ b/xen/include/xen/byteorder/little_endian.h
@@ -1,10 +1,6 @@
 #ifndef __XEN_BYTEORDER_LITTLE_ENDIAN_H__
 #define __XEN_BYTEORDER_LITTLE_ENDIAN_H__
 
-#ifndef __LITTLE_ENDIAN
-#define __LITTLE_ENDIAN 1234
-#endif
-
 #include <xen/types.h>
 #include <xen/byteorder/swab.h>
 
diff --git a/xen/include/xen/byteswap.h b/xen/include/xen/byteswap.h
new file mode 100644
index 000000000000..46d93f88eac9
--- /dev/null
+++ b/xen/include/xen/byteswap.h
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+#ifndef XEN_BYTESWAP_H
+#define XEN_BYTESWAP_H
+
+#define bswap16(x) __builtin_bswap16(x)
+#define bswap32(x) __builtin_bswap32(x)
+#define bswap64(x) __builtin_bswap64(x)
+
+#if BITS_PER_LONG == 64
+# define bswapl(x) bswap64(x)
+#elif BITS_PER_LONG == 32
+# define bswapl(x) bswap32(x)
+#endif
+
+#endif /* XEN_BYTESWAP_H */
diff --git a/xen/include/xen/config.h b/xen/include/xen/config.h
index d888b2314daf..6815a0ef0c1a 100644
--- a/xen/include/xen/config.h
+++ b/xen/include/xen/config.h
@@ -98,4 +98,10 @@
 #define ZERO_BLOCK_PTR ((void *)-1L)
 #endif
 
+#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+# define __LITTLE_ENDIAN
+#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+# define __BIG_ENDIAN
+#endif
+
 #endif /* __XEN_CONFIG_H__ */
-- 
2.39.5



^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH v5 04/16] xen/lib: Switch to xen/byteorder.h
  2025-03-28 13:44 [PATCH v5 00/16] xen: Centralise byteswap infrastructure Andrew Cooper
                   ` (2 preceding siblings ...)
  2025-03-28 13:44 ` [PATCH v5 03/16] xen: Implement common byte{order,swap}.h Andrew Cooper
@ 2025-03-28 13:44 ` Andrew Cooper
  2025-03-31  8:44   ` Jan Beulich
  2025-03-28 13:44 ` [PATCH v5 05/16] xen/device-tree: Remove use of *_to_cpup() helpers Andrew Cooper
                   ` (11 subsequent siblings)
  15 siblings, 1 reply; 30+ messages in thread
From: Andrew Cooper @ 2025-03-28 13:44 UTC (permalink / raw)
  To: Xen-devel
  Cc: Lin Liu, Anthony PERARD, Michal Orzel, Jan Beulich, Julien Grall,
	Roger Pau Monné, Stefano Stabellini, Volodymyr Babchuk,
	Bertrand Marquis, Shawn Anastasio, Oleksii Kurochko,
	Daniel P . Smith

From: Lin Liu <lin.liu@citrix.com>

In divmod.c, additionally swap xen/lib.h for xen/macros.h as only ABS() is
needed.

In find-next-bit.c, ext2 has nothing to do with this logic.  Despite the
comments, it was a local modification when the logic was imported from Linux,
because Xen didn't have a suitable helper.

The new infrsatructure does have a suitable primitive, so use it.

No functional change.

Signed-off-by: Lin Liu <lin.liu@citrix.com>
---
CC: Anthony PERARD <anthony.perard@vates.tech>
CC: Michal Orzel <michal.orzel@amd.com>
CC: Jan Beulich <jbeulich@suse.com>
CC: Julien Grall <julien@xen.org>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
CC: Bertrand Marquis <bertrand.marquis@arm.com>
CC: Shawn Anastasio <sanastasio@raptorengineering.com>
CC: Oleksii Kurochko <oleksii.kurochko@gmail.com>
CC: Daniel P. Smith <dpsmith@apertussolutions.com>
CC: Lin Liu <lin.liu@citrix.com>

The find-next-bit.c changes, being inside __BIG_ENDIAN aren't even compiled in
any build of Xen.  I manually checked that they compiled.

v5:
 * Rebase
 * Include a fixto divmod.c
 * Explain why even Linux has never had anything by the name ext2_swab()
---
 xen/lib/divmod.c        |  5 ++---
 xen/lib/find-next-bit.c | 39 +++++++--------------------------------
 2 files changed, 9 insertions(+), 35 deletions(-)

diff --git a/xen/lib/divmod.c b/xen/lib/divmod.c
index 0377d62130ae..b5b111dacecc 100644
--- a/xen/lib/divmod.c
+++ b/xen/lib/divmod.c
@@ -1,6 +1,5 @@
-#include <xen/lib.h>
-#include <xen/types.h>
-#include <asm/byteorder.h>
+#include <xen/byteorder.h>
+#include <xen/macros.h>
 
 /*
  * A couple of 64 bit operations ported from FreeBSD.
diff --git a/xen/lib/find-next-bit.c b/xen/lib/find-next-bit.c
index 761b02739841..9b8d7814f20c 100644
--- a/xen/lib/find-next-bit.c
+++ b/xen/lib/find-next-bit.c
@@ -9,8 +9,7 @@
  * 2 of the License, or (at your option) any later version.
  */
 #include <xen/bitops.h>
-
-#include <asm/byteorder.h>
+#include <xen/byteorder.h>
 
 #define __ffs(x) (ffsl(x) - 1)
 #define ffz(x) __ffs(~(x))
@@ -164,30 +163,6 @@ EXPORT_SYMBOL(find_first_zero_bit);
 
 #ifdef __BIG_ENDIAN
 
-/* include/linux/byteorder does not support "unsigned long" type */
-static inline unsigned long ext2_swabp(const unsigned long * x)
-{
-#if BITS_PER_LONG == 64
-	return (unsigned long) __swab64p((u64 *) x);
-#elif BITS_PER_LONG == 32
-	return (unsigned long) __swab32p((u32 *) x);
-#else
-#error BITS_PER_LONG not defined
-#endif
-}
-
-/* include/linux/byteorder doesn't support "unsigned long" type */
-static inline unsigned long ext2_swab(const unsigned long y)
-{
-#if BITS_PER_LONG == 64
-	return (unsigned long) __swab64((u64) y);
-#elif BITS_PER_LONG == 32
-	return (unsigned long) __swab32((u32) y);
-#else
-#error BITS_PER_LONG not defined
-#endif
-}
-
 #ifndef find_next_zero_bit_le
 unsigned long find_next_zero_bit_le(const void *addr, unsigned
 		long size, unsigned long offset)
@@ -202,7 +177,7 @@ unsigned long find_next_zero_bit_le(const void *addr, unsigned
 	size -= result;
 	offset &= (BITS_PER_LONG - 1UL);
 	if (offset) {
-		tmp = ext2_swabp(p++);
+		tmp = bswapl(*p++);
 		tmp |= (~0UL >> (BITS_PER_LONG - offset));
 		if (size < BITS_PER_LONG)
 			goto found_first;
@@ -220,7 +195,7 @@ unsigned long find_next_zero_bit_le(const void *addr, unsigned
 	}
 	if (!size)
 		return result;
-	tmp = ext2_swabp(p);
+	tmp = bswapl(*p);
 found_first:
 	tmp |= ~0UL << size;
 	if (tmp == ~0UL)	/* Are any bits zero? */
@@ -229,7 +204,7 @@ unsigned long find_next_zero_bit_le(const void *addr, unsigned
 	return result + ffz(tmp);
 
 found_middle_swap:
-	return result + ffz(ext2_swab(tmp));
+	return result + ffz(bswapl(tmp));
 }
 EXPORT_SYMBOL(find_next_zero_bit_le);
 #endif
@@ -248,7 +223,7 @@ unsigned long find_next_bit_le(const void *addr, unsigned
 	size -= result;
 	offset &= (BITS_PER_LONG - 1UL);
 	if (offset) {
-		tmp = ext2_swabp(p++);
+		tmp = bswapl(*p++);
 		tmp &= (~0UL << offset);
 		if (size < BITS_PER_LONG)
 			goto found_first;
@@ -267,7 +242,7 @@ unsigned long find_next_bit_le(const void *addr, unsigned
 	}
 	if (!size)
 		return result;
-	tmp = ext2_swabp(p);
+	tmp = bswapl(*p);
 found_first:
 	tmp &= (~0UL >> (BITS_PER_LONG - size));
 	if (tmp == 0UL)		/* Are any bits set? */
@@ -276,7 +251,7 @@ unsigned long find_next_bit_le(const void *addr, unsigned
 	return result + __ffs(tmp);
 
 found_middle_swap:
-	return result + __ffs(ext2_swab(tmp));
+	return result + __ffs(bswapl(tmp));
 }
 EXPORT_SYMBOL(find_next_bit_le);
 #endif
-- 
2.39.5



^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH v5 05/16] xen/device-tree: Remove use of *_to_cpup() helpers
  2025-03-28 13:44 [PATCH v5 00/16] xen: Centralise byteswap infrastructure Andrew Cooper
                   ` (3 preceding siblings ...)
  2025-03-28 13:44 ` [PATCH v5 04/16] xen/lib: Switch to xen/byteorder.h Andrew Cooper
@ 2025-03-28 13:44 ` Andrew Cooper
  2025-03-28 13:44 ` [PATCH v5 06/16] xen/decompressors: " Andrew Cooper
                   ` (10 subsequent siblings)
  15 siblings, 0 replies; 30+ messages in thread
From: Andrew Cooper @ 2025-03-28 13:44 UTC (permalink / raw)
  To: Xen-devel
  Cc: Lin Liu, Andrew Cooper, Anthony PERARD, Michal Orzel, Jan Beulich,
	Julien Grall, Roger Pau Monné, Stefano Stabellini,
	Volodymyr Babchuk, Bertrand Marquis, Shawn Anastasio,
	Oleksii Kurochko, Daniel P . Smith

From: Lin Liu <lin.liu@citrix.com>

These wrappers simply hide a deference, which adds to the cognitive complexity
of reading the code.  As such, they're not going to be included in the new
byteswap infrastructure.

No functional change.

Signed-off-by: Lin Liu <lin.liu@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Anthony PERARD <anthony.perard@vates.tech>
CC: Michal Orzel <michal.orzel@amd.com>
CC: Jan Beulich <jbeulich@suse.com>
CC: Julien Grall <julien@xen.org>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
CC: Bertrand Marquis <bertrand.marquis@arm.com>
CC: Shawn Anastasio <sanastasio@raptorengineering.com>
CC: Oleksii Kurochko <oleksii.kurochko@gmail.com>
CC: Daniel P. Smith <dpsmith@apertussolutions.com>
CC: Lin Liu <lin.liu@citrix.com>

v5:
 * Rebase
 * Split out of later patch
---
 xen/common/device-tree/device-tree.c | 44 ++++++++++++++--------------
 1 file changed, 22 insertions(+), 22 deletions(-)

diff --git a/xen/common/device-tree/device-tree.c b/xen/common/device-tree/device-tree.c
index e8f810b2fe10..90fee2ba0315 100644
--- a/xen/common/device-tree/device-tree.c
+++ b/xen/common/device-tree/device-tree.c
@@ -173,7 +173,7 @@ bool dt_property_read_u32(const struct dt_device_node *np,
     if ( !val || len < sizeof(*out_value) )
         return 0;
 
-    *out_value = be32_to_cpup(val);
+    *out_value = be32_to_cpu(*val);
 
     return 1;
 }
@@ -266,7 +266,7 @@ int dt_property_read_variable_u32_array(const struct dt_device_node *np,
 
     count = sz;
     while ( count-- )
-        *out_values++ = be32_to_cpup(val++);
+        *out_values++ = be32_to_cpu(*val++);
 
     return sz;
 }
@@ -493,7 +493,7 @@ static int __dt_n_addr_cells(const struct dt_device_node *np, bool parent)
 
         ip = dt_get_property(np, "#address-cells", NULL);
         if ( ip )
-            return be32_to_cpup(ip);
+            return be32_to_cpu(*ip);
     } while ( np->parent );
     /* No #address-cells property for the root node */
     return DT_ROOT_NODE_ADDR_CELLS_DEFAULT;
@@ -510,7 +510,7 @@ static int __dt_n_size_cells(const struct dt_device_node *np, bool parent)
 
         ip = dt_get_property(np, "#size-cells", NULL);
         if ( ip )
-            return be32_to_cpup(ip);
+            return be32_to_cpu(*ip);
     } while ( np->parent );
     /* No #address-cells property for the root node */
     return DT_ROOT_NODE_SIZE_CELLS_DEFAULT;
@@ -643,7 +643,7 @@ static void dt_bus_pci_count_cells(const struct dt_device_node *np,
 static unsigned int dt_bus_pci_get_flags(const __be32 *addr)
 {
     unsigned int flags = 0;
-    u32 w = be32_to_cpup(addr);
+    u32 w = be32_to_cpu(*addr);
 
     switch((w >> 24) & 0x03) {
     case 0x01:
@@ -1096,7 +1096,7 @@ dt_irq_find_parent(const struct dt_device_node *child)
         if ( parp == NULL )
             p = dt_get_parent(child);
         else
-            p = dt_find_node_by_phandle(be32_to_cpup(parp));
+            p = dt_find_node_by_phandle(be32_to_cpu(*parp));
         child = p;
     } while ( p && dt_get_property(p, "#interrupt-cells", NULL) == NULL );
 
@@ -1129,7 +1129,7 @@ unsigned int dt_number_of_irq(const struct dt_device_node *device)
     intlen /= sizeof(*intspec);
 
     dt_dprintk(" using 'interrupts' property\n");
-    dt_dprintk(" intspec=%d intlen=%d\n", be32_to_cpup(intspec), intlen);
+    dt_dprintk(" intspec=%d intlen=%d\n", be32_to_cpu(*intspec), intlen);
 
     /* Look for the interrupt parent. */
     p = dt_irq_find_parent(device);
@@ -1260,7 +1260,7 @@ int dt_for_each_irq_map(const struct dt_device_node *dev,
         imaplen -= addrsize + intsize;
 
         /* Get the interrupt parent */
-        ipar = dt_find_node_by_phandle(be32_to_cpup(imap));
+        ipar = dt_find_node_by_phandle(be32_to_cpu(*imap));
         imap++;
         --imaplen;
 
@@ -1377,8 +1377,8 @@ static int dt_irq_map_raw(const struct dt_device_node *parent,
     int match, i;
 
     dt_dprintk("dt_irq_map_raw: par=%s,intspec=[0x%08x 0x%08x...],ointsize=%d\n",
-               parent->full_name, be32_to_cpup(intspec),
-               be32_to_cpup(intspec + 1), ointsize);
+               parent->full_name, be32_to_cpu(*intspec),
+               be32_to_cpu(*(intspec+1)), ointsize);
 
     ipar = parent;
 
@@ -1490,7 +1490,7 @@ static int dt_irq_map_raw(const struct dt_device_node *parent,
             dt_dprintk(" -> match=%d (imaplen=%d)\n", match, imaplen);
 
             /* Get the interrupt parent */
-            newpar = dt_find_node_by_phandle(be32_to_cpup(imap));
+            newpar = dt_find_node_by_phandle(be32_to_cpu(*imap));
             imap++;
             --imaplen;
 
@@ -1584,7 +1584,7 @@ int dt_device_get_raw_irq(const struct dt_device_node *device,
     intlen /= sizeof(*intspec);
 
     dt_dprintk(" using 'interrupts' property\n");
-    dt_dprintk(" intspec=%d intlen=%d\n", be32_to_cpup(intspec), intlen);
+    dt_dprintk(" intspec=%d intlen=%d\n", be32_to_cpu(*intspec), intlen);
 
     /* Look for the interrupt parent. */
     p = dt_irq_find_parent(device);
@@ -1695,7 +1695,7 @@ static int __dt_parse_phandle_with_args(const struct dt_device_node *np,
          * If phandle is 0, then it is an empty entry with no
          * arguments.  Skip forward to the next entry.
          * */
-        phandle = be32_to_cpup(list++);
+        phandle = be32_to_cpu(*list++);
         if ( phandle )
         {
             /*
@@ -1764,7 +1764,7 @@ static int __dt_parse_phandle_with_args(const struct dt_device_node *np,
                 out_args->np = node;
                 out_args->args_count = count;
                 for ( i = 0; i < count; i++ )
-                    out_args->args[i] = be32_to_cpup(list++);
+                    out_args->args[i] = be32_to_cpu(*list++);
             }
 
             /* Found it! return success */
@@ -1845,7 +1845,7 @@ static unsigned long unflatten_dt_node(const void *fdt,
     int has_name = 0;
     int new_format = 0;
 
-    tag = be32_to_cpup((__be32 *)(*p));
+    tag = be32_to_cpu(*(__be32 *)(*p));
     if ( tag != FDT_BEGIN_NODE )
     {
         printk(XENLOG_WARNING "Weird tag at start of node: %x\n", tag);
@@ -1938,7 +1938,7 @@ static unsigned long unflatten_dt_node(const void *fdt,
         u32 sz, noff;
         const char *pname;
 
-        tag = be32_to_cpup((__be32 *)(*p));
+        tag = be32_to_cpu(*(__be32 *)(*p));
         if ( tag == FDT_NOP )
         {
             *p += 4;
@@ -1947,8 +1947,8 @@ static unsigned long unflatten_dt_node(const void *fdt,
         if ( tag != FDT_PROP )
             break;
         *p += 4;
-        sz = be32_to_cpup((__be32 *)(*p));
-        noff = be32_to_cpup((__be32 *)((*p) + 4));
+        sz = be32_to_cpu(*(__be32 *)(*p));
+        noff = be32_to_cpu(*(__be32 *)((*p) + 4));
         *p += 8;
         if ( fdt_version(fdt) < 0x10 )
             *p = ROUNDUP(*p, sz >= 8 ? 8 : 4);
@@ -1975,13 +1975,13 @@ static unsigned long unflatten_dt_node(const void *fdt,
                  (strcmp(pname, "linux,phandle") == 0) )
             {
                 if ( np->phandle == 0 )
-                    np->phandle = be32_to_cpup((__be32*)*p);
+                    np->phandle = be32_to_cpu(*(__be32*)*p);
             }
             /* And we process the "ibm,phandle" property
              * used in pSeries dynamic device tree
              * stuff */
             if ( strcmp(pname, "ibm,phandle") == 0 )
-                np->phandle = be32_to_cpup((__be32 *)*p);
+                np->phandle = be32_to_cpu(*(__be32 *)*p);
             pp->name = pname;
             pp->length = sz;
             pp->value = (void *)*p;
@@ -2053,7 +2053,7 @@ static unsigned long unflatten_dt_node(const void *fdt,
             *p += 4;
         else
             mem = unflatten_dt_node(fdt, mem, p, np, allnextpp, fpsize);
-        tag = be32_to_cpup((__be32 *)(*p));
+        tag = be32_to_cpu(*(__be32 *)(*p));
     }
     if ( tag != FDT_END_NODE )
     {
@@ -2099,7 +2099,7 @@ int unflatten_device_tree(const void *fdt, struct dt_device_node **mynodes)
     /* Second pass, do actual unflattening */
     start = ((unsigned long)fdt) + fdt_off_dt_struct(fdt);
     unflatten_dt_node(fdt, mem, &start, NULL, &allnextp, 0);
-    if ( be32_to_cpup((__be32 *)start) != FDT_END )
+    if ( be32_to_cpu(*(__be32 *)start) != FDT_END )
     {
         printk(XENLOG_ERR "Weird tag at end of tree: %08x\n",
                   *((u32 *)start));
-- 
2.39.5



^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH v5 06/16] xen/decompressors: Remove use of *_to_cpup() helpers
  2025-03-28 13:44 [PATCH v5 00/16] xen: Centralise byteswap infrastructure Andrew Cooper
                   ` (4 preceding siblings ...)
  2025-03-28 13:44 ` [PATCH v5 05/16] xen/device-tree: Remove use of *_to_cpup() helpers Andrew Cooper
@ 2025-03-28 13:44 ` Andrew Cooper
  2025-03-28 14:07   ` Andrew Cooper
  2025-03-28 13:44 ` [PATCH v5 07/16] xen/arch: Switch to new byteorder infrastructure Andrew Cooper
                   ` (9 subsequent siblings)
  15 siblings, 1 reply; 30+ messages in thread
From: Andrew Cooper @ 2025-03-28 13:44 UTC (permalink / raw)
  To: Xen-devel
  Cc: Lin Liu, Andrew Cooper, Anthony PERARD, Michal Orzel, Jan Beulich,
	Julien Grall, Roger Pau Monné, Stefano Stabellini,
	Volodymyr Babchuk, Bertrand Marquis, Shawn Anastasio,
	Oleksii Kurochko, Daniel P . Smith

From: Lin Liu <lin.liu@citrix.com>

These wrappers simply hide a deference, which adds to the cognitive complexity
of reading the code.  As such, they're not going to be included in the new
byteswap infrastructure.

No functional change.

Signed-off-by: Lin Liu <lin.liu@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Anthony PERARD <anthony.perard@vates.tech>
CC: Michal Orzel <michal.orzel@amd.com>
CC: Jan Beulich <jbeulich@suse.com>
CC: Julien Grall <julien@xen.org>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
CC: Bertrand Marquis <bertrand.marquis@arm.com>
CC: Shawn Anastasio <sanastasio@raptorengineering.com>
CC: Oleksii Kurochko <oleksii.kurochko@gmail.com>
CC: Daniel P. Smith <dpsmith@apertussolutions.com>
CC: Lin Liu <lin.liu@citrix.com>

v5:
 * Rebase
 * Rearranged from other patches
---
 tools/libs/guest/xg_dom_decompress_unsafe_xz.c | 13 +++++++------
 xen/common/lz4/defs.h                          |  6 +++++-
 xen/common/xz/private.h                        | 12 +++++++++---
 3 files changed, 21 insertions(+), 10 deletions(-)

diff --git a/tools/libs/guest/xg_dom_decompress_unsafe_xz.c b/tools/libs/guest/xg_dom_decompress_unsafe_xz.c
index 80eed912dd68..7dbd2622c3b8 100644
--- a/tools/libs/guest/xg_dom_decompress_unsafe_xz.c
+++ b/tools/libs/guest/xg_dom_decompress_unsafe_xz.c
@@ -19,18 +19,19 @@ typedef uint32_t __le32;
 static inline u32 cpu_to_le32(const u32 v)
 {
 #if BYTE_ORDER == BIG_ENDIAN
-	return (((v & 0x000000ffUL) << 24) |
-	        ((v & 0x0000ff00UL) <<  8) |
-	        ((v & 0x00ff0000UL) >>  8) |
-	        ((v & 0xff000000UL) >> 24));
+        return __builtin_bswap32(v);
 #else
 	return v;
 #endif
 }
 
-static inline u32 le32_to_cpup(const u32 *p)
+static inline u32 le32_to_cpu(const u32 p)
 {
-	return cpu_to_le32(*p);
+#if BYTE_ORDER == BIG_ENDIAN
+        return __builtin_bswap32(v);
+#else
+	return v;
+#endif
 }
 
 #define __force
diff --git a/xen/common/lz4/defs.h b/xen/common/lz4/defs.h
index ecfbf07f8323..e477806634c1 100644
--- a/xen/common/lz4/defs.h
+++ b/xen/common/lz4/defs.h
@@ -18,7 +18,11 @@
 
 static inline u16 get_unaligned_le16(const void *p)
 {
-	return le16_to_cpup(p);
+	u16 v;
+
+	memcpy(&v, p, sizeof(v));
+
+	return le16_to_cpu(v);
 }
 
 #endif
diff --git a/xen/common/xz/private.h b/xen/common/xz/private.h
index 2299705378ac..a63379994fd6 100644
--- a/xen/common/xz/private.h
+++ b/xen/common/xz/private.h
@@ -18,17 +18,23 @@
 
 static inline u32 get_unaligned_le32(const void *p)
 {
-	return le32_to_cpup(p);
+	u32 v;
+
+	memcpy(&v, p, sizeof(v));
+
+	return le32_to_cpu(v);
 }
 
 static inline void put_unaligned_le32(u32 val, void *p)
 {
-	*(__force __le32*)p = cpu_to_le32(val);
+	u32 v = cpu_to_le32(val);
+
+	memcpy(p, &v, sizeof(v));
 }
 
 #endif
 
-#define get_le32(p) le32_to_cpup((const uint32_t *)(p))
+#define get_le32(p) le32_to_cpu(*(const uint32_t *)(p))
 
 #define false 0
 #define true 1
-- 
2.39.5



^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH v5 07/16] xen/arch: Switch to new byteorder infrastructure
  2025-03-28 13:44 [PATCH v5 00/16] xen: Centralise byteswap infrastructure Andrew Cooper
                   ` (5 preceding siblings ...)
  2025-03-28 13:44 ` [PATCH v5 06/16] xen/decompressors: " Andrew Cooper
@ 2025-03-28 13:44 ` Andrew Cooper
  2025-03-31 13:53   ` Jan Beulich
  2025-03-28 13:44 ` [PATCH v5 08/16] xen/decompressors: Use " Andrew Cooper
                   ` (8 subsequent siblings)
  15 siblings, 1 reply; 30+ messages in thread
From: Andrew Cooper @ 2025-03-28 13:44 UTC (permalink / raw)
  To: Xen-devel
  Cc: Lin Liu, Andrew Cooper, Anthony PERARD, Michal Orzel, Jan Beulich,
	Julien Grall, Roger Pau Monné, Stefano Stabellini,
	Volodymyr Babchuk, Bertrand Marquis, Shawn Anastasio,
	Oleksii Kurochko, Daniel P . Smith

From: Lin Liu <lin.liu@citrix.com>

This needs to be done in several steps, because of common vs arch issues.
Start by using the new common infastructure inside the arch infrastructure.

libelf-private.h is awkward, and the only thing in Xen using swabXX()
directly.  It needs updating at the same time.

Signed-off-by: Lin Liu <lin.liu@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Anthony PERARD <anthony.perard@vates.tech>
CC: Michal Orzel <michal.orzel@amd.com>
CC: Jan Beulich <jbeulich@suse.com>
CC: Julien Grall <julien@xen.org>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
CC: Bertrand Marquis <bertrand.marquis@arm.com>
CC: Shawn Anastasio <sanastasio@raptorengineering.com>
CC: Oleksii Kurochko <oleksii.kurochko@gmail.com>
CC: Daniel P. Smith <dpsmith@apertussolutions.com>
CC: Lin Liu <lin.liu@citrix.com>

v5:
 * Rebase
 * Rearange from other patches to maintain bisectability
---
 xen/arch/arm/include/asm/byteorder.h   |  4 +---
 xen/arch/ppc/include/asm/byteorder.h   |  8 +-------
 xen/arch/riscv/include/asm/byteorder.h |  4 +---
 xen/arch/x86/include/asm/byteorder.h   | 25 +------------------------
 xen/common/libelf/libelf-private.h     |  6 +++---
 5 files changed, 7 insertions(+), 40 deletions(-)

diff --git a/xen/arch/arm/include/asm/byteorder.h b/xen/arch/arm/include/asm/byteorder.h
index 9c712c47884a..7f1419c45a16 100644
--- a/xen/arch/arm/include/asm/byteorder.h
+++ b/xen/arch/arm/include/asm/byteorder.h
@@ -1,9 +1,7 @@
 #ifndef __ASM_ARM_BYTEORDER_H__
 #define __ASM_ARM_BYTEORDER_H__
 
-#define __BYTEORDER_HAS_U64__
-
-#include <xen/byteorder/little_endian.h>
+#include <xen/byteorder.h>
 
 #endif /* __ASM_ARM_BYTEORDER_H__ */
 /*
diff --git a/xen/arch/ppc/include/asm/byteorder.h b/xen/arch/ppc/include/asm/byteorder.h
index 2b5f6b9f6321..8df6adbf0d7d 100644
--- a/xen/arch/ppc/include/asm/byteorder.h
+++ b/xen/arch/ppc/include/asm/byteorder.h
@@ -1,12 +1,6 @@
 #ifndef _ASM_PPC_BYTEORDER_H
 #define _ASM_PPC_BYTEORDER_H
 
-#define __arch__swab16 __builtin_bswap16
-#define __arch__swab32 __builtin_bswap32
-#define __arch__swab64 __builtin_bswap64
-
-#define __BYTEORDER_HAS_U64__
-
-#include <xen/byteorder/little_endian.h>
+#include <xen/byteorder.h>
 
 #endif /* _ASM_PPC_BYTEORDER_H */
diff --git a/xen/arch/riscv/include/asm/byteorder.h b/xen/arch/riscv/include/asm/byteorder.h
index 8ca65e1b330e..a32bca02df38 100644
--- a/xen/arch/riscv/include/asm/byteorder.h
+++ b/xen/arch/riscv/include/asm/byteorder.h
@@ -1,9 +1,7 @@
 #ifndef ASM__RISCV__BYTEORDER_H
 #define ASM__RISCV__BYTEORDER_H
 
-#define __BYTEORDER_HAS_U64__
-
-#include <xen/byteorder/little_endian.h>
+#include <xen/byteorder.h>
 
 #endif /* ASM__RISCV__BYTEORDER_H */
 /*
diff --git a/xen/arch/x86/include/asm/byteorder.h b/xen/arch/x86/include/asm/byteorder.h
index 44c240376d3a..3524a6cee741 100644
--- a/xen/arch/x86/include/asm/byteorder.h
+++ b/xen/arch/x86/include/asm/byteorder.h
@@ -1,29 +1,6 @@
 #ifndef __ASM_X86_BYTEORDER_H__
 #define __ASM_X86_BYTEORDER_H__
 
-#include <xen/types.h>
-#include <xen/compiler.h>
-
-static inline attr_const uint32_t ___arch__swab32(uint32_t x)
-{
-    asm("bswap %0" : "=r" (x) : "0" (x));
-    return x;
-}
-
-static inline attr_const uint64_t ___arch__swab64(uint64_t x)
-{ 
-    asm ( "bswap %0" : "+r" (x) );
-    return x;
-} 
-
-/* Do not define swab16.  Gcc is smart enough to recognize "C" version and
-   convert it into rotation or exhange.  */
-
-#define __arch__swab64(x) ___arch__swab64(x)
-#define __arch__swab32(x) ___arch__swab32(x)
-
-#define __BYTEORDER_HAS_U64__
-
-#include <xen/byteorder/little_endian.h>
+#include <xen/byteorder.h>
 
 #endif /* __ASM_X86_BYTEORDER_H__ */
diff --git a/xen/common/libelf/libelf-private.h b/xen/common/libelf/libelf-private.h
index 197d7a7623a3..65417dffc8a0 100644
--- a/xen/common/libelf/libelf-private.h
+++ b/xen/common/libelf/libelf-private.h
@@ -31,9 +31,9 @@
    printk(fmt, ## args )
 
 #define strtoull(str, end, base) simple_strtoull(str, end, base)
-#define bswap_16(x) swab16(x)
-#define bswap_32(x) swab32(x)
-#define bswap_64(x) swab64(x)
+#define bswap_16(x) bswap16(x)
+#define bswap_32(x) bswap32(x)
+#define bswap_64(x) bswap64(x)
 
 #else /* !__XEN__ */
 
-- 
2.39.5



^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH v5 08/16] xen/decompressors: Use new byteorder infrastructure
  2025-03-28 13:44 [PATCH v5 00/16] xen: Centralise byteswap infrastructure Andrew Cooper
                   ` (6 preceding siblings ...)
  2025-03-28 13:44 ` [PATCH v5 07/16] xen/arch: Switch to new byteorder infrastructure Andrew Cooper
@ 2025-03-28 13:44 ` Andrew Cooper
  2025-03-31 13:55   ` Jan Beulich
  2025-03-28 13:44 ` [PATCH v5 09/16] xen: Remove old " Andrew Cooper
                   ` (7 subsequent siblings)
  15 siblings, 1 reply; 30+ messages in thread
From: Andrew Cooper @ 2025-03-28 13:44 UTC (permalink / raw)
  To: Xen-devel
  Cc: Lin Liu, Anthony PERARD, Michal Orzel, Jan Beulich, Julien Grall,
	Roger Pau Monné, Stefano Stabellini, Volodymyr Babchuk,
	Bertrand Marquis, Shawn Anastasio, Oleksii Kurochko,
	Daniel P . Smith

From: Lin Liu <lin.liu@citrix.com>

unaligned.h already inlcudes byteorder.h, so most can simply be dropped.

No functional change.

Signed-off-by: Lin Liu <lin.liu@citrix.com>
---
CC: Anthony PERARD <anthony.perard@vates.tech>
CC: Michal Orzel <michal.orzel@amd.com>
CC: Jan Beulich <jbeulich@suse.com>
CC: Julien Grall <julien@xen.org>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
CC: Bertrand Marquis <bertrand.marquis@arm.com>
CC: Shawn Anastasio <sanastasio@raptorengineering.com>
CC: Oleksii Kurochko <oleksii.kurochko@gmail.com>
CC: Daniel P. Smith <dpsmith@apertussolutions.com>
CC: Lin Liu <lin.liu@citrix.com>

v5:
 * New
---
 tools/libs/guest/xg_dom_decompress_unsafe_zstd.c | 3 +--
 xen/common/lz4/defs.h                            | 1 -
 xen/common/lzo.c                                 | 1 -
 xen/common/unlzo.c                               | 1 -
 xen/common/xz/private.h                          | 1 -
 5 files changed, 1 insertion(+), 6 deletions(-)

diff --git a/tools/libs/guest/xg_dom_decompress_unsafe_zstd.c b/tools/libs/guest/xg_dom_decompress_unsafe_zstd.c
index ff45732a3616..319816a390eb 100644
--- a/tools/libs/guest/xg_dom_decompress_unsafe_zstd.c
+++ b/tools/libs/guest/xg_dom_decompress_unsafe_zstd.c
@@ -30,9 +30,8 @@ typedef uint64_t __be64;
 
 #undef ERROR
 
-#define __BYTEORDER_HAS_U64__
 #define __TYPES_H__ /* xen/types.h guard */
-#include "../../xen/include/xen/byteorder/little_endian.h"
+#include "../../xen/include/xen/byteorder.h"
 #include "../../xen/include/xen/unaligned.h"
 #include "../../xen/include/xen/xxhash.h"
 #include "../../xen/lib/xxhash64.c"
diff --git a/xen/common/lz4/defs.h b/xen/common/lz4/defs.h
index e477806634c1..b697a06c00d7 100644
--- a/xen/common/lz4/defs.h
+++ b/xen/common/lz4/defs.h
@@ -12,7 +12,6 @@
 #define COMMON_LZ4_DEFS_H
 
 #ifdef __XEN__
-#include <asm/byteorder.h>
 #include <xen/unaligned.h>
 #else
 
diff --git a/xen/common/lzo.c b/xen/common/lzo.c
index 07b4017812dc..0393ec5c4472 100644
--- a/xen/common/lzo.c
+++ b/xen/common/lzo.c
@@ -68,7 +68,6 @@
 
 #ifdef __XEN__
 #include <xen/lib.h>
-#include <asm/byteorder.h>
 #include <xen/unaligned.h>
 #else
 #define get_unaligned_le16(_p) (*(u16 *)(_p))
diff --git a/xen/common/unlzo.c b/xen/common/unlzo.c
index acb8dff600fc..d52c1c92548d 100644
--- a/xen/common/unlzo.c
+++ b/xen/common/unlzo.c
@@ -33,7 +33,6 @@
 #include <xen/lzo.h>
 
 #ifdef __XEN__
-#include <asm/byteorder.h>
 #include <xen/unaligned.h>
 #else
 
diff --git a/xen/common/xz/private.h b/xen/common/xz/private.h
index a63379994fd6..3dce124fa743 100644
--- a/xen/common/xz/private.h
+++ b/xen/common/xz/private.h
@@ -12,7 +12,6 @@
 
 #ifdef __XEN__
 #include <xen/kernel.h>
-#include <asm/byteorder.h>
 #include <xen/unaligned.h>
 #else
 
-- 
2.39.5



^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH v5 09/16] xen: Remove old byteorder infrastructure
  2025-03-28 13:44 [PATCH v5 00/16] xen: Centralise byteswap infrastructure Andrew Cooper
                   ` (7 preceding siblings ...)
  2025-03-28 13:44 ` [PATCH v5 08/16] xen/decompressors: Use " Andrew Cooper
@ 2025-03-28 13:44 ` Andrew Cooper
  2025-03-28 13:44 ` [PATCH v5 10/16] crypto/vmac: Switch to xen/byteswap.h Andrew Cooper
                   ` (6 subsequent siblings)
  15 siblings, 0 replies; 30+ messages in thread
From: Andrew Cooper @ 2025-03-28 13:44 UTC (permalink / raw)
  To: Xen-devel
  Cc: Lin Liu, Andrew Cooper, Anthony PERARD, Michal Orzel, Jan Beulich,
	Julien Grall, Roger Pau Monné, Stefano Stabellini,
	Volodymyr Babchuk, Bertrand Marquis, Shawn Anastasio,
	Oleksii Kurochko, Daniel P . Smith

From: Lin Liu <lin.liu@citrix.com>

It is no longer used.

Signed-off-by: Lin Liu <lin.liu@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Anthony PERARD <anthony.perard@vates.tech>
CC: Michal Orzel <michal.orzel@amd.com>
CC: Jan Beulich <jbeulich@suse.com>
CC: Julien Grall <julien@xen.org>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
CC: Bertrand Marquis <bertrand.marquis@arm.com>
CC: Shawn Anastasio <sanastasio@raptorengineering.com>
CC: Oleksii Kurochko <oleksii.kurochko@gmail.com>
CC: Daniel P. Smith <dpsmith@apertussolutions.com>
CC: Lin Liu <lin.liu@citrix.com>
---
 xen/include/xen/byteorder/big_endian.h    |  95 ------------
 xen/include/xen/byteorder/generic.h       |  68 --------
 xen/include/xen/byteorder/little_endian.h |  95 ------------
 xen/include/xen/byteorder/swab.h          | 179 ----------------------
 4 files changed, 437 deletions(-)
 delete mode 100644 xen/include/xen/byteorder/big_endian.h
 delete mode 100644 xen/include/xen/byteorder/generic.h
 delete mode 100644 xen/include/xen/byteorder/little_endian.h
 delete mode 100644 xen/include/xen/byteorder/swab.h

diff --git a/xen/include/xen/byteorder/big_endian.h b/xen/include/xen/byteorder/big_endian.h
deleted file mode 100644
index 512291c76f1b..000000000000
--- a/xen/include/xen/byteorder/big_endian.h
+++ /dev/null
@@ -1,95 +0,0 @@
-#ifndef __XEN_BYTEORDER_BIG_ENDIAN_H__
-#define __XEN_BYTEORDER_BIG_ENDIAN_H__
-
-#include <xen/types.h>
-#include <xen/byteorder/swab.h>
-
-#define __constant_cpu_to_le64(x) ((__force __le64)___constant_swab64((x)))
-#define __constant_le64_to_cpu(x) ___constant_swab64((__force uint64_t)(__le64)(x))
-#define __constant_cpu_to_le32(x) ((__force __le32)___constant_swab32((x)))
-#define __constant_le32_to_cpu(x) ___constant_swab32((__force uint32_t)(__le32)(x))
-#define __constant_cpu_to_le16(x) ((__force __le16)___constant_swab16((x)))
-#define __constant_le16_to_cpu(x) ___constant_swab16((__force uint16_t)(__le16)(x))
-#define __constant_cpu_to_be64(x) ((__force __be64)(uint64_t)(x))
-#define __constant_be64_to_cpu(x) ((__force uint64_t)(__be64)(x))
-#define __constant_cpu_to_be32(x) ((__force __be32)(uint32_t)(x))
-#define __constant_be32_to_cpu(x) ((__force uint32_t)(__be32)(x))
-#define __constant_cpu_to_be16(x) ((__force __be16)(uint16_t)(x))
-#define __constant_be16_to_cpu(x) ((__force uint16_t)(__be16)(x))
-#define __cpu_to_le64(x) ((__force __le64)__swab64((x)))
-#define __le64_to_cpu(x) __swab64((__force uint64_t)(__le64)(x))
-#define __cpu_to_le32(x) ((__force __le32)__swab32((x)))
-#define __le32_to_cpu(x) __swab32((__force uint32_t)(__le32)(x))
-#define __cpu_to_le16(x) ((__force __le16)__swab16((x)))
-#define __le16_to_cpu(x) __swab16((__force uint16_t)(__le16)(x))
-#define __cpu_to_be64(x) ((__force __be64)(uint64_t)(x))
-#define __be64_to_cpu(x) ((__force uint64_t)(__be64)(x))
-#define __cpu_to_be32(x) ((__force __be32)(uint32_t)(x))
-#define __be32_to_cpu(x) ((__force uint32_t)(__be32)(x))
-#define __cpu_to_be16(x) ((__force __be16)(uint16_t)(x))
-#define __be16_to_cpu(x) ((__force uint16_t)(__be16)(x))
-
-static inline __le64 __cpu_to_le64p(const uint64_t *p)
-{
-    return (__force __le64)__swab64p(p);
-}
-static inline uint64_t __le64_to_cpup(const __le64 *p)
-{
-    return __swab64p((const uint64_t *)p);
-}
-static inline __le32 __cpu_to_le32p(const uint32_t *p)
-{
-    return (__force __le32)__swab32p(p);
-}
-static inline uint32_t __le32_to_cpup(const __le32 *p)
-{
-    return __swab32p((const uint32_t *)p);
-}
-static inline __le16 __cpu_to_le16p(const uint16_t *p)
-{
-    return (__force __le16)__swab16p(p);
-}
-static inline uint16_t __le16_to_cpup(const __le16 *p)
-{
-    return __swab16p((const uint16_t *)p);
-}
-static inline __be64 __cpu_to_be64p(const uint64_t *p)
-{
-    return (__force __be64)*p;
-}
-static inline uint64_t __be64_to_cpup(const __be64 *p)
-{
-    return (__force uint64_t)*p;
-}
-static inline __be32 __cpu_to_be32p(const uint32_t *p)
-{
-    return (__force __be32)*p;
-}
-static inline uint32_t __be32_to_cpup(const __be32 *p)
-{
-    return (__force uint32_t)*p;
-}
-static inline __be16 __cpu_to_be16p(const uint16_t *p)
-{
-    return (__force __be16)*p;
-}
-static inline uint16_t __be16_to_cpup(const __be16 *p)
-{
-    return (__force uint16_t)*p;
-}
-#define __cpu_to_le64s(x) __swab64s((x))
-#define __le64_to_cpus(x) __swab64s((x))
-#define __cpu_to_le32s(x) __swab32s((x))
-#define __le32_to_cpus(x) __swab32s((x))
-#define __cpu_to_le16s(x) __swab16s((x))
-#define __le16_to_cpus(x) __swab16s((x))
-#define __cpu_to_be64s(x) do {} while (0)
-#define __be64_to_cpus(x) do {} while (0)
-#define __cpu_to_be32s(x) do {} while (0)
-#define __be32_to_cpus(x) do {} while (0)
-#define __cpu_to_be16s(x) do {} while (0)
-#define __be16_to_cpus(x) do {} while (0)
-
-#include <xen/byteorder/generic.h>
-
-#endif /* __XEN_BYTEORDER_BIG_ENDIAN_H__ */
diff --git a/xen/include/xen/byteorder/generic.h b/xen/include/xen/byteorder/generic.h
deleted file mode 100644
index 8a0006b75594..000000000000
--- a/xen/include/xen/byteorder/generic.h
+++ /dev/null
@@ -1,68 +0,0 @@
-#ifndef __XEN_BYTEORDER_GENERIC_H__
-#define __XEN_BYTEORDER_GENERIC_H__
-
-/*
- * Generic Byte-reordering support
- *
- * The "... p" macros, like le64_to_cpup, can be used with pointers
- * to unaligned data, but there will be a performance penalty on 
- * some architectures.  Use get_unaligned for unaligned data.
- *
- * The following macros are to be defined by <asm/byteorder.h>:
- *
- * Conversion of XX-bit integers (16- 32- or 64-)
- * between native CPU format and little/big endian format
- * 64-bit stuff only defined for proper architectures
- *     cpu_to_[bl]eXX(__uXX x)
- *     [bl]eXX_to_cpu(__uXX x)
- *
- * The same, but takes a pointer to the value to convert
- *     cpu_to_[bl]eXXp(__uXX x)
- *     [bl]eXX_to_cpup(__uXX x)
- *
- * The same, but change in situ
- *     cpu_to_[bl]eXXs(__uXX x)
- *     [bl]eXX_to_cpus(__uXX x)
- *
- * See asm-foo/byteorder.h for examples of how to provide
- * architecture-optimized versions
- */
-
-#define cpu_to_le64 __cpu_to_le64
-#define le64_to_cpu __le64_to_cpu
-#define cpu_to_le32 __cpu_to_le32
-#define le32_to_cpu __le32_to_cpu
-#define cpu_to_le16 __cpu_to_le16
-#define le16_to_cpu __le16_to_cpu
-#define cpu_to_be64 __cpu_to_be64
-#define be64_to_cpu __be64_to_cpu
-#define cpu_to_be32 __cpu_to_be32
-#define be32_to_cpu __be32_to_cpu
-#define cpu_to_be16 __cpu_to_be16
-#define be16_to_cpu __be16_to_cpu
-#define cpu_to_le64p __cpu_to_le64p
-#define le64_to_cpup __le64_to_cpup
-#define cpu_to_le32p __cpu_to_le32p
-#define le32_to_cpup __le32_to_cpup
-#define cpu_to_le16p __cpu_to_le16p
-#define le16_to_cpup __le16_to_cpup
-#define cpu_to_be64p __cpu_to_be64p
-#define be64_to_cpup __be64_to_cpup
-#define cpu_to_be32p __cpu_to_be32p
-#define be32_to_cpup __be32_to_cpup
-#define cpu_to_be16p __cpu_to_be16p
-#define be16_to_cpup __be16_to_cpup
-#define cpu_to_le64s __cpu_to_le64s
-#define le64_to_cpus __le64_to_cpus
-#define cpu_to_le32s __cpu_to_le32s
-#define le32_to_cpus __le32_to_cpus
-#define cpu_to_le16s __cpu_to_le16s
-#define le16_to_cpus __le16_to_cpus
-#define cpu_to_be64s __cpu_to_be64s
-#define be64_to_cpus __be64_to_cpus
-#define cpu_to_be32s __cpu_to_be32s
-#define be32_to_cpus __be32_to_cpus
-#define cpu_to_be16s __cpu_to_be16s
-#define be16_to_cpus __be16_to_cpus
-
-#endif /* __XEN_BYTEORDER_GENERIC_H__ */
diff --git a/xen/include/xen/byteorder/little_endian.h b/xen/include/xen/byteorder/little_endian.h
deleted file mode 100644
index bd1afc6a67c3..000000000000
--- a/xen/include/xen/byteorder/little_endian.h
+++ /dev/null
@@ -1,95 +0,0 @@
-#ifndef __XEN_BYTEORDER_LITTLE_ENDIAN_H__
-#define __XEN_BYTEORDER_LITTLE_ENDIAN_H__
-
-#include <xen/types.h>
-#include <xen/byteorder/swab.h>
-
-#define __constant_cpu_to_le64(x) ((__force __le64)(uint64_t)(x))
-#define __constant_le64_to_cpu(x) ((__force uint64_t)(__le64)(x))
-#define __constant_cpu_to_le32(x) ((__force __le32)(uint32_t)(x))
-#define __constant_le32_to_cpu(x) ((__force uint32_t)(__le32)(x))
-#define __constant_cpu_to_le16(x) ((__force __le16)(uint16_t)(x))
-#define __constant_le16_to_cpu(x) ((__force uint16_t)(__le16)(x))
-#define __constant_cpu_to_be64(x) ((__force __be64)___constant_swab64((x)))
-#define __constant_be64_to_cpu(x) ___constant_swab64((__force uint64_t)(__be64)(x))
-#define __constant_cpu_to_be32(x) ((__force __be32)___constant_swab32((x)))
-#define __constant_be32_to_cpu(x) ___constant_swab32((__force uint32_t)(__be32)(x))
-#define __constant_cpu_to_be16(x) ((__force __be16)___constant_swab16((x)))
-#define __constant_be16_to_cpu(x) ___constant_swab16((__force uint16_t)(__be16)(x))
-#define __cpu_to_le64(x) ((__force __le64)(uint64_t)(x))
-#define __le64_to_cpu(x) ((__force uint64_t)(__le64)(x))
-#define __cpu_to_le32(x) ((__force __le32)(uint32_t)(x))
-#define __le32_to_cpu(x) ((__force uint32_t)(__le32)(x))
-#define __cpu_to_le16(x) ((__force __le16)(uint16_t)(x))
-#define __le16_to_cpu(x) ((__force uint16_t)(__le16)(x))
-#define __cpu_to_be64(x) ((__force __be64)__swab64((x)))
-#define __be64_to_cpu(x) __swab64((__force uint64_t)(__be64)(x))
-#define __cpu_to_be32(x) ((__force __be32)__swab32((x)))
-#define __be32_to_cpu(x) __swab32((__force uint32_t)(__be32)(x))
-#define __cpu_to_be16(x) ((__force __be16)__swab16((x)))
-#define __be16_to_cpu(x) __swab16((__force uint16_t)(__be16)(x))
-
-static inline __le64 __cpu_to_le64p(const uint64_t *p)
-{
-    return (__force __le64)*p;
-}
-static inline uint64_t __le64_to_cpup(const __le64 *p)
-{
-    return (__force uint64_t)*p;
-}
-static inline __le32 __cpu_to_le32p(const uint32_t *p)
-{
-    return (__force __le32)*p;
-}
-static inline uint32_t __le32_to_cpup(const __le32 *p)
-{
-    return (__force uint32_t)*p;
-}
-static inline __le16 __cpu_to_le16p(const uint16_t *p)
-{
-    return (__force __le16)*p;
-}
-static inline uint16_t __le16_to_cpup(const __le16 *p)
-{
-    return (__force uint16_t)*p;
-}
-static inline __be64 __cpu_to_be64p(const uint64_t *p)
-{
-    return (__force __be64)__swab64p(p);
-}
-static inline uint64_t __be64_to_cpup(const __be64 *p)
-{
-    return __swab64p((const uint64_t *)p);
-}
-static inline __be32 __cpu_to_be32p(const uint32_t *p)
-{
-    return (__force __be32)__swab32p(p);
-}
-static inline uint32_t __be32_to_cpup(const __be32 *p)
-{
-    return __swab32p((const uint32_t *)p);
-}
-static inline __be16 __cpu_to_be16p(const uint16_t *p)
-{
-    return (__force __be16)__swab16p(p);
-}
-static inline uint16_t __be16_to_cpup(const __be16 *p)
-{
-    return __swab16p((const uint16_t *)p);
-}
-#define __cpu_to_le64s(x) do {} while (0)
-#define __le64_to_cpus(x) do {} while (0)
-#define __cpu_to_le32s(x) do {} while (0)
-#define __le32_to_cpus(x) do {} while (0)
-#define __cpu_to_le16s(x) do {} while (0)
-#define __le16_to_cpus(x) do {} while (0)
-#define __cpu_to_be64s(x) __swab64s((x))
-#define __be64_to_cpus(x) __swab64s((x))
-#define __cpu_to_be32s(x) __swab32s((x))
-#define __be32_to_cpus(x) __swab32s((x))
-#define __cpu_to_be16s(x) __swab16s((x))
-#define __be16_to_cpus(x) __swab16s((x))
-
-#include <xen/byteorder/generic.h>
-
-#endif /* __XEN_BYTEORDER_LITTLE_ENDIAN_H__ */
diff --git a/xen/include/xen/byteorder/swab.h b/xen/include/xen/byteorder/swab.h
deleted file mode 100644
index ffcf1cf800b2..000000000000
--- a/xen/include/xen/byteorder/swab.h
+++ /dev/null
@@ -1,179 +0,0 @@
-#ifndef __XEN_BYTEORDER_SWAB_H__
-#define __XEN_BYTEORDER_SWAB_H__
-
-/*
- * Byte-swapping, independently from CPU endianness
- *     swabXX[ps]?(foo)
- *
- * Francois-Rene Rideau <fare@tunes.org> 19971205
- *    separated swab functions from cpu_to_XX,
- *    to clean up support for bizarre-endian architectures.
- */
-
-#define ___swab16(x)                                    \
-({                                                      \
-    uint16_t x_ = (x);                                  \
-    (uint16_t)(                                         \
-        (((uint16_t)(x_) & 0x00ffU) << 8) |             \
-        (((uint16_t)(x_) & 0xff00U) >> 8));             \
-})
-
-#define ___swab32(x)                                            \
-({                                                              \
-    uint32_t x_ = (x);                                          \
-    (uint32_t)(                                                 \
-        (((uint32_t)(x_) & 0x000000ffU) << 24) |                \
-        (((uint32_t)(x_) & 0x0000ff00U) <<  8) |                \
-        (((uint32_t)(x_) & 0x00ff0000U) >>  8) |                \
-        (((uint32_t)(x_) & 0xff000000U) >> 24));                \
-})
-
-#define ___swab64(x)                                                       \
-({                                                                         \
-    uint64_t x_ = (x);                                                     \
-    (uint64_t)(                                                            \
-        (((uint64_t)(x_) & 0x00000000000000ffULL) << 56) |                 \
-        (((uint64_t)(x_) & 0x000000000000ff00ULL) << 40) |                 \
-        (((uint64_t)(x_) & 0x0000000000ff0000ULL) << 24) |                 \
-        (((uint64_t)(x_) & 0x00000000ff000000ULL) <<  8) |                 \
-        (((uint64_t)(x_) & 0x000000ff00000000ULL) >>  8) |                 \
-        (((uint64_t)(x_) & 0x0000ff0000000000ULL) >> 24) |                 \
-        (((uint64_t)(x_) & 0x00ff000000000000ULL) >> 40) |                 \
-        (((uint64_t)(x_) & 0xff00000000000000ULL) >> 56));                 \
-})
-
-#define ___constant_swab16(x)                   \
-    ((uint16_t)(                                \
-        (((uint16_t)(x) & 0x00ffU) << 8) |      \
-        (((uint16_t)(x) & 0xff00U) >> 8)))
-#define ___constant_swab32(x)                           \
-    ((uint32_t)(                                        \
-        (((uint32_t)(x) & 0x000000ffU) << 24) |         \
-        (((uint32_t)(x) & 0x0000ff00U) <<  8) |         \
-        (((uint32_t)(x) & 0x00ff0000U) >>  8) |         \
-        (((uint32_t)(x) & 0xff000000U) >> 24)))
-#define ___constant_swab64(x)                                            \
-    ((uint64_t)(                                                         \
-        (((uint64_t)(x) & 0x00000000000000ffULL) << 56) |                \
-        (((uint64_t)(x) & 0x000000000000ff00ULL) << 40) |                \
-        (((uint64_t)(x) & 0x0000000000ff0000ULL) << 24) |                \
-        (((uint64_t)(x) & 0x00000000ff000000ULL) <<  8) |                \
-        (((uint64_t)(x) & 0x000000ff00000000ULL) >>  8) |                \
-        (((uint64_t)(x) & 0x0000ff0000000000ULL) >> 24) |                \
-        (((uint64_t)(x) & 0x00ff000000000000ULL) >> 40) |                \
-        (((uint64_t)(x) & 0xff00000000000000ULL) >> 56)))
-
-/*
- * provide defaults when no architecture-specific optimization is detected
- */
-#ifndef __arch__swab16
-#  define __arch__swab16(x) ___swab16(x)
-#endif
-#ifndef __arch__swab32
-#  define __arch__swab32(x) ___swab32(x)
-#endif
-#ifndef __arch__swab64
-#  define __arch__swab64(x) ___swab64(x)
-#endif
-
-#ifndef __arch__swab16p
-#  define __arch__swab16p(x) __arch__swab16(*(x))
-#endif
-#ifndef __arch__swab32p
-#  define __arch__swab32p(x) __arch__swab32(*(x))
-#endif
-#ifndef __arch__swab64p
-#  define __arch__swab64p(x) __arch__swab64(*(x))
-#endif
-
-#ifndef __arch__swab16s
-#  define __arch__swab16s(x) do { *(x) = __arch__swab16p((x)); } while (0)
-#endif
-#ifndef __arch__swab32s
-#  define __arch__swab32s(x) do { *(x) = __arch__swab32p((x)); } while (0)
-#endif
-#ifndef __arch__swab64s
-#  define __arch__swab64s(x) do { *(x) = __arch__swab64p((x)); } while (0)
-#endif
-
-
-/*
- * Allow constant folding
- */
-#if defined(__GNUC__) && defined(__OPTIMIZE__)
-#  define __swab16(x) \
-(__builtin_constant_p((uint16_t)(x)) ? \
- ___swab16((x)) : \
- __fswab16((x)))
-#  define __swab32(x) \
-(__builtin_constant_p((uint32_t)(x)) ? \
- ___swab32((x)) : \
- __fswab32((x)))
-#  define __swab64(x) \
-(__builtin_constant_p((uint64_t)(x)) ? \
- ___swab64((x)) : \
- __fswab64((x)))
-#else
-#  define __swab16(x) __fswab16(x)
-#  define __swab32(x) __fswab32(x)
-#  define __swab64(x) __fswab64(x)
-#endif /* OPTIMIZE */
-
-
-static inline attr_const uint16_t __fswab16(uint16_t x)
-{
-    return __arch__swab16(x);
-}
-static inline uint16_t __swab16p(const uint16_t *x)
-{
-    return __arch__swab16p(x);
-}
-static inline void __swab16s(uint16_t *addr)
-{
-    __arch__swab16s(addr);
-}
-
-static inline attr_const uint32_t __fswab32(uint32_t x)
-{
-    return __arch__swab32(x);
-}
-static inline uint32_t __swab32p(const uint32_t *x)
-{
-    return __arch__swab32p(x);
-}
-static inline void __swab32s(uint32_t *addr)
-{
-    __arch__swab32s(addr);
-}
-
-#ifdef __BYTEORDER_HAS_U64__
-static inline attr_const uint64_t __fswab64(uint64_t x)
-{
-#  ifdef __SWAB_64_THRU_32__
-    uint32_t h = x >> 32, l = x;
-    return ((uint64_t)__swab32(l) << 32) | __swab32(h);
-#  else
-    return __arch__swab64(x);
-#  endif
-}
-static inline uint64_t __swab64p(const uint64_t *x)
-{
-    return __arch__swab64p(x);
-}
-static inline void __swab64s(uint64_t *addr)
-{
-    __arch__swab64s(addr);
-}
-#endif /* __BYTEORDER_HAS_U64__ */
-
-#define swab16 __swab16
-#define swab32 __swab32
-#define swab64 __swab64
-#define swab16p __swab16p
-#define swab32p __swab32p
-#define swab64p __swab64p
-#define swab16s __swab16s
-#define swab32s __swab32s
-#define swab64s __swab64s
-
-#endif /* __XEN_BYTEORDER_SWAB_H__ */
-- 
2.39.5



^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH v5 10/16] crypto/vmac: Switch to xen/byteswap.h
  2025-03-28 13:44 [PATCH v5 00/16] xen: Centralise byteswap infrastructure Andrew Cooper
                   ` (8 preceding siblings ...)
  2025-03-28 13:44 ` [PATCH v5 09/16] xen: Remove old " Andrew Cooper
@ 2025-03-28 13:44 ` Andrew Cooper
  2025-03-28 13:44 ` [PATCH v5 11/16] xsm/flask: Switch {asm -> xen}/byteorder.h Andrew Cooper
                   ` (5 subsequent siblings)
  15 siblings, 0 replies; 30+ messages in thread
From: Andrew Cooper @ 2025-03-28 13:44 UTC (permalink / raw)
  To: Xen-devel
  Cc: Lin Liu, Jan Beulich, Andrew Cooper, Anthony PERARD, Michal Orzel,
	Julien Grall, Roger Pau Monné, Stefano Stabellini,
	Volodymyr Babchuk, Bertrand Marquis, Shawn Anastasio,
	Oleksii Kurochko, Daniel P . Smith

From: Lin Liu <lin.liu@citrix.com>

This file has its own implementation of swap bytes. Clean up
the code with xen/byteswap.h.

No functional change.

Signed-off-by: Lin Liu <lin.liu@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Anthony PERARD <anthony.perard@vates.tech>
CC: Michal Orzel <michal.orzel@amd.com>
CC: Jan Beulich <jbeulich@suse.com>
CC: Julien Grall <julien@xen.org>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
CC: Bertrand Marquis <bertrand.marquis@arm.com>
CC: Shawn Anastasio <sanastasio@raptorengineering.com>
CC: Oleksii Kurochko <oleksii.kurochko@gmail.com>
CC: Daniel P. Smith <dpsmith@apertussolutions.com>
CC: Lin Liu <lin.liu@citrix.com>
---
 xen/crypto/vmac.c | 76 ++---------------------------------------------
 1 file changed, 3 insertions(+), 73 deletions(-)

diff --git a/xen/crypto/vmac.c b/xen/crypto/vmac.c
index 294dd16a52cb..acb4e015f511 100644
--- a/xen/crypto/vmac.c
+++ b/xen/crypto/vmac.c
@@ -8,6 +8,7 @@
 
 /* start for Xen */
 #include <xen/init.h>
+#include <xen/byteswap.h>
 #include <xen/types.h>
 #include <xen/lib.h>
 #include <crypto/vmac.h>
@@ -50,7 +51,6 @@ const uint64_t mpoly = UINT64_C(0x1fffffff1fffffff);  /* Poly key mask     */
  * MUL64: 64x64->128-bit multiplication
  * PMUL64: assumes top bits cleared on inputs
  * ADD128: 128x128->128-bit addition
- * GET_REVERSED_64: load and byte-reverse 64-bit word  
  * ----------------------------------------------------------------------- */
 
 /* ----------------------------------------------------------------------- */
@@ -68,22 +68,6 @@ const uint64_t mpoly = UINT64_C(0x1fffffff1fffffff);  /* Poly key mask     */
 
 #define PMUL64 MUL64
 
-#define GET_REVERSED_64(p)                                                \
-    ({uint64_t x;                                                         \
-     asm ("bswapq %0" : "=r" (x) : "0"(*(uint64_t *)(p))); x;})
-
-/* ----------------------------------------------------------------------- */
-#elif (__GNUC__ && __i386__)
-/* ----------------------------------------------------------------------- */
-
-#define GET_REVERSED_64(p)                                                \
-    ({ uint64_t x;                                                        \
-    uint32_t *tp = (uint32_t *)(p);                                       \
-    asm  ("bswap %%edx\n\t"                                               \
-          "bswap %%eax"                                                   \
-    : "=A"(x)                                                             \
-    : "a"(tp[1]), "d"(tp[0]));                                            \
-    x; })
 
 /* ----------------------------------------------------------------------- */
 #elif (__GNUC__ && __ppc64__)
@@ -103,37 +87,6 @@ const uint64_t mpoly = UINT64_C(0x1fffffff1fffffff);  /* Poly key mask     */
 
 #define PMUL64 MUL64
 
-#define GET_REVERSED_64(p)                                                \
-    ({ uint32_t hi, lo, *_p = (uint32_t *)(p);                            \
-       asm volatile ("lwbrx %0, %1, %2" : "=r"(lo) : "b%"(0), "r"(_p) );  \
-       asm volatile ("lwbrx %0, %1, %2" : "=r"(hi) : "b%"(4), "r"(_p) );  \
-       ((uint64_t)hi << 32) | (uint64_t)lo; } )
-
-/* ----------------------------------------------------------------------- */
-#elif (__GNUC__ && (__ppc__ || __PPC__))
-/* ----------------------------------------------------------------------- */
-
-#define GET_REVERSED_64(p)                                                \
-    ({ uint32_t hi, lo, *_p = (uint32_t *)(p);                            \
-       asm volatile ("lwbrx %0, %1, %2" : "=r"(lo) : "b%"(0), "r"(_p) );  \
-       asm volatile ("lwbrx %0, %1, %2" : "=r"(hi) : "b%"(4), "r"(_p) );  \
-       ((uint64_t)hi << 32) | (uint64_t)lo; } )
-
-/* ----------------------------------------------------------------------- */
-#elif (__GNUC__ && (__ARMEL__ || __ARM__))
-/* ----------------------------------------------------------------------- */
-
-#define bswap32(v)                                                        \
-({ uint32_t tmp,out;                                                      \
-    asm volatile(                                                         \
-        "eor    %1, %2, %2, ror #16\n"                                    \
-        "bic    %1, %1, #0x00ff0000\n"                                    \
-        "mov    %0, %2, ror #8\n"                                         \
-        "eor    %0, %0, %1, lsr #8"                                       \
-    : "=r" (out), "=&r" (tmp)                                             \
-    : "r" (v));                                                           \
-    out;})
-
 /* ----------------------------------------------------------------------- */
 #elif _MSC_VER
 /* ----------------------------------------------------------------------- */
@@ -154,11 +107,6 @@ const uint64_t mpoly = UINT64_C(0x1fffffff1fffffff);  /* Poly key mask     */
         (rh) += (ih) + ((rl) < (_il));                               \
     }
 
-#if _MSC_VER >= 1300
-#define GET_REVERSED_64(p) _byteswap_uint64(*(uint64_t *)(p))
-#pragma intrinsic(_byteswap_uint64)
-#endif
-
 #if _MSC_VER >= 1400 && \
     (!defined(__INTEL_COMPILER) || __INTEL_COMPILER >= 1000)
 #define MUL32(i1,i2)    (__emulu((uint32_t)(i1),(uint32_t)(i2)))
@@ -219,24 +167,6 @@ const uint64_t mpoly = UINT64_C(0x1fffffff1fffffff);  /* Poly key mask     */
     }
 #endif
 
-#ifndef GET_REVERSED_64
-#ifndef bswap64
-#ifndef bswap32
-#define bswap32(x)                                                        \
-  ({ uint32_t bsx = (x);                                                  \
-      ((((bsx) & 0xff000000u) >> 24) | (((bsx) & 0x00ff0000u) >>  8) |    \
-       (((bsx) & 0x0000ff00u) <<  8) | (((bsx) & 0x000000ffu) << 24)); })
-#endif
-#define bswap64(x)                                                        \
-     ({ union { uint64_t ll; uint32_t l[2]; } w, r;                       \
-         w.ll = (x);                                                      \
-         r.l[0] = bswap32 (w.l[1]);                                       \
-         r.l[1] = bswap32 (w.l[0]);                                       \
-         r.ll; })
-#endif
-#define GET_REVERSED_64(p) bswap64(*(uint64_t *)(p)) 
-#endif
-
 /* ----------------------------------------------------------------------- */
 
 #if (VMAC_PREFER_BIG_ENDIAN)
@@ -247,9 +177,9 @@ const uint64_t mpoly = UINT64_C(0x1fffffff1fffffff);  /* Poly key mask     */
 
 #if (VMAC_ARCH_BIG_ENDIAN)
 #  define get64BE(ptr) (*(uint64_t *)(ptr))
-#  define get64LE(ptr) GET_REVERSED_64(ptr)
+#  define get64LE(ptr) bswap64(*(uint64_t *)(ptr))
 #else /* assume little-endian */
-#  define get64BE(ptr) GET_REVERSED_64(ptr)
+#  define get64BE(ptr) bswap64(*(uint64_t *)(ptr))
 #  define get64LE(ptr) (*(uint64_t *)(ptr))
 #endif
 
-- 
2.39.5



^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH v5 11/16] xsm/flask: Switch {asm -> xen}/byteorder.h
  2025-03-28 13:44 [PATCH v5 00/16] xen: Centralise byteswap infrastructure Andrew Cooper
                   ` (9 preceding siblings ...)
  2025-03-28 13:44 ` [PATCH v5 10/16] crypto/vmac: Switch to xen/byteswap.h Andrew Cooper
@ 2025-03-28 13:44 ` Andrew Cooper
  2025-03-28 13:44 ` [PATCH v5 12/16] xen/common: " Andrew Cooper
                   ` (4 subsequent siblings)
  15 siblings, 0 replies; 30+ messages in thread
From: Andrew Cooper @ 2025-03-28 13:44 UTC (permalink / raw)
  To: Xen-devel
  Cc: Andrew Cooper, Anthony PERARD, Michal Orzel, Jan Beulich,
	Julien Grall, Roger Pau Monné, Stefano Stabellini,
	Volodymyr Babchuk, Bertrand Marquis, Shawn Anastasio,
	Oleksii Kurochko, Daniel P . Smith, Lin Liu

Sort the includes while at it.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Anthony PERARD <anthony.perard@vates.tech>
CC: Michal Orzel <michal.orzel@amd.com>
CC: Jan Beulich <jbeulich@suse.com>
CC: Julien Grall <julien@xen.org>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
CC: Bertrand Marquis <bertrand.marquis@arm.com>
CC: Shawn Anastasio <sanastasio@raptorengineering.com>
CC: Oleksii Kurochko <oleksii.kurochko@gmail.com>
CC: Daniel P. Smith <dpsmith@apertussolutions.com>
CC: Lin Liu <lin.liu@citrix.com>

v5:
 * New
---
 xen/xsm/flask/ss/avtab.c       | 4 ++--
 xen/xsm/flask/ss/conditional.c | 9 ++++-----
 xen/xsm/flask/ss/ebitmap.c     | 9 ++++-----
 xen/xsm/flask/ss/policydb.c    | 7 +++----
 4 files changed, 13 insertions(+), 16 deletions(-)

diff --git a/xen/xsm/flask/ss/avtab.c b/xen/xsm/flask/ss/avtab.c
index 9761d028d82d..2d07917e79e5 100644
--- a/xen/xsm/flask/ss/avtab.c
+++ b/xen/xsm/flask/ss/avtab.c
@@ -19,11 +19,11 @@
 
 /* Ported to Xen 3.0, George Coker, <gscoker@alpha.ncsc.mil> */
 
+#include <xen/byteorder.h>
+#include <xen/errno.h>
 #include <xen/lib.h>
-#include <asm/byteorder.h>
 #include <xen/types.h>
 #include <xen/xmalloc.h>
-#include <xen/errno.h>
 
 #include "avtab.h"
 #include "policydb.h"
diff --git a/xen/xsm/flask/ss/conditional.c b/xen/xsm/flask/ss/conditional.c
index d314f772b405..a0d255596204 100644
--- a/xen/xsm/flask/ss/conditional.c
+++ b/xen/xsm/flask/ss/conditional.c
@@ -9,15 +9,14 @@
 
 /* Ported to Xen 3.0, George Coker, <gscoker@alpha.ncsc.mil> */
 
-#include <xen/lib.h>
-#include <xen/types.h>
+#include <xen/byteorder.h>
 #include <xen/errno.h>
-#include <xen/string.h>
+#include <xen/lib.h>
 #include <xen/spinlock.h>
+#include <xen/string.h>
+#include <xen/types.h>
 #include <xen/xmalloc.h>
 
-#include <asm/byteorder.h>
-
 #include "security.h"
 #include "conditional.h"
 
diff --git a/xen/xsm/flask/ss/ebitmap.c b/xen/xsm/flask/ss/ebitmap.c
index 1db69d9ad1bd..1ced81ea0287 100644
--- a/xen/xsm/flask/ss/ebitmap.c
+++ b/xen/xsm/flask/ss/ebitmap.c
@@ -10,13 +10,12 @@
 
 /* Ported to Xen 3.0, George Coker, <gscoker@alpha.ncsc.mil> */
 
-#include <xen/lib.h>
-#include <xen/xmalloc.h>
+#include <xen/bitmap.h>
+#include <xen/byteorder.h>
 #include <xen/errno.h>
+#include <xen/lib.h>
 #include <xen/spinlock.h>
-#include <xen/bitmap.h>
-
-#include <asm/byteorder.h>
+#include <xen/xmalloc.h>
 
 #include "ebitmap.h"
 #include "policydb.h"
diff --git a/xen/xsm/flask/ss/policydb.c b/xen/xsm/flask/ss/policydb.c
index 5af45fdc2783..165304c1331c 100644
--- a/xen/xsm/flask/ss/policydb.c
+++ b/xen/xsm/flask/ss/policydb.c
@@ -22,13 +22,12 @@
 
 /* Ported to Xen 3.0, George Coker, <gscoker@alpha.ncsc.mil> */
 
+#include <xen/byteorder.h>
+#include <xen/errno.h>
 #include <xen/lib.h>
+#include <xen/string.h>
 #include <xen/types.h>
 #include <xen/xmalloc.h>
-#include <xen/string.h>
-#include <xen/errno.h>
-
-#include <asm/byteorder.h>
 
 #include <conditional.h>
 #include "security.h"
-- 
2.39.5



^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH v5 12/16] xen/common: Switch {asm -> xen}/byteorder.h
  2025-03-28 13:44 [PATCH v5 00/16] xen: Centralise byteswap infrastructure Andrew Cooper
                   ` (10 preceding siblings ...)
  2025-03-28 13:44 ` [PATCH v5 11/16] xsm/flask: Switch {asm -> xen}/byteorder.h Andrew Cooper
@ 2025-03-28 13:44 ` Andrew Cooper
  2025-03-31 13:58   ` Jan Beulich
  2025-03-28 13:44 ` [PATCH v5 13/16] arm: Remove asm/byteorder.h Andrew Cooper
                   ` (3 subsequent siblings)
  15 siblings, 1 reply; 30+ messages in thread
From: Andrew Cooper @ 2025-03-28 13:44 UTC (permalink / raw)
  To: Xen-devel
  Cc: Andrew Cooper, Anthony PERARD, Michal Orzel, Jan Beulich,
	Julien Grall, Roger Pau Monné, Stefano Stabellini,
	Volodymyr Babchuk, Bertrand Marquis, Shawn Anastasio,
	Oleksii Kurochko, Daniel P . Smith, Lin Liu

Sort the includes.  Drop useless includes of xen/types.h

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Anthony PERARD <anthony.perard@vates.tech>
CC: Michal Orzel <michal.orzel@amd.com>
CC: Jan Beulich <jbeulich@suse.com>
CC: Julien Grall <julien@xen.org>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
CC: Bertrand Marquis <bertrand.marquis@arm.com>
CC: Shawn Anastasio <sanastasio@raptorengineering.com>
CC: Oleksii Kurochko <oleksii.kurochko@gmail.com>
CC: Daniel P. Smith <dpsmith@apertussolutions.com>
CC: Lin Liu <lin.liu@citrix.com>

v5:
 * New
---
 xen/common/bitmap.c                 | 5 ++---
 xen/common/libelf/libelf-private.h  | 3 ++-
 xen/drivers/char/ehci-dbgp.c        | 4 +++-
 xen/include/xen/bitmap.h            | 2 +-
 xen/include/xen/device_tree.h       | 3 ++-
 xen/include/xen/libfdt/libfdt_env.h | 3 +--
 xen/include/xen/unaligned.h         | 3 +--
 7 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/xen/common/bitmap.c b/xen/common/bitmap.c
index 3da63a32a680..f605c98a02b2 100644
--- a/xen/common/bitmap.c
+++ b/xen/common/bitmap.c
@@ -5,14 +5,13 @@
  * This source code is licensed under the GNU General Public License,
  * Version 2.  See the file COPYING for more details.
  */
-#include <xen/types.h>
-#include <xen/errno.h>
 #include <xen/bitmap.h>
 #include <xen/bitops.h>
+#include <xen/byteorder.h>
 #include <xen/cpumask.h>
+#include <xen/errno.h>
 #include <xen/guest_access.h>
 #include <xen/lib.h>
-#include <asm/byteorder.h>
 
 /*
  * bitmaps provide an array of bits, implemented using an an
diff --git a/xen/common/libelf/libelf-private.h b/xen/common/libelf/libelf-private.h
index 65417dffc8a0..e5c9cc109972 100644
--- a/xen/common/libelf/libelf-private.h
+++ b/xen/common/libelf/libelf-private.h
@@ -17,10 +17,11 @@
 
 #ifdef __XEN__
 
+#include <xen/byteorder.h>
 #include <xen/lib.h>
 #include <xen/libelf.h>
 #include <xen/softirq.h>
-#include <asm/byteorder.h>
+
 #include <public/elfnote.h>
 
 /* we would like to use elf->log_callback but we can't because
diff --git a/xen/drivers/char/ehci-dbgp.c b/xen/drivers/char/ehci-dbgp.c
index 1ad3c6bebf87..e9cd59b25463 100644
--- a/xen/drivers/char/ehci-dbgp.c
+++ b/xen/drivers/char/ehci-dbgp.c
@@ -5,15 +5,17 @@
  * Linux; see the Linux source for authorship and copyrights.
  */
 
+#include <xen/byteorder.h>
 #include <xen/console.h>
 #include <xen/delay.h>
 #include <xen/errno.h>
 #include <xen/param.h>
 #include <xen/pci.h>
 #include <xen/serial.h>
-#include <asm/byteorder.h>
+
 #include <asm/io.h>
 #include <asm/fixmap.h>
+
 #include <public/physdev.h>
 
 /* #define DBGP_DEBUG */
diff --git a/xen/include/xen/bitmap.h b/xen/include/xen/bitmap.h
index 4b642cd4207b..b5e9cdd3db86 100644
--- a/xen/include/xen/bitmap.h
+++ b/xen/include/xen/bitmap.h
@@ -230,7 +230,7 @@ static inline unsigned int bitmap_weight(const unsigned long *src,
 	return __bitmap_weight(src, nbits);
 }
 
-#include <asm/byteorder.h>
+#include <xen/byteorder.h>
 
 #ifdef __LITTLE_ENDIAN
 #define BITMAP_MEM_ALIGNMENT 8
diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h
index 0ff80fda04da..6dc1fb5159cd 100644
--- a/xen/include/xen/device_tree.h
+++ b/xen/include/xen/device_tree.h
@@ -10,7 +10,8 @@
 #ifndef __XEN_DEVICE_TREE_H__
 #define __XEN_DEVICE_TREE_H__
 
-#include <asm/byteorder.h>
+#include <xen/byteorder.h>
+
 #include <asm/device.h>
 #include <public/xen.h>
 #include <public/device_tree_defs.h>
diff --git a/xen/include/xen/libfdt/libfdt_env.h b/xen/include/xen/libfdt/libfdt_env.h
index 8368787391b7..04abc6bb68c6 100644
--- a/xen/include/xen/libfdt/libfdt_env.h
+++ b/xen/include/xen/libfdt/libfdt_env.h
@@ -7,9 +7,8 @@
  * Copyright 2012 Kim Phillips, Freescale Semiconductor.
  */
 
-#include <xen/types.h>
+#include <xen/byteorder.h>
 #include <xen/string.h>
-#include <asm/byteorder.h>
 
 #ifdef __CHECKER__
 #define FDT_FORCE __attribute__((force))
diff --git a/xen/include/xen/unaligned.h b/xen/include/xen/unaligned.h
index 8c8b08338b8d..e64813ab4b20 100644
--- a/xen/include/xen/unaligned.h
+++ b/xen/include/xen/unaligned.h
@@ -3,8 +3,7 @@
 #define __XEN_UNALIGNED_H__
 
 #ifdef __XEN__
-#include <xen/types.h>
-#include <asm/byteorder.h>
+#include <xen/byteorder.h>
 #endif
 
 /*
-- 
2.39.5



^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH v5 13/16] arm: Remove asm/byteorder.h
  2025-03-28 13:44 [PATCH v5 00/16] xen: Centralise byteswap infrastructure Andrew Cooper
                   ` (11 preceding siblings ...)
  2025-03-28 13:44 ` [PATCH v5 12/16] xen/common: " Andrew Cooper
@ 2025-03-28 13:44 ` Andrew Cooper
  2025-03-28 13:44 ` [PATCH v5 14/16] ppc: Drop asm/byteorder.h Andrew Cooper
                   ` (2 subsequent siblings)
  15 siblings, 0 replies; 30+ messages in thread
From: Andrew Cooper @ 2025-03-28 13:44 UTC (permalink / raw)
  To: Xen-devel
  Cc: Andrew Cooper, Anthony PERARD, Michal Orzel, Jan Beulich,
	Julien Grall, Roger Pau Monné, Stefano Stabellini,
	Volodymyr Babchuk, Bertrand Marquis, Shawn Anastasio,
	Oleksii Kurochko, Daniel P . Smith, Lin Liu

With the common code moved fully onto xen/byteorder.h, clean up the dregs.

Sort includes in some files while swapping over to xen/byteorder.h.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Anthony PERARD <anthony.perard@vates.tech>
CC: Michal Orzel <michal.orzel@amd.com>
CC: Jan Beulich <jbeulich@suse.com>
CC: Julien Grall <julien@xen.org>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
CC: Bertrand Marquis <bertrand.marquis@arm.com>
CC: Shawn Anastasio <sanastasio@raptorengineering.com>
CC: Oleksii Kurochko <oleksii.kurochko@gmail.com>
CC: Daniel P. Smith <dpsmith@apertussolutions.com>
CC: Lin Liu <lin.liu@citrix.com>

v5:
 * New
---
 xen/arch/arm/alternative.c           |  6 +++---
 xen/arch/arm/arm64/livepatch.c       |  2 +-
 xen/arch/arm/include/asm/arm32/io.h  |  3 ++-
 xen/arch/arm/include/asm/arm64/io.h  |  3 ++-
 xen/arch/arm/include/asm/byteorder.h | 14 --------------
 xen/arch/arm/kernel.c                |  2 +-
 xen/arch/arm/vgic/vgic-mmio.c        |  3 ++-
 7 files changed, 11 insertions(+), 22 deletions(-)
 delete mode 100644 xen/arch/arm/include/asm/byteorder.h

diff --git a/xen/arch/arm/alternative.c b/xen/arch/arm/alternative.c
index 2c1af6e7e426..adb9b7d8814b 100644
--- a/xen/arch/arm/alternative.c
+++ b/xen/arch/arm/alternative.c
@@ -6,18 +6,18 @@
  * Copyright (C) 2014-2016 ARM Ltd.
  */
 
+#include <xen/byteorder.h>
 #include <xen/init.h>
-#include <xen/types.h>
 #include <xen/kernel.h>
 #include <xen/llc-coloring.h>
 #include <xen/mm.h>
-#include <xen/vmap.h>
 #include <xen/smp.h>
 #include <xen/stop_machine.h>
 #include <xen/virtual_region.h>
+#include <xen/vmap.h>
+
 #include <asm/alternative.h>
 #include <asm/atomic.h>
-#include <asm/byteorder.h>
 #include <asm/cpufeature.h>
 #include <asm/insn.h>
 #include <asm/page.h>
diff --git a/xen/arch/arm/arm64/livepatch.c b/xen/arch/arm/arm64/livepatch.c
index 6efe4ec770d4..e135bd5bf99a 100644
--- a/xen/arch/arm/arm64/livepatch.c
+++ b/xen/arch/arm/arm64/livepatch.c
@@ -3,6 +3,7 @@
  */
 
 #include <xen/bitops.h>
+#include <xen/byteorder.h>
 #include <xen/errno.h>
 #include <xen/lib.h>
 #include <xen/livepatch_elf.h>
@@ -11,7 +12,6 @@
 #include <xen/vmap.h>
 
 #include <asm/bitops.h>
-#include <asm/byteorder.h>
 #include <asm/insn.h>
 #include <asm/livepatch.h>
 
diff --git a/xen/arch/arm/include/asm/arm32/io.h b/xen/arch/arm/include/asm/arm32/io.h
index 782b564809e3..fb0425e62930 100644
--- a/xen/arch/arm/include/asm/arm32/io.h
+++ b/xen/arch/arm/include/asm/arm32/io.h
@@ -21,8 +21,9 @@
 #ifndef _ARM_ARM32_IO_H
 #define _ARM_ARM32_IO_H
 
+#include <xen/byteorder.h>
+
 #include <asm/system.h>
-#include <asm/byteorder.h>
 
 static inline void __raw_writeb(u8 val, volatile void __iomem *addr)
 {
diff --git a/xen/arch/arm/include/asm/arm64/io.h b/xen/arch/arm/include/asm/arm64/io.h
index 2e2ab24f7838..7d5959877759 100644
--- a/xen/arch/arm/include/asm/arm64/io.h
+++ b/xen/arch/arm/include/asm/arm64/io.h
@@ -20,8 +20,9 @@
 #ifndef _ARM_ARM64_IO_H
 #define _ARM_ARM64_IO_H
 
+#include <xen/byteorder.h>
+
 #include <asm/system.h>
-#include <asm/byteorder.h>
 #include <asm/alternative.h>
 
 /*
diff --git a/xen/arch/arm/include/asm/byteorder.h b/xen/arch/arm/include/asm/byteorder.h
deleted file mode 100644
index 7f1419c45a16..000000000000
--- a/xen/arch/arm/include/asm/byteorder.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef __ASM_ARM_BYTEORDER_H__
-#define __ASM_ARM_BYTEORDER_H__
-
-#include <xen/byteorder.h>
-
-#endif /* __ASM_ARM_BYTEORDER_H__ */
-/*
- * Local variables:
- * mode: C
- * c-file-style: "BSD"
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- */
diff --git a/xen/arch/arm/kernel.c b/xen/arch/arm/kernel.c
index 6eaf9e2b06b3..2647812e8e3e 100644
--- a/xen/arch/arm/kernel.c
+++ b/xen/arch/arm/kernel.c
@@ -4,6 +4,7 @@
  *
  * Copyright (C) 2011 Citrix Systems, Inc.
  */
+#include <xen/byteorder.h>
 #include <xen/domain_page.h>
 #include <xen/errno.h>
 #include <xen/guest_access.h>
@@ -15,7 +16,6 @@
 #include <xen/sched.h>
 #include <xen/vmap.h>
 
-#include <asm/byteorder.h>
 #include <asm/kernel.h>
 #include <asm/setup.h>
 
diff --git a/xen/arch/arm/vgic/vgic-mmio.c b/xen/arch/arm/vgic/vgic-mmio.c
index b4ba34cfc368..d2bcb32cd797 100644
--- a/xen/arch/arm/vgic/vgic-mmio.c
+++ b/xen/arch/arm/vgic/vgic-mmio.c
@@ -14,10 +14,11 @@
 
 #include <xen/bitops.h>
 #include <xen/bsearch.h>
+#include <xen/byteorder.h>
 #include <xen/lib.h>
 #include <xen/sched.h>
+
 #include <asm/new_vgic.h>
-#include <asm/byteorder.h>
 
 #include "vgic.h"
 #include "vgic-mmio.h"
-- 
2.39.5



^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH v5 14/16] ppc: Drop asm/byteorder.h
  2025-03-28 13:44 [PATCH v5 00/16] xen: Centralise byteswap infrastructure Andrew Cooper
                   ` (12 preceding siblings ...)
  2025-03-28 13:44 ` [PATCH v5 13/16] arm: Remove asm/byteorder.h Andrew Cooper
@ 2025-03-28 13:44 ` Andrew Cooper
  2025-03-28 13:44 ` [PATCH v5 15/16] riscv: Remove asm/byteorder.h Andrew Cooper
  2025-03-28 13:44 ` [PATCH v5 16/16] x86: Drop asm/byteorder.h Andrew Cooper
  15 siblings, 0 replies; 30+ messages in thread
From: Andrew Cooper @ 2025-03-28 13:44 UTC (permalink / raw)
  To: Xen-devel
  Cc: Andrew Cooper, Anthony PERARD, Michal Orzel, Jan Beulich,
	Julien Grall, Roger Pau Monné, Stefano Stabellini,
	Volodymyr Babchuk, Bertrand Marquis, Shawn Anastasio,
	Oleksii Kurochko, Daniel P . Smith, Lin Liu

With the common code moved fully onto xen/byteorder.h, clean up the dregs.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Anthony PERARD <anthony.perard@vates.tech>
CC: Michal Orzel <michal.orzel@amd.com>
CC: Jan Beulich <jbeulich@suse.com>
CC: Julien Grall <julien@xen.org>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
CC: Bertrand Marquis <bertrand.marquis@arm.com>
CC: Shawn Anastasio <sanastasio@raptorengineering.com>
CC: Oleksii Kurochko <oleksii.kurochko@gmail.com>
CC: Daniel P. Smith <dpsmith@apertussolutions.com>
CC: Lin Liu <lin.liu@citrix.com>

v5:
 * New
---
 xen/arch/ppc/include/asm/byteorder.h | 6 ------
 xen/arch/ppc/include/asm/page.h      | 4 +---
 xen/arch/ppc/mm-radix.c              | 2 +-
 3 files changed, 2 insertions(+), 10 deletions(-)
 delete mode 100644 xen/arch/ppc/include/asm/byteorder.h

diff --git a/xen/arch/ppc/include/asm/byteorder.h b/xen/arch/ppc/include/asm/byteorder.h
deleted file mode 100644
index 8df6adbf0d7d..000000000000
--- a/xen/arch/ppc/include/asm/byteorder.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef _ASM_PPC_BYTEORDER_H
-#define _ASM_PPC_BYTEORDER_H
-
-#include <xen/byteorder.h>
-
-#endif /* _ASM_PPC_BYTEORDER_H */
diff --git a/xen/arch/ppc/include/asm/page.h b/xen/arch/ppc/include/asm/page.h
index 6d4cd2611c2b..c6160afcfdb8 100644
--- a/xen/arch/ppc/include/asm/page.h
+++ b/xen/arch/ppc/include/asm/page.h
@@ -3,9 +3,7 @@
 #define _ASM_PPC_PAGE_H
 
 #include <xen/bitops.h>
-#include <xen/types.h>
-
-#include <asm/byteorder.h>
+#include <xen/byteorder.h>
 
 #define PDE_VALID     PPC_BIT(0)
 #define PDE_NLB_MASK  0x1ffffffffffffe0UL
diff --git a/xen/arch/ppc/mm-radix.c b/xen/arch/ppc/mm-radix.c
index 24232f3907aa..9a00ae416af0 100644
--- a/xen/arch/ppc/mm-radix.c
+++ b/xen/arch/ppc/mm-radix.c
@@ -1,5 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0-or-later */
 #include <xen/bitops.h>
+#include <xen/byteorder.h>
 #include <xen/init.h>
 #include <xen/kernel.h>
 #include <xen/mm.h>
@@ -7,7 +8,6 @@
 #include <xen/types.h>
 #include <xen/lib.h>
 
-#include <asm/byteorder.h>
 #include <asm/early_printk.h>
 #include <asm/page.h>
 #include <asm/processor.h>
-- 
2.39.5



^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH v5 15/16] riscv: Remove asm/byteorder.h
  2025-03-28 13:44 [PATCH v5 00/16] xen: Centralise byteswap infrastructure Andrew Cooper
                   ` (13 preceding siblings ...)
  2025-03-28 13:44 ` [PATCH v5 14/16] ppc: Drop asm/byteorder.h Andrew Cooper
@ 2025-03-28 13:44 ` Andrew Cooper
  2025-03-31 14:52   ` Oleksii Kurochko
  2025-03-28 13:44 ` [PATCH v5 16/16] x86: Drop asm/byteorder.h Andrew Cooper
  15 siblings, 1 reply; 30+ messages in thread
From: Andrew Cooper @ 2025-03-28 13:44 UTC (permalink / raw)
  To: Xen-devel
  Cc: Andrew Cooper, Anthony PERARD, Michal Orzel, Jan Beulich,
	Julien Grall, Roger Pau Monné, Stefano Stabellini,
	Volodymyr Babchuk, Bertrand Marquis, Shawn Anastasio,
	Oleksii Kurochko, Daniel P . Smith, Lin Liu

With the common code moved fully onto xen/byteorder.h, clean up the dregs.

The use of byteorder.h in io.h appears to have been copy&paste from ARM.  It's
not needed, but macros and types are.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Anthony PERARD <anthony.perard@vates.tech>
CC: Michal Orzel <michal.orzel@amd.com>
CC: Jan Beulich <jbeulich@suse.com>
CC: Julien Grall <julien@xen.org>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
CC: Bertrand Marquis <bertrand.marquis@arm.com>
CC: Shawn Anastasio <sanastasio@raptorengineering.com>
CC: Oleksii Kurochko <oleksii.kurochko@gmail.com>
CC: Daniel P. Smith <dpsmith@apertussolutions.com>
CC: Lin Liu <lin.liu@citrix.com>

v5:
 * New
---
 xen/arch/riscv/include/asm/byteorder.h | 14 --------------
 xen/arch/riscv/include/asm/io.h        |  3 ++-
 2 files changed, 2 insertions(+), 15 deletions(-)
 delete mode 100644 xen/arch/riscv/include/asm/byteorder.h

diff --git a/xen/arch/riscv/include/asm/byteorder.h b/xen/arch/riscv/include/asm/byteorder.h
deleted file mode 100644
index a32bca02df38..000000000000
--- a/xen/arch/riscv/include/asm/byteorder.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef ASM__RISCV__BYTEORDER_H
-#define ASM__RISCV__BYTEORDER_H
-
-#include <xen/byteorder.h>
-
-#endif /* ASM__RISCV__BYTEORDER_H */
-/*
- * Local variables:
- * mode: C
- * c-file-style: "BSD"
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- */
diff --git a/xen/arch/riscv/include/asm/io.h b/xen/arch/riscv/include/asm/io.h
index 55f329dde321..8bab4ffa0390 100644
--- a/xen/arch/riscv/include/asm/io.h
+++ b/xen/arch/riscv/include/asm/io.h
@@ -38,7 +38,8 @@
 #ifndef ASM__RISCV__IO_H
 #define ASM__RISCV__IO_H
 
-#include <asm/byteorder.h>
+#include <xen/macros.h>
+#include <xen/types.h>
 
 /*
  * The RISC-V ISA doesn't yet specify how to query or modify PMAs, so we can't
-- 
2.39.5



^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH v5 16/16] x86: Drop asm/byteorder.h
  2025-03-28 13:44 [PATCH v5 00/16] xen: Centralise byteswap infrastructure Andrew Cooper
                   ` (14 preceding siblings ...)
  2025-03-28 13:44 ` [PATCH v5 15/16] riscv: Remove asm/byteorder.h Andrew Cooper
@ 2025-03-28 13:44 ` Andrew Cooper
  2025-03-31 14:12   ` Jan Beulich
  15 siblings, 1 reply; 30+ messages in thread
From: Andrew Cooper @ 2025-03-28 13:44 UTC (permalink / raw)
  To: Xen-devel
  Cc: Andrew Cooper, Anthony PERARD, Michal Orzel, Jan Beulich,
	Julien Grall, Roger Pau Monné, Stefano Stabellini,
	Volodymyr Babchuk, Bertrand Marquis, Shawn Anastasio,
	Oleksii Kurochko, Daniel P . Smith, Lin Liu

With the common code moved fully onto xen/byteorder.h, clean up the dregs.

It turns out that msi.h has not needed byteorder.h since the use of
__{BIG,LITTLE}_ENDIAN_BITFIELD was dropped in commit d58f3941ce3f ("x86/MSI:
use standard C types in structures/unions").

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Anthony PERARD <anthony.perard@vates.tech>
CC: Michal Orzel <michal.orzel@amd.com>
CC: Jan Beulich <jbeulich@suse.com>
CC: Julien Grall <julien@xen.org>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
CC: Bertrand Marquis <bertrand.marquis@arm.com>
CC: Shawn Anastasio <sanastasio@raptorengineering.com>
CC: Oleksii Kurochko <oleksii.kurochko@gmail.com>
CC: Daniel P. Smith <dpsmith@apertussolutions.com>
CC: Lin Liu <lin.liu@citrix.com>

v5:
 * New
---
 xen/arch/x86/include/asm/byteorder.h | 6 ------
 xen/arch/x86/include/asm/msi.h       | 1 -
 2 files changed, 7 deletions(-)
 delete mode 100644 xen/arch/x86/include/asm/byteorder.h

diff --git a/xen/arch/x86/include/asm/byteorder.h b/xen/arch/x86/include/asm/byteorder.h
deleted file mode 100644
index 3524a6cee741..000000000000
--- a/xen/arch/x86/include/asm/byteorder.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef __ASM_X86_BYTEORDER_H__
-#define __ASM_X86_BYTEORDER_H__
-
-#include <xen/byteorder.h>
-
-#endif /* __ASM_X86_BYTEORDER_H__ */
diff --git a/xen/arch/x86/include/asm/msi.h b/xen/arch/x86/include/asm/msi.h
index 975d0f26b35d..00059d4a3a9d 100644
--- a/xen/arch/x86/include/asm/msi.h
+++ b/xen/arch/x86/include/asm/msi.h
@@ -3,7 +3,6 @@
 
 #include <xen/cpumask.h>
 #include <xen/pci.h>
-#include <asm/byteorder.h>
 #include <asm/hvm/vmx/vmcs.h>
 
 /*
-- 
2.39.5



^ permalink raw reply related	[flat|nested] 30+ messages in thread

* Re: [PATCH v5 06/16] xen/decompressors: Remove use of *_to_cpup() helpers
  2025-03-28 13:44 ` [PATCH v5 06/16] xen/decompressors: " Andrew Cooper
@ 2025-03-28 14:07   ` Andrew Cooper
  0 siblings, 0 replies; 30+ messages in thread
From: Andrew Cooper @ 2025-03-28 14:07 UTC (permalink / raw)
  To: Xen-devel
  Cc: Lin Liu, Anthony PERARD, Michal Orzel, Jan Beulich, Julien Grall,
	Roger Pau Monné, Stefano Stabellini, Volodymyr Babchuk,
	Bertrand Marquis, Shawn Anastasio, Oleksii Kurochko,
	Daniel P . Smith

On 28/03/2025 1:44 pm, Andrew Cooper wrote:
> From: Lin Liu <lin.liu@citrix.com>
>
> These wrappers simply hide a deference, which adds to the cognitive complexity
> of reading the code.  As such, they're not going to be included in the new
> byteswap infrastructure.
>
> No functional change.
>
> Signed-off-by: Lin Liu <lin.liu@citrix.com>
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> ---
> CC: Anthony PERARD <anthony.perard@vates.tech>
> CC: Michal Orzel <michal.orzel@amd.com>
> CC: Jan Beulich <jbeulich@suse.com>
> CC: Julien Grall <julien@xen.org>
> CC: Roger Pau Monné <roger.pau@citrix.com>
> CC: Stefano Stabellini <sstabellini@kernel.org>
> CC: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
> CC: Bertrand Marquis <bertrand.marquis@arm.com>
> CC: Shawn Anastasio <sanastasio@raptorengineering.com>
> CC: Oleksii Kurochko <oleksii.kurochko@gmail.com>
> CC: Daniel P. Smith <dpsmith@apertussolutions.com>
> CC: Lin Liu <lin.liu@citrix.com>
>
> v5:
>  * Rebase
>  * Rearranged from other patches
> ---
>  tools/libs/guest/xg_dom_decompress_unsafe_xz.c | 13 +++++++------
>  xen/common/lz4/defs.h                          |  6 +++++-
>  xen/common/xz/private.h                        | 12 +++++++++---

CI says that there's more lz4 and lzo1x to clean up.  Fixed locally, but
I won't repost for now.


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH v5 01/16] xen/lzo: Remove more remanants of TMEM
  2025-03-28 13:44 ` [PATCH v5 01/16] xen/lzo: Remove more remanants of TMEM Andrew Cooper
@ 2025-03-31  7:30   ` Jan Beulich
  0 siblings, 0 replies; 30+ messages in thread
From: Jan Beulich @ 2025-03-31  7:30 UTC (permalink / raw)
  To: Andrew Cooper
  Cc: Anthony PERARD, Michal Orzel, Julien Grall, Roger Pau Monné,
	Stefano Stabellini, Volodymyr Babchuk, Bertrand Marquis,
	Shawn Anastasio, Oleksii Kurochko, Daniel P . Smith, Lin Liu,
	Xen-devel

On 28.03.2025 14:44, Andrew Cooper wrote:
> This logic was inserted by commit 447f613c5404 ("lzo: update LZO compression
> to current upstream version") but was only relevant for the TMEM logic, so
> should have been deleted in commit c492e19fdd05 ("xen: remove tmem from
> hypervisor")
> 
> Fixes: c492e19fdd05 ("xen: remove tmem from hypervisor")
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>

Acked-by: Jan Beulich <jbeulich@suse.com>




^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH v5 02/16] xen: Remove __{BIG,LITTLE}_ENDIAN_BITFIELD
  2025-03-28 13:44 ` [PATCH v5 02/16] xen: Remove __{BIG,LITTLE}_ENDIAN_BITFIELD Andrew Cooper
@ 2025-03-31  7:42   ` Jan Beulich
  2025-03-31 14:08     ` Andrew Cooper
  0 siblings, 1 reply; 30+ messages in thread
From: Jan Beulich @ 2025-03-31  7:42 UTC (permalink / raw)
  To: Andrew Cooper
  Cc: Anthony PERARD, Michal Orzel, Julien Grall, Roger Pau Monné,
	Stefano Stabellini, Volodymyr Babchuk, Bertrand Marquis,
	Shawn Anastasio, Oleksii Kurochko, Daniel P . Smith, Lin Liu,
	Xen-devel

On 28.03.2025 14:44, Andrew Cooper wrote:
> There is a singular user.  It's unlikely we'll gain a big-endian build of Xen,
> but it's far more unlikely that bitfields will differ from main endianness.

Just one point: While endian-ness in general is dictated by hardware, endian-
ness of bitfields is entirely a psABI thing, aiui. Hence tying both together
(beyond the latter defaulting to the former) doesn't seem quite appropriate
to me.

> I'm tempted to simply drop the logic in maptrack_node.  If any big-endian
> build of Xen came along, that's probably the least of it's worries.

As long as it's not obviously broken, I'd prefer to keep such. While it may
not be a primary worry, it's still one less of all the worries then.

Jan


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH v5 03/16] xen: Implement common byte{order,swap}.h
  2025-03-28 13:44 ` [PATCH v5 03/16] xen: Implement common byte{order,swap}.h Andrew Cooper
@ 2025-03-31  8:32   ` Jan Beulich
  2025-03-31 13:59     ` Andrew Cooper
  0 siblings, 1 reply; 30+ messages in thread
From: Jan Beulich @ 2025-03-31  8:32 UTC (permalink / raw)
  To: Andrew Cooper
  Cc: Lin Liu, Anthony PERARD, Michal Orzel, Julien Grall,
	Roger Pau Monné, Stefano Stabellini, Volodymyr Babchuk,
	Bertrand Marquis, Shawn Anastasio, Oleksii Kurochko,
	Daniel P . Smith, Xen-devel

On 28.03.2025 14:44, Andrew Cooper wrote:
> From: Lin Liu <lin.liu@citrix.com>
> 
> The current swab??() infrastructure is unecesserily complicated, and can be
> repated entirely with compiler builtins.
> 
> All supported compilers provide __BYTE_ORDER__ and __builtin_bswap??().
> 
> Nothing in Xen cares about the values of __{BIG,LITTLE}_ENDIAN; just that one
> of them is defined.  Therefore, centralise their definitions in xen/config.h

And even if we cared somewhere, __ORDER_{BIG,LITTLE}_ENDIAN__ supply them
just fine.

> Signed-off-by: Lin Liu <lin.liu@citrix.com>
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>

Reviewed-by: Jan Beulich <jbeulich@suse.com>
with two nits taken care of:

> --- /dev/null
> +++ b/xen/include/xen/byteorder.h
> @@ -0,0 +1,44 @@
> +/* SPDX-License-Identifier: GPL-2.0-or-later */
> +#ifndef XEN_BYTEORDER_H
> +#define XEN_BYTEORDER_H
> +
> +#include <xen/byteswap.h>
> +#include <xen/types.h>

It's stdint.h that's needed here, not types.h?

> +#if defined(__LITTLE_ENDIAN)
> +
> +# define cpu_to_le64(x) (uint64_t)(x)
> +# define le64_to_cpu(x) (uint64_t)(x)
> +# define cpu_to_le32(x) (uint32_t)(x)
> +# define le32_to_cpu(x) (uint32_t)(x)
> +# define cpu_to_le16(x) (uint16_t)(x)
> +# define le16_to_cpu(x) (uint16_t)(x)

(Not just) for Misra these all need another pair of parentheses around the
entire expressions.

> +# define cpu_to_be64(x) bswap64(x)
> +# define be64_to_cpu(x) bswap64(x)
> +# define cpu_to_be32(x) bswap32(x)
> +# define be32_to_cpu(x) bswap32(x)
> +# define cpu_to_be16(x) bswap16(x)
> +# define be16_to_cpu(x) bswap16(x)
> +
> +#elif defined(__BIG_ENDIAN)
> +
> +# define cpu_to_le64(x) bswap64(x)
> +# define le64_to_cpu(x) bswap64(x)
> +# define cpu_to_le32(x) bswap32(x)
> +# define le32_to_cpu(x) bswap32(x)
> +# define cpu_to_le16(x) bswap16(x)
> +# define le16_to_cpu(x) bswap16(x)
> +
> +# define cpu_to_be64(x) (uint64_t)(x)
> +# define be64_to_cpu(x) (uint64_t)(x)
> +# define cpu_to_be32(x) (uint32_t)(x)
> +# define be32_to_cpu(x) (uint32_t)(x)
> +# define cpu_to_be16(x) (uint16_t)(x)
> +# define be16_to_cpu(x) (uint16_t)(x)

Same here, even if Eclair likely wouldn't spot this right now.

Jan


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH v5 04/16] xen/lib: Switch to xen/byteorder.h
  2025-03-28 13:44 ` [PATCH v5 04/16] xen/lib: Switch to xen/byteorder.h Andrew Cooper
@ 2025-03-31  8:44   ` Jan Beulich
  0 siblings, 0 replies; 30+ messages in thread
From: Jan Beulich @ 2025-03-31  8:44 UTC (permalink / raw)
  To: Andrew Cooper
  Cc: Lin Liu, Anthony PERARD, Michal Orzel, Julien Grall,
	Roger Pau Monné, Stefano Stabellini, Volodymyr Babchuk,
	Bertrand Marquis, Shawn Anastasio, Oleksii Kurochko,
	Daniel P . Smith, Xen-devel

On 28.03.2025 14:44, Andrew Cooper wrote:
> From: Lin Liu <lin.liu@citrix.com>
> 
> In divmod.c, additionally swap xen/lib.h for xen/macros.h as only ABS() is
> needed.
> 
> In find-next-bit.c, ext2 has nothing to do with this logic.

While I agree here, ...

>  Despite the
> comments, it was a local modification when the logic was imported from Linux,
> because Xen didn't have a suitable helper.

... I certainly can see functions of these names in Linux 2.6.16. Just in the
PA-RISC bitops.h, though. Yet this may be an indication that yet earlier on
this was a wider thing there.

> The new infrsatructure does have a suitable primitive, so use it.
> 
> No functional change.
> 
> Signed-off-by: Lin Liu <lin.liu@citrix.com>

Missing your own S-o-b?

Reviewed-by: Jan Beulich <jbeulich@suse.com>

Jan


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH v5 07/16] xen/arch: Switch to new byteorder infrastructure
  2025-03-28 13:44 ` [PATCH v5 07/16] xen/arch: Switch to new byteorder infrastructure Andrew Cooper
@ 2025-03-31 13:53   ` Jan Beulich
  0 siblings, 0 replies; 30+ messages in thread
From: Jan Beulich @ 2025-03-31 13:53 UTC (permalink / raw)
  To: Andrew Cooper
  Cc: Lin Liu, Anthony PERARD, Michal Orzel, Julien Grall,
	Roger Pau Monné, Stefano Stabellini, Volodymyr Babchuk,
	Bertrand Marquis, Shawn Anastasio, Oleksii Kurochko,
	Daniel P . Smith, Xen-devel

On 28.03.2025 14:44, Andrew Cooper wrote:
> From: Lin Liu <lin.liu@citrix.com>
> 
> This needs to be done in several steps, because of common vs arch issues.
> Start by using the new common infastructure inside the arch infrastructure.
> 
> libelf-private.h is awkward, and the only thing in Xen using swabXX()
> directly.  It needs updating at the same time.
> 
> Signed-off-by: Lin Liu <lin.liu@citrix.com>
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>

Reviewed-by: Jan Beulich <jbeulich@suse.com>




^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH v5 08/16] xen/decompressors: Use new byteorder infrastructure
  2025-03-28 13:44 ` [PATCH v5 08/16] xen/decompressors: Use " Andrew Cooper
@ 2025-03-31 13:55   ` Jan Beulich
  0 siblings, 0 replies; 30+ messages in thread
From: Jan Beulich @ 2025-03-31 13:55 UTC (permalink / raw)
  To: Andrew Cooper
  Cc: Lin Liu, Anthony PERARD, Michal Orzel, Julien Grall,
	Roger Pau Monné, Stefano Stabellini, Volodymyr Babchuk,
	Bertrand Marquis, Shawn Anastasio, Oleksii Kurochko,
	Daniel P . Smith, Xen-devel

On 28.03.2025 14:44, Andrew Cooper wrote:
> From: Lin Liu <lin.liu@citrix.com>
> 
> unaligned.h already inlcudes byteorder.h, so most can simply be dropped.
> 
> No functional change.
> 
> Signed-off-by: Lin Liu <lin.liu@citrix.com>

Nit: Again missing your own S-o-b?

Acked-by: Jan Beulich <jbeulich@suse.com>

Jan


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH v5 12/16] xen/common: Switch {asm -> xen}/byteorder.h
  2025-03-28 13:44 ` [PATCH v5 12/16] xen/common: " Andrew Cooper
@ 2025-03-31 13:58   ` Jan Beulich
  0 siblings, 0 replies; 30+ messages in thread
From: Jan Beulich @ 2025-03-31 13:58 UTC (permalink / raw)
  To: Andrew Cooper
  Cc: Anthony PERARD, Michal Orzel, Julien Grall, Roger Pau Monné,
	Stefano Stabellini, Volodymyr Babchuk, Bertrand Marquis,
	Shawn Anastasio, Oleksii Kurochko, Daniel P . Smith, Lin Liu,
	Xen-devel

On 28.03.2025 14:44, Andrew Cooper wrote:
> Sort the includes.  Drop useless includes of xen/types.h
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>

Acked-by: Jan Beulich <jbeulich@suse.com>




^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH v5 03/16] xen: Implement common byte{order,swap}.h
  2025-03-31  8:32   ` Jan Beulich
@ 2025-03-31 13:59     ` Andrew Cooper
  2025-03-31 14:08       ` Jan Beulich
  0 siblings, 1 reply; 30+ messages in thread
From: Andrew Cooper @ 2025-03-31 13:59 UTC (permalink / raw)
  To: Jan Beulich
  Cc: Lin Liu, Anthony PERARD, Michal Orzel, Julien Grall,
	Roger Pau Monné, Stefano Stabellini, Volodymyr Babchuk,
	Bertrand Marquis, Shawn Anastasio, Oleksii Kurochko,
	Daniel P . Smith, Xen-devel

On 31/03/2025 9:32 am, Jan Beulich wrote:
> On 28.03.2025 14:44, Andrew Cooper wrote:
>> From: Lin Liu <lin.liu@citrix.com>
>>
>> The current swab??() infrastructure is unecesserily complicated, and can be
>> repated entirely with compiler builtins.
>>
>> All supported compilers provide __BYTE_ORDER__ and __builtin_bswap??().
>>
>> Nothing in Xen cares about the values of __{BIG,LITTLE}_ENDIAN; just that one
>> of them is defined.  Therefore, centralise their definitions in xen/config.h
> And even if we cared somewhere, __ORDER_{BIG,LITTLE}_ENDIAN__ supply them
> just fine.
>
>> Signed-off-by: Lin Liu <lin.liu@citrix.com>
>> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> Reviewed-by: Jan Beulich <jbeulich@suse.com>
> with two nits taken care of:
>
>> --- /dev/null
>> +++ b/xen/include/xen/byteorder.h
>> @@ -0,0 +1,44 @@
>> +/* SPDX-License-Identifier: GPL-2.0-or-later */
>> +#ifndef XEN_BYTEORDER_H
>> +#define XEN_BYTEORDER_H
>> +
>> +#include <xen/byteswap.h>
>> +#include <xen/types.h>
> It's stdint.h that's needed here, not types.h?

Perhaps.

>
>> +#if defined(__LITTLE_ENDIAN)
>> +
>> +# define cpu_to_le64(x) (uint64_t)(x)
>> +# define le64_to_cpu(x) (uint64_t)(x)
>> +# define cpu_to_le32(x) (uint32_t)(x)
>> +# define le32_to_cpu(x) (uint32_t)(x)
>> +# define cpu_to_le16(x) (uint16_t)(x)
>> +# define le16_to_cpu(x) (uint16_t)(x)
> (Not just) for Misra these all need another pair of parentheses around the
> entire expressions.

Why?  For both points?  Eclair is happy, with this at least.

What does fail is a bit a of a curveball.

https://saas.eclairit.com:3787/fs/var/local/eclair/xen-project.ecdf/xen-project/people/andyhhp/xen/ECLAIR_normal/xen-bswap/ARM64/9556392204/PROJECT.ecd;/by_service/MC3A2.R20.6.html

cpu_to_le64() turns from a real function to a macro under ARM, meaning
that the #ifdef __BIG_ENDIAN in the middle of a bunch of constants
becomes UB.

I'll need to fix that separately.

~Andrew


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH v5 03/16] xen: Implement common byte{order,swap}.h
  2025-03-31 13:59     ` Andrew Cooper
@ 2025-03-31 14:08       ` Jan Beulich
  0 siblings, 0 replies; 30+ messages in thread
From: Jan Beulich @ 2025-03-31 14:08 UTC (permalink / raw)
  To: Andrew Cooper
  Cc: Lin Liu, Anthony PERARD, Michal Orzel, Julien Grall,
	Roger Pau Monné, Stefano Stabellini, Volodymyr Babchuk,
	Bertrand Marquis, Shawn Anastasio, Oleksii Kurochko,
	Daniel P . Smith, Xen-devel

On 31.03.2025 15:59, Andrew Cooper wrote:
> On 31/03/2025 9:32 am, Jan Beulich wrote:
>> On 28.03.2025 14:44, Andrew Cooper wrote:
>>> +#if defined(__LITTLE_ENDIAN)
>>> +
>>> +# define cpu_to_le64(x) (uint64_t)(x)
>>> +# define le64_to_cpu(x) (uint64_t)(x)
>>> +# define cpu_to_le32(x) (uint32_t)(x)
>>> +# define le32_to_cpu(x) (uint32_t)(x)
>>> +# define cpu_to_le16(x) (uint16_t)(x)
>>> +# define le16_to_cpu(x) (uint16_t)(x)
>> (Not just) for Misra these all need another pair of parentheses around the
>> entire expressions.
> 
> Why?  For both points?  Eclair is happy, with this at least.

As was explained to us, Eclair looks at the final, expanded code. Hence it may
well be that right now, in the code Eclair checks, we have no violations. Ones
may start to appear elsewhere or later, though. The fix then would still be to
get these macros into fully parenthesized shape.

That said, I can't think of any "good" code needing these parentheses here. I
can think of bad code though, which would properly fail to compile if the
parentheses were added, e.g.

    le32_to_cpu(a)++;

I fear I can't answer the 2nd question - what do you mean by "For both points?"?

Jan


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH v5 02/16] xen: Remove __{BIG,LITTLE}_ENDIAN_BITFIELD
  2025-03-31  7:42   ` Jan Beulich
@ 2025-03-31 14:08     ` Andrew Cooper
  0 siblings, 0 replies; 30+ messages in thread
From: Andrew Cooper @ 2025-03-31 14:08 UTC (permalink / raw)
  To: Jan Beulich
  Cc: Anthony PERARD, Michal Orzel, Julien Grall, Roger Pau Monné,
	Stefano Stabellini, Volodymyr Babchuk, Bertrand Marquis,
	Shawn Anastasio, Oleksii Kurochko, Daniel P . Smith, Lin Liu,
	Xen-devel

On 31/03/2025 8:42 am, Jan Beulich wrote:
> On 28.03.2025 14:44, Andrew Cooper wrote:
>> There is a singular user.  It's unlikely we'll gain a big-endian build of Xen,
>> but it's far more unlikely that bitfields will differ from main endianness.
> Just one point: While endian-ness in general is dictated by hardware, endian-
> ness of bitfields is entirely a psABI thing, aiui. Hence tying both together
> (beyond the latter defaulting to the former) doesn't seem quite appropriate
> to me.
>
>> I'm tempted to simply drop the logic in maptrack_node.  If any big-endian
>> build of Xen came along, that's probably the least of it's worries.
> As long as it's not obviously broken, I'd prefer to keep such. While it may
> not be a primary worry, it's still one less of all the worries then.

Given the way patch 3 has ended up, this is easier to keep than in
earlier revisions.

Still, I think it's of very dubious utility.

~Andrew


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH v5 16/16] x86: Drop asm/byteorder.h
  2025-03-28 13:44 ` [PATCH v5 16/16] x86: Drop asm/byteorder.h Andrew Cooper
@ 2025-03-31 14:12   ` Jan Beulich
  0 siblings, 0 replies; 30+ messages in thread
From: Jan Beulich @ 2025-03-31 14:12 UTC (permalink / raw)
  To: Andrew Cooper
  Cc: Anthony PERARD, Michal Orzel, Julien Grall, Roger Pau Monné,
	Stefano Stabellini, Volodymyr Babchuk, Bertrand Marquis,
	Shawn Anastasio, Oleksii Kurochko, Daniel P . Smith, Lin Liu,
	Xen-devel

On 28.03.2025 14:44, Andrew Cooper wrote:
> With the common code moved fully onto xen/byteorder.h, clean up the dregs.
> 
> It turns out that msi.h has not needed byteorder.h since the use of
> __{BIG,LITTLE}_ENDIAN_BITFIELD was dropped in commit d58f3941ce3f ("x86/MSI:
> use standard C types in structures/unions").
> 
> No functional change.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>

Acked-by: Jan Beulich <jbeulich@suse.com>




^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH v5 15/16] riscv: Remove asm/byteorder.h
  2025-03-28 13:44 ` [PATCH v5 15/16] riscv: Remove asm/byteorder.h Andrew Cooper
@ 2025-03-31 14:52   ` Oleksii Kurochko
  0 siblings, 0 replies; 30+ messages in thread
From: Oleksii Kurochko @ 2025-03-31 14:52 UTC (permalink / raw)
  To: Andrew Cooper, Xen-devel
  Cc: Anthony PERARD, Michal Orzel, Jan Beulich, Julien Grall,
	Roger Pau Monné, Stefano Stabellini, Volodymyr Babchuk,
	Bertrand Marquis, Shawn Anastasio, Daniel P . Smith, Lin Liu

[-- Attachment #1: Type: text/plain, Size: 2209 bytes --]


On 3/28/25 2:44 PM, Andrew Cooper wrote:
> With the common code moved fully onto xen/byteorder.h, clean up the dregs.
>
> The use of byteorder.h in io.h appears to have been copy&paste from ARM.  It's
> not needed, but macros and types are.
>
> No functional change.
>
> Signed-off-by: Andrew Cooper<andrew.cooper3@citrix.com>

Reviewed-by:Oleksii Kurochko <oleksii.kurochko@gmail.com>

Thanks.

~ Oleksii

> ---
> CC: Anthony PERARD<anthony.perard@vates.tech>
> CC: Michal Orzel<michal.orzel@amd.com>
> CC: Jan Beulich<jbeulich@suse.com>
> CC: Julien Grall<julien@xen.org>
> CC: Roger Pau Monné<roger.pau@citrix.com>
> CC: Stefano Stabellini<sstabellini@kernel.org>
> CC: Volodymyr Babchuk<Volodymyr_Babchuk@epam.com>
> CC: Bertrand Marquis<bertrand.marquis@arm.com>
> CC: Shawn Anastasio<sanastasio@raptorengineering.com>
> CC: Oleksii Kurochko<oleksii.kurochko@gmail.com>
> CC: Daniel P. Smith<dpsmith@apertussolutions.com>
> CC: Lin Liu<lin.liu@citrix.com>
>
> v5:
>   * New
> ---
>   xen/arch/riscv/include/asm/byteorder.h | 14 --------------
>   xen/arch/riscv/include/asm/io.h        |  3 ++-
>   2 files changed, 2 insertions(+), 15 deletions(-)
>   delete mode 100644 xen/arch/riscv/include/asm/byteorder.h
>
> diff --git a/xen/arch/riscv/include/asm/byteorder.h b/xen/arch/riscv/include/asm/byteorder.h
> deleted file mode 100644
> index a32bca02df38..000000000000
> --- a/xen/arch/riscv/include/asm/byteorder.h
> +++ /dev/null
> @@ -1,14 +0,0 @@
> -#ifndef ASM__RISCV__BYTEORDER_H
> -#define ASM__RISCV__BYTEORDER_H
> -
> -#include <xen/byteorder.h>
> -
> -#endif /* ASM__RISCV__BYTEORDER_H */
> -/*
> - * Local variables:
> - * mode: C
> - * c-file-style: "BSD"
> - * c-basic-offset: 4
> - * indent-tabs-mode: nil
> - * End:
> - */
> diff --git a/xen/arch/riscv/include/asm/io.h b/xen/arch/riscv/include/asm/io.h
> index 55f329dde321..8bab4ffa0390 100644
> --- a/xen/arch/riscv/include/asm/io.h
> +++ b/xen/arch/riscv/include/asm/io.h
> @@ -38,7 +38,8 @@
>   #ifndef ASM__RISCV__IO_H
>   #define ASM__RISCV__IO_H
>   
> -#include <asm/byteorder.h>
> +#include <xen/macros.h>
> +#include <xen/types.h>
>   
>   /*
>    * The RISC-V ISA doesn't yet specify how to query or modify PMAs, so we can't

[-- Attachment #2: Type: text/html, Size: 3965 bytes --]

^ permalink raw reply	[flat|nested] 30+ messages in thread

end of thread, other threads:[~2025-03-31 14:52 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-28 13:44 [PATCH v5 00/16] xen: Centralise byteswap infrastructure Andrew Cooper
2025-03-28 13:44 ` [PATCH v5 01/16] xen/lzo: Remove more remanants of TMEM Andrew Cooper
2025-03-31  7:30   ` Jan Beulich
2025-03-28 13:44 ` [PATCH v5 02/16] xen: Remove __{BIG,LITTLE}_ENDIAN_BITFIELD Andrew Cooper
2025-03-31  7:42   ` Jan Beulich
2025-03-31 14:08     ` Andrew Cooper
2025-03-28 13:44 ` [PATCH v5 03/16] xen: Implement common byte{order,swap}.h Andrew Cooper
2025-03-31  8:32   ` Jan Beulich
2025-03-31 13:59     ` Andrew Cooper
2025-03-31 14:08       ` Jan Beulich
2025-03-28 13:44 ` [PATCH v5 04/16] xen/lib: Switch to xen/byteorder.h Andrew Cooper
2025-03-31  8:44   ` Jan Beulich
2025-03-28 13:44 ` [PATCH v5 05/16] xen/device-tree: Remove use of *_to_cpup() helpers Andrew Cooper
2025-03-28 13:44 ` [PATCH v5 06/16] xen/decompressors: " Andrew Cooper
2025-03-28 14:07   ` Andrew Cooper
2025-03-28 13:44 ` [PATCH v5 07/16] xen/arch: Switch to new byteorder infrastructure Andrew Cooper
2025-03-31 13:53   ` Jan Beulich
2025-03-28 13:44 ` [PATCH v5 08/16] xen/decompressors: Use " Andrew Cooper
2025-03-31 13:55   ` Jan Beulich
2025-03-28 13:44 ` [PATCH v5 09/16] xen: Remove old " Andrew Cooper
2025-03-28 13:44 ` [PATCH v5 10/16] crypto/vmac: Switch to xen/byteswap.h Andrew Cooper
2025-03-28 13:44 ` [PATCH v5 11/16] xsm/flask: Switch {asm -> xen}/byteorder.h Andrew Cooper
2025-03-28 13:44 ` [PATCH v5 12/16] xen/common: " Andrew Cooper
2025-03-31 13:58   ` Jan Beulich
2025-03-28 13:44 ` [PATCH v5 13/16] arm: Remove asm/byteorder.h Andrew Cooper
2025-03-28 13:44 ` [PATCH v5 14/16] ppc: Drop asm/byteorder.h Andrew Cooper
2025-03-28 13:44 ` [PATCH v5 15/16] riscv: Remove asm/byteorder.h Andrew Cooper
2025-03-31 14:52   ` Oleksii Kurochko
2025-03-28 13:44 ` [PATCH v5 16/16] x86: Drop asm/byteorder.h Andrew Cooper
2025-03-31 14:12   ` Jan Beulich

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.