From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xenproject.org>
Cc: "Lin Liu" <lin.liu@citrix.com>,
"Andrew Cooper" <andrew.cooper3@citrix.com>,
"Anthony PERARD" <anthony.perard@vates.tech>,
"Michal Orzel" <michal.orzel@amd.com>,
"Jan Beulich" <jbeulich@suse.com>,
"Julien Grall" <julien@xen.org>,
"Roger Pau Monné" <roger.pau@citrix.com>,
"Stefano Stabellini" <sstabellini@kernel.org>,
"Volodymyr Babchuk" <Volodymyr_Babchuk@epam.com>,
"Bertrand Marquis" <bertrand.marquis@arm.com>,
"Shawn Anastasio" <sanastasio@raptorengineering.com>,
"Oleksii Kurochko" <oleksii.kurochko@gmail.com>,
"Daniel P . Smith" <dpsmith@apertussolutions.com>
Subject: [PATCH v5 06/16] xen/decompressors: Remove use of *_to_cpup() helpers
Date: Fri, 28 Mar 2025 13:44:17 +0000 [thread overview]
Message-ID: <20250328134427.874848-7-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <20250328134427.874848-1-andrew.cooper3@citrix.com>
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
next prev parent reply other threads:[~2025-03-28 13:45 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Andrew Cooper [this message]
2025-03-28 14:07 ` [PATCH v5 06/16] xen/decompressors: " 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250328134427.874848-7-andrew.cooper3@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=Volodymyr_Babchuk@epam.com \
--cc=anthony.perard@vates.tech \
--cc=bertrand.marquis@arm.com \
--cc=dpsmith@apertussolutions.com \
--cc=jbeulich@suse.com \
--cc=julien@xen.org \
--cc=lin.liu@citrix.com \
--cc=michal.orzel@amd.com \
--cc=oleksii.kurochko@gmail.com \
--cc=roger.pau@citrix.com \
--cc=sanastasio@raptorengineering.com \
--cc=sstabellini@kernel.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.