All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH-for-6.0 0/3] hw/virtio: Allow to disable legacy VIRTIO
@ 2020-11-05 12:43 Philippe Mathieu-Daudé
  2020-11-05 12:43 ` [PATCH-for-6.0 1/3] hw/virtio: Add configure switch " Philippe Mathieu-Daudé
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-11-05 12:43 UTC (permalink / raw)
  To: qemu-devel
  Cc: Elena Ufimtseva, Fam Zheng, Thomas Huth, Jagannathan Raman,
	qemu-block, Michael S. Tsirkin, Alex Bennée, Jason Wang,
	Cornelia Huck, Christian Schoenebeck, Greg Kurz,
	Wainer dos Santos Moschetta, Max Reitz, Stefan Hajnoczi,
	Paolo Bonzini, Marc-André Lureau, Kevin Wolf,
	Philippe Mathieu-Daudé

Stefan told me it would help the multi-process QEMU
series if virtio devices where not arch-specific.
As it didn't seem too complex, I gave it a try.

Philippe Mathieu-Daudé (3):
  hw/virtio: Add configure switch to disable legacy VIRTIO
  hw/virtio: Build most of virtio devices as arch-independent objects
  gitlab-ci: Test the --disable-virtio-legacy option

 configure                         | 10 ++++++++++
 meson.build                       |  1 +
 include/hw/virtio/virtio-access.h | 19 +++++--------------
 hw/virtio/virtio-legacy.c         | 29 +++++++++++++++++++++++++++++
 .gitlab-ci.yml                    |  1 +
 hw/9pfs/meson.build               |  2 +-
 hw/block/dataplane/meson.build    |  2 +-
 hw/block/meson.build              |  2 +-
 hw/char/meson.build               |  2 +-
 hw/net/meson.build                |  2 +-
 hw/scsi/meson.build               |  2 +-
 hw/virtio/meson.build             | 14 +++++++++-----
 12 files changed, 61 insertions(+), 25 deletions(-)
 create mode 100644 hw/virtio/virtio-legacy.c

-- 
2.26.2




^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH-for-6.0 1/3] hw/virtio: Add configure switch to disable legacy VIRTIO
  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é
  2020-11-05 13:06   ` Cornelia Huck
  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é
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-11-05 12:43 UTC (permalink / raw)
  To: qemu-devel
  Cc: Elena Ufimtseva, Fam Zheng, Thomas Huth, Jagannathan Raman,
	qemu-block, Michael S. Tsirkin, Alex Bennée, Jason Wang,
	Cornelia Huck, Christian Schoenebeck, Greg Kurz,
	Wainer dos Santos Moschetta, Max Reitz, Stefan Hajnoczi,
	Paolo Bonzini, Marc-André Lureau, Kevin Wolf,
	Philippe Mathieu-Daudé

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



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH-for-6.0 2/3] hw/virtio: Build most of virtio devices as arch-independent objects
  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 ` [PATCH-for-6.0 1/3] hw/virtio: Add configure switch " Philippe Mathieu-Daudé
@ 2020-11-05 12:43 ` 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 14:12 ` [PATCH-for-6.0 0/3] hw/virtio: Allow to disable legacy VIRTIO Philippe Mathieu-Daudé
  3 siblings, 2 replies; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-11-05 12:43 UTC (permalink / raw)
  To: qemu-devel
  Cc: Elena Ufimtseva, Fam Zheng, Thomas Huth, Jagannathan Raman,
	qemu-block, Michael S. Tsirkin, Stefan Hajnoczi,
	Alex Bennée, Jason Wang, Cornelia Huck,
	Christian Schoenebeck, Greg Kurz, Wainer dos Santos Moschetta,
	Max Reitz, Stefan Hajnoczi, Paolo Bonzini,
	Marc-André Lureau, Kevin Wolf, Philippe Mathieu-Daudé

VirtIO devices shouldn't be arch-specific. Some device have to
use PAGE_SIZE definition or access to CPUState. Keep building
them as arch-specific objects. Move all we can to libcommon.fa.

Suggested-by: Stefan Hajnoczi <stefanha@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 hw/9pfs/meson.build            |  2 +-
 hw/block/dataplane/meson.build |  2 +-
 hw/block/meson.build           |  2 +-
 hw/char/meson.build            |  2 +-
 hw/net/meson.build             |  2 +-
 hw/scsi/meson.build            |  2 +-
 hw/virtio/meson.build          | 15 +++++++++------
 7 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/hw/9pfs/meson.build b/hw/9pfs/meson.build
index cc094262122..ac964be15ce 100644
--- a/hw/9pfs/meson.build
+++ b/hw/9pfs/meson.build
@@ -17,4 +17,4 @@
 fs_ss.add(when: 'CONFIG_XEN', if_true: files('xen-9p-backend.c'))
 softmmu_ss.add_all(when: 'CONFIG_9PFS', if_true: fs_ss)
 
-specific_ss.add(when: 'CONFIG_VIRTIO_9P', if_true: files('virtio-9p-device.c'))
+softmmu_ss.add(when: 'CONFIG_VIRTIO_9P', if_true: files('virtio-9p-device.c'))
diff --git a/hw/block/dataplane/meson.build b/hw/block/dataplane/meson.build
index 12c6a264f10..e2f3721ce24 100644
--- a/hw/block/dataplane/meson.build
+++ b/hw/block/dataplane/meson.build
@@ -1,2 +1,2 @@
-specific_ss.add(when: 'CONFIG_VIRTIO_BLK', if_true: files('virtio-blk.c'))
+softmmu_ss.add(when: 'CONFIG_VIRTIO_BLK', if_true: files('virtio-blk.c'))
 specific_ss.add(when: 'CONFIG_XEN', if_true: files('xen-block.c'))
diff --git a/hw/block/meson.build b/hw/block/meson.build
index 602ca6c8541..497592c33ac 100644
--- a/hw/block/meson.build
+++ b/hw/block/meson.build
@@ -15,7 +15,7 @@
 softmmu_ss.add(when: 'CONFIG_SH4', if_true: files('tc58128.c'))
 softmmu_ss.add(when: 'CONFIG_NVME_PCI', if_true: files('nvme.c', 'nvme-ns.c'))
 
-specific_ss.add(when: 'CONFIG_VIRTIO_BLK', if_true: files('virtio-blk.c'))
+softmmu_ss.add(when: 'CONFIG_VIRTIO_BLK', if_true: files('virtio-blk.c'))
 specific_ss.add(when: 'CONFIG_VHOST_USER_BLK', if_true: files('vhost-user-blk.c'))
 
 subdir('dataplane')
diff --git a/hw/char/meson.build b/hw/char/meson.build
index 196ac91fa29..7496594ea07 100644
--- a/hw/char/meson.build
+++ b/hw/char/meson.build
@@ -37,5 +37,5 @@
 
 specific_ss.add(when: 'CONFIG_HTIF', if_true: files('riscv_htif.c'))
 specific_ss.add(when: 'CONFIG_TERMINAL3270', if_true: files('terminal3270.c'))
-specific_ss.add(when: 'CONFIG_VIRTIO', if_true: files('virtio-serial-bus.c'))
+softmmu_ss.add(when: 'CONFIG_VIRTIO', if_true: files('virtio-serial-bus.c'))
 specific_ss.add(when: 'CONFIG_PSERIES', if_true: files('spapr_vty.c'))
diff --git a/hw/net/meson.build b/hw/net/meson.build
index 4a7051b54a0..c795af23eee 100644
--- a/hw/net/meson.build
+++ b/hw/net/meson.build
@@ -43,7 +43,7 @@
 specific_ss.add(when: 'CONFIG_XILINX_ETHLITE', if_true: files('xilinx_ethlite.c'))
 
 softmmu_ss.add(when: 'CONFIG_VIRTIO_NET', if_true: files('net_rx_pkt.c'))
-specific_ss.add(when: 'CONFIG_VIRTIO_NET', if_true: files('virtio-net.c'))
+softmmu_ss.add(when: 'CONFIG_VIRTIO_NET', if_true: files('virtio-net.c'))
 
 softmmu_ss.add(when: ['CONFIG_VIRTIO_NET', 'CONFIG_VHOST_NET'], if_true: files('vhost_net.c'), if_false: files('vhost_net-stub.c'))
 softmmu_ss.add(when: 'CONFIG_ALL', if_true: files('vhost_net-stub.c'))
diff --git a/hw/scsi/meson.build b/hw/scsi/meson.build
index 923a34f344c..fdf27156f6a 100644
--- a/hw/scsi/meson.build
+++ b/hw/scsi/meson.build
@@ -19,7 +19,7 @@
 virtio_scsi_ss.add(files('virtio-scsi.c', 'virtio-scsi-dataplane.c'))
 virtio_scsi_ss.add(when: 'CONFIG_VHOST_SCSI', if_true: files('vhost-scsi-common.c', 'vhost-scsi.c'))
 virtio_scsi_ss.add(when: 'CONFIG_VHOST_USER_SCSI', if_true: files('vhost-scsi-common.c', 'vhost-user-scsi.c'))
-specific_scsi_ss.add_all(when: 'CONFIG_VIRTIO_SCSI', if_true: virtio_scsi_ss)
+softmmu_ss.add_all(when: 'CONFIG_VIRTIO_SCSI', if_true: virtio_scsi_ss)
 
 specific_scsi_ss.add(when: 'CONFIG_SPAPR_VSCSI', if_true: files('spapr_vscsi.c'))
 
diff --git a/hw/virtio/meson.build b/hw/virtio/meson.build
index 95415913a9a..40df99f1a48 100644
--- a/hw/virtio/meson.build
+++ b/hw/virtio/meson.build
@@ -9,12 +9,15 @@
 
 softmmu_ss.add(when: 'CONFIG_ALL', if_true: files('vhost-stub.c'))
 
+virtio_arch_ss = ss.source_set()
+virtio_arch_ss.add(files('virtio.c'))
+virtio_arch_ss.add(when: 'CONFIG_VIRTIO_LEGACY', if_true: files('virtio-legacy.c'))
+virtio_arch_ss.add(when: 'CONFIG_VHOST_USER', if_true: files('vhost-user.c'))
+virtio_arch_ss.add(when: 'CONFIG_VHOST_VDPA', if_true: files('vhost-vdpa.c'))
+virtio_arch_ss.add(when: 'CONFIG_VIRTIO_IOMMU', if_true: files('virtio-iommu.c'))
+
 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'))
 virtio_ss.add(when: 'CONFIG_VIRTIO_BALLOON', if_true: files('virtio-balloon.c'))
 virtio_ss.add(when: 'CONFIG_VIRTIO_CRYPTO', if_true: files('virtio-crypto.c'))
 virtio_ss.add(when: ['CONFIG_VIRTIO_CRYPTO', 'CONFIG_VIRTIO_PCI'], if_true: files('virtio-crypto-pci.c'))
@@ -24,7 +27,6 @@
 virtio_ss.add(when: 'CONFIG_VHOST_VSOCK', if_true: files('vhost-vsock.c', 'vhost-vsock-common.c'))
 virtio_ss.add(when: 'CONFIG_VHOST_USER_VSOCK', if_true: files('vhost-user-vsock.c', 'vhost-vsock-common.c'))
 virtio_ss.add(when: 'CONFIG_VIRTIO_RNG', if_true: files('virtio-rng.c'))
-virtio_ss.add(when: 'CONFIG_VIRTIO_IOMMU', if_true: files('virtio-iommu.c'))
 virtio_ss.add(when: 'CONFIG_VIRTIO_MEM', if_true: files('virtio-mem.c'))
 
 virtio_pci_ss = ss.source_set()
@@ -49,4 +51,5 @@
 
 virtio_ss.add_all(when: 'CONFIG_VIRTIO_PCI', if_true: virtio_pci_ss)
 
-specific_ss.add_all(when: 'CONFIG_VIRTIO', if_true: virtio_ss)
+softmmu_ss.add_all(when: 'CONFIG_VIRTIO', if_true: virtio_ss)
+specific_ss.add_all(when: 'CONFIG_VIRTIO', if_true: virtio_arch_ss)
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH-for-6.0 3/3] gitlab-ci: Test the --disable-virtio-legacy option
  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 ` [PATCH-for-6.0 1/3] hw/virtio: Add configure switch " Philippe Mathieu-Daudé
  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 12:43 ` 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é
  3 siblings, 1 reply; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-11-05 12:43 UTC (permalink / raw)
  To: qemu-devel
  Cc: Elena Ufimtseva, Fam Zheng, Thomas Huth, Jagannathan Raman,
	qemu-block, Michael S. Tsirkin, Alex Bennée, Jason Wang,
	Cornelia Huck, Christian Schoenebeck, Greg Kurz,
	Wainer dos Santos Moschetta, Max Reitz, Stefan Hajnoczi,
	Paolo Bonzini, Marc-André Lureau, Kevin Wolf,
	Philippe Mathieu-Daudé

Add the recently introduced '--disable-virtio-legacy' configuration
to the 'build-disabled' job.

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 .gitlab-ci.yml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 3b15ae5c302..21fa1a459fd 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -218,6 +218,7 @@ build-disabled:
       --disable-strip --disable-tpm --disable-usb-redir --disable-vdi
       --disable-vhost-crypto --disable-vhost-net --disable-vhost-scsi
       --disable-vhost-user --disable-vhost-vdpa --disable-vhost-vsock
+      --disable-virtio-legacy
       --disable-virglrenderer --disable-vnc --disable-vte --disable-vvfat
       --disable-xen --disable-zstd
     TARGETS: arm-softmmu i386-softmmu ppc64-softmmu mips64-softmmu
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH-for-6.0 1/3] hw/virtio: Add configure switch to disable legacy VIRTIO
  2020-11-05 12:43 ` [PATCH-for-6.0 1/3] hw/virtio: Add configure switch " Philippe Mathieu-Daudé
