hw/misc/ivshmem: Fix ivshmem_recv_msg() to also work on big endian systems
PATCH 1/1 hw/misc/ivshmem: Fix ivshmem_recv_msg() to also work on big endian systems
The "slow" ivshmem-tests currently fail when they are running on a big endian host:
$ uname -m ppc64 $ V=1 QTEST_QEMU_BINARY=x86_64-softmmu/qemu-system-x86_64 tests/ivshmem-test -m slow /x86_64/ivshmem/single: OK /x86_64/ivshmem/hotplug: OK /x86_64/ivshmem/memdev: OK /x86_64/ivshmem/pair: OK /x86_64/ivshmem/server-msi: qemu-system-x86_64: -device ivshmem-doorbell,chardev=chr0,vectors=2: server sent invalid ID message Broken pipe
The problem is that the server side code in ivshmem_server_send_one_msg() correctly translates all messages IDs into little endian 64-bit values, but the client side code in the ivshmem_recv_msg() function does not swap the byte order back. Fix it by passing the value through le64_to_cpu().
--- hw/misc/ivshmem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/misc/ivshmem.c +1 -1
@@ -653,7 +653,7 @@ static int64_t ivshmem_recv_msg(IVShmemState *s, int *pfd, Error **errp) }while (n <sizeof (msg)); *pfd =qemu_chr_fe_get_msgfd (&s->server_chr); -return msg; +return le64_to_cpu (msg); }static void ivshmem_recv_setup (IVShmemState *s,Error **errp)
Signature · 1 line
1.8.3.1
Quoted 29 lines · On Wed, 30 Aug 2017 15:39:03 +0200 Thomas Huth <[email protected]> wrote:
The "slow" ivshmem-tests currently fail when they are running on a big endian host:
$ uname -m ppc64 $ V=1 QTEST_QEMU_BINARY=x86_64-softmmu/qemu-system-x86_64 tests/ivshmem-test -m slow /x86_64/ivshmem/single: OK /x86_64/ivshmem/hotplug: OK /x86_64/ivshmem/memdev: OK /x86_64/ivshmem/pair: OK /x86_64/ivshmem/server-msi: qemu-system-x86_64: -device ivshmem-doorbell,chardev=chr0,vectors=2: server sent invalid ID message Broken pipeThe problem is that the server side code in
ivshmem_server_send_one_msg()correctly translates all messages IDs into little endian 64-bit values, but the client side code in theivshmem_recv_msg()function does not swap the byte order back. Fix it by passing the value throughle64_to_cpu().Signed-off-by Thomas Huth <[email protected]>--- hw/misc/ivshmem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/misc/ivshmem.c +0
-0
hw/misc/ivshmem.c static int64_t ivshmem_recv_msg(IVShmemState *s, int *pfd, Error **errp) · line 659
Quoted 8 lines
hw/misc/ivshmem.c +1
-1@@ -653,7 +653,7 @@ static int64_t ivshmem_recv_msg(IVShmemState *s, int *pfd, Error **errp) }while (n <sizeof (msg)); *pfd =qemu_chr_fe_get_msgfd (&s->server_chr); -return msg; +return le64_to_cpu (msg); }static void ivshmem_recv_setup (IVShmemState *s,Error **errp)
This fixes the "invalid ID message" problem on s390x for me as well, and I run now into the same error as on x86 (which you also have a fix for IIRC), so I guess this is
Hi
Quoted 16 lines · Thomas Huth
The "slow" ivshmem-tests currently fail when they are running on a big endian host:
$ uname -m ppc64 $ V=1 QTEST_QEMU_BINARY=x86_64-softmmu/qemu-system-x86_64 tests/ivshmem-test -m slow /x86_64/ivshmem/single: OK /x86_64/ivshmem/hotplug: OK /x86_64/ivshmem/memdev: OK /x86_64/ivshmem/pair: OK /x86_64/ivshmem/server-msi: qemu-system-x86_64: -device ivshmem-doorbell,chardev=chr0,vectors=2: server sent invalid ID message Broken pipe
Quoted 6 lines
The problem is that the server side code in
ivshmem_server_send_one_msg()correctly translates all messages IDs into little endian 64-bit values, but the client side code in theivshmem_recv_msg()function does not swap the byte order back. Fix it by passing the value throughle64_to_cpu().
ivshmem_read() is correct though
Quoted 1 line
---
Quoted 21 lines
hw/misc/ivshmem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/misc/ivshmem.c +1
-1@@ -653,7 +653,7 @@ static int64_t ivshmem_recv_msg(IVShmemState *s, int *pfd, Error **errp) }while (n <sizeof (msg)); *pfd =qemu_chr_fe_get_msgfd (&s->server_chr); -return msg; +return le64_to_cpu (msg); }static void
ivshmem_recv_setup(IVShmemState *s, Error **errp)
--
1.8.3.1
Quoted 1 line
--
Marc-André Lureau
Quoted 23 lines · Cornelia Huck
Quoted 20 lines · On Wed, 30 Aug 2017 15:39:03 +0200 Thomas Huth <[email protected]> wrote:
The "slow" ivshmem-tests currently fail when they are running on a big endian host:
$ uname -m ppc64 $ V=1 QTEST_QEMU_BINARY=x86_64-softmmu/qemu-system-x86_64 tests/ivshmem-test -m slow /x86_64/ivshmem/single: OK /x86_64/ivshmem/hotplug: OK /x86_64/ivshmem/memdev: OK /x86_64/ivshmem/pair: OK /x86_64/ivshmem/server-msi: qemu-system-x86_64: -device ivshmem-doorbell,chardev=chr0,vectors=2: server sent invalid ID message Broken pipeThe problem is that the server side code in
ivshmem_server_send_one_msg()correctly translates all messages IDs into little endian 64-bit values, but the client side code in theivshmem_recv_msg()function does not swap the byte order back. Fix it by passing the value throughle64_to_cpu().Signed-off-by Thomas Huth <[email protected]>
[...]
Quoted 3 lines
This fixes the "invalid ID message" problem on s390x for me as well, and I run now into the same error as on x86 (which you also have a fix for IIRC)
Yes, you also need my other patch, look for "tests: Fix broken ivshmem-server-msi/-irq tests" on the list.
Thomas
Quoted 14 lines · Thomas Huth
The "slow" ivshmem-tests currently fail when they are running on a big endian host:
$ uname -m ppc64 $ V=1 QTEST_QEMU_BINARY=x86_64-softmmu/qemu-system-x86_64 tests/ivshmem-test -m slow /x86_64/ivshmem/single: OK /x86_64/ivshmem/hotplug: OK /x86_64/ivshmem/memdev: OK /x86_64/ivshmem/pair: OK /x86_64/ivshmem/server-msi: qemu-system-x86_64: -device ivshmem-doorbell,chardev=chr0,vectors=2: server sent invalid ID message Broken pipe
Quoted 4 lines
The problem is that the server side code in
ivshmem_server_send_one_msg()correctly translates all messages IDs into little endian 64-bit values, but the client side code in theivshmem_recv_msg()function does not swap the byte order back. Fix it by passing the value throughle64_to_cpu().
Yes, we lack BE testing :(
I read we can run docker on s390x, I wonder if we can ask for a FOSS account on some to run the test suite.
Quoted 2 lines
Signed-off-by Thomas Huth <[email protected]>
Quoted 18 lines
--- hw/misc/ivshmem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/misc/ivshmem.c +1
-1@@ -653,7 +653,7 @@ static int64_t ivshmem_recv_msg(IVShmemState *s, int *pfd, Error **errp) }while (n <sizeof (msg)); *pfd =qemu_chr_fe_get_msgfd (&s->server_chr); -return msg; +return le64_to_cpu (msg); }static void ivshmem_recv_setup (IVShmemState *s,Error **errp)
Quoted 17 lines · Philippe Mathieu-Daudé
Quoted 16 lines · Thomas Huth
The "slow" ivshmem-tests currently fail when they are running on a big endian host:
$ uname -m ppc64 $ V=1 QTEST_QEMU_BINARY=x86_64-softmmu/qemu-system-x86_64 tests/ivshmem-test -m slow /x86_64/ivshmem/single: OK /x86_64/ivshmem/hotplug: OK /x86_64/ivshmem/memdev: OK /x86_64/ivshmem/pair: OK /x86_64/ivshmem/server-msi: qemu-system-x86_64: -device ivshmem-doorbell,chardev=chr0,vectors=2: server sent invalid ID message Broken pipe
Quoted 6 lines
Quoted 4 lines
The problem is that the server side code in
ivshmem_server_send_one_msg()correctly translates all messages IDs into little endian 64-bit values, but the client side code in theivshmem_recv_msg()function does not swap the byte order back. Fix it by passing the value throughle64_to_cpu().Yes, we lack BE testing :(
As far as I know, some people are already running the tests on s390x and ppc64 ... the problem is that apparently nobody is running with SPEED=slow there - that's why this problem slipped through so far. Maybe we should switch to the SPEED=slow by default in the Makefile?
Thomas
Quoted 8 lines · Philippe Mathieu-Daudé
Quoted 4 lines · Thomas Huth
The problem is that the server side code in
ivshmem_server_send_one_msg()correctly translates all messages IDs into little endian 64-bit values, but the client side code in theivshmem_recv_msg()function does not swap the byte order back. Fix it by passing the value throughle64_to_cpu().Yes, we lack BE testing :(
My pre-pull-request test set includes s390 and ppc64 bigendian. This one was just missed because the 'slow' tests aren't in 'make check'.
thanks
-- PMM
Quoted 23 lines · On Wed, 30 Aug 2017 16:59:03 +0200 Thomas Huth <[email protected]> wrote:
Quoted 22 lines · Philippe Mathieu-Daudé
Quoted 20 lines · Thomas Huth
The "slow" ivshmem-tests currently fail when they are running on a big endian host:
$ uname -m ppc64 $ V=1 QTEST_QEMU_BINARY=x86_64-softmmu/qemu-system-x86_64 tests/ivshmem-test -m slow /x86_64/ivshmem/single: OK /x86_64/ivshmem/hotplug: OK /x86_64/ivshmem/memdev: OK /x86_64/ivshmem/pair: OK /x86_64/ivshmem/server-msi: qemu-system-x86_64: -device ivshmem-doorbell,chardev=chr0,vectors=2: server sent invalid ID message Broken pipeThe problem is that the server side code in
ivshmem_server_send_one_msg()correctly translates all messages IDs into little endian 64-bit values, but the client side code in theivshmem_recv_msg()function does not swap the byte order back. Fix it by passing the value throughle64_to_cpu().
Quoted 6 lines
Quoted 1 line
Yes, we lack BE testing :(
As far as I know, some people are already running the tests on s390x and ppc64 ... the problem is that apparently nobody is running with SPEED=slow there - that's why this problem slipped through so far. Maybe we should switch to the SPEED=slow by default in the
Makefile?
Not sure whether that is a good idea. /me adding this to my s390x tests should help, though.
Quoted 8 lines · Peter Maydell
Quoted 7 lines · Philippe Mathieu-Daudé
Quoted 4 lines · Thomas Huth
The problem is that the server side code in
ivshmem_server_send_one_msg()correctly translates all messages IDs into little endian 64-bit values, but the client side code in theivshmem_recv_msg()function does not swap the byte order back. Fix it by passing the value throughle64_to_cpu().
Quoted 5 lines
Quoted 1 line
Yes, we lack BE testing :(
My pre-pull-request test set includes s390 and ppc64 bigendian. This one was just missed because the 'slow' tests aren't in 'make check'.
I'm not what makes sense for staging this fix. I could take it through my tree, but it's not an obvious match, since this isn't really related to ppc at all.
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Quoted 3 lines · David Gibson
I'm not what makes sense for staging this fix. I could take it through my tree, but it's not an obvious match, since this isn't really related to ppc at all.
Paolo's misc? :D
Quoted 11 lines · David Gibson
Quoted 10 lines · Peter Maydell
Quoted 8 lines · Philippe Mathieu-Daudé
Quoted 4 lines · Thomas Huth
The problem is that the server side code in
ivshmem_server_send_one_msg()correctly translates all messages IDs into little endian 64-bit values, but the client side code in theivshmem_recv_msg()function does not swap the byte order back. Fix it by passing the value throughle64_to_cpu().Yes, we lack BE testing :(
Quoted 7 lines
Quoted 3 lines
My pre-pull-request test set includes s390 and ppc64 bigendian. This one was just missed because the 'slow' tests aren't in 'make check'.
I'm not what makes sense for staging this fix. I could take it through my tree, but it's not an obvious match, since this isn't really related to ppc at all.
There does not seem to be maintainer for ivshmem, as far as I can see, so I'd say any tree that is distantly related is fine. So I think you could either take it through your ppc tree (since the bug affects big endian ppc machines), or maybe Cornelia could take it through the s390x tree (since we've seen the problem on the big endian s390x machines, too). Otherwise I have to wait and see whether it goes through misc or trivial, I guess...
Thomas
Quoted 20 lines · On Mon, 11 Sep 2017 04:35:08 +0200 Thomas Huth <[email protected]> wrote:
Quoted 11 lines · David Gibson
Quoted 10 lines · Peter Maydell
Quoted 8 lines · Philippe Mathieu-Daudé
Quoted 4 lines · Thomas Huth
The problem is that the server side code in
ivshmem_server_send_one_msg()correctly translates all messages IDs into little endian 64-bit values, but the client side code in theivshmem_recv_msg()function does not swap the byte order back. Fix it by passing the value throughle64_to_cpu().Yes, we lack BE testing :(
Quoted 7 lines
Quoted 3 lines
My pre-pull-request test set includes s390 and ppc64 bigendian. This one was just missed because the 'slow' tests aren't in 'make check'.
I'm not what makes sense for staging this fix. I could take it through my tree, but it's not an obvious match, since this isn't really related to ppc at all.
Quoted 7 lines
There does not seem to be maintainer for ivshmem, as far as I can see, so I'd say any tree that is distantly related is fine. So I think you could either take it through your ppc tree (since the bug affects big endian ppc machines), or maybe Cornelia could take it through the s390x tree (since we've seen the problem on the big endian s390x machines, too). Otherwise I have to wait and see whether it goes through misc or trivial, I guess...
I'll queue it; and whoever sends the first pull request, 'wins' :)
Michael Tokarev
Applied30.08.2017 16:39, Thomas Huth пишет:
Quoted 2 lines
The "slow" ivshmem-tests currently fail when they are running on a big endian host:
Applied to -trivial, thanks!
/mjt