Skip to contentSkip to conversation

virtio/vhost: cross endian support

GIT PULL In review Michael S. Tsirkin 8 participants 25 messages Jul 1, 2015 – Jul 13, 2015

Subsystems (10)
lore
Share & tools
lore

Michael S. Tsirkin

author maintainer
#0 lore raw

The following changes since commit 8a7b19d8b542b87bccc3eaaf81dcc90a5ca48aea:

include/uapi/linux/virtio_balloon.h: include linux/virtio_types.h (2015-06-01 15:46:54 +0200)

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git tags/for_linus

for you to fetch changes up to 59a5b0f7bf74f88da6670bcbf924d8cc1e75b1ee:

virtio-pci: alloc only resources actually used. (2015-06-24 08:15:09 +0200)

----------------------------------------------------------------
virtio/vhost: cross endian support

I have just queued some more bugfix patches today but none fix regressions and none are related to these ones, so it looks like a good time for a merge for -rc1.

----------------------------------------------------------------
Gerd Hoffmann (1):
virtio-pci: alloc only resources actually used.

Greg Kurz (8):
virtio: introduce virtio_is_little_endian() helper
tun: add tun_is_little_endian() helper
macvtap: introduce macvtap_is_little_endian() helper
vringh: introduce vringh_is_little_endian() helper
vhost: introduce vhost_is_little_endian() helper
virtio: add explicit big-endian support to memory accessors
vhost: cross-endian support for legacy devices macvtap/tun: cross-endian support for little-endian hosts

 drivers/vhost/vhost.h              | 25 ++++++++---
 drivers/virtio/virtio_pci_common.h |  2 +
 include/linux/virtio_byteorder.h   | 24 ++++++-----
 include/linux/virtio_config.h      | 18 +++++---
 include/linux/vringh.h             | 18 +++++---
 include/uapi/linux/if_tun.h        |  6 +++
 include/uapi/linux/vhost.h         | 14 +++++++
 drivers/net/macvtap.c              | 65 ++++++++++++++++++++++++++++-
 drivers/net/tun.c                  | 67 +++++++++++++++++++++++++++++-
 drivers/vhost/vhost.c              | 85 +++++++++++++++++++++++++++++++++++++-
 drivers/virtio/virtio_pci_common.c |  7 ----
 drivers/virtio/virtio_pci_legacy.c | 13 +++++-
 drivers/virtio/virtio_pci_modern.c | 24 ++++++++---
 drivers/net/Kconfig                | 14 +++++++
 drivers/vhost/Kconfig              | 15 +++++++
 15 files changed, 350 insertions(+), 47 deletions(-)
#1 lore raw
Quoted 1 line · Michael S. Tsirkin

virtio/vhost: cross endian support

Ugh. Does this really have to be dynamic?

Can't virtio do the sane thing, and just use a _fixed_ endianness?

Doing a unconditional byte swap is faster and simpler than the crazy conditionals. That's true regardless of endianness, but gets to be even more so if the fixed endianness is little-endian, since BE is not-so-slowly fading from the world.

Linus

#2 lore raw
Quoted 3 lines · Linus Torvalds

Doing a unconditional byte swap is faster and simpler than the crazy conditionals.

Unconditional endianness not only makes for simpler and faster code, it also ends up being easier to debug and add things like type annotations for sparse.

Linus

author maintainer
#4 lore raw
In reply to Linus Torvalds
Quoted 5 lines · Linus Torvalds
Quoted 1 line · Michael S. Tsirkin

virtio/vhost: cross endian support

Ugh. Does this really have to be dynamic?

Quoted 8 lines

Can't virtio do the sane thing, and just use a _fixed_ endianness?

Doing a unconditional byte swap is faster and simpler than the crazy conditionals. That's true regardless of endianness, but gets to be even more so if the fixed endianness is little-endian, since BE is not-so-slowly fading from the world.

Linus

Yea, well - support for legacy BE guests on the new LE hosts is exactly the motivation for this.

I dislike it too, but there are two redeeming properties that made me merge this:

1. It's a trivial amount of code: since we wrap host/guest accesses anyway, almost all of it is well hidden from drivers.

2. Sane platforms would never set flags like VHOST_CROSS_ENDIAN_LEGACY - and when it's clear, there's zero overhead (as some point it was tested by compiling with and without the patches, got the same stripped binary).

Maybe we could create a Kconfig symbol to enforce point (2): prevent people from enabling it e.g. on x86. I will look into this - but it can be done by a patch on top, so I think this can be merged as is.

Or do you know of someone using kernel with all config options enabled undiscriminately?

Thanks,

Signature · 1 line
MST
author maintainer
#3 lore raw
In reply to Linus Torvalds
Quoted 11 lines · Linus Torvalds
Quoted 3 lines · Linus Torvalds

Doing a unconditional byte swap is faster and simpler than the crazy conditionals.

Unconditional endianness not only makes for simpler and faster code, it also ends up being easier to debug and add things like type annotations for sparse.

Linus

At least this last one is well covered by these patches: this uses separate sparse types so all accesses are statically verified by sparse to use the correct accessor.

Signature · 1 line
MST
#5 lore raw
In reply to Michael S. Tsirkin
Quoted 24 lines · On Thu, 2 Jul 2015 08:01:28 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 5 lines · Linus Torvalds
Quoted 1 line · Michael S. Tsirkin