@ 2020-11-05 13:06   ` Cornelia Huck
  2020-11-05 13:53     ` Philippe Mathieu-Daudé
  2020-11-05 13:08   ` Paolo Bonzini
  1 sibling, 1 reply; 11+ messages in thread
From: Cornelia Huck @ 2020-11-05 13:06 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Elena Ufimtseva, Fam Zheng, Thomas Huth, Jagannathan Raman,
	qemu-block, Michael S. Tsirkin, Jason Wang,
	Christian Schoenebeck, Greg Kurz, Wainer dos Santos Moschetta,
	qemu-devel, Kevin Wolf, Stefan Hajnoczi, Paolo Bonzini,
	Marc-André Lureau, Max Reitz, Alex Bennée

On Thu,  5 Nov 2020 13:43:51 +0100
Philippe Mathieu-Daudé <philmd@redhat.com> wrote:

> 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).

This is only dealing with endianess issues; there are other differences
on the control plane as well.

Currently, virtio-pci has the option to make devices non-transitional,
but virtio-ccw has not (only for device types). For virtio-mmio, you
need to select one of legacy or non-transitional, IIRC.

> 
> [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/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;

This will make migration from a QEMU that has devices for which 1.0 has
not been negotiated fail.

> -#endif
>  }
> +#endif
>  
>  static inline uint16_t virtio_lduw_phys(VirtIODevice *vdev, hwaddr pa)
>  {



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH-for-6.0 1/3] hw/virtio: Add configure switch to disable legacy VIRTIO
  2020-11-05 12:43 ` [PATCH-for-6.0 1/3] hw/virtio: Add configure switch " Philippe Mathieu-Daudé
  2020-11-05 13:06   ` Cornelia Huck
@ 2020-11-05 13:08   ` Paolo Bonzini
  1 sibling, 0 replies; 11+ messages in thread
