On 2/8/26 9:19 PM, Richard Henderson wrote:
On 2/7/26 08:19, Pierrick Bouvier wrote:
virtio_is_big_endian already checks for VIRTIO_F_VERSION_1 feature, so
this is redundant with big_endian_code.
Also, clarify why we explicitly check for ppc64 and arm arch.
Signed-off-by: Pierrick Bouvier <[email protected]>
---
include/hw/virtio/virtio-access.h | 17 ++++++-----------
1 file changed, 6 insertions(+), 11 deletions(-)
diff --git a/include/hw/virtio/virtio-access.h
b/include/hw/virtio/virtio-access.h
index 1bea3445979..9aed3d1da4f 100644
--- a/include/hw/virtio/virtio-access.h
+++ b/include/hw/virtio/virtio-access.h
@@ -22,21 +22,16 @@
#include "hw/virtio/virtio.h"
#include "hw/virtio/virtio-bus.h"
+static inline bool legacy_virtio_is_biendian(void)
+{
+ return target_ppc64() || target_base_arm();
+}
+
static inline bool virtio_access_is_big_endian(VirtIODevice *vdev)
{
- if (target_ppc64() || target_base_arm()) {
+ if (target_big_endian() || legacy_virtio_is_biendian()) {
return virtio_is_big_endian(vdev);
}
This now calls the hook for all big-endian, not just bi-endian.
I don't think you need to change anything here...
If I'm correct, that's what original code was doing:
#if defined(LEGACY_VIRTIO_IS_BIENDIAN)
return virtio_is_big_endian(vdev);
#elif TARGET_BIG_ENDIAN
/* duplicated code for virtio_is_big_endian(vdev) */
if (virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1)) {
/* Devices conforming to VIRTIO 1.0 or later are always LE. */
return false;
}
return true;
#else
return false;
From what I understand, legacy virtio devices follow host endianness
(thus considering all big-endian arch), while virtio >= 1.0 devices are
always little endian.
What did I miss to consider it should only be called for bi-endian arch?
The bi-endian part was specifically introduced for a regression that was
found (see c02d7030c3c538312c7f464cb79b72c29a20df74).
But it seems it's quite duplicating what TARGET_BIG_ENDIAN is doing, and
I'm not sure why both were never unified, thus the current patch and
proposal. That said, there seems to be a lot of history around this
specific function, so I would be happy to hear any detail I might have
missed.
Regards,
Pierrick