virtio/vhost: cross endian support

Ugh. Does this really have to be dynamic?

Quoted 8 lines

Can't virtio do the sane thing, and just use a _fixed_ endianness?

Doing a unconditional byte swap is faster and simpler than the crazy conditionals. That's true regardless of endianness, but gets to be even more so if the fixed endianness is little-endian, since BE is not-so-slowly fading from the world.

Linus

Yea, well - support for legacy BE guests on the new LE hosts is exactly the motivation for this.

I dislike it too, but there are two redeeming properties that made me merge this:

1. It's a trivial amount of code: since we wrap host/guest accesses anyway, almost all of it is well hidden from drivers.

Quoted 9 lines

2. Sane platforms would never set flags like VHOST_CROSS_ENDIAN_LEGACY - and when it's clear, there's zero overhead (as some point it was tested by compiling with and without the patches, got the same stripped binary).

Maybe we could create a Kconfig symbol to enforce point (2): prevent people from enabling it e.g. on x86. I will look into this - but it can be done by a patch on top, so I think this can be merged as is.

This cross-endian *oddity* is targeting PowerPC book3s_64 processors... I am not aware of any other users. Maybe create a symbol that would be only selected by PPC_BOOK3S_64 ?

Quoted 5 lines

Or do you know of someone using kernel with all config options enabled undiscriminately?

Thanks,

author maintainer
#6 lore raw
Quoted 32 lines · Greg Kurz
Quoted 29 lines · On Thu, 2 Jul 2015 08:01:28 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 5 lines · Linus Torvalds
Quoted 1 line · Michael S. Tsirkin

virtio/vhost: cross endian support

Ugh. Does this really have to be dynamic?

Quoted 8 lines

Can't virtio do the sane thing, and just use a _fixed_ endianness?

Doing a unconditional byte swap is faster and simpler than the crazy conditionals. That's true regardless of endianness, but gets to be even more so if the fixed endianness is little-endian, since BE is not-so-slowly fading from the world.

Linus

Yea, well - support for legacy BE guests on the new LE hosts is exactly the motivation for this.

I dislike it too, but there are two redeeming properties that made me merge this:

1. It's a trivial amount of code: since we wrap host/guest accesses anyway, almost all of it is well hidden from drivers.

2. Sane platforms would never set flags like VHOST_CROSS_ENDIAN_LEGACY - and when it's clear, there's zero overhead (as some point it was tested by compiling with and without the patches, got the same stripped binary).

Quoted 8 lines
Quoted 4 lines

Maybe we could create a Kconfig symbol to enforce point (2): prevent people from enabling it e.g. on x86. I will look into this - but it can be done by a patch on top, so I think this can be merged as is.

This cross-endian *oddity* is targeting PowerPC book3s_64 processors... I am not aware of any other users. Maybe create a symbol that would be only selected by PPC_BOOK3S_64 ?

I think some ARM systems are trying to support cross-endian configurations as well.

Besides that, yes, this is more or less what I had in mind.

Quoted 6 lines
Quoted 6 lines

Or do you know of someone using kernel with all config options enabled undiscriminately?

Thanks,

author maintainer
#22 lore raw
In reply to Michael S. Tsirkin
Quoted 24 lines · Michael S. Tsirkin
Quoted 5 lines · Linus Torvalds
Quoted 1 line · Michael S. Tsirkin

virtio/vhost: cross endian support

Ugh. Does this really have to be dynamic?

Quoted 8 lines

Can't virtio do the sane thing, and just use a _fixed_ endianness?

Doing a unconditional byte swap is faster and simpler than the crazy conditionals. That's true regardless of endianness, but gets to be even more so if the fixed endianness is little-endian, since BE is not-so-slowly fading from the world.

Linus

Yea, well - support for legacy BE guests on the new LE hosts is exactly the motivation for this.

I dislike it too, but there are two redeeming properties that made me merge this:

1. It's a trivial amount of code: since we wrap host/guest accesses anyway, almost all of it is well hidden from drivers.

Quoted 8 lines

2. Sane platforms would never set flags like VHOST_CROSS_ENDIAN_LEGACY - and when it's clear, there's zero overhead (as some point it was tested by compiling with and without the patches, got the same stripped binary).

Maybe we could create a Kconfig symbol to enforce point (2): prevent people from enabling it e.g. on x86. I will look into this - but it can be done by a patch on top, so I think this can be merged as is.

Linus, could you please clarify whether making the feature depend on the cross-endian guest support would address your comment, and whether you think this can be merged as is, and the dependency added after -rc1?

Quoted 7 lines

Or do you know of someone using kernel with all config options enabled undiscriminately?

Thanks,

Signature · 1 line
MST
author maintainer
#24 lore raw
In reply to Michael S. Tsirkin
Quoted 24 lines · Michael S. Tsirkin
Quoted 5 lines · Linus Torvalds
Quoted 1 line · Michael S. Tsirkin

virtio/vhost: cross endian support

Ugh. Does this really have to be dynamic?

Quoted 8 lines

Can't virtio do the sane thing, and just use a _fixed_ endianness?

Doing a unconditional byte swap is faster and simpler than the crazy conditionals. That's true regardless of endianness, but gets to be even more so if the fixed endianness is little-endian, since BE is not-so-slowly fading from the world.