From: Paolo Bonzini @ 2020-11-05 13:08 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Elena Ufimtseva, Fam Zheng, Thomas Huth, Jagannathan Raman,
	qemu-block, Michael S. Tsirkin, Jason Wang, Cornelia Huck,
	Christian Schoenebeck, Greg Kurz, Wainer dos Santos Moschetta,
	Max Reitz, Stefan Hajnoczi, Marc-André Lureau, Kevin Wolf,
	Alex Bennée

On 05/11/20 13:43, Philippe Mathieu-Daudé wrote:
> +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

Please use meson_options.txt instead (you can make it a boolean option 
with true/false as the choices for the shell variable).

Paolo

>   # 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')}



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH-for-6.0 2/3] hw/virtio: Build most of virtio devices as arch-independent objects
  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
  1 sibling, 0 replies; 11+ messages in thread
From: Paolo Bonzini @ 2020-11-05 13:08 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Elena Ufimtseva, Fam Zheng, Thomas Huth, Jagannathan Raman,
	qemu-block, Michael S. Tsirkin, Stefan Hajnoczi, Jason Wang,
	Cornelia Huck, Christian Schoenebeck, Greg Kurz,
	Wainer dos Santos Moschetta, Max Reitz, Stefan Hajnoczi,
	Marc-André Lureau, Kevin Wolf, Alex Bennée

