KVM: s390: check if kernel irqchip is actually enabled
PATCH 1/1 KVM: s390: check if kernel irqchip is actually enabled
On s390, we only allow userspace to create an in-kernel irqchip if it has first enabled the KVM_CAP_S390_IRQCHIP vm capability. Let's assume that a userspace that enabled that capability has created an irqchip as well.
---
A more precise check would be to add a field in kvm_arch that tracks whether an irqchip has actually been created; not sure if that is really needed.
Found while trying to hunt down QEMU crashes with kvm-irqchip=off; this is not sufficient, though. I *think* everything but irqfds should work without kvm-irqchip as well, but have not found the problem yet.
--- arch/s390/kvm/irq.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/s390/kvm/irq.h +1 -1
@@ -13,7 +13,7 @@static inline int irqchip_in_kernel (struct kvm *kvm) { -return 1 ; +return !!kvm->arch.use_irqchip; }#endif
Signature · 1 line
2.21.1
Quoted 7 lines · On Thu, 9 Jan 2020 14:47:13 +0100 Cornelia Huck <[email protected]> wrote:
On s390, we only allow userspace to create an in-kernel irqchip if it has first enabled the
KVM_CAP_S390_IRQCHIPvm capability. Let's assume that a userspace that enabled that capability has created an irqchip as well.Fixes 84223598778b ("KVM: s390: irq routing for adapter interrupts.")Signed-off-by Cornelia Huck <[email protected]>
Quoted 7 lines
---
A more precise check would be to add a field in
kvm_archthat tracks whether an irqchip has actually been created; not sure if that is really needed.Found while trying to hunt down QEMU crashes with kvm-irqchip=off;
s/kvm-irqchip/kernel_irqchip/
Quoted 21 lines
this is not sufficient, though. I *think* everything but irqfds should work without kvm-irqchip as well, but have not found the problem yet.
--- arch/s390/kvm/irq.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/s390/kvm/irq.h +1
-1@@ -13,7 +13,7 @@static inline int irqchip_in_kernel (struct kvm *kvm) { -return 1 ; +return !!kvm->arch.use_irqchip; }#endif
Quoted 28 lines · Cornelia Huck
On s390, we only allow userspace to create an in-kernel irqchip if it has first enabled the
KVM_CAP_S390_IRQCHIPvm capability. Let's assume that a userspace that enabled that capability has created an irqchip as well.Fixes 84223598778b ("KVM: s390: irq routing for adapter interrupts.")Signed-off-by Cornelia Huck <[email protected]>---
A more precise check would be to add a field in
kvm_archthat tracks whether an irqchip has actually been created; not sure if that is really needed.Found while trying to hunt down QEMU crashes with kvm-irqchip=off; this is not sufficient, though. I *think* everything but irqfds should work without kvm-irqchip as well, but have not found the problem yet.
--- arch/s390/kvm/irq.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/s390/kvm/irq.h +0
-0
arch/s390/kvm/irq.h line 19
Quoted 8 lines
arch/s390/kvm/irq.h +1
-1@@ -13,7 +13,7 @@static inline int irqchip_in_kernel (struct kvm *kvm) { -return 1 ; +return !!kvm->arch.use_irqchip; }#endif
This function is used on s390x/common code only in
virt/kvm/irqchip.c:kvm_send_userspace_msi()
That function is only used with CONFIG_HAVE_KVM_MSI. That is not selected for s390x.
What does this patch fix?
Signature · 3 lines
Thanks, David / dhildenb
Quoted 40 lines · On Thu, 9 Jan 2020 14:57:43 +0100 David Hildenbrand <[email protected]> wrote:
Quoted 28 lines · Cornelia Huck
On s390, we only allow userspace to create an in-kernel irqchip if it has first enabled the
KVM_CAP_S390_IRQCHIPvm capability. Let's assume that a userspace that enabled that capability has created an irqchip as well.Fixes 84223598778b ("KVM: s390: irq routing for adapter interrupts.")Signed-off-by Cornelia Huck <[email protected]>---
A more precise check would be to add a field in
kvm_archthat tracks whether an irqchip has actually been created; not sure if that is really needed.Found while trying to hunt down QEMU crashes with kvm-irqchip=off; this is not sufficient, though. I *think* everything but irqfds should work without kvm-irqchip as well, but have not found the problem yet.
--- arch/s390/kvm/irq.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/s390/kvm/irq.h +0
-0arch/s390/kvm/irq.h line 19
Quoted 8 lines
arch/s390/kvm/irq.h +1
-1@@ -13,7 +13,7 @@static inline int irqchip_in_kernel (struct kvm *kvm) { -return 1 ; +return !!kvm->arch.use_irqchip; }#endif This function is used on s390x/common code only in
Quoted 6 lines
virt/kvm/irqchip.c:kvm_send_userspace_msi()
That function is only used with
CONFIG_HAVE_KVM_MSI. That is not selected for s390x.What does this patch fix?
Currently, only future callers... but maybe this should be an optional function instead that is only defined by the architectures that can actually do something useful here? TBH, I'm not completely sure what this function is actually supposed to indicate...
Quoted 5 lines · Cornelia Huck
On s390, we only allow userspace to create an in-kernel irqchip if it has first enabled the
KVM_CAP_S390_IRQCHIPvm capability. Let's assume that a userspace that enabled that capability has created an irqchip as well.
Quoted 7 lines
Fixes 84223598778b ("KVM: s390: irq routing for adapter interrupts.")Signed-off-by Cornelia Huck <[email protected]>---
A more precise check would be to add a field in
kvm_archthat tracks whether an irqchip has actually been created; not sure if that is really needed.
I think this is semantically wrong. We always have in-kernel irq handling. It is actually not possible to not use it. So I understand where you are coming from but this feels kind of wrong.
Quoted 24 lines
Found while trying to hunt down QEMU crashes with kvm-irqchip=off; this is not sufficient, though. I *think* everything but irqfds should work without kvm-irqchip as well, but have not found the problem yet.
--- arch/s390/kvm/irq.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/s390/kvm/irq.h +1
-1@@ -13,7 +13,7 @@static inline int irqchip_in_kernel (struct kvm *kvm) { -return 1 ; +return !!kvm->arch.use_irqchip; }#endif
Quoted 10 lines · On Thu, 9 Jan 2020 15:06:22 +0100 Christian Borntraeger…
Quoted 9 lines · Cornelia Huck
On s390, we only allow userspace to create an in-kernel irqchip if it has first enabled the
KVM_CAP_S390_IRQCHIPvm capability. Let's assume that a userspace that enabled that capability has created an irqchip as well.Fixes 84223598778b ("KVM: s390: irq routing for adapter interrupts.")Signed-off-by Cornelia Huck <[email protected]>---
Quoted 7 lines
Quoted 3 lines
A more precise check would be to add a field in
kvm_archthat tracks whether an irqchip has actually been created; not sure if that is really needed.I think this is semantically wrong. We always have in-kernel irq handling. It is actually not possible to not use it. So I understand where you are coming from but this feels kind of wrong.
You cannot actually call create_irqchip if not enabled, though... as I said in my other reply, the intended semantics here are a bit unclear.
Quoted 26 lines
Quoted 25 lines
Found while trying to hunt down QEMU crashes with kvm-irqchip=off; this is not sufficient, though. I *think* everything but irqfds should work without kvm-irqchip as well, but have not found the problem yet.
--- arch/s390/kvm/irq.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/s390/kvm/irq.h +1
-1@@ -13,7 +13,7 @@static inline int irqchip_in_kernel (struct kvm *kvm) { -return 1 ; +return !!kvm->arch.use_irqchip; }#endif