Linus

Yea, well - support for legacy BE guests on the new LE hosts is exactly the motivation for this.

I dislike it too, but there are two redeeming properties that made me merge this:

1. It's a trivial amount of code: since we wrap host/guest accesses anyway, almost all of it is well hidden from drivers.

Quoted 8 lines

2. Sane platforms would never set flags like VHOST_CROSS_ENDIAN_LEGACY - and when it's clear, there's zero overhead (as some point it was tested by compiling with and without the patches, got the same stripped binary).

Maybe we could create a Kconfig symbol to enforce point (2): prevent people from enabling it e.g. on x86. I will look into this - but it can be done by a patch on top, so I think this can be merged as is.

Linus, could you please clarify whether making the feature depend on the cross-endian guest support would address your comment, and whether you think this can be merged as is, and the dependency added after -rc1?

Quoted 7 lines

Or do you know of someone using kernel with all config options enabled undiscriminately?

Thanks,

Signature · 1 line
MST
#23 lore raw
In reply to Michael S. Tsirkin
Quoted 6 lines · Michael S. Tsirkin

Linus, could you please clarify whether making the feature depend on the cross-endian guest support would address your comment, and whether you think this can be merged as is, and the dependency added after -rc1?

I'll take it. I still think dynamic byte order is a fundamental (and much too common) mistake, but whatever.

Linus

#7 lore raw
In reply to Michael S. Tsirkin
Quoted 3 lines · On Thu, 2 Jul 2015 11:32:52 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 2 lines · Greg Kurz

On Thu, 2 Jul 2015 08:01:28 +0200
"Michael S. Tsirkin" <[email protected]> wrote:

...

Quoted 19 lines
Quoted 19 lines
Quoted 18 lines

Yea, well - support for legacy BE guests on the new LE hosts is exactly the motivation for this.

I dislike it too, but there are two redeeming properties that made me merge this:

1. It's a trivial amount of code: since we wrap host/guest accesses anyway, almost all of it is well hidden from drivers.

2. Sane platforms would never set flags like VHOST_CROSS_ENDIAN_LEGACY - and when it's clear, there's zero overhead (as some point it was tested by compiling with and without the patches, got the same stripped binary).

Maybe we could create a Kconfig symbol to enforce point (2): prevent people from enabling it e.g. on x86. I will look into this - but it can be done by a patch on top, so I think this can be merged as is.

Quoted 8 lines
Quoted 3 lines

This cross-endian *oddity* is targeting PowerPC book3s_64 processors... I am not aware of any other users. Maybe create a symbol that would be only selected by PPC_BOOK3S_64 ?

I think some ARM systems are trying to support cross-endian configurations as well.

Besides that, yes, this is more or less what I had in mind.

Would something simple like this already do the job:

drivers/vhost/Kconfig +1 -0
@@ -35,6 +35,7 @@ config VHOST
 
 config VHOST_CROSS_ENDIAN_LEGACY
 	bool "Cross-endian support for vhost"
+	depends on KVM_BOOK3S_64 || KVM_ARM_HOST
 	default n
 	---help---
 	  This option allows vhost to support guests with a different byte

?

If that looks acceptable, I can submit a proper patch if you like.

Thomas

#21 lore raw
In reply to Michael S. Tsirkin
Quoted 3 lines · On Thu, 2 Jul 2015 11:32:52 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 2 lines · Greg Kurz

On Thu, 2 Jul 2015 08:01:28 +0200
"Michael S. Tsirkin" <[email protected]> wrote:

...

Quoted 19 lines
Quoted 19 lines
Quoted 18 lines

Yea, well - support for legacy BE guests on the new LE hosts is exactly the motivation for this.

I dislike it too, but there are two redeeming properties that made me merge this:

1. It's a trivial amount of code: since we wrap host/guest accesses anyway, almost all of it is well hidden from drivers.

2. Sane platforms would never set flags like VHOST_CROSS_ENDIAN_LEGACY - and when it's clear, there's zero overhead (as some point it was tested by compiling with and without the patches, got the same stripped binary).

Maybe we could create a Kconfig symbol to enforce point (2): prevent people from enabling it e.g. on x86. I will look into this - but it can be done by a patch on top, so I think this can be merged as is.

Quoted 8 lines
Quoted 3 lines

This cross-endian *oddity* is targeting PowerPC book3s_64 processors... I am not aware of any other users. Maybe create a symbol that would be only selected by PPC_BOOK3S_64 ?

I think some ARM systems are trying to support cross-endian configurations as well.

Besides that, yes, this is more or less what I had in mind.

Would something simple like this already do the job:

drivers/vhost/Kconfig +1 -0
@@ -35,6 +35,7 @@ config VHOST
 
 config VHOST_CROSS_ENDIAN_LEGACY
 	bool "Cross-endian support for vhost"
+	depends on KVM_BOOK3S_64 || KVM_ARM_HOST
 	default n
 	---help---
 	  This option allows vhost to support guests with a different byte

?

If that looks acceptable, I can submit a proper patch if you like.

Thomas

author maintainer
#8 lore raw
In reply to Thomas Huth
Quoted 49 lines · Thomas Huth
Quoted 3 lines · On Thu, 2 Jul 2015 11:32:52 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 2 lines · Greg Kurz

