From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Daniel Henrique Barboza" <dbarboza@ventanamicro.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Laurent Vivier" <lvivier@redhat.com>,
"Mark Cave-Ayland" <mark.cave-ayland@ilande.co.uk>,
"Alistair Francis" <alistair.francis@wdc.com>,
"Anton Johansson" <anjo@rev.ng>, "Zhao Liu" <zhao1.liu@intel.com>,
"Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
"David Hildenbrand" <david@redhat.com>,
qemu-s390x@nongnu.org, "Max Filippov" <jcmvbkbc@gmail.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Nicholas Piggin" <npiggin@gmail.com>,
qemu-arm@nongnu.org, "Thomas Huth" <thuth@redhat.com>,
qemu-riscv@nongnu.org,
"Alistair Francis" <alistair@alistair23.me>,
qemu-ppc@nongnu.org,
"Richard Henderson" <richard.henderson@linaro.org>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: [PATCH 01/20] exec/tswap: Rename target_words_bigendian -> qemu_binary_is_bigendian
Date: Wed, 4 Dec 2024 21:25:43 +0100 [thread overview]
Message-ID: <20241204202602.58083-2-philmd@linaro.org> (raw)
In-Reply-To: <20241204202602.58083-1-philmd@linaro.org>
target_words_bigendian() doesn't return whether a target vCPU
expects data in big-endian order, but whether the *binary* has
been compiled with big-endian flavor by default. Rename it
appropriately to reduce confusion. Mechanical change doing:
$ sed -i -e s/target_words_bigendian/qemu_binary_is_bigendian/ \
$(git grep -l target_words_bigendian)
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
include/exec/tswap.h | 18 +++++++++---------
cpu-target.c | 2 +-
disas/disas-common.c | 2 +-
hw/core/cpu-sysemu.c | 2 +-
hw/core/generic-loader.c | 2 +-
hw/display/vga.c | 4 ++--
hw/virtio/virtio.c | 2 +-
system/qtest.c | 2 +-
8 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/include/exec/tswap.h b/include/exec/tswap.h
index ecd4faef015..0113ff88fcc 100644
--- a/include/exec/tswap.h
+++ b/include/exec/tswap.h
@@ -11,15 +11,15 @@
#include "qemu/bswap.h"
/**
- * target_words_bigendian:
- * Returns true if the (default) endianness of the target is big endian,
- * false otherwise. Note that in target-specific code, you can use
- * TARGET_BIG_ENDIAN directly instead. On the other hand, common
- * code should normally never need to know about the endianness of the
- * target, so please do *not* use this function unless you know very well
- * what you are doing!
+ * qemu_binary_is_bigendian: Returns QEMU binary default endianness
+ *
+ * Returns whether the QEMU binary is built for big endianness flavor
+ * by default.
+ * vCPUs use this flavor by default when their endianness is not specified.
+ *
+ * This is not a clear API so please do *not* use this function.
*/
-bool target_words_bigendian(void);
+bool qemu_binary_is_bigendian(void);
/*
* If we're in target-specific code, we can hard-code the swapping
@@ -28,7 +28,7 @@ bool target_words_bigendian(void);
#ifdef COMPILING_PER_TARGET
#define target_needs_bswap() (HOST_BIG_ENDIAN != TARGET_BIG_ENDIAN)
#else
-#define target_needs_bswap() (HOST_BIG_ENDIAN != target_words_bigendian())
+#define target_needs_bswap() (HOST_BIG_ENDIAN != qemu_binary_is_bigendian())
#endif /* COMPILING_PER_TARGET */
static inline uint16_t tswap16(uint16_t s)
diff --git a/cpu-target.c b/cpu-target.c
index 499facf7747..ff8c55a810a 100644
--- a/cpu-target.c
+++ b/cpu-target.c
@@ -463,7 +463,7 @@ out:
}
#endif
-bool target_words_bigendian(void)
+bool qemu_binary_is_bigendian(void)
{
return TARGET_BIG_ENDIAN;
}
diff --git a/disas/disas-common.c b/disas/disas-common.c
index de61f6d8a12..7377de0715c 100644
--- a/disas/disas-common.c
+++ b/disas/disas-common.c
@@ -61,7 +61,7 @@ void disas_initialize_debug_target(CPUDebug *s, CPUState *cpu)
s->cpu = cpu;
s->info.print_address_func = print_address;
- if (target_words_bigendian()) {
+ if (qemu_binary_is_bigendian()) {
s->info.endian = BFD_ENDIAN_BIG;
} else {
s->info.endian = BFD_ENDIAN_LITTLE;
diff --git a/hw/core/cpu-sysemu.c b/hw/core/cpu-sysemu.c
index 2a9a2a4eb54..4b85face02b 100644
--- a/hw/core/cpu-sysemu.c
+++ b/hw/core/cpu-sysemu.c
@@ -129,7 +129,7 @@ bool cpu_virtio_is_big_endian(CPUState *cpu)
if (cc->sysemu_ops->virtio_is_big_endian) {
return cc->sysemu_ops->virtio_is_big_endian(cpu);
}
- return target_words_bigendian();
+ return qemu_binary_is_bigendian();
}
GuestPanicInformation *cpu_get_crash_info(CPUState *cpu)
diff --git a/hw/core/generic-loader.c b/hw/core/generic-loader.c
index ea8628b8926..abdd4c08a38 100644
--- a/hw/core/generic-loader.c
+++ b/hw/core/generic-loader.c
@@ -134,7 +134,7 @@ static void generic_loader_realize(DeviceState *dev, Error **errp)
s->cpu = first_cpu;
}
- big_endian = target_words_bigendian();
+ big_endian = qemu_binary_is_bigendian();
if (s->file) {
AddressSpace *as = s->cpu ? s->cpu->as : NULL;
diff --git a/hw/display/vga.c b/hw/display/vga.c
index 6dbbbf49073..6be02006000 100644
--- a/hw/display/vga.c
+++ b/hw/display/vga.c
@@ -2116,7 +2116,7 @@ static bool vga_endian_state_needed(void *opaque)
* default one, thus ensuring backward compatibility for
* migration of the common case
*/
- return s->big_endian_fb != target_words_bigendian();
+ return s->big_endian_fb != qemu_binary_is_bigendian();
}
static const VMStateDescription vmstate_vga_endian = {
@@ -2264,7 +2264,7 @@ bool vga_common_init(VGACommonState *s, Object *obj, Error **errp)
* into a device attribute set by the machine/platform to remove
* all target endian dependencies from this file.
*/
- s->big_endian_fb = target_words_bigendian();
+ s->big_endian_fb = qemu_binary_is_bigendian();
vga_dirty_log_start(s);
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index f12c4aa81eb..b3dede476ed 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -2248,7 +2248,7 @@ int virtio_set_status(VirtIODevice *vdev, uint8_t val)
static enum virtio_device_endian virtio_default_endian(void)
{
- if (target_words_bigendian()) {
+ if (qemu_binary_is_bigendian()) {
return VIRTIO_DEVICE_ENDIAN_BIG;
} else {
return VIRTIO_DEVICE_ENDIAN_LITTLE;
diff --git a/system/qtest.c b/system/qtest.c
index 12703a20455..8675a0bd316 100644
--- a/system/qtest.c
+++ b/system/qtest.c
@@ -704,7 +704,7 @@ static void qtest_process_command(CharBackend *chr, gchar **words)
qtest_send(chr, "OK\n");
} else if (strcmp(words[0], "endianness") == 0) {
qtest_send_prefix(chr);
- if (target_words_bigendian()) {
+ if (qemu_binary_is_bigendian()) {
qtest_sendf(chr, "OK big\n");
} else {
qtest_sendf(chr, "OK little\n");
--
2.45.2
next prev parent reply other threads:[~2024-12-04 20:27 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-04 20:25 [PATCH 00/20] target: Implement CPUClass::datapath_is_big_endian() handlers Philippe Mathieu-Daudé
2024-12-04 20:25 ` Philippe Mathieu-Daudé [this message]
2024-12-04 23:33 ` [PATCH 01/20] exec/tswap: Rename target_words_bigendian -> qemu_binary_is_bigendian Richard Henderson
2024-12-04 20:25 ` [PATCH 02/20] hw/core/cpu: Introduce CPUClass::datapath_is_big_endian() handler Philippe Mathieu-Daudé
2024-12-04 20:25 ` [PATCH 03/20] target/arm: Implement CPUClass::datapath_is_big_endian Philippe Mathieu-Daudé
2024-12-04 23:37 ` Richard Henderson
2024-12-04 20:25 ` [PATCH 04/20] target/ppc: Register CPUClass::datapath_is_big_endian Philippe Mathieu-Daudé
2024-12-04 20:25 ` [PATCH 05/20] target/rx: Implement CPUClass::datapath_is_big_endian Philippe Mathieu-Daudé
2024-12-04 20:25 ` [PATCH 06/20] target/sparc: " Philippe Mathieu-Daudé
2024-12-04 20:25 ` [PATCH 07/20] target/riscv: " Philippe Mathieu-Daudé
2024-12-04 20:25 ` [PATCH 08/20] target/sh4: Expose CPUSH4State::little_endian property Philippe Mathieu-Daudé
2024-12-04 20:25 ` [PATCH 09/20] target/sh4: Implement CPUClass::datapath_is_big_endian Philippe Mathieu-Daudé
2024-12-04 20:25 ` [PATCH 10/20] target/microblaze: " Philippe Mathieu-Daudé
2024-12-04 20:25 ` [PATCH 11/20] target/mips: " Philippe Mathieu-Daudé
2024-12-04 20:25 ` [PATCH 12/20] target/xtensa: Implement xtensa_isa_is_big_endian() Philippe Mathieu-Daudé
2024-12-04 20:25 ` [PATCH 13/20] target/xtensa: Implement CPUClass::datapath_is_big_endian Philippe Mathieu-Daudé
2024-12-04 20:25 ` [PATCH 14/20] target: Implement CPUClass::datapath_is_big_endian (little-endian) Philippe Mathieu-Daudé
2024-12-04 20:25 ` [PATCH 15/20] target: Implement CPUClass::datapath_is_big_endian (big-endian) Philippe Mathieu-Daudé
2024-12-09 20:21 ` Brian Cain
2024-12-04 20:25 ` [PATCH 16/20] hw/core/cpu: Expose cpu_datapath_is_big_endian() method Philippe Mathieu-Daudé
2024-12-04 20:25 ` [PATCH 17/20] disas: Use cpu_datapath_is_big_endian() Philippe Mathieu-Daudé
2024-12-04 23:40 ` Richard Henderson
2024-12-05 10:47 ` Peter Maydell
2024-12-04 20:26 ` [PATCH 18/20] hw/core/generic-loader: " Philippe Mathieu-Daudé
2024-12-05 0:05 ` Richard Henderson
2024-12-04 20:26 ` [RFC PATCH 19/20] hw/virtio: " Philippe Mathieu-Daudé
2024-12-04 20:26 ` [PATCH 20/20] hw/core/cpu: Remove cpu_virtio_is_big_endian() Philippe Mathieu-Daudé
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=20241204202602.58083-2-philmd@linaro.org \
--to=philmd@linaro.org \
--cc=alistair.francis@wdc.com \
--cc=alistair@alistair23.me \
--cc=anjo@rev.ng \
--cc=david@redhat.com \
--cc=dbarboza@ventanamicro.com \
--cc=edgar.iglesias@gmail.com \
--cc=jcmvbkbc@gmail.com \
--cc=lvivier@redhat.com \
--cc=mark.cave-ayland@ilande.co.uk \
--cc=mst@redhat.com \
--cc=npiggin@gmail.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=qemu-riscv@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=thuth@redhat.com \
--cc=zhao1.liu@intel.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).