From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Elena Ufimtseva" <elena.ufimtseva@oracle.com>,
"Fam Zheng" <fam@euphon.net>, "Thomas Huth" <thuth@redhat.com>,
"Jagannathan Raman" <jag.raman@oracle.com>,
qemu-block@nongnu.org, "Michael S. Tsirkin" <mst@redhat.com>,
"Alex Bennée" <alex.bennee@linaro.org>,
"Jason Wang" <jasowang@redhat.com>,
"Cornelia Huck" <cohuck@redhat.com>,
"Christian Schoenebeck" <qemu_oss@crudebyte.com>,
"Greg Kurz" <groug@kaod.org>,
"Wainer dos Santos Moschetta" <wainersm@redhat.com>,
"Max Reitz" <mreitz@redhat.com>,
"Stefan Hajnoczi" <stefanha@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Kevin Wolf" <kwolf@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@redhat.com>
Subject: [PATCH-for-6.0 1/3] hw/virtio: Add configure switch to disable legacy VIRTIO
Date: Thu, 5 Nov 2020 13:43:51 +0100 [thread overview]
Message-ID: <20201105124353.3680057-2-philmd@redhat.com> (raw)
In-Reply-To: <20201105124353.3680057-1-philmd@redhat.com>
Per [1] (Terminology):
Legacy interfaces are not required; ie. don’t implement them
unless you have a need for backwards compatibility!
[2] (Version 1.0):
The device configuration space uses the little-endian format
for multi-byte fields.
and [3] (Legacy Interface):
for legacy interfaces, device configuration space is generally
the guest’s native endian, rather than PCI’s little-endian.
The correct endian-ness is documented for each device.
Add the --disable-virtio-legacy configure flag to produce builds
with VIRTIO 1.0 only, and the --enable-virtio-legacy to include
legacy VIRTIO support (supporting legacy VIRTIO is the default).
[1] http://docs.oasis-open.org/virtio/virtio/v1.0/cs04/virtio-v1.0-cs04.html#x1-60001
[2] http://docs.oasis-open.org/virtio/virtio/v1.0/cs04/virtio-v1.0-cs04.html#x1-170003
[3] http://docs.oasis-open.org/virtio/virtio/v1.0/cs04/virtio-v1.0-cs04.html#x1-200003
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
configure | 10 ++++++++++
meson.build | 1 +
include/hw/virtio/virtio-access.h | 19 +++++--------------
hw/virtio/virtio-legacy.c | 29 +++++++++++++++++++++++++++++
hw/virtio/meson.build | 1 +
5 files changed, 46 insertions(+), 14 deletions(-)
create mode 100644 hw/virtio/virtio-legacy.c
diff --git a/configure b/configure
index 2c3c69f1188..f46216b3788 100755
--- a/configure
+++ b/configure
@@ -302,6 +302,7 @@ fdt="auto"
netmap="no"
sdl="auto"
sdl_image="auto"
+virtio_legacy="enabled"
virtiofsd="auto"
virtfs=""
libudev="auto"
@@ -1001,6 +1002,10 @@ for opt do
;;
--enable-libudev) libudev="enabled"
;;
+ --disable-virtio-legacy) virtio_legacy="disabled"
+ ;;
+ --enable-virtio-legacy) virtio_legacy="enabled"
+ ;;
--disable-virtiofsd) virtiofsd="disabled"
;;
--enable-virtiofsd) virtiofsd="enabled"
@@ -1764,6 +1769,7 @@ disabled with --disable-FEATURE, default is enabled if available:
vnc-png PNG compression for VNC server
cocoa Cocoa UI (Mac OS X only)
virtfs VirtFS
+ virtio-legacy enable support for legacy virtio (before VIRTIO 1.0)
virtiofsd build virtiofs daemon (virtiofsd)
libudev Use libudev to enumerate host devices
mpath Multipath persistent reservation passthrough
@@ -6816,6 +6822,10 @@ if test "$safe_stack" = "yes"; then
echo "CONFIG_SAFESTACK=y" >> $config_host_mak
fi
+if test "$virtio_legacy" = "enabled"; then
+ echo "CONFIG_VIRTIO_LEGACY=y" >> $config_host_mak
+fi
+
# If we're using a separate build tree, set it up now.
# DIRS are directories which we simply mkdir in the build tree;
# LINKS are things to symlink back into the source tree
diff --git a/meson.build b/meson.build
index 39ac5cf6d8a..51406c28c6e 100644
--- a/meson.build
+++ b/meson.build
@@ -2061,6 +2061,7 @@
summary_info += {'Block whitelist (rw)': config_host['CONFIG_BDRV_RW_WHITELIST']}
summary_info += {'Block whitelist (ro)': config_host['CONFIG_BDRV_RO_WHITELIST']}
summary_info += {'VirtFS support': config_host.has_key('CONFIG_VIRTFS')}
+summary_info += {'Legacy VIRTIO support': config_host.has_key('CONFIG_VIRTIO_LEGACY')}
summary_info += {'build virtiofs daemon': have_virtiofsd}
summary_info += {'Multipath support': mpathpersist.found()}
summary_info += {'VNC support': vnc.found()}
diff --git a/include/hw/virtio/virtio-access.h b/include/hw/virtio/virtio-access.h
index 6818a23a2d3..b6c060f8cc6 100644
--- a/include/hw/virtio/virtio-access.h
+++ b/include/hw/virtio/virtio-access.h
@@ -20,24 +20,15 @@
#include "hw/virtio/virtio.h"
#include "hw/virtio/virtio-bus.h"
-#if defined(TARGET_PPC64) || defined(TARGET_ARM)
-#define LEGACY_VIRTIO_IS_BIENDIAN 1
-#endif
-
+#ifdef CONFIG_VIRTIO_LEGACY
+bool virtio_access_is_big_endian(VirtIODevice *vdev);
+#else
static inline bool virtio_access_is_big_endian(VirtIODevice *vdev)
{
-#if defined(LEGACY_VIRTIO_IS_BIENDIAN)
- return virtio_is_big_endian(vdev);
-#elif defined(TARGET_WORDS_BIGENDIAN)
- 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
+ /* Devices conforming to VIRTIO 1.0 or later are always LE. */
return false;
-#endif
}
+#endif
static inline uint16_t virtio_lduw_phys(VirtIODevice *vdev, hwaddr pa)
{
diff --git a/hw/virtio/virtio-legacy.c b/hw/virtio/virtio-legacy.c
new file mode 100644
index 00000000000..bf28c824a25
--- /dev/null
+++ b/hw/virtio/virtio-legacy.c
@@ -0,0 +1,29 @@
+/*
+ * Legacy virtio endian helpers.
+ *
+ * Copyright Red Hat, Inc. 2020
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+#include "qemu/osdep.h"
+#include "hw/virtio/virtio.h"
+#include "hw/virtio/virtio-access.h"
+
+#if defined(TARGET_PPC64) || defined(TARGET_ARM)
+# define LEGACY_VIRTIO_IS_BIENDIAN 1
+#endif
+
+bool virtio_access_is_big_endian(VirtIODevice *vdev)
+{
+#if defined(LEGACY_VIRTIO_IS_BIENDIAN)
+ return virtio_is_big_endian(vdev);
+#elif defined(TARGET_WORDS_BIGENDIAN)
+ 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;
+#endif
+}
diff --git a/hw/virtio/meson.build b/hw/virtio/meson.build
index fbff9bc9d4d..95415913a9a 100644
--- a/hw/virtio/meson.build
+++ b/hw/virtio/meson.build
@@ -11,6 +11,7 @@
virtio_ss = ss.source_set()
virtio_ss.add(files('virtio.c'))
+virtio_ss.add(when: 'CONFIG_VIRTIO_LEGACY', if_true: files('virtio-legacy.c'))
virtio_ss.add(when: 'CONFIG_VHOST', if_true: files('vhost.c', 'vhost-backend.c'))
virtio_ss.add(when: 'CONFIG_VHOST_USER', if_true: files('vhost-user.c'))
virtio_ss.add(when: 'CONFIG_VHOST_VDPA', if_true: files('vhost-vdpa.c'))
--
2.26.2
next prev parent reply other threads:[~2020-11-05 12:48 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-05 12:43 [PATCH-for-6.0 0/3] hw/virtio: Allow to disable legacy VIRTIO Philippe Mathieu-Daudé
2020-11-05 12:43 ` Philippe Mathieu-Daudé [this message]
2020-11-05 13:06 ` [PATCH-for-6.0 1/3] hw/virtio: Add configure switch " Cornelia Huck
2020-11-05 13:53 ` Philippe Mathieu-Daudé
2020-11-05 13:08 ` Paolo Bonzini
2020-11-05 12:43 ` [PATCH-for-6.0 2/3] hw/virtio: Build most of virtio devices as arch-independent objects Philippe Mathieu-Daudé
2020-11-05 13:08 ` Paolo Bonzini
2020-11-05 14:33 ` Greg Kurz
2020-11-05 12:43 ` [PATCH-for-6.0 3/3] gitlab-ci: Test the --disable-virtio-legacy option Philippe Mathieu-Daudé
2020-11-05 13:33 ` Thomas Huth
2020-11-05 14:12 ` [PATCH-for-6.0 0/3] hw/virtio: Allow to disable legacy VIRTIO Philippe Mathieu-Daudé
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=20201105124353.3680057-2-philmd@redhat.com \
--to=philmd@redhat.com \
--cc=alex.bennee@linaro.org \
--cc=cohuck@redhat.com \
--cc=elena.ufimtseva@oracle.com \
--cc=fam@euphon.net \
--cc=groug@kaod.org \
--cc=jag.raman@oracle.com \
--cc=jasowang@redhat.com \
--cc=kwolf@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=mreitz@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu_oss@crudebyte.com \
--cc=stefanha@redhat.com \
--cc=thuth@redhat.com \
--cc=wainersm@redhat.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).