On Thu, 2 Jul 2015 08:01:28 +0200
"Michael S. Tsirkin" <[email protected]> wrote:

...

Quoted 19 lines
Quoted 19 lines
Quoted 18 lines

Yea, well - support for legacy BE guests on the new LE hosts is exactly the motivation for this.

I dislike it too, but there are two redeeming properties that made me merge this:

1. It's a trivial amount of code: since we wrap host/guest accesses anyway, almost all of it is well hidden from drivers.

2. Sane platforms would never set flags like VHOST_CROSS_ENDIAN_LEGACY - and when it's clear, there's zero overhead (as some point it was tested by compiling with and without the patches, got the same stripped binary).

Maybe we could create a Kconfig symbol to enforce point (2): prevent people from enabling it e.g. on x86. I will look into this - but it can be done by a patch on top, so I think this can be merged as is.

Quoted 8 lines
Quoted 3 lines

This cross-endian *oddity* is targeting PowerPC book3s_64 processors... I am not aware of any other users. Maybe create a symbol that would be only selected by PPC_BOOK3S_64 ?

I think some ARM systems are trying to support cross-endian configurations as well.

Besides that, yes, this is more or less what I had in mind.

Would something simple like this already do the job:

drivers/vhost/Kconfig +1 -0
@@ -35,6 +35,7 @@ config VHOST
 
 config VHOST_CROSS_ENDIAN_LEGACY
 	bool "Cross-endian support for vhost"
+	depends on KVM_BOOK3S_64 || KVM_ARM_HOST
 	default n
 	---help---
 	  This option allows vhost to support guests with a different byte
Quoted 1 line

?

Do all ARM hosts support this dynamic endian-ness?

Quoted 3 lines

If that looks acceptable, I can submit a proper patch if you like.

Thomas

I think I prefer some kind of symbol defined by these arches, so I don't get to maintain an arch list in vhost.

Signature · 1 line
MST
#9 lore raw

PATCH 1/1 KVM: Add Kconfig option to signal cross-endian guests

The option for supporting cross-endianness legacy guests in the vhost and tun code should only be available on systems that support cross-endian guests.

---
 arch/arm/kvm/Kconfig     | 1 +
 arch/arm64/kvm/Kconfig   | 1 +
 arch/powerpc/kvm/Kconfig | 1 +
 drivers/net/Kconfig      | 1 +
 drivers/vhost/Kconfig    | 1 +
 virt/kvm/Kconfig         | 3 +++
 6 files changed, 8 insertions(+)
arch/arm/kvm/Kconfig +1 -0
index bfb915d..9d8f363 100644
@@ -31,6 +31,7 @@ config KVM
 	select KVM_VFIO
 	select HAVE_KVM_EVENTFD
 	select HAVE_KVM_IRQFD
+	select KVM_CROSS_ENDIAN_GUESTS
 	depends on ARM_VIRT_EXT && ARM_LPAE && ARM_ARCH_TIMER
 	---help---
 	  Support hosting virtualized guest machines.
arch/arm64/kvm/Kconfig +1 -0
index bfffe8f..9af39fe 100644
@@ -31,6 +31,7 @@ config KVM
 	select KVM_VFIO
 	select HAVE_KVM_EVENTFD
 	select HAVE_KVM_IRQFD
+	select KVM_CROSS_ENDIAN_GUESTS
 	---help---
 	  Support hosting virtualized guest machines.
 
arch/powerpc/kvm/Kconfig +1 -0
index 3caec2c..e028710 100644
@@ -79,6 +79,7 @@ config KVM_BOOK3S_64_HV
 	select KVM_BOOK3S_HV_POSSIBLE
 	select MMU_NOTIFIER
 	select CMA
+	select KVM_CROSS_ENDIAN_GUESTS
 	---help---
 	  Support running unmodified book3s_64 guest kernels in
 	  virtual machines on POWER7 and PPC970 processors that have
drivers/net/Kconfig +1 -0
index c18f9e6..0c4ce47 100644
@@ -261,6 +261,7 @@ config TUN
 config TUN_VNET_CROSS_LE
 	bool "Support for cross-endian vnet headers on little-endian kernels"
 	default n
+	depends on KVM_CROSS_ENDIAN_GUESTS
 	---help---
 	  This option allows TUN/TAP and MACVTAP device drivers in a
 	  little-endian kernel to parse vnet headers that come from a
drivers/vhost/Kconfig +1 -0
index 533eaf0..4d8ae6b 100644
@@ -35,6 +35,7 @@ config VHOST
 
 config VHOST_CROSS_ENDIAN_LEGACY
 	bool "Cross-endian support for vhost"
+	depends on KVM_CROSS_ENDIAN_GUESTS
 	default n
 	---help---
 	  This option allows vhost to support guests with a different byte
virt/kvm/Kconfig +3 -0
index e2c876d..cc7b28a 100644
@@ -47,3 +47,6 @@ config KVM_GENERIC_DIRTYLOG_READ_PROTECT
 config KVM_COMPAT
        def_bool y
        depends on COMPAT && !S390
+
+config KVM_CROSS_ENDIAN_GUESTS
+       bool
Signature · 1 line
1.8.3.1
#20 lore raw

