All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Cornelia Huck <cohuck@redhat.com>
Cc: "Markus Armbruster" <armbru@redhat.com>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	qemu-devel@nongnu.org, "David Hildenbrand" <david@kernel.org>,
	"Igor Mammedov" <imammedo@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Marcelo Tosatti" <mtosatti@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Halil Pasic" <pasic@linux.ibm.com>,
	"Eric Farman" <farman@linux.ibm.com>,
	qemu-s390x@nongnu.org,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>
Subject: Re: qemu-system-x86_64 appears to have sgx-epc, but not memory-backend-epc
Date: Wed, 11 Nov 2026 14:15:55 +0000	[thread overview]
Message-ID: <avR4m8ZtI-m8-V4r@redhat.com> (raw)
In-Reply-To: <87jymjwl0w.fsf@redhat.com>

On Wed, Nov 11, 2026 at 02:33:03PM +0100, Cornelia Huck wrote:
> On Wed, Nov 11 2026, Daniel P. Berrangé <berrange@redhat.com> wrote:
> 
> > On Wed, Nov 11, 2026 at 01:16:36PM +0100, Markus Armbruster wrote:
> >> Peter Maydell <peter.maydell@linaro.org> writes:
> >> 
> >> > On Fri, 23 Oct 2026 at 11:21, Daniel P. Berrangé <berrange@redhat.com> wrote:
> >> >>
> >> >> On Thu, Oct 22, 2026 at 02:58:16PM +0200, Markus Armbruster wrote:
> >> >> > My build of qemu-system-x86_64 has device sgx-epc:
> >> >> >
> >> >> >  --> {"execute": "qom-list-types", "arguments": {"implements": "sgx-epc"}}
> >> >> >  <-- {"return": [{"name": "sgx-epc", "parent": "device"}]}
> >> >> >
> >> >> > The device as a link property to a memory-backend-epc:
> >> >> >
> >> >> >  --> {"execute": "qom-list-properties", "arguments": {"typename": "sgx-epc"}}
> >> >> >  <-- {"return": [...
> >> >> >                  {"name": "memdev", "type": "link<memory-backend-epc>"},
> >> >> >                  ...]}
> >> >> >
> >> >> > However, type memory-backend-epc does not exist:
> >> >
> >> >> There is some rather dubious code that conditionally registers
> >> >> the type
> >> >>
> >> >> static void register_types(void)
> >> >> {
> >> >>     int fd = qemu_open_old("/dev/sgx_vepc", O_RDWR);
> >> >>     if (fd >= 0) {
> >> >>         close(fd);
> >> >>
> >> >>         type_register_static(&sgx_epc_backed_info);
> >> >>     }
> >> >> }
> >> >>
> >> >>
> >> >> Normal practice is for types to be unconditionally registered.  Do we
> >> >> have any examples outside of this SGX case where we conditionally
> >> >> register types ?   Should we change this to follow normal practice ?
> >> >
> >> > TYPE_MEMORY_BACKEND_MEMFD does the same. I did a quick grep for
> >> > "calls to type_register not indented by exactly 4 spaces" and
> >> > I think the other cases are "misindented" or "data-driven
> >> > type registration" rather than trying to do things conditionally
> >> > (but I didn't actually look at all of them, instead making
> >> > guesses based on variable names, so maybe there's one or two
> >> > more I missed).
> >> 
> >> Alright, I looked.  In addition to "misindented" or "data-driven", I
> >> found:
> >> 
> >> * register_types() in hostmem-memfd.c registers "memory-backend-memfd"
> >>   only when a test of memfd_create() succeeds.  This is what Peter
> >>   reported.
> >> 
> >> * virtio_ccw_gpu_register() in hw/s390x/virtio-ccw-gpu.c registers
> >>   "virtio-gpu-ccw" only when have_virtio_ccw, which is true when
> >>   hw/s390x/virtio-ccw.c gets compiled into the binary.  So it's
> >>   effectively compile-time conditional.
> >> 
> >>   I wish it was literally compile-time conditional, either in meson or
> >>   using #if.
> >
> > That looks like it is dead code to me. hw/s390x/meson.build does
> >
> >   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}
> >
> > it doesn't look like 'have_virtio_ccw' can ever be false, due
> > to the CONFIG_VIRTIO_CCW Kconfig check ?
> 
> adcf33a504de ("s390x: modularize virtio-gpu-ccw") seems to indicate that
> this is needed for virtio-gpu-ccw being a module, not sure if that is
> still the case.

I'm not understanding why modules affects this though ?

If CONFIG_VIRTIO_CCW is set, then we know virtio-ccw is builtin,
and the module loading for virtio-gpu-ccw is fine.

If CONFIG_VIRTIO_CCW is unset, then neither virtio-gpu-ccw or
virtio-ccw are built at all, so there's no module to load.

With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|



  reply	other threads:[~2026-11-11 14:16 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-22 12:58 qemu-system-x86_64 appears to have sgx-epc, but not memory-backend-epc Markus Armbruster
2026-10-23 10:20 ` Daniel P. Berrangé
2026-10-23 10:44   ` Peter Maydell
2026-10-23 11:07     ` Daniel P. Berrangé
2026-10-23 11:50       ` Peter Maydell
2026-10-23 12:36         ` Daniel P. Berrangé
2026-10-23 12:44           ` Peter Maydell
2026-10-27  6:28         ` Markus Armbruster
2026-10-27  6:40       ` Markus Armbruster
2026-11-02 11:23         ` Igor Mammedov
2026-11-11 14:02           ` Markus Armbruster
2026-11-11 12:16     ` Markus Armbruster
2026-11-11 12:27       ` Daniel P. Berrangé
2026-11-11 13:33         ` Cornelia Huck
2026-11-11 14:15           ` Daniel P. Berrangé [this message]
2026-11-11 16:02             ` Cornelia Huck
2026-11-09 14:29   ` Markus Armbruster
2026-11-12 12:15     ` Markus Armbruster
2026-11-12 15:36       ` Daniel P. Berrangé

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=avR4m8ZtI-m8-V4r@redhat.com \
    --to=berrange@redhat.com \
    --cc=armbru@redhat.com \
    --cc=cohuck@redhat.com \
    --cc=david@kernel.org \
    --cc=farman@linux.ibm.com \
    --cc=imammedo@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=mst@redhat.com \
    --cc=mtosatti@redhat.com \
    --cc=pasic@linux.ibm.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-s390x@nongnu.org \
    --cc=richard.henderson@linaro.org \
    /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 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.