On 05/11/20 13:43, Philippe Mathieu-Daudé wrote:
> VirtIO devices shouldn't be arch-specific. Some device have to
> use PAGE_SIZE definition or access to CPUState. Keep building
> them as arch-specific objects. Move all we can to libcommon.fa.
> 
> Suggested-by: Stefan Hajnoczi <stefanha@gmail.com>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
>   hw/9pfs/meson.build            |  2 +-
>   hw/block/dataplane/meson.build |  2 +-
>   hw/block/meson.build           |  2 +-
>   hw/char/meson.build            |  2 +-
>   hw/net/meson.build             |  2 +-
>   hw/scsi/meson.build            |  2 +-
>   hw/virtio/meson.build          | 15 +++++++++------
>   7 files changed, 15 insertions(+), 12 deletions(-)
> 
> diff --git a/hw/9pfs/meson.build b/hw/9pfs/meson.build
> index cc094262122..ac964be15ce 100644
> --- a/hw/9pfs/meson.build
> +++ b/hw/9pfs/meson.build
> @@ -17,4 +17,4 @@
>   fs_ss.add(when: 'CONFIG_XEN', if_true: files('xen-9p-backend.c'))
>   softmmu_ss.add_all(when: 'CONFIG_9PFS', if_true: fs_ss)
>   
> -specific_ss.add(when: 'CONFIG_VIRTIO_9P', if_true: files('virtio-9p-device.c'))
> +softmmu_ss.add(when: 'CONFIG_VIRTIO_9P', if_true: files('virtio-9p-device.c'))
> diff --git a/hw/block/dataplane/meson.build b/hw/block/dataplane/meson.build
> index 12c6a264f10..e2f3721ce24 100644
> --- a/hw/block/dataplane/meson.build
> +++ b/hw/block/dataplane/meson.build
> @@ -1,2 +1,2 @@
> -specific_ss.add(when: 'CONFIG_VIRTIO_BLK', if_true: files('virtio-blk.c'))
> +softmmu_ss.add(when: 'CONFIG_VIRTIO_BLK', if_true: files('virtio-blk.c'))
>   specific_ss.add(when: 'CONFIG_XEN', if_true: files('xen-block.c'))
> diff --git a/hw/block/meson.build b/hw/block/meson.build
> index 602ca6c8541..497592c33ac 100644
> --- a/hw/block/meson.build
> +++ b/hw/block/meson.build
> @@ -15,7 +15,7 @@
>   softmmu_ss.add(when: 'CONFIG_SH4', if_true: files('tc58128.c'))
>   softmmu_ss.add(when: 'CONFIG_NVME_PCI', if_true: files('nvme.c', 'nvme-ns.c'))
>   
> -specific_ss.add(when: 'CONFIG_VIRTIO_BLK', if_true: files('virtio-blk.c'))
> +softmmu_ss.add(when: 'CONFIG_VIRTIO_BLK', if_true: files('virtio-blk.c'))
>   specific_ss.add(when: 'CONFIG_VHOST_USER_BLK', if_true: files('vhost-user-blk.c'))
>   
>   subdir('dataplane')
> diff --git a/hw/char/meson.build b/hw/char/meson.build
> index 196ac91fa29..7496594ea07 100644
> --- a/hw/char/meson.build
> +++ b/hw/char/meson.build
> @@ -37,5 +37,5 @@
>   
>   specific_ss.add(when: 'CONFIG_HTIF', if_true: files('riscv_htif.c'))
>   specific_ss.add(when: 'CONFIG_TERMINAL3270', if_true: files('terminal3270.c'))
> -specific_ss.add(when: 'CONFIG_VIRTIO', if_true: files('virtio-serial-bus.c'))
> +softmmu_ss.add(when: 'CONFIG_VIRTIO', if_true: files('virtio-serial-bus.c'))
>   specific_ss.add(when: 'CONFIG_PSERIES', if_true: files('spapr_vty.c'))
> diff --git a/hw/net/meson.build b/hw/net/meson.build
> index 4a7051b54a0..c795af23eee 100644
> --- a/hw/net/meson.build
> +++ b/hw/net/meson.build
> @@ -43,7 +43,7 @@
>   specific_ss.add(when: 'CONFIG_XILINX_ETHLITE', if_true: files('xilinx_ethlite.c'))
>   
>   softmmu_ss.add(when: 'CONFIG_VIRTIO_NET', if_true: files('net_rx_pkt.c'))
> -specific_ss.add(when: 'CONFIG_VIRTIO_NET', if_true: files('virtio-net.c'))
> +softmmu_ss.add(when: 'CONFIG_VIRTIO_NET', if_true: files('virtio-net.c'))
>   
>   softmmu_ss.add(when: ['CONFIG_VIRTIO_NET', 'CONFIG_VHOST_NET'], if_true: files('vhost_net.c'), if_false: files('vhost_net-stub.c'))
>   softmmu_ss.add(when: 'CONFIG_ALL', if_true: files('vhost_net-stub.c'))
> diff --git a/hw/scsi/meson.build b/hw/scsi/meson.build
> index 923a34f344c..fdf27156f6a 100644
> --- a/hw/scsi/meson.build
> +++ b/hw/scsi/meson.build
> @@ -19,7 +19,7 @@
>   virtio_scsi_ss.add(files('virtio-scsi.c', 'virtio-scsi-dataplane.c'))
>   virtio_scsi_ss.add(when: 'CONFIG_VHOST_SCSI', if_true: files('vhost-scsi-common.c', 'vhost-scsi.c'))
>   virtio_scsi_ss.add(when: 'CONFIG_VHOST_USER_SCSI', if_true: files('vhost-scsi-common.c', 'vhost-user-scsi.c'))
> -specific_scsi_ss.add_all(when: 'CONFIG_VIRTIO_SCSI', if_true: virtio_scsi_ss)
> +softmmu_ss.add_all(when: 'CONFIG_VIRTIO_SCSI', if_true: virtio_scsi_ss)
>   
>   specific_scsi_ss.add(when: 'CONFIG_SPAPR_VSCSI', if_true: files('spapr_vscsi.c'))
>   
> diff --git a/hw/virtio/meson.build b/hw/virtio/meson.build
> index 95415913a9a..40df99f1a48 100644
> --- a/hw/virtio/meson.build
> +++ b/hw/virtio/meson.build
> @@ -9,12 +9,15 @@
>   
>   softmmu_ss.add(when: 'CONFIG_ALL', if_true: files('vhost-stub.c'))
>   
> +virtio_arch_ss = ss.source_set()
> +virtio_arch_ss.add(files('virtio.c'))
> +virtio_arch_ss.add(when: 'CONFIG_VIRTIO_LEGACY', if_true: files('virtio-legacy.c'))
> +virtio_arch_ss.add(when: 'CONFIG_VHOST_USER', if_true: files('vhost-user.c'))
> +virtio_arch_ss.add(when: 'CONFIG_VHOST_VDPA', if_true: files('vhost-vdpa.c'))
> +virtio_arch_ss.add(when: 'CONFIG_VIRTIO_IOMMU', if_true: files('virtio-iommu.c'))
> +
>   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'))
>   virtio_ss.add(when: 'CONFIG_VIRTIO_BALLOON', if_true: files('virtio-balloon.c'))
>   virtio_ss.add(when: 'CONFIG_VIRTIO_CRYPTO', if_true: files('virtio-crypto.c'))
>   virtio_ss.add(when: ['CONFIG_VIRTIO_CRYPTO', 'CONFIG_VIRTIO_PCI'], if_true: files('virtio-crypto-pci.c'))
> @@ -24,7 +27,6 @@
>   virtio_ss.add(when: 'CONFIG_VHOST_VSOCK', if_true: files('vhost-vsock.c', 'vhost-vsock-common.c'))
>   virtio_ss.add(when: 'CONFIG_VHOST_USER_VSOCK', if_true: files('vhost-user-vsock.c', 'vhost-vsock-common.c'))
>   virtio_ss.add(when: 'CONFIG_VIRTIO_RNG', if_true: files('virtio-rng.c'))
> -virtio_ss.add(when: 'CONFIG_VIRTIO_IOMMU', if_true: files('virtio-iommu.c'))
>   virtio_ss.add(when: 'CONFIG_VIRTIO_MEM', if_true: files('virtio-mem.c'))
>   
>   virtio_pci_ss = ss.source_set()
> @@ -49,4 +51,5 @@
>   
>   virtio_ss.add_all(when: 'CONFIG_VIRTIO_PCI', if_true: virtio_pci_ss)
>   
> -specific_ss.add_all(when: 'CONFIG_VIRTIO', if_true: virtio_ss)
> +softmmu_ss.add_all(when: 'CONFIG_VIRTIO', if_true: virtio_ss)
> +specific_ss.add_all(when: 'CONFIG_VIRTIO', if_true: virtio_arch_ss)
> 

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH-for-6.0 3/3] gitlab-ci: Test the --disable-virtio-legacy option
  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
  0 siblings, 0 replies; 11+ messages in thread