PATCH 1/1 KVM: Add Kconfig option to signal cross-endian guests

In reply to Michael S. Tsirkin

The option for supporting cross-endianness legacy guests in the vhost and tun code should only be available on systems that support cross-endian guests.

---
 arch/arm/kvm/Kconfig     | 1 +
 arch/arm64/kvm/Kconfig   | 1 +
 arch/powerpc/kvm/Kconfig | 1 +
 drivers/net/Kconfig      | 1 +
 drivers/vhost/Kconfig    | 1 +
 virt/kvm/Kconfig         | 3 +++
 6 files changed, 8 insertions(+)
arch/arm/kvm/Kconfig +1 -0
index bfb915d..9d8f363 100644
@@ -31,6 +31,7 @@ config KVM
 	select KVM_VFIO
 	select HAVE_KVM_EVENTFD
 	select HAVE_KVM_IRQFD
+	select KVM_CROSS_ENDIAN_GUESTS
 	depends on ARM_VIRT_EXT && ARM_LPAE && ARM_ARCH_TIMER
 	---help---
 	  Support hosting virtualized guest machines.
arch/arm64/kvm/Kconfig +1 -0
index bfffe8f..9af39fe 100644
@@ -31,6 +31,7 @@ config KVM
 	select KVM_VFIO
 	select HAVE_KVM_EVENTFD
 	select HAVE_KVM_IRQFD
+	select KVM_CROSS_ENDIAN_GUESTS
 	---help---
 	  Support hosting virtualized guest machines.
 
arch/powerpc/kvm/Kconfig +1 -0
index 3caec2c..e028710 100644
@@ -79,6 +79,7 @@ config KVM_BOOK3S_64_HV
 	select KVM_BOOK3S_HV_POSSIBLE
 	select MMU_NOTIFIER
 	select CMA
+	select KVM_CROSS_ENDIAN_GUESTS
 	---help---
 	  Support running unmodified book3s_64 guest kernels in
 	  virtual machines on POWER7 and PPC970 processors that have
drivers/net/Kconfig +1 -0
index c18f9e6..0c4ce47 100644
@@ -261,6 +261,7 @@ config TUN
 config TUN_VNET_CROSS_LE
 	bool "Support for cross-endian vnet headers on little-endian kernels"
 	default n
+	depends on KVM_CROSS_ENDIAN_GUESTS
 	---help---
 	  This option allows TUN/TAP and MACVTAP device drivers in a
 	  little-endian kernel to parse vnet headers that come from a
drivers/vhost/Kconfig +1 -0
index 533eaf0..4d8ae6b 100644
@@ -35,6 +35,7 @@ config VHOST
 
 config VHOST_CROSS_ENDIAN_LEGACY
 	bool "Cross-endian support for vhost"
+	depends on KVM_CROSS_ENDIAN_GUESTS
 	default n
 	---help---
 	  This option allows vhost to support guests with a different byte
virt/kvm/Kconfig +3 -0
index e2c876d..cc7b28a 100644
@@ -47,3 +47,6 @@ config KVM_GENERIC_DIRTYLOG_READ_PROTECT
 config KVM_COMPAT
        def_bool y
        depends on COMPAT && !S390
+
+config KVM_CROSS_ENDIAN_GUESTS
+       bool
Signature · 1 line
1.8.3.1
#10 lore raw

Re: [PATCH] KVM: Add Kconfig option to signal cross-endian guests

In reply to Thomas Huth
Quoted 3 lines · Thomas Huth

The option for supporting cross-endianness legacy guests in the vhost and tun code should only be available on systems that support cross-endian guests.

I'm sure I misunderstand something, but what happens if we use QEMU with TCG instead of KVM, i.e. a big endian powerpc kernel guest on x86_64 little endian host ?
Do you forbid the use of vhost in this case ?

Quoted 82 lines
---
 arch/arm/kvm/Kconfig     | 1 +
 arch/arm64/kvm/Kconfig   | 1 +
 arch/powerpc/kvm/Kconfig | 1 +
 drivers/net/Kconfig      | 1 +
 drivers/vhost/Kconfig    | 1 +
 virt/kvm/Kconfig         | 3 +++
 6 files changed, 8 insertions(+)
arch/arm/kvm/Kconfig +1 -0
index bfb915d..9d8f363 100644
@@ -31,6 +31,7 @@ config KVM
 	select KVM_VFIO
 	select HAVE_KVM_EVENTFD
 	select HAVE_KVM_IRQFD
+	select KVM_CROSS_ENDIAN_GUESTS
 	depends on ARM_VIRT_EXT && ARM_LPAE && ARM_ARCH_TIMER
 	---help---
 	  Support hosting virtualized guest machines.
arch/arm64/kvm/Kconfig +1 -0
index bfffe8f..9af39fe 100644
@@ -31,6 +31,7 @@ config KVM
 	select KVM_VFIO
 	select HAVE_KVM_EVENTFD
 	select HAVE_KVM_IRQFD
+	select KVM_CROSS_ENDIAN_GUESTS
 	---help---
 	  Support hosting virtualized guest machines.
 
arch/powerpc/kvm/Kconfig +1 -0
index 3caec2c..e028710 100644
@@ -79,6 +79,7 @@ config KVM_BOOK3S_64_HV
 	select KVM_BOOK3S_HV_POSSIBLE
 	select MMU_NOTIFIER
 	select CMA
