* [Qemu-devel] [PATCH] kvm: fix ioeventfd endianness on bi-endian architectures
@ 2015-03-13 21:23 Greg Kurz
2015-03-13 21:30 ` Patchew Tool
0 siblings, 1 reply; 4+ messages in thread
From: Greg Kurz @ 2015-03-13 21:23 UTC (permalink / raw)
To: qemu-devel; +Cc: Paolo Bonzini
KVM expects host endian values. Hosts that don't use the default endianness
need to negate the swap performed in adjust_endianness().
Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
---
kvm-all.c | 24 ++++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
diff --git a/kvm-all.c b/kvm-all.c
index cbedc25..1adfef4 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -527,13 +527,33 @@ int kvm_vm_check_extension(KVMState *s, unsigned int extension)
return ret;
}
+static uint32_t adjust_ioeventfd_endianness(uint32_t val, uint32_t size)
+{
+#if defined(HOST_WORDS_BIGENDIAN) != defined(TARGET_WORDS_BIGENDIAN)
+ /* The kernel expects ioeventfd values in HOST_WORDS_BIGENDIAN
+ * 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;
+ }
+#endif
+ return val;
+}
+
static int kvm_set_ioeventfd_mmio(int fd, hwaddr addr, uint32_t val,
bool assign, uint32_t size, bool datamatch)
{
int ret;
struct kvm_ioeventfd iofd;
- iofd.datamatch = datamatch ? val : 0;
+ iofd.datamatch = datamatch ? adjust_ioeventfd_endianness(val, size) : 0;
iofd.addr = addr;
iofd.len = size;
iofd.flags = 0;
@@ -563,7 +583,7 @@ static int kvm_set_ioeventfd_pio(int fd, uint16_t addr, uint16_t val,
bool assign, uint32_t size, bool datamatch)
{
struct kvm_ioeventfd kick = {
- .datamatch = datamatch ? val : 0,
+ .datamatch = datamatch ? adjust_ioeventfd_endianness(val, size) : 0,
.addr = addr,
.flags = KVM_IOEVENTFD_FLAG_PIO,
.len = size,
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] kvm: fix ioeventfd endianness on bi-endian architectures
2015-03-13 21:23 [Qemu-devel] [PATCH] kvm: fix ioeventfd endianness on bi-endian architectures Greg Kurz
@ 2015-03-13 21:30 ` Patchew Tool
2015-03-15 9:14 ` Paolo Bonzini
0 siblings, 1 reply; 4+ messages in thread
From: Patchew Tool @ 2015-03-13 21:30 UTC (permalink / raw)
To: qemu-devel
This series passed Patchew automatic testing, but there are some warnings.
Find the log fragments below, or open the following URL to see the full log:
http://qemu.patchew.org/testing/log/<20150313212337.31142.3991.stgit@bahia.local>
----------8<---------
=== Starting docker ===
Copying test script "/home/patchew/tests/qemu-devel.sh"
Starting docker...
docker run --net=none -v /var/tmp/patchew-tester/tmpEMd8Zd:/var/tmp/patchew-test patchew:fedora-20 timeout 3600 /var/tmp/patchew-test/qemu-devel.sh /var/tmp/patchew-test
*** Testing 'coding style check' ***
Checking 0001-kvm--fix-ioeventfd-endianness-on-bi-endian-architectures.patch
command failed with exit code 0
$@
ERROR: space required before the open parenthesis '('
#26: FILE: kvm-all.c:538:
+ switch(size) {
total: 1 errors, 0 warnings, 42 lines checked
0001-kvm--fix-ioeventfd-endianness-on-bi-endian-architectures.patch has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
*** Testing 'configure' ***
Install prefix /usr/local
BIOS directory /usr/local/share/qemu
binary directory /usr/local/bin
library directory /usr/local/lib
module directory /usr/local/lib/qemu
libexec directory /usr/local/libexec
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] kvm: fix ioeventfd endianness on bi-endian architectures
2015-03-13 21:30 ` Patchew Tool
@ 2015-03-15 9:14 ` Paolo Bonzini
2015-03-17 7:56 ` Greg Kurz
0 siblings, 1 reply; 4+ messages in thread
From: Paolo Bonzini @ 2015-03-15 9:14 UTC (permalink / raw)
To: qemu-devel, Greg Kurz
On 13/03/2015 22:30, Patchew Tool wrote:
> This series passed Patchew automatic testing, but there are some warnings.
>
> Find the log fragments below, or open the following URL to see the full log:
>
> http://qemu.patchew.org/testing/log/<20150313212337.31142.3991.stgit@bahia.local>
I'll fix this up when applying.
The patch is okay.
Paolo
> ----------8<---------
>
>
> === Starting docker ===
>
> Copying test script "/home/patchew/tests/qemu-devel.sh"
> Starting docker...
> docker run --net=none -v /var/tmp/patchew-tester/tmpEMd8Zd:/var/tmp/patchew-test patchew:fedora-20 timeout 3600 /var/tmp/patchew-test/qemu-devel.sh /var/tmp/patchew-test
>
> *** Testing 'coding style check' ***
>
> Checking 0001-kvm--fix-ioeventfd-endianness-on-bi-endian-architectures.patch
> command failed with exit code 0
> $@
> ERROR: space required before the open parenthesis '('
> #26: FILE: kvm-all.c:538:
> + switch(size) {
>
> total: 1 errors, 0 warnings, 42 lines checked
>
> 0001-kvm--fix-ioeventfd-endianness-on-bi-endian-architectures.patch has style problems, please review. If any of these errors
> are false positives report them to the maintainer, see
> CHECKPATCH in MAINTAINERS.
>
>
> *** Testing 'configure' ***
>
> Install prefix /usr/local
> BIOS directory /usr/local/share/qemu
> binary directory /usr/local/bin
> library directory /usr/local/lib
> module directory /usr/local/lib/qemu
> libexec directory /usr/local/libexec
>
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] kvm: fix ioeventfd endianness on bi-endian architectures
2015-03-15 9:14 ` Paolo Bonzini
@ 2015-03-17 7:56 ` Greg Kurz
0 siblings, 0 replies; 4+ messages in thread
From: Greg Kurz @ 2015-03-17 7:56 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: qemu-devel
On Sun, 15 Mar 2015 10:14:18 +0100
Paolo Bonzini <pbonzini@redhat.com> wrote:
>
>
> On 13/03/2015 22:30, Patchew Tool wrote:
> > This series passed Patchew automatic testing, but there are some warnings.
> >
> > Find the log fragments below, or open the following URL to see the full log:
> >
> > http://qemu.patchew.org/testing/log/<20150313212337.31142.3991.stgit@bahia.local>
>
>
> I'll fix this up when applying.
>
Thanks !
--
Greg
BTW I could not connect to patchew with the link above (Error code: ERR_CONNECTION_REFUSED)
> The patch is okay.
>
> Paolo
>
> > ----------8<---------
> >
> >
> > === Starting docker ===
> >
> > Copying test script "/home/patchew/tests/qemu-devel.sh"
> > Starting docker...
> > docker run --net=none -v /var/tmp/patchew-tester/tmpEMd8Zd:/var/tmp/patchew-test patchew:fedora-20 timeout 3600 /var/tmp/patchew-test/qemu-devel.sh /var/tmp/patchew-test
> >
> > *** Testing 'coding style check' ***
> >
> > Checking 0001-kvm--fix-ioeventfd-endianness-on-bi-endian-architectures.patch
> > command failed with exit code 0
> > $@
> > ERROR: space required before the open parenthesis '('
> > #26: FILE: kvm-all.c:538:
> > + switch(size) {
> >
> > total: 1 errors, 0 warnings, 42 lines checked
> >
> > 0001-kvm--fix-ioeventfd-endianness-on-bi-endian-architectures.patch has style problems, please review. If any of these errors
> > are false positives report them to the maintainer, see
> > CHECKPATCH in MAINTAINERS.
> >
> >
> > *** Testing 'configure' ***
> >
> > Install prefix /usr/local
> > BIOS directory /usr/local/share/qemu
> > binary directory /usr/local/bin
> > library directory /usr/local/lib
> > module directory /usr/local/lib/qemu
> > libexec directory /usr/local/libexec
> >
> >
> >
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-03-17 7:56 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-13 21:23 [Qemu-devel] [PATCH] kvm: fix ioeventfd endianness on bi-endian architectures Greg Kurz
2015-03-13 21:30 ` Patchew Tool
2015-03-15 9:14 ` Paolo Bonzini
2015-03-17 7:56 ` Greg Kurz
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.