From: Andrew Jones <ajones@ventanamicro.com>
To: Thomas Huth <thuth@redhat.com>
Cc: qemu-devel@nongnu.org, pbonzini@redhat.com, mtosatti@redhat.com,
peter.maydell@linaro.org, pasic@linux.ibm.com,
borntraeger@linux.ibm.com, dbarboza@ventanamicro.com,
kvm@vger.kernel.org, qemu-arm@nongnu.org, qemu-s390x@nongnu.org
Subject: Re: [PATCH] kvm: Remove KVM_CREATE_IRQCHIP support assumption
Date: Tue, 25 Jul 2023 14:19:36 +0200 [thread overview]
Message-ID: <20230725-539b009b8e15994408dbb47b@orel> (raw)
In-Reply-To: <81dd6b4c-200f-bb35-69fa-ed623eb7e6d1@redhat.com>
On Mon, Jul 24, 2023 at 11:53:39AM +0200, Thomas Huth wrote:
> On 22/07/2023 08.21, Andrew Jones wrote:
> > Since Linux commit 00f918f61c56 ("RISC-V: KVM: Skeletal in-kernel AIA
> > irqchip support") checking KVM_CAP_IRQCHIP returns non-zero when the
> > RISC-V platform has AIA. The cap indicates KVM supports at least one
> > of the following ioctls:
> >
> > KVM_CREATE_IRQCHIP
> > KVM_IRQ_LINE
> > KVM_GET_IRQCHIP
> > KVM_SET_IRQCHIP
> > KVM_GET_LAPIC
> > KVM_SET_LAPIC
> >
> > but the cap doesn't imply that KVM must support any of those ioctls
> > in particular. However, QEMU was assuming the KVM_CREATE_IRQCHIP
> > ioctl was supported. Stop making that assumption by introducing a
> > KVM parameter that each architecture which supports KVM_CREATE_IRQCHIP
> > sets. Adding parameters isn't awesome, but given how the
> > KVM_CAP_IRQCHIP isn't very helpful on its own, we don't have a lot of
> > options.
> >
> > Signed-off-by: Andrew Jones <ajones@ventanamicro.com>
> > ---
> >
> > While this fixes booting guests on riscv KVM with AIA it's unlikely
> > to get merged before the QEMU support for KVM AIA[1] lands, which
> > would also fix the issue. I think this patch is still worth considering
> > though since QEMU's assumption is wrong.
> >
> > [1] https://lore.kernel.org/all/20230714084429.22349-1-yongxuan.wang@sifive.com/
> >
> >
> > accel/kvm/kvm-all.c | 5 ++++-
> > include/sysemu/kvm.h | 1 +
> > target/arm/kvm.c | 3 +++
> > target/i386/kvm/kvm.c | 2 ++
> > target/s390x/kvm/kvm.c | 3 +++
> > 5 files changed, 13 insertions(+), 1 deletion(-)
> >
> > diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
> > index 373d876c0580..0f5ff8630502 100644
> > --- a/accel/kvm/kvm-all.c
> > +++ b/accel/kvm/kvm-all.c
> > @@ -86,6 +86,7 @@ struct KVMParkedVcpu {
> > };
> > KVMState *kvm_state;
> > +bool kvm_has_create_irqchip;
> > bool kvm_kernel_irqchip;
> > bool kvm_split_irqchip;
> > bool kvm_async_interrupts_allowed;
> > @@ -2377,8 +2378,10 @@ static void kvm_irqchip_create(KVMState *s)
> > if (s->kernel_irqchip_split == ON_OFF_AUTO_ON) {
> > error_report("Split IRQ chip mode not supported.");
> > exit(1);
> > - } else {
> > + } else if (kvm_has_create_irqchip) {
> > ret = kvm_vm_ioctl(s, KVM_CREATE_IRQCHIP);
> > + } else {
> > + return;
> > }
> > }
> > if (ret < 0) {
>
> I think I'd do this differntly... at the beginning of the function, there is
> a check for kvm_check_extension(s, KVM_CAP_IRQCHIP) etc. ... I think you
> could now replace that check with a simple
>
> if (!kvm_has_create_irqchip) {
> return;
> }
>
> The "kvm_vm_enable_cap(s, KVM_CAP_S390_IRQCHIP, 0)" of course has to be
> moved to the target/s390x/kvm/kvm.c file, too.
Actually, once we've moved the s390 cap enablement to the s390 file we can
just drop the whole if-else chain. We don't want the
if (!kvm_has_create_irqchip) at the top because we want to try
kvm_arch_irqchip_create() even when kvm_has_create_irqchip is false, and
we don't need to check KVM_CREATE_IRQCHIP for kvm_arch_irqchip_create()
either. Keeping the check, as it is above in this v1, of
kvm_has_create_irqchip for KVM_CREATE_IRQCHIP is still necessary, though.
Thanks,
drew
prev parent reply other threads:[~2023-07-25 12:20 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-22 6:21 [PATCH] kvm: Remove KVM_CREATE_IRQCHIP support assumption Andrew Jones
2023-07-24 9:53 ` Thomas Huth
2023-07-25 10:24 ` Andrew Jones
2023-07-25 12:19 ` Andrew Jones [this message]
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=20230725-539b009b8e15994408dbb47b@orel \
--to=ajones@ventanamicro.com \
--cc=borntraeger@linux.ibm.com \
--cc=dbarboza@ventanamicro.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=pasic@linux.ibm.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=thuth@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).