From: Ben Dooks <ben.dooks@codethink.co.uk>
To: kvm@vger.kernel.org
Cc: felix.chong@codethink.co.uk, lawrence.hunter@codethink.co.uk,
roan.richmond@codethink.co.uk,
Ben Dooks <ben.dooks@codethink.co.uk>
Subject: [PATCH kvmtool] kvmtool: virtio: fix endian for big endian hosts
Date: Wed, 15 Jan 2025 10:11:25 +0000 [thread overview]
Message-ID: <20250115101125.526492-1-ben.dooks@codethink.co.uk> (raw)
When running on a big endian host, the virtio mmio-modern.c correctly
sets all reads to return little endian values. However the header uses
a 4 byte char for the magic value, which is always going to be in the
correct endian regardless of host endian.
To make the simplest change, simply avoid endian convresion of the
read of the magic value. This fixes the following bug from the guest:
[ 0.592838] virtio-mmio 10020000.virtio: Wrong magic value 0x76697274!
Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
---
virtio/mmio-modern.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/virtio/mmio-modern.c b/virtio/mmio-modern.c
index 6c0bb38..fd9c0cb 100644
--- a/virtio/mmio-modern.c
+++ b/virtio/mmio-modern.c
@@ -66,7 +66,10 @@ static void virtio_mmio_config_in(struct kvm_cpu *vcpu,
return;
}
- *data = cpu_to_le32(val);
+ if (addr != VIRTIO_MMIO_MAGIC_VALUE)
+ *data = cpu_to_le32(val);
+ else
+ *data = val;
}
static void virtio_mmio_config_out(struct kvm_cpu *vcpu,
--
2.37.2.352.g3c44437643
next reply other threads:[~2025-01-15 10:26 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-15 10:11 Ben Dooks [this message]
2025-01-15 14:24 ` [PATCH kvmtool] kvmtool: virtio: fix endian for big endian hosts Andrew Jones
2025-01-15 15:09 ` Ben Dooks
2025-01-16 9:28 ` Andrew Jones
2025-01-17 9:57 ` Ben Dooks
2025-01-17 10:07 ` Andrew Jones
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=20250115101125.526492-1-ben.dooks@codethink.co.uk \
--to=ben.dooks@codethink.co.uk \
--cc=felix.chong@codethink.co.uk \
--cc=kvm@vger.kernel.org \
--cc=lawrence.hunter@codethink.co.uk \
--cc=roan.richmond@codethink.co.uk \
/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.