Message ID | 20240506101751.3145407-4-foxywang@tencent.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | KVM: irqchip: synchronize srcu only if needed | expand |
Am 06.05.24 um 12:17 schrieb Yi Wang: > From: Yi Wang <foxywang@tencent.com> > > As we have setup empty irq routing in kvm_create_vm(), there's > no need to setup dummy routing when KVM_CREATE_IRQCHIP. > > Signed-off-by: Yi Wang <foxywang@tencent.com> Acked-by: Christian Borntraeger <borntraeger@linux.ibm.com> > --- > arch/s390/kvm/kvm-s390.c | 9 +-------- > 1 file changed, 1 insertion(+), 8 deletions(-) > > diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c > index 5147b943a864..ba7fd39bcbf4 100644 > --- a/arch/s390/kvm/kvm-s390.c > +++ b/arch/s390/kvm/kvm-s390.c > @@ -2998,14 +2998,7 @@ int kvm_arch_vm_ioctl(struct file *filp, unsigned int ioctl, unsigned long arg) > break; > } > case KVM_CREATE_IRQCHIP: { > - struct kvm_irq_routing_entry routing; > - > - r = -EINVAL; > - if (kvm->arch.use_irqchip) { > - /* Set up dummy routing. */ > - memset(&routing, 0, sizeof(routing)); > - r = kvm_set_irq_routing(kvm, &routing, 0, 0); > - } > + r = 0; > break; > } > case KVM_SET_DEVICE_ATTR: {
On Mon, May 06, 2024, Yi Wang wrote: > From: Yi Wang <foxywang@tencent.com> > > As we have setup empty irq routing in kvm_create_vm(), there's > no need to setup dummy routing when KVM_CREATE_IRQCHIP. > > Signed-off-by: Yi Wang <foxywang@tencent.com> > --- > arch/s390/kvm/kvm-s390.c | 9 +-------- > 1 file changed, 1 insertion(+), 8 deletions(-) > > diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c > index 5147b943a864..ba7fd39bcbf4 100644 > --- a/arch/s390/kvm/kvm-s390.c > +++ b/arch/s390/kvm/kvm-s390.c > @@ -2998,14 +2998,7 @@ int kvm_arch_vm_ioctl(struct file *filp, unsigned int ioctl, unsigned long arg) > break; > } > case KVM_CREATE_IRQCHIP: { > - struct kvm_irq_routing_entry routing; > - > - r = -EINVAL; > - if (kvm->arch.use_irqchip) { > - /* Set up dummy routing. */ > - memset(&routing, 0, sizeof(routing)); > - r = kvm_set_irq_routing(kvm, &routing, 0, 0); > - } > + r = 0; This is wrong, KVM_CREATE_IRQCHIP should fail with -EINVAL if kvm->arch.use_irqchip is false. There's also a functional change here, though I highly doubt it negatively affects userspace. Nothing in s390 prevents invoking KVM_CREATE_IRQCHIP after KVM_SET_GSI_ROUTING, so userspace could very theoretically use KVM_CREATE_IRQCHIP to reset to empty IRQ routing. Christian, if it works for you, I'll massage it to this when applying. -- From: Yi Wang <foxywang@tencent.com> Date: Mon, 6 May 2024 18:17:51 +0800 Subject: [PATCH] KVM: s390: Don't re-setup dummy routing when KVM_CREATE_IRQCHIP Now that KVM sets up empty irq routing in kvm_create_vm(), there's no need to setup dummy routing when KVM_CREATE_IRQCHIP. Note, userspace could very theoretically use KVM_CREATE_IRQCHIP after KVM_SET_GSI_ROUTING to reset to empty IRQ routing, but it's extremely unlikely any VMM does that, e.g. the main reason s390 does anything for KVM_CREATE_IRQCHIP is to that s390 doesn't need to be special cased by the VMM. Signed-off-by: Yi Wang <foxywang@tencent.com> Acked-by: Christian Borntraeger <borntraeger@linux.ibm.com> Link: https://lore.kernel.org/r/20240506101751.3145407-4-foxywang@tencent.com [sean: keep use_irqchip check, call out KVM_SET_GSI_ROUTING impact] Signed-off-by: Sean Christopherson <seanjc@google.com> --- arch/s390/kvm/kvm-s390.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c index 82e9631cd9ef..4641083ee100 100644 --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c @@ -2996,14 +2996,9 @@ int kvm_arch_vm_ioctl(struct file *filp, unsigned int ioctl, unsigned long arg) break; } case KVM_CREATE_IRQCHIP: { - struct kvm_irq_routing_entry routing; - r = -EINVAL; - if (kvm->arch.use_irqchip) { - /* Set up dummy routing. */ - memset(&routing, 0, sizeof(routing)); - r = kvm_set_irq_routing(kvm, &routing, 0, 0); - } + if (kvm->arch.use_irqchip) + r = 0; break; } case KVM_SET_DEVICE_ATTR: { base-commit: 9a859becf1b7f6879466e8c0ebee492b236f2080 --
Am 10.06.24 um 18:19 schrieb Sean Christopherson: > On Mon, May 06, 2024, Yi Wang wrote: >> From: Yi Wang <foxywang@tencent.com> >> >> As we have setup empty irq routing in kvm_create_vm(), there's >> no need to setup dummy routing when KVM_CREATE_IRQCHIP. >> >> Signed-off-by: Yi Wang <foxywang@tencent.com> >> --- >> arch/s390/kvm/kvm-s390.c | 9 +-------- >> 1 file changed, 1 insertion(+), 8 deletions(-) >> >> diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c >> index 5147b943a864..ba7fd39bcbf4 100644 >> --- a/arch/s390/kvm/kvm-s390.c >> +++ b/arch/s390/kvm/kvm-s390.c >> @@ -2998,14 +2998,7 @@ int kvm_arch_vm_ioctl(struct file *filp, unsigned int ioctl, unsigned long arg) >> break; >> } >> case KVM_CREATE_IRQCHIP: { >> - struct kvm_irq_routing_entry routing; >> - >> - r = -EINVAL; >> - if (kvm->arch.use_irqchip) { >> - /* Set up dummy routing. */ >> - memset(&routing, 0, sizeof(routing)); >> - r = kvm_set_irq_routing(kvm, &routing, 0, 0); >> - } >> + r = 0; > > This is wrong, KVM_CREATE_IRQCHIP should fail with -EINVAL if kvm->arch.use_irqchip > is false. > > There's also a functional change here, though I highly doubt it negatively affects > userspace. Nothing in s390 prevents invoking KVM_CREATE_IRQCHIP after > KVM_SET_GSI_ROUTING, so userspace could very theoretically use KVM_CREATE_IRQCHIP > to reset to empty IRQ routing. > > Christian, if it works for you, I'll massage it to this when applying. Oops. Yes please do so.
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c index 5147b943a864..ba7fd39bcbf4 100644 --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c @@ -2998,14 +2998,7 @@ int kvm_arch_vm_ioctl(struct file *filp, unsigned int ioctl, unsigned long arg) break; } case KVM_CREATE_IRQCHIP: { - struct kvm_irq_routing_entry routing; - - r = -EINVAL; - if (kvm->arch.use_irqchip) { - /* Set up dummy routing. */ - memset(&routing, 0, sizeof(routing)); - r = kvm_set_irq_routing(kvm, &routing, 0, 0); - } + r = 0; break; } case KVM_SET_DEVICE_ATTR: {