+	select KVM_CROSS_ENDIAN_GUESTS
 	---help---
 	  Support running unmodified book3s_64 guest kernels in
 	  virtual machines on POWER7 and PPC970 processors that have
drivers/net/Kconfig +1 -0
index c18f9e6..0c4ce47 100644
@@ -261,6 +261,7 @@ config TUN
 config TUN_VNET_CROSS_LE
 	bool "Support for cross-endian vnet headers on little-endian kernels"
 	default n
+	depends on KVM_CROSS_ENDIAN_GUESTS
 	---help---
 	  This option allows TUN/TAP and MACVTAP device drivers in a
 	  little-endian kernel to parse vnet headers that come from a
drivers/vhost/Kconfig +1 -0
index 533eaf0..4d8ae6b 100644
@@ -35,6 +35,7 @@ config VHOST
 
 config VHOST_CROSS_ENDIAN_LEGACY
 	bool "Cross-endian support for vhost"
+	depends on KVM_CROSS_ENDIAN_GUESTS
 	default n
 	---help---
 	  This option allows vhost to support guests with a different byte
virt/kvm/Kconfig +3 -0
index e2c876d..cc7b28a 100644
@@ -47,3 +47,6 @@ config KVM_GENERIC_DIRTYLOG_READ_PROTECT
 config KVM_COMPAT
        def_bool y
        depends on COMPAT && !S390
+
+config KVM_CROSS_ENDIAN_GUESTS
+       bool
#14 lore raw

Re: [PATCH] KVM: Add Kconfig option to signal cross-endian guests

In reply to Thomas Huth
Quoted 3 lines · Thomas Huth

The option for supporting cross-endianness legacy guests in the vhost and tun code should only be available on systems that support cross-endian guests.

I'm sure I misunderstand something, but what happens if we use QEMU with TCG instead of KVM, i.e. a big endian powerpc kernel guest on x86_64 little endian host ?
Do you forbid the use of vhost in this case ?

Quoted 82 lines
---
 arch/arm/kvm/Kconfig     | 1 +
 arch/arm64/kvm/Kconfig   | 1 +
 arch/powerpc/kvm/Kconfig | 1 +
 drivers/net/Kconfig      | 1 +
 drivers/vhost/Kconfig    | 1 +
 virt/kvm/Kconfig         | 3 +++
 6 files changed, 8 insertions(+)
arch/arm/kvm/Kconfig +1 -0
index bfb915d..9d8f363 100644
@@ -31,6 +31,7 @@ config KVM
 	select KVM_VFIO
 	select HAVE_KVM_EVENTFD
 	select HAVE_KVM_IRQFD
+	select KVM_CROSS_ENDIAN_GUESTS
 	depends on ARM_VIRT_EXT && ARM_LPAE && ARM_ARCH_TIMER
 	---help---
 	  Support hosting virtualized guest machines.
arch/arm64/kvm/Kconfig +1 -0
index bfffe8f..9af39fe 100644
@@ -31,6 +31,7 @@ config KVM
 	select KVM_VFIO
 	select HAVE_KVM_EVENTFD
 	select HAVE_KVM_IRQFD
+	select KVM_CROSS_ENDIAN_GUESTS
 	---help---
 	  Support hosting virtualized guest machines.
 
arch/powerpc/kvm/Kconfig +1 -0
index 3caec2c..e028710 100644
@@ -79,6 +79,7 @@ config KVM_BOOK3S_64_HV
 	select KVM_BOOK3S_HV_POSSIBLE
 	select MMU_NOTIFIER
 	select CMA
+	select KVM_CROSS_ENDIAN_GUESTS
 	---help---
 	  Support running unmodified book3s_64 guest kernels in
 	  virtual machines on POWER7 and PPC970 processors that have
drivers/net/Kconfig +1 -0
index c18f9e6..0c4ce47 100644
@@ -261,6 +261,7 @@ config TUN
 config TUN_VNET_CROSS_LE
 	bool "Support for cross-endian vnet headers on little-endian kernels"
 	default n
+	depends on KVM_CROSS_ENDIAN_GUESTS
 	---help---
 	  This option allows TUN/TAP and MACVTAP device drivers in a
 	  little-endian kernel to parse vnet headers that come from a
drivers/vhost/Kconfig +1 -0
index 533eaf0..4d8ae6b 100644
@@ -35,6 +35,7 @@ config VHOST
 
 config VHOST_CROSS_ENDIAN_LEGACY
 	bool "Cross-endian support for vhost"
+	depends on KVM_CROSS_ENDIAN_GUESTS
 	default n
 	---help---
 	  This option allows vhost to support guests with a different byte
virt/kvm/Kconfig +3 -0
index e2c876d..cc7b28a 100644
@@ -47,3 +47,6 @@ config KVM_GENERIC_DIRTYLOG_READ_PROTECT
 config KVM_COMPAT
        def_bool y
        depends on COMPAT && !S390
+
+config KVM_CROSS_ENDIAN_GUESTS
+       bool
Acked-by on v1 1/1
#16 lore raw

Re: [PATCH] KVM: Add Kconfig option to signal cross-endian guests

