From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xenproject.org>
Cc: "Lin Liu" <lin.liu@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 04/16] xen/lib: Switch to xen/byteorder.h
Date: Fri, 28 Mar 2025 13:44:15 +0000 [thread overview]
Message-ID: <20250328134427.874848-5-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <20250328134427.874848-1-andrew.cooper3@citrix.com>
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
next prev parent reply other threads:[~2025-03-28 13:44 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 ` Andrew Cooper [this message]
2025-03-31 8:44 ` [PATCH v5 04/16] xen/lib: Switch to xen/byteorder.h 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
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-5-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.