Re: [PATCH 1/1] KVM: s390: mark irq_state.flags as non-usable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 21 Nov 2017 16:18:53 +0100
David Hildenbrand <david@xxxxxxxxxx> wrote:

> On 21.11.2017 16:08, Christian Borntraeger wrote:
> > Old kernels did not check for zero in the irq_state.flags field and old
> > QEMUs did not zero the flag field when calling KVM_S390_*_IRQ_STATE.
> > Let's add a comment and dummy code to prevent future usage of flags
> > and pad.
> > 
> > Signed-off-by: Christian Borntraeger <borntraeger@xxxxxxxxxx>
> > ---
> >  arch/s390/kvm/kvm-s390.c | 14 ++++++++++++++
> >  1 file changed, 14 insertions(+)
> > 
> > diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
> > index 6a5e02f..1baa393 100644
> > --- a/arch/s390/kvm/kvm-s390.c
> > +++ b/arch/s390/kvm/kvm-s390.c
> > @@ -3834,6 +3834,16 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
> >  			r = -EINVAL;
> >  			break;
> >  		}
> > +		if (irq_state.flags) {  
> 
> I don't see the need for if (do I need more coffee?).

I think the if can be dropped and flags zeroed unconditionally, as we
can't do anything special for flags != 0 anyway.

> 
> > +			/*
> > +			 * This is a placeholder to make sure that nobody uses
> > +			 * flags and pad. Old kernels did not check for zero
> > +			 * and old QEMUs did not zero the flag field.
> > +			 * That means that we cannot use the flags field for
> > +			 * any possible extension.
> > +			 */
> > +			irq_state.flags = 0;
> > +		}
> >  		r = kvm_s390_set_irq_state(vcpu,
> >  					   (void __user *) irq_state.buf,
> >  					   irq_state.len);
> > @@ -3849,6 +3859,10 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
> >  			r = -EINVAL;
> >  			break;
> >  		}
> > +		if (irq_state.flags) {  
> 
> dito
> 
> > +			/* see above */  
> 
> /* same handling as for kvm_s390_set_irq_state() */

I like that comment better.

> 
> > +			irq_state.flags = 0;
> > +		}
> >  		r = kvm_s390_get_irq_state(vcpu,
> >  					   (__u8 __user *)  irq_state.buf,
> >  					   irq_state.len);
> >   
> 
> 

We should also document this in Documentation/virtual/kvm/api.txt, I
think.

(Checking, the documentation for set_irq_state also seems wrong.)



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux