All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] s390x: modularize virtio-gpu-ccw
@ 2021-03-17  9:56 Gerd Hoffmann
  2021-03-17  9:56 ` [PATCH 1/3] s390x: move S390_ADAPTER_SUPPRESSIBLE Gerd Hoffmann
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Gerd Hoffmann @ 2021-03-17  9:56 UTC (permalink / raw)
  To: qemu-devel
  Cc: Thomas Huth, David Hildenbrand, Cornelia Huck, Richard Henderson,
	Halil Pasic, Christian Borntraeger, qemu-s390x,
	Michael S. Tsirkin, Gerd Hoffmann

Maybe not the most elegant but rather simple approach to the "parent
object missing" problem: Use a symbol reference to make sure ccw modules
load only in case ccw support is present.

Also split the cpu changes to a separate patch.

Gerd Hoffmann (3):
  s390x: move S390_ADAPTER_SUPPRESSIBLE
  s390x: add have_virtio_ccw
  s390x: modularize virtio-gpu-ccw

 hw/s390x/virtio-ccw.h        | 5 +++++
 include/hw/s390x/css.h       | 7 -------
 include/hw/s390x/s390_flic.h | 3 +++
 target/s390x/cpu.h           | 9 ++++++---
 hw/s390x/virtio-ccw-gpu.c    | 4 +++-
 hw/s390x/virtio-ccw.c        | 2 ++
 util/module.c                | 1 +
 hw/s390x/meson.build         | 8 +++++++-
 8 files changed, 27 insertions(+), 12 deletions(-)

-- 
2.30.2




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

* [PATCH 1/3] s390x: move S390_ADAPTER_SUPPRESSIBLE
  2021-03-17  9:56 [PATCH 0/3] s390x: modularize virtio-gpu-ccw Gerd Hoffmann
@ 2021-03-17  9:56 ` Gerd Hoffmann
  2021-03-17 11:30   ` Philippe Mathieu-Daudé
  2021-03-17  9:56 ` [PATCH 2/3] s390x: add have_virtio_ccw Gerd Hoffmann
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 7+ messages in thread
From: Gerd Hoffmann @ 2021-03-17  9:56 UTC (permalink / raw)
  To: qemu-devel
  Cc: Thomas Huth, David Hildenbrand, Cornelia Huck, Richard Henderson,
	Halil Pasic, Christian Borntraeger, qemu-s390x,
	Michael S. Tsirkin, Gerd Hoffmann

The definition S390_ADAPTER_SUPPRESSIBLE was moved to "cpu.h", per
suggestion of Thomas Huth. From interface design perspective, IMHO, not
a good thing as it belongs to the public interface of
css_register_io_adapters(). We did this because CONFIG_KVM requeires
NEED_CPU_H and Thomas, and other commenters did not like the
consequences of that.

Moving the interrupt related declarations to s390_flic.h was suggested
by Cornelia Huck.

Signed-off-by: Halil Pasic <pasic@linux.ibm.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 include/hw/s390x/css.h       | 7 -------
 include/hw/s390x/s390_flic.h | 3 +++
 target/s390x/cpu.h           | 9 ++++++---
 3 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/include/hw/s390x/css.h b/include/hw/s390x/css.h
index 7901ab276ce9..bba7593d2eaa 100644
--- a/include/hw/s390x/css.h
+++ b/include/hw/s390x/css.h
@@ -12,7 +12,6 @@
 #ifndef CSS_H
 #define CSS_H
 
-#include "cpu.h"
 #include "hw/s390x/adapter.h"
 #include "hw/s390x/s390_flic.h"
 #include "hw/s390x/ioinst.h"
@@ -233,12 +232,6 @@ uint32_t css_get_adapter_id(CssIoAdapterType type, uint8_t isc);
 void css_register_io_adapters(CssIoAdapterType type, bool swap, bool maskable,
                               uint8_t flags, Error **errp);
 
-#ifndef CONFIG_KVM
-#define S390_ADAPTER_SUPPRESSIBLE 0x01
-#else
-#define S390_ADAPTER_SUPPRESSIBLE KVM_S390_ADAPTER_SUPPRESSIBLE
-#endif
-
 #ifndef CONFIG_USER_ONLY
 SubchDev *css_find_subch(uint8_t m, uint8_t cssid, uint8_t ssid,
                          uint16_t schid);
diff --git a/include/hw/s390x/s390_flic.h b/include/hw/s390x/s390_flic.h
index e91b15d2d6af..3907a13d0766 100644
--- a/include/hw/s390x/s390_flic.h
+++ b/include/hw/s390x/s390_flic.h
@@ -134,6 +134,9 @@ void s390_flic_init(void);
 S390FLICState *s390_get_flic(void);
 QEMUS390FLICState *s390_get_qemu_flic(S390FLICState *fs);
 S390FLICStateClass *s390_get_flic_class(S390FLICState *fs);
+void s390_crw_mchk(void);
+void s390_io_interrupt(uint16_t subchannel_id, uint16_t subchannel_nr,
+                       uint32_t io_int_parm, uint32_t io_int_word);
 bool ais_needed(void *opaque);
 
 #endif /* HW_S390_FLIC_H */
diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h
index 60d434d5edd5..b434b905c0ae 100644
--- a/target/s390x/cpu.h
+++ b/target/s390x/cpu.h
@@ -40,6 +40,12 @@
 
 #define S390_MAX_CPUS 248
 
+#ifndef CONFIG_KVM
+#define S390_ADAPTER_SUPPRESSIBLE 0x01
+#else
+#define S390_ADAPTER_SUPPRESSIBLE KVM_S390_ADAPTER_SUPPRESSIBLE
+#endif
+
 typedef struct PSW {
     uint64_t mask;
     uint64_t addr;
@@ -806,9 +812,6 @@ int cpu_s390x_signal_handler(int host_signum, void *pinfo, void *puc);
 
 
 /* interrupt.c */
-void s390_crw_mchk(void);
-void s390_io_interrupt(uint16_t subchannel_id, uint16_t subchannel_nr,
-                       uint32_t io_int_parm, uint32_t io_int_word);
 #define RA_IGNORED                  0
 void s390_program_interrupt(CPUS390XState *env, uint32_t code, uintptr_t ra);
 /* service interrupts are floating therefore we must not pass an cpustate */
-- 
2.30.2



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

* [PATCH 2/3] s390x: add have_virtio_ccw
  2021-03-17  9:56 [PATCH 0/3] s390x: modularize virtio-gpu-ccw Gerd Hoffmann
  2021-03-17  9:56 ` [PATCH 1/3] s390x: move S390_ADAPTER_SUPPRESSIBLE Gerd Hoffmann
@ 2021-03-17  9:56 ` Gerd Hoffmann
  2021-03-17  9:56 ` [PATCH 3/3] s390x: modularize virtio-gpu-ccw Gerd Hoffmann
  2021-03-22 13:12 ` [PATCH 0/3] " Halil Pasic
  3 siblings, 0 replies; 7+ messages in thread
From: Gerd Hoffmann @ 2021-03-17  9:56 UTC (permalink / raw)
  To: qemu-devel
  Cc: Thomas Huth, David Hildenbrand, Cornelia Huck, Richard Henderson,
	Halil Pasic, Christian Borntraeger, qemu-s390x,
	Michael S. Tsirkin, Gerd Hoffmann

Introduce a symbol which can be used to prevent ccw modules
being loaded into system emulators without ccw support.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/s390x/virtio-ccw.h | 5 +++++
 hw/s390x/virtio-ccw.c | 2 ++
 2 files changed, 7 insertions(+)

diff --git a/hw/s390x/virtio-ccw.h b/hw/s390x/virtio-ccw.h
index 49a2b8ca42df..0168232e3b8d 100644
--- a/hw/s390x/virtio-ccw.h
+++ b/hw/s390x/virtio-ccw.h
@@ -63,6 +63,11 @@ typedef struct VirtioBusClass VirtioCcwBusClass;
 DECLARE_OBJ_CHECKERS(VirtioCcwBusState, VirtioCcwBusClass,
                      VIRTIO_CCW_BUS, TYPE_VIRTIO_CCW_BUS)
 
+/*
+ * modules can reference this symbol to avoid being loaded
+ * into system emulators without ccw support
+ */
+extern bool have_virtio_ccw;
 
 struct VirtIOCCWDeviceClass {
     CCWDeviceClass parent_class;
diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c
index 06c06056814b..314ed7b24566 100644
--- a/hw/s390x/virtio-ccw.c
+++ b/hw/s390x/virtio-ccw.c
@@ -35,6 +35,8 @@
 
 #define NR_CLASSIC_INDICATOR_BITS 64
 
+bool have_virtio_ccw = true;
+
 static int virtio_ccw_dev_post_load(void *opaque, int version_id)
 {
     VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(opaque);
-- 
2.30.2



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

* [PATCH 3/3] s390x: modularize virtio-gpu-ccw
  2021-03-17  9:56 [PATCH 0/3] s390x: modularize virtio-gpu-ccw Gerd Hoffmann
  2021-03-17  9:56 ` [PATCH 1/3] s390x: move S390_ADAPTER_SUPPRESSIBLE Gerd Hoffmann
  2021-03-17  9:56 ` [PATCH 2/3] s390x: add have_virtio_ccw Gerd Hoffmann
@ 2021-03-17  9:56 ` Gerd Hoffmann
  2021-03-22 13:12 ` [PATCH 0/3] " Halil Pasic
  3 siblings, 0 replies; 7+ messages in thread
From: Gerd Hoffmann @ 2021-03-17  9:56 UTC (permalink / raw)
  To: qemu-devel
  Cc: Thomas Huth, David Hildenbrand, Cornelia Huck, Richard Henderson,
	Halil Pasic, Christian Borntraeger, qemu-s390x,
	Michael S. Tsirkin, Gerd Hoffmann

Since the virtio-gpu-ccw device depends on the hw-display-virtio-gpu
module, which provides the type virtio-gpu-device, packaging the
hw-display-virtio-gpu module as a separate package that may or may not
be installed along with the qemu package leads to problems. Namely if
the hw-display-virtio-gpu is absent, qemu continues to advertise
virtio-gpu-ccw, but it aborts not only when one attempts using
virtio-gpu-ccw, but also when libvirtd's capability probing tries
to instantiate the type to introspect it.

Let us thus introduce a module named hw-s390x-virtio-gpu-ccw that
is going to provide the virtio-gpu-ccw device. The hw-s390x prefix
was chosen because it is not a portable device.

With virtio-gpu-ccw built as a module, the correct way to package a
modularized qemu is to require that hw-display-virtio-gpu must be
installed whenever the module hw-s390x-virtio-gpu-ccw.

Signed-off-by: Halil Pasic <pasic@linux.ibm.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/s390x/virtio-ccw-gpu.c | 4 +++-
 util/module.c             | 1 +
 hw/s390x/meson.build      | 8 +++++++-
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/hw/s390x/virtio-ccw-gpu.c b/hw/s390x/virtio-ccw-gpu.c
index c301e2586bde..75a9e4bb3908 100644
--- a/hw/s390x/virtio-ccw-gpu.c
+++ b/hw/s390x/virtio-ccw-gpu.c
@@ -62,7 +62,9 @@ static const TypeInfo virtio_ccw_gpu = {
 
 static void virtio_ccw_gpu_register(void)
 {
-    type_register_static(&virtio_ccw_gpu);
+    if (have_virtio_ccw) {
+        type_register_static(&virtio_ccw_gpu);
+    }
 }
 
 type_init(virtio_ccw_gpu_register)
diff --git a/util/module.c b/util/module.c
index c65060c167df..cbe89fede628 100644
--- a/util/module.c
+++ b/util/module.c
@@ -304,6 +304,7 @@ static struct {
     { "virtio-gpu-pci-base",   "hw-", "display-virtio-gpu-pci" },
     { "virtio-gpu-pci",        "hw-", "display-virtio-gpu-pci" },
     { "vhost-user-gpu-pci",    "hw-", "display-virtio-gpu-pci" },
+    { "virtio-gpu-ccw",        "hw-", "s390x-virtio-gpu-ccw"   },
     { "virtio-vga-base",       "hw-", "display-virtio-vga"    },
     { "virtio-vga",            "hw-", "display-virtio-vga"    },
     { "vhost-user-vga",        "hw-", "display-virtio-vga"    },
diff --git a/hw/s390x/meson.build b/hw/s390x/meson.build
index 91495b563146..327e9c93afa9 100644
--- a/hw/s390x/meson.build
+++ b/hw/s390x/meson.build
@@ -34,7 +34,6 @@ virtio_ss.add(files('virtio-ccw.c'))
 virtio_ss.add(when: 'CONFIG_VIRTIO_BALLOON', if_true: files('virtio-ccw-balloon.c'))
 virtio_ss.add(when: 'CONFIG_VIRTIO_BLK', if_true: files('virtio-ccw-blk.c'))
 virtio_ss.add(when: 'CONFIG_VIRTIO_CRYPTO', if_true: files('virtio-ccw-crypto.c'))
-virtio_ss.add(when: 'CONFIG_VIRTIO_GPU', if_true: files('virtio-ccw-gpu.c'))
 virtio_ss.add(when: 'CONFIG_VIRTIO_INPUT', if_true: files('virtio-ccw-input.c'))
 virtio_ss.add(when: 'CONFIG_VIRTIO_NET', if_true: files('virtio-ccw-net.c'))
 virtio_ss.add(when: 'CONFIG_VIRTIO_RNG', if_true: files('virtio-ccw-rng.c'))
@@ -48,3 +47,10 @@ virtio_ss.add(when: 'CONFIG_VHOST_USER_FS', if_true: files('vhost-user-fs-ccw.c'
 s390x_ss.add_all(when: 'CONFIG_VIRTIO_CCW', if_true: virtio_ss)
 
 hw_arch += {'s390x': s390x_ss}
+
+hw_s390x_modules = {}
+virtio_gpu_ccw_ss = ss.source_set()
+virtio_gpu_ccw_ss.add(when: ['CONFIG_VIRTIO_GPU', 'CONFIG_VIRTIO_CCW'],
+                      if_true: [files('virtio-ccw-gpu.c'), pixman])
+hw_s390x_modules += {'virtio-gpu-ccw': virtio_gpu_ccw_ss}
+modules += {'hw-s390x': hw_s390x_modules}
-- 
2.30.2



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

* Re: [PATCH 1/3] s390x: move S390_ADAPTER_SUPPRESSIBLE
  2021-03-17  9:56 ` [PATCH 1/3] s390x: move S390_ADAPTER_SUPPRESSIBLE Gerd Hoffmann
@ 2021-03-17 11:30   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-03-17 11:30 UTC (permalink / raw)
  To: Gerd Hoffmann, qemu-devel
  Cc: Thomas Huth, David Hildenbrand, Cornelia Huck, Richard Henderson,
	Halil Pasic, Christian Borntraeger, qemu-s390x,
	Michael S. Tsirkin

On 3/17/21 10:56 AM, Gerd Hoffmann wrote:
> The definition S390_ADAPTER_SUPPRESSIBLE was moved to "cpu.h", per
> suggestion of Thomas Huth. From interface design perspective, IMHO, not
> a good thing as it belongs to the public interface of
> css_register_io_adapters(). We did this because CONFIG_KVM requeires

Typo "requeires" -> "requires"

> NEED_CPU_H and Thomas, and other commenters did not like the
> consequences of that.
> 
> Moving the interrupt related declarations to s390_flic.h was suggested
> by Cornelia Huck.
> 
> Signed-off-by: Halil Pasic <pasic@linux.ibm.com>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
>  include/hw/s390x/css.h       | 7 -------
>  include/hw/s390x/s390_flic.h | 3 +++
>  target/s390x/cpu.h           | 9 ++++++---
>  3 files changed, 9 insertions(+), 10 deletions(-)



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

* Re: [PATCH 0/3] s390x: modularize virtio-gpu-ccw
  2021-03-17  9:56 [PATCH 0/3] s390x: modularize virtio-gpu-ccw Gerd Hoffmann
                   ` (2 preceding siblings ...)
  2021-03-17  9:56 ` [PATCH 3/3] s390x: modularize virtio-gpu-ccw Gerd Hoffmann
@ 2021-03-22 13:12 ` Halil Pasic
  2021-03-26  8:40   ` Gerd Hoffmann
  3 siblings, 1 reply; 7+ messages in thread
From: Halil Pasic @ 2021-03-22 13:12 UTC (permalink / raw)
  To: Gerd Hoffmann
  Cc: Thomas Huth, David Hildenbrand, Cornelia Huck, Richard Henderson,
	qemu-devel, Christian Borntraeger, qemu-s390x,
	Michael S. Tsirkin

On Wed, 17 Mar 2021 10:56:19 +0100
Gerd Hoffmann <kraxel@redhat.com> wrote:

> Maybe not the most elegant but rather simple approach to the "parent
> object missing" problem: Use a symbol reference to make sure ccw modules
> load only in case ccw support is present.

[..]

Hi Gerd! I've tested this and I think mostly does what it should. The
only thing that I'm inclined to consider a little quirky is the first
message:

$ ./qemu-system-x86_64 -device virtio-gpu-ccw
Failed to open module: /home/pasic/build/qemu/hw-s390x-virtio-gpu-ccw.so: undefined symbol: have_virtio_ccw
qemu-system-x86_64: -device virtio-gpu-ccw: 'virtio-gpu-ccw' is not a valid device model name

But with something like --help we don't see it, and I assume neither do
we when probing, because there the modules are loaded with mayfail. So
for me this is acceptable, because it happens only if one tries to use a
device that ain't advertised.

Compared to Daniels suggestion, I find that one conceptually clearer,
and even more flexible. Implementation-wise I find this patch-set
simpler. I don't know how would it scale to modules depending on modules
(and it feels a little hackish), but we can address such problems as they
emerge if they emerge, so I did not think too hard.

Let me also note, that you took authorship of all three patches, which
I'm fine with. All I really care about at this stage is getting this
fixed in a remotely sane way, and this is definitely one. I'm also
willing to invest more work in that symlink based approach, if that is
what the community wants, but I would prefer this fixed as soon as
possible.

If you keep the authorship for all the patches, I would like to offer:
Reviewed-by: Halil Pasic <pasic@linux.ibm.com>
Tested-by: Halil Pasic <pasic@linux.ibm.com>
for all three patches. (If I'm going to be the author of some of the
patches, those tags don't make sense for those).

Thanks for your work!

Regards,
Halil


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

* Re: [PATCH 0/3] s390x: modularize virtio-gpu-ccw
  2021-03-22 13:12 ` [PATCH 0/3] " Halil Pasic
@ 2021-03-26  8:40   ` Gerd Hoffmann
  0 siblings, 0 replies; 7+ messages in thread
From: Gerd Hoffmann @ 2021-03-26  8:40 UTC (permalink / raw)
  To: Halil Pasic
  Cc: Thomas Huth, David Hildenbrand, Cornelia Huck, Richard Henderson,
	qemu-devel, Christian Borntraeger, qemu-s390x,
	Michael S. Tsirkin

  Hi,

> Compared to Daniels suggestion, I find that one conceptually clearer,
> and even more flexible. Implementation-wise I find this patch-set
> simpler.

Given we are in fixes-only mode I think we should go for the simple
solution.  Should be easy enough to revert in case we want replace
this with something else after the 6.0 release.

> Reviewed-by: Halil Pasic <pasic@linux.ibm.com>
> Tested-by: Halil Pasic <pasic@linux.ibm.com>

Added & queued.
CI running, pull req later today when all goes well.

thanks,
  Gerd



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

end of thread, other threads:[~2021-03-26  8:41 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-17  9:56 [PATCH 0/3] s390x: modularize virtio-gpu-ccw Gerd Hoffmann
2021-03-17  9:56 ` [PATCH 1/3] s390x: move S390_ADAPTER_SUPPRESSIBLE Gerd Hoffmann
2021-03-17 11:30   ` Philippe Mathieu-Daudé
2021-03-17  9:56 ` [PATCH 2/3] s390x: add have_virtio_ccw Gerd Hoffmann
2021-03-17  9:56 ` [PATCH 3/3] s390x: modularize virtio-gpu-ccw Gerd Hoffmann
2021-03-22 13:12 ` [PATCH 0/3] " Halil Pasic
2021-03-26  8:40   ` Gerd Hoffmann

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.