aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilippe Mathieu-Daudé <philmd@linaro.org>2025-04-17 10:37:53 +0200
committerPhilippe Mathieu-Daudé <philmd@linaro.org>2025-04-25 17:09:58 +0200
commit56f8fb6886c49a99962d50912a8dde9e8dbfc306 (patch)
tree16ce2ffe218998dc87fa50ca15db76622193ccab
parent4e442406fde1957a8c4eebbcd878fb5f25cc49c1 (diff)
downloadqemu-56f8fb6886c49a99962d50912a8dde9e8dbfc306.zip
qemu-56f8fb6886c49a99962d50912a8dde9e8dbfc306.tar.gz
qemu-56f8fb6886c49a99962d50912a8dde9e8dbfc306.tar.bz2
accel/kvm: Use target_needs_bswap()
Check whether we need to swap at runtime using target_needs_bswap(). Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20250417131004.47205-3-philmd@linaro.org>
-rw-r--r--accel/kvm/kvm-all.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index b8c68c7..278a506 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -33,6 +33,7 @@
#include "system/cpus.h"
#include "system/accel-blocker.h"
#include "qemu/bswap.h"
+#include "exec/tswap.h"
#include "system/memory.h"
#include "system/ram_addr.h"
#include "qemu/event_notifier.h"
@@ -1318,21 +1319,22 @@ bool kvm_hwpoisoned_mem(void)
static uint32_t adjust_ioeventfd_endianness(uint32_t val, uint32_t size)
{
-#if HOST_BIG_ENDIAN != TARGET_BIG_ENDIAN
- /* The kernel expects ioeventfd values in HOST_BIG_ENDIAN
- * endianness, but the memory core hands them in target endianness.
- * For example, PPC is always treated as big-endian even if running
- * on KVM and on PPC64LE. Correct here.
- */
- switch (size) {
- case 2:
- val = bswap16(val);
- break;
- case 4:
- val = bswap32(val);
- break;
+ if (target_needs_bswap()) {
+ /*
+ * The kernel expects ioeventfd values in HOST_BIG_ENDIAN
+ * endianness, but the memory core hands them in target endianness.
+ * For example, PPC is always treated as big-endian even if running
+ * on KVM and on PPC64LE. Correct here, swapping back.
+ */
+ switch (size) {
+ case 2:
+ val = bswap16(val);
+ break;
+ case 4:
+ val = bswap32(val);
+ break;
+ }
}
-#endif
return val;
}