From: Thomas Huth @ 2020-11-05 13:33 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Elena Ufimtseva, Fam Zheng, Jagannathan Raman, qemu-block,
	Michael S. Tsirkin, Jason Wang, Cornelia Huck,
	Christian Schoenebeck, Greg Kurz, Wainer dos Santos Moschetta,
	Max Reitz, Stefan Hajnoczi, Paolo Bonzini,
	Marc-André Lureau, Kevin Wolf, Alex Bennée

On 05/11/2020 13.43, Philippe Mathieu-Daudé wrote:
> Add the recently introduced '--disable-virtio-legacy' configuration
> to the 'build-disabled' job.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
>  .gitlab-ci.yml | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
> index 3b15ae5c302..21fa1a459fd 100644
> --- a/.gitlab-ci.yml
> +++ b/.gitlab-ci.yml
> @@ -218,6 +218,7 @@ build-disabled:
>        --disable-strip --disable-tpm --disable-usb-redir --disable-vdi
>        --disable-vhost-crypto --disable-vhost-net --disable-vhost-scsi
>        --disable-vhost-user --disable-vhost-vdpa --disable-vhost-vsock
> +      --disable-virtio-legacy
>        --disable-virglrenderer --disable-vnc --disable-vte --disable-vvfat
>        --disable-xen --disable-zstd
>      TARGETS: arm-softmmu i386-softmmu ppc64-softmmu mips64-softmmu
> 