In reply to Thomas Huth
Quoted 1 line · On Thu, 9 Jul 2015 09:49:05 +0200 Thomas Huth <[email protected]> wrote:

The option for supporting cross-endianness legacy guests in

s/cross-endianness/cross-endian/ ?

Quoted 4 lines

the vhost and tun code should only be available on systems that support cross-endian guests.

Quoted 8 lines
---
 arch/arm/kvm/Kconfig     | 1 +
 arch/arm64/kvm/Kconfig   | 1 +
 arch/powerpc/kvm/Kconfig | 1 +
 drivers/net/Kconfig      | 1 +
 drivers/vhost/Kconfig    | 1 +
 virt/kvm/Kconfig         | 3 +++
 6 files changed, 8 insertions(+)
Acked-by on v1 1/1
#17 lore raw

Re: [PATCH] KVM: Add Kconfig option to signal cross-endian guests

In reply to Thomas Huth
Quoted 1 line · On Thu, 9 Jul 2015 09:49:05 +0200 Thomas Huth <[email protected]> wrote:

The option for supporting cross-endianness legacy guests in

s/cross-endianness/cross-endian/ ?

Quoted 4 lines

the vhost and tun code should only be available on systems that support cross-endian guests.

Quoted 8 lines
---
 arch/arm/kvm/Kconfig     | 1 +
 arch/arm64/kvm/Kconfig   | 1 +
 arch/powerpc/kvm/Kconfig | 1 +
 drivers/net/Kconfig      | 1 +
 drivers/vhost/Kconfig    | 1 +
 virt/kvm/Kconfig         | 3 +++
 6 files changed, 8 insertions(+)
maintainer
#11 lore raw

Re: [PATCH] KVM: Add Kconfig option to signal cross-endian guests

In reply to Laurent Vivier
Quoted 10 lines · Laurent Vivier
Quoted 3 lines · Thomas Huth

The option for supporting cross-endianness legacy guests in the vhost and tun code should only be available on systems that support cross-endian guests.

I'm sure I misunderstand something, but what happens if we use QEMU with TCG instead of KVM, i.e. a big endian powerpc kernel guest on x86_64 little endian host ?

TCG does not yet support irqfd/ioeventfd, so it cannot be used with vhost.

Paolo

Quoted 84 lines

Do you forbid the use of vhost in this case ?

Quoted 82 lines
---
 arch/arm/kvm/Kconfig     | 1 +
 arch/arm64/kvm/Kconfig   | 1 +
 arch/powerpc/kvm/Kconfig | 1 +
 drivers/net/Kconfig      | 1 +
 drivers/vhost/Kconfig    | 1 +
 virt/kvm/Kconfig         | 3 +++
 6 files changed, 8 insertions(+)
arch/arm/kvm/Kconfig +1 -0
index bfb915d..9d8f363 100644
@@ -31,6 +31,7 @@ config KVM
 	select KVM_VFIO
 	select HAVE_KVM_EVENTFD
 	select HAVE_KVM_IRQFD
+	select KVM_CROSS_ENDIAN_GUESTS
 	depends on ARM_VIRT_EXT && ARM_LPAE && ARM_ARCH_TIMER
 	---help---
 	  Support hosting virtualized guest machines.
arch/arm64/kvm/Kconfig +1 -0
index bfffe8f..9af39fe 100644
@@ -31,6 +31,7 @@ config KVM
 	select KVM_VFIO
 	select HAVE_KVM_EVENTFD
 	select HAVE_KVM_IRQFD
+	select KVM_CROSS_ENDIAN_GUESTS
 	---help---
 	  Support hosting virtualized guest machines.
 
arch/powerpc/kvm/Kconfig +1 -0
index 3caec2c..e028710 100644
@@ -79,6 +79,7 @@ config KVM_BOOK3S_64_HV
 	select KVM_BOOK3S_HV_POSSIBLE
 	select MMU_NOTIFIER
 	select CMA
+	select KVM_CROSS_ENDIAN_GUESTS
 	---help---
 	  Support running unmodified book3s_64 guest kernels in
 	  virtual machines on POWER7 and PPC970 processors that have
drivers/net/Kconfig +1 -0
index c18f9e6..0c4ce47 100644
@@ -261,6 +261,7 @@ config TUN
 config TUN_VNET_CROSS_LE
 	bool "Support for cross-endian vnet headers on little-endian kernels"
 	default n
+	depends on KVM_CROSS_ENDIAN_GUESTS
 	---help---
 	  This option allows TUN/TAP and MACVTAP device drivers in a
 	  little-endian kernel to parse vnet headers that come from a
drivers/vhost/Kconfig +1 -0
index 533eaf0..4d8ae6b 100644
@@ -35,6 +35,7 @@ config VHOST
 
 config VHOST_CROSS_ENDIAN_LEGACY
 	bool "Cross-endian support for vhost"
+	depends on KVM_CROSS_ENDIAN_GUESTS
 	default n
 	---help---
 	  This option allows vhost to support guests with a different byte
virt/kvm/Kconfig +3 -0
index e2c876d..cc7b28a 100644
@@ -47,3 +47,6 @@ config KVM_GENERIC_DIRTYLOG_READ_PROTECT
 config KVM_COMPAT
        def_bool y
        depends on COMPAT && !S390
