All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Cc: "Andreas Grapentin" <gra@linux.ibm.com>,
	"Pierrick Bouvier" <pierrick.bouvier@linaro.org>,
	qemu-devel@nongnu.org,
	"Richard Henderson" <richard.henderson@linaro.org>,
	eric.auger@redhat.com, "Paolo Bonzini" <pbonzini@redhat.com>,
	"Cédric Le Goater" <clg@redhat.com>,
	philmd@linaro.org, qemu-ppc@nongnu.org,
	"Christian Borntraeger" <borntraeger@linux.ibm.com>,
	"Steffen Eiden" <seiden@linux.ibm.com>
Subject: Re: [PATCH v5 8/8] hw/vfio: all vfio files can now be common files
Date: Fri, 28 Aug 2026 11:18:23 +0100	[thread overview]
Message-ID: <871pbi4kgg.fsf@draig.linaro.org> (raw)
In-Reply-To: <7ce963fc-cca4-43df-8e03-36fe09dc80f1@oss.qualcomm.com> (Pierrick Bouvier's message of "Thu, 20 Aug 2026 09:24:05 -0700")

Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com> writes:

> On 8/19/2026 1:06 PM, Andreas Grapentin wrote:
>> On Aug 18 26, Pierrick Bouvier wrote:
>>> It would be better to keep it as system_ss, since bringing back
>>> specific_ss will break the single-binary compilation.
>>> It should not be needed to rely on target config within the C file
>>> directly. At least, we didn't meet any situation where it was.
>>> That said, there is nothing in CI (yet) that prevent such regression,
>>> but I would appreciate if you could keep it as it is for now.
>>>
>>> If you need to filter a specific function per config
>>> (host/target/whatever), the right way is to isolate this in a new file,
>>> and condition inclusion from build system instead.
>>>
>>> system_ss.add_all(when: 'CONFIG_X', if_true: [newfile.c])
>>> Also, you can add associated stubs for other configs in stub_ss.
>>> stub_ss.add(files('newfile-stubs.c'))
>>>
>>> I don't know the details of the series you sent (and too big for me to
>>> take a look now), but if you have a precise question on a specific
>>> patch, feel free to reach out to me by email.
>>>
>>> Regards,
>>> Pierrick
>> 
>> Thanks Patrick,
>> 
>> To give some context, the linked series enables s390 host linux KVM to
>> virtualize guests with different (non-native) guest architectures. So we
>> would need to build (on host architecture s390x):
>> 
>> a) qemu-system-s390x with vfio using asm-s390/kvm.h, and
>> b) qemu-system-aarch64 with vfio using asm-arm64/kvm.h
>> 
>> which (based on my current understanding of the code) would make it
>> necessary to build the kvm-helpers in the vfio code twice, once per
>> guest architecture s390x and aarch64.

These are common KVM API headers aren't they? Which bits do you need
apart from the ioctl #defines?

>>
>
> Depending which functions/constants you need from asm-$arch/kvm.h, the
> simpler is probably to expose it in a proper API, and then prefix
> symbols per architecture. Finally, you can have a dispatcher function to
> return the right value:
>
> void kvm_get_X() {
>   if (target_aarch64()) {
>     return kvm_aarch64_get_X();
>   }
>   else if (target_s390x()) {
>     return kvm_s390x_get_X();
>   }
>   g_assert_not_reached().
> }

This is basically KVMCPUOps (like TCGCPUOps) with extra steps. I suggest
that is the way to handle the abstraction of kvm_arch_* functions.

>
> However, it does not scale very well if you need to expose a lot of X.
> You could also generate a struct with all values populated per arch, and
> use that.
>
> What kind of information do you need to extract from this header?
>
>> I understand that this is a problem for the single-binary efforts of
>> qemu, and needs further thought. We are currently trying to come up with
>> an approach that more closely aligns with the single-binary goal, and
>> any advice you could give to that end would be appreciated :)
>> 
>> Of course this problem extends to all components in qemu that require
>> architecture-specific components of the KVM UAPI.
>>
>
> We didn't really meet any issue so far with this, but maybe it's because
> we didn't yet to mix two different arch supporting kvm. In all cases, we
> take the problems one after another, and we don't anticipate things - it
> proved to an inefficient approach.
>
>> Thanks,
>> Andreas
>
> Regards,
> Pierrick

-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro


  reply	other threads:[~2026-08-28 10:19 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-18 17:47 [PATCH v5 0/8] hw/vfio: single-binary Pierrick Bouvier
2026-03-18 17:47 ` [PATCH v5 1/8] hw/vfio/listener.c: remove CONFIG_KVM Pierrick Bouvier
2026-03-18 17:47 ` [PATCH v5 2/8] hw/vfio/helpers.c: extract kvm helpers in kvm-helpers.c Pierrick Bouvier
2026-03-18 17:47 ` [PATCH v5 3/8] hw/vfio/pci-quirks.c: remove CONFIG_VFIO_IGD Pierrick Bouvier
2026-03-18 17:47 ` [PATCH v5 4/8] hw/vfio: eradicate CONFIG_IOMMU from sources Pierrick Bouvier
2026-03-19  8:32   ` Cédric Le Goater
2026-03-18 17:47 ` [PATCH v5 5/8] hw/vfio/pci.c: eradicate CONFIG_KVM Pierrick Bouvier
2026-03-19  8:33   ` Cédric Le Goater
2026-03-18 17:47 ` [PATCH v5 6/8] hw/vfio/ap.c: use full path for target specific header Pierrick Bouvier
2026-03-18 17:47 ` [PATCH v5 7/8] hw/vfio/spapr.c: extract vfio_spapr_kvm_attach_tce to hw/vfio/kvm-spapr.c Pierrick Bouvier
2026-03-19  8:32   ` Cédric Le Goater
2026-03-18 17:47 ` [PATCH v5 8/8] hw/vfio: all vfio files can now be common files Pierrick Bouvier
2026-08-18  6:18   ` Andreas Grapentin
2026-08-18 16:35     ` Pierrick Bouvier
2026-08-19 20:06       ` Andreas Grapentin
2026-08-20 16:24         ` Pierrick Bouvier
2026-08-28 10:18           ` Alex Bennée [this message]
2026-03-19  7:45 ` [PATCH v5 0/8] hw/vfio: single-binary Philippe Mathieu-Daudé
2026-03-19  8:33 ` Cédric Le Goater

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=871pbi4kgg.fsf@draig.linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=borntraeger@linux.ibm.com \
    --cc=clg@redhat.com \
    --cc=eric.auger@redhat.com \
    --cc=gra@linux.ibm.com \
    --cc=pbonzini@redhat.com \
    --cc=philmd@linaro.org \
    --cc=pierrick.bouvier@linaro.org \
    --cc=pierrick.bouvier@oss.qualcomm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=seiden@linux.ibm.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 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.