Acked-by: Thomas Huth <thuth@redhat.com>



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH-for-6.0 1/3] hw/virtio: Add configure switch to disable legacy VIRTIO
  2020-11-05 13:06   ` Cornelia Huck
@ 2020-11-05 13:53     ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-11-05 13:53 UTC (permalink / raw)
  To: Cornelia Huck
  Cc: Elena Ufimtseva, Fam Zheng, Thomas Huth, Jagannathan Raman,
	qemu-block, Michael S. Tsirkin, Jason Wang,
	Christian Schoenebeck, Greg Kurz, Wainer dos Santos Moschetta,
	qemu-devel, Kevin Wolf, Stefan Hajnoczi, Paolo Bonzini,
	Marc-André Lureau, Max Reitz, Alex Bennée

On 11/5/20 2:06 PM, Cornelia Huck wrote:
> On Thu,  5 Nov 2020 13:43:51 +0100
> Philippe Mathieu-Daudé <philmd@redhat.com> wrote:
> 
>> 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).
> 
> This is only dealing with endianess issues; there are other differences
> on the control plane as well.
> 
> Currently, virtio-pci has the option to make devices non-transitional,
> but virtio-ccw has not (only for device types). For virtio-mmio, you
> need to select one of legacy or non-transitional, IIRC.
> 
>>
>> [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/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;
> 
> This will make migration from a QEMU that has devices for which 1.0 has
> not been negotiated fail.

Oh good point... Not as easy as I thought then :/
Now I'm seeing plenty of possible problems.

Commits 9b3a35ec823 & d55f518248f help a bit:
("virtio: verify that legacy support is not accidentally on")
("virtio: skip legacy support check on machine types less than 5.1")

Thanks for warning :)

> 
>> -#endif
>>  }
>> +#endif
>>  
>>  static inline uint16_t virtio_lduw_phys(VirtIODevice *vdev, hwaddr pa)
>>  {
> 



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH-for-6.0 0/3] hw/virtio: Allow to disable legacy VIRTIO
  2020-11-05 12:43 [PATCH-for-6.0 0/3] hw/virtio: Allow to disable legacy VIRTIO Philippe Mathieu-Daudé
                   ` (2 preceding siblings ...)
  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 14:12 ` Philippe Mathieu-Daudé
  3 siblings, 0 replies; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-11-05 14:12 UTC (permalink / raw)
  To: qemu-devel
  Cc: Elena Ufimtseva, Fam Zheng, Thomas Huth, Jagannathan Raman,
	qemu-block, Michael S. Tsirkin, Jason Wang, Cornelia Huck,
	Christian Schoenebeck, Greg Kurz, Wainer dos Santos Moschetta,
	Max Reitz, Stefan Hajnoczi, Paolo Bonzini,
	Marc-André Lureau, Kevin Wolf, Alex Bennée

On 11/5/20 1:43 PM, Philippe Mathieu-Daudé wrote:
> Stefan told me it would help the multi-process QEMU
> series if virtio devices where not arch-specific.
> As it didn't seem too complex, I gave it a try.
> 
> Philippe Mathieu-Daudé (3):
>   hw/virtio: Add configure switch to disable legacy VIRTIO
>   hw/virtio: Build most of virtio devices as arch-independent objects
>   gitlab-ci: Test the --disable-virtio-legacy option

Please disregard this series, as it requires more work.



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH-for-6.0 2/3] hw/virtio: Build most of virtio devices as arch-independent objects
  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
  1 sibling, 0 replies; 11+ messages in thread
From: Greg Kurz @ 2020-11-05 14:33 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Elena Ufimtseva, Fam Zheng, Thomas Huth, Jagannathan Raman,
	qemu-block, Michael S. Tsirkin, Stefan Hajnoczi, Jason Wang,
	Cornelia Huck, Christian Schoenebeck, qemu-devel,
	Wainer dos Santos Moschetta, Max Reitz, Stefan Hajnoczi,
	Paolo Bonzini, Marc-André Lureau, Kevin Wolf,
	Alex Bennée

On Thu,  5 Nov 2020 13:43:52 +0100
Philippe Mathieu-Daudé <philmd@redhat.com> wrote:

> VirtIO devices shouldn't be arch-specific. Some device have to
> use PAGE_SIZE definition or access to CPUState. Keep building
> them as arch-specific objects. Move all we can to libcommon.fa.
> 

This patch breaks build:

$ ./configure && make
...

[890/2578] Compiling C object libcommon.fa.p/hw_virtio_virtio-mem.c.o
FAILED: libcommon.fa.p/hw_virtio_virtio-mem.c.o 
cc -Ilibcommon.fa.p -I. -I.. -I../slirp -I../slirp/src -Iqapi -Itrace -Iui -Iui/shader -I/usr/include/SDL2 -I/usr/include/pixman-1 -I/usr/include/libpng16 -I/usr/include/capstone -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -fdiagnostics-color=auto -pipe -Wall -Winvalid-pch -Werror -std=gnu99 -O2 -g -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -m64 -mcx16 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wundef -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fno-common -fwrapv -Wold-style-declaration -Wold-style-definition -Wtype-limits -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wempty-body -Wnested-externs -Wendif-labels -Wexpansion-to-defined -Wno-missing-include-dirs -Wno-shift-negative-value -Wno-psabi -fstack-protector-strong -isystem /var/tmp/qemu/linux-headers -isystem linux-headers -iquote /var/tmp/qemu/tcg/i386 -iquote . -iquote /var/tmp/qemu -iquote /var/tmp/qemu/accel/tcg -iquote /var/tmp/qemu/include -iquote /var/tmp/qemu/disas/libvixl -pthread -fPIC -D_REENTRANT -Wno-undef -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 -DNCURSES_WIDECHAR -MD -MQ libcommon.fa.p/hw_virtio_virtio-mem.c.o -MF libcommon.fa.p/hw_virtio_virtio-mem.c.o.d -o libcommon.fa.p/hw_virtio_virtio-mem.c.o -c ../hw/virtio/virtio-mem.c
In file included from ../hw/virtio/virtio-mem.c:28:
/var/tmp/qemu/include/exec/ram_addr.h:23:10: fatal error: cpu.h: No such file or directory
   23 | #include "cpu.h"
      |          ^~~~~~~
compilation terminated.

Unless I'm missing something legacy devices require to be built according
to the target because of the endianess.

> Suggested-by: Stefan Hajnoczi <stefanha@gmail.com>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
>  hw/9pfs/meson.build            |  2 +-
>  hw/block/dataplane/meson.build |  2 +-
>  hw/block/meson.build           |  2 +-
>  hw/char/meson.build            |  2 +-
>  hw/net/meson.build             |  2 +-
>  hw/scsi/meson.build            |  2 +-
>  hw/virtio/meson.build          | 15 +++++++++------
>  7 files changed, 15 insertions(+), 12 deletions(-)
> 
> diff --git a/hw/9pfs/meson.build b/hw/9pfs/meson.build
> index cc094262122..ac964be15ce 100644
> --- a/hw/9pfs/meson.build
> +++ b/hw/9pfs/meson.build
> @@ -17,4 +17,4 @@
>  fs_ss.add(when: 'CONFIG_XEN', if_true: files('xen-9p-backend.c'))
>  softmmu_ss.add_all(when: 'CONFIG_9PFS', if_true: fs_ss)
>  
> -specific_ss.add(when: 'CONFIG_VIRTIO_9P', if_true: files('virtio-9p-device.c'))
> +softmmu_ss.add(when: 'CONFIG_VIRTIO_9P', if_true: files('virtio-9p-device.c'))
> diff --git a/hw/block/dataplane/meson.build b/hw/block/dataplane/meson.build
> index 12c6a264f10..e2f3721ce24 100644
> --- a/hw/block/dataplane/meson.build
> +++ b/hw/block/dataplane/meson.build
> @@ -1,2 +1,2 @@
> -specific_ss.add(when: 'CONFIG_VIRTIO_BLK', if_true: files('virtio-blk.c'))
> +softmmu_ss.add(when: 'CONFIG_VIRTIO_BLK', if_true: files('virtio-blk.c'))
>  specific_ss.add(when: 'CONFIG_XEN', if_true: files('xen-block.c'))
> diff --git a/hw/block/meson.build b/hw/block/meson.build
> index 602ca6c8541..497592c33ac 100644
> --- a/hw/block/meson.build
> +++ b/hw/block/meson.build
> @@ -15,7 +15,7 @@
>  softmmu_ss.add(when: 'CONFIG_SH4', if_true: files('tc58128.c'))
>  softmmu_ss.add(when: 'CONFIG_NVME_PCI', if_true: files('nvme.c', 'nvme-ns.c'))
>  
> -specific_ss.add(when: 'CONFIG_VIRTIO_BLK', if_true: files('virtio-blk.c'))
> +softmmu_ss.add(when: 'CONFIG_VIRTIO_BLK', if_true: files('virtio-blk.c'))
>  specific_ss.add(when: 'CONFIG_VHOST_USER_BLK', if_true: files('vhost-user-blk.c'))
>  
>  subdir('dataplane')
> diff --git a/hw/char/meson.build b/hw/char/meson.build
> index 196ac91fa29..7496594ea07 100644
> --- a/hw/char/meson.build
> +++ b/hw/char/meson.build
> @@ -37,5 +37,5 @@
>  
>  specific_ss.add(when: 'CONFIG_HTIF', if_true: files('riscv_htif.c'))
>  specific_ss.add(when: 'CONFIG_TERMINAL3270', if_true: files('terminal3270.c'))
> -specific_ss.add(when: 'CONFIG_VIRTIO', if_true: files('virtio-serial-bus.c'))
> +softmmu_ss.add(when: 'CONFIG_VIRTIO', if_true: files('virtio-serial-bus.c'))
>  specific_ss.add(when: 'CONFIG_PSERIES', if_true: files('spapr_vty.c'))
> diff --git a/hw/net/meson.build b/hw/net/meson.build
> index 4a7051b54a0..c795af23eee 100644
> --- a/hw/net/meson.build
> +++ b/hw/net/meson.build
> @@ -43,7 +43,7 @@
>  specific_ss.add(when: 'CONFIG_XILINX_ETHLITE', if_true: files('xilinx_ethlite.c'))
>  
>  softmmu_ss.add(when: 'CONFIG_VIRTIO_NET', if_true: files('net_rx_pkt.c'))
> -specific_ss.add(when: 'CONFIG_VIRTIO_NET', if_true: files('virtio-net.c'))
> +softmmu_ss.add(when: 'CONFIG_VIRTIO_NET', if_true: files('virtio-net.c'))
>  
>  softmmu_ss.add(when: ['CONFIG_VIRTIO_NET', 'CONFIG_VHOST_NET'], if_true: files('vhost_net.c'), if_false: files('vhost_net-stub.c'))
>  softmmu_ss.add(when: 'CONFIG_ALL', if_true: files('vhost_net-stub.c'))
> diff --git a/hw/scsi/meson.build b/hw/scsi/meson.build
> index 923a34f344c..fdf27156f6a 100644
> --- a/hw/scsi/meson.build
> +++ b/hw/scsi/meson.build
> @@ -19,7 +19,7 @@
>  virtio_scsi_ss.add(files('virtio-scsi.c', 'virtio-scsi-dataplane.c'))
>  virtio_scsi_ss.add(when: 'CONFIG_VHOST_SCSI', if_true: files('vhost-scsi-common.c', 'vhost-scsi.c'))
>  virtio_scsi_ss.add(when: 'CONFIG_VHOST_USER_SCSI', if_true: files('vhost-scsi-common.c', 'vhost-user-scsi.c'))
> -specific_scsi_ss.add_all(when: 'CONFIG_VIRTIO_SCSI', if_true: virtio_scsi_ss)
> +softmmu_ss.add_all(when: 'CONFIG_VIRTIO_SCSI', if_true: virtio_scsi_ss)
>  
>  specific_scsi_ss.add(when: 'CONFIG_SPAPR_VSCSI', if_true: files('spapr_vscsi.c'))
>  
> diff --git a/hw/virtio/meson.build b/hw/virtio/meson.build
> index 95415913a9a..40df99f1a48 100644
> --- a/hw/virtio/meson.build
> +++ b/hw/virtio/meson.build
> @@ -9,12 +9,15 @@
>  
>  softmmu_ss.add(when: 'CONFIG_ALL', if_true: files('vhost-stub.c'))
>  
> +virtio_arch_ss = ss.source_set()
> +virtio_arch_ss.add(files('virtio.c'))
> +virtio_arch_ss.add(when: 'CONFIG_VIRTIO_LEGACY', if_true: files('virtio-legacy.c'))
> +virtio_arch_ss.add(when: 'CONFIG_VHOST_USER', if_true: files('vhost-user.c'))
> +virtio_arch_ss.add(when: 'CONFIG_VHOST_VDPA', if_true: files('vhost-vdpa.c'))
> +virtio_arch_ss.add(when: 'CONFIG_VIRTIO_IOMMU', if_true: files('virtio-iommu.c'))
> +
>  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'))
>  virtio_ss.add(when: 'CONFIG_VIRTIO_BALLOON', if_true: files('virtio-balloon.c'))
>  virtio_ss.add(when: 'CONFIG_VIRTIO_CRYPTO', if_true: files('virtio-crypto.c'))
>  virtio_ss.add(when: ['CONFIG_VIRTIO_CRYPTO', 'CONFIG_VIRTIO_PCI'], if_true: files('virtio-crypto-pci.c'))
> @@ -24,7 +27,6 @@
>  virtio_ss.add(when: 'CONFIG_VHOST_VSOCK', if_true: files('vhost-vsock.c', 'vhost-vsock-common.c'))
>  virtio_ss.add(when: 'CONFIG_VHOST_USER_VSOCK', if_true: files('vhost-user-vsock.c', 'vhost-vsock-common.c'))
>  virtio_ss.add(when: 'CONFIG_VIRTIO_RNG', if_true: files('virtio-rng.c'))
> -virtio_ss.add(when: 'CONFIG_VIRTIO_IOMMU', if_true: files('virtio-iommu.c'))
>  virtio_ss.add(when: 'CONFIG_VIRTIO_MEM', if_true: files('virtio-mem.c'))
>  
>  virtio_pci_ss = ss.source_set()
> @@ -49,4 +51,5 @@
>  
>  virtio_ss.add_all(when: 'CONFIG_VIRTIO_PCI', if_true: virtio_pci_ss)
>  
> -specific_ss.add_all(when: 'CONFIG_VIRTIO', if_true: virtio_ss)
> +softmmu_ss.add_all(when: 'CONFIG_VIRTIO', if_true: virtio_ss)
> +specific_ss.add_all(when: 'CONFIG_VIRTIO', if_true: virtio_arch_ss)



^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2020-11-05 14:34 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH-for-6.0 1/3] hw/virtio: Add configure switch " Philippe Mathieu-Daudé
2020-11-05 13:06   ` 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é

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.