+
+config KVM_CROSS_ENDIAN_GUESTS
+       bool
author maintainer
#12 lore raw

Re: [PATCH] KVM: Add Kconfig option to signal cross-endian guests

Quoted 10 lines · Paolo Bonzini
Quoted 7 lines · Laurent Vivier
Quoted 3 lines · Thomas Huth

The option for supporting cross-endianness legacy guests in the vhost and tun code should only be available on systems that support cross-endian guests.

Quoted 7 lines
Quoted 3 lines

I'm sure I misunderstand something, but what happens if we use QEMU with TCG instead of KVM, i.e. a big endian powerpc kernel guest on x86_64 little endian host ?

TCG does not yet support irqfd/ioeventfd, so it cannot be used with vhost.

Paolo

vhost does not require irqfd anymore. I think ioeventfd actually works fine though I didn't try, it would be easy to support.

Quoted 84 lines
Quoted 84 lines

Do you forbid the use of vhost in this case ?

Quoted 82 lines
---
 arch/arm/kvm/Kconfig     | 1 +
 arch/arm64/kvm/Kconfig   | 1 +
 arch/powerpc/kvm/Kconfig | 1 +
 drivers/net/Kconfig      | 1 +
 drivers/vhost/Kconfig    | 1 +
 virt/kvm/Kconfig         | 3 +++
 6 files changed, 8 insertions(+)
arch/arm/kvm/Kconfig +1 -0
index bfb915d..9d8f363 100644
@@ -31,6 +31,7 @@ config KVM
 	select KVM_VFIO
 	select HAVE_KVM_EVENTFD
 	select HAVE_KVM_IRQFD
+	select KVM_CROSS_ENDIAN_GUESTS
 	depends on ARM_VIRT_EXT && ARM_LPAE && ARM_ARCH_TIMER
 	---help---
 	  Support hosting virtualized guest machines.
arch/arm64/kvm/Kconfig +1 -0
index bfffe8f..9af39fe 100644
@@ -31,6 +31,7 @@ config KVM
 	select KVM_VFIO
 	select HAVE_KVM_EVENTFD
 	select HAVE_KVM_IRQFD
+	select KVM_CROSS_ENDIAN_GUESTS
 	---help---
 	  Support hosting virtualized guest machines.
 
arch/powerpc/kvm/Kconfig +1 -0
index 3caec2c..e028710 100644
@@ -79,6 +79,7 @@ config KVM_BOOK3S_64_HV
 	select KVM_BOOK3S_HV_POSSIBLE
 	select MMU_NOTIFIER
 	select CMA
+	select KVM_CROSS_ENDIAN_GUESTS
 	---help---
 	  Support running unmodified book3s_64 guest kernels in
 	  virtual machines on POWER7 and PPC970 processors that have
drivers/net/Kconfig +1 -0
index c18f9e6..0c4ce47 100644
@@ -261,6 +261,7 @@ config TUN
 config TUN_VNET_CROSS_LE
 	bool "Support for cross-endian vnet headers on little-endian kernels"
 	default n
+	depends on KVM_CROSS_ENDIAN_GUESTS
 	---help---
 	  This option allows TUN/TAP and MACVTAP device drivers in a
 	  little-endian kernel to parse vnet headers that come from a
drivers/vhost/Kconfig +1 -0
index 533eaf0..4d8ae6b 100644
@@ -35,6 +35,7 @@ config VHOST
 
 config VHOST_CROSS_ENDIAN_LEGACY
 	bool "Cross-endian support for vhost"
+	depends on KVM_CROSS_ENDIAN_GUESTS
 	default n
 	---help---
 	  This option allows vhost to support guests with a different byte
virt/kvm/Kconfig +3 -0
index e2c876d..cc7b28a 100644
@@ -47,3 +47,6 @@ config KVM_GENERIC_DIRTYLOG_READ_PROTECT
 config KVM_COMPAT
        def_bool y
        depends on COMPAT && !S390
+
+config KVM_CROSS_ENDIAN_GUESTS
+       bool
#13 lore raw

Re: [PATCH] KVM: Add Kconfig option to signal cross-endian guests

Quoted 15 lines · On Thu, 9 Jul 2015 16:07:47 +0300 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 14 lines · Paolo Bonzini
Quoted 10 lines · Laurent Vivier
Quoted 3 lines · Thomas Huth

The option for supporting cross-endianness legacy guests in the vhost and tun code should only be available on systems that support cross-endian guests.

I'm sure I misunderstand something, but what happens if we use QEMU with TCG instead of KVM, i.e. a big endian powerpc kernel guest on x86_64 little endian host ?

Quoted 6 lines
Quoted 3 lines

TCG does not yet support irqfd/ioeventfd, so it cannot be used with vhost.

Paolo

vhost does not require irqfd anymore. I think ioeventfd actually works fine though I didn't try, it would be easy to support.

That's an interesting issue, thanks for pointing this out, Laurent! So do we now rather want to leave everything as it currently is, in case somebody wants to use vhost-net with a cross-endian TCG guest one day?

Or do we assume that either
a) TCG is so slow anyway that nobody wants to accelerate it with vhost or
b) TCG vhost likely won't happen that soon so we hope that everybody will already be using virtio 1.0 at that point in time (with a fixed endianness)
?
... then I think we should go on and include this patch.

Thomas