* [PATCH 1/1] KVM: s390: mark irq_state.flags as non-usable
@ 2017-11-21 15:08 Christian Borntraeger
2017-11-21 15:08 ` Christian Borntraeger
2017-11-21 15:18 ` David Hildenbrand
0 siblings, 2 replies; 6+ messages in thread
From: Christian Borntraeger @ 2017-11-21 15:08 UTC (permalink / raw)
To: Cornelia Huck
Cc: KVM, Christian Borntraeger, linux-s390, Thomas Huth, Halil Pasic
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@de.ibm.com>
---
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) {
+ /*
+ * 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) {
+ /* see above */
+ irq_state.flags = 0;
+ }
r = kvm_s390_get_irq_state(vcpu,
(__u8 __user *) irq_state.buf,
irq_state.len);
--
2.9.4
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH 1/1] KVM: s390: mark irq_state.flags as non-usable
2017-11-21 15:08 [PATCH 1/1] KVM: s390: mark irq_state.flags as non-usable Christian Borntraeger
@ 2017-11-21 15:08 ` Christian Borntraeger
2017-11-21 15:18 ` David Hildenbrand
1 sibling, 0 replies; 6+ messages in thread
From: Christian Borntraeger @ 2017-11-21 15:08 UTC (permalink / raw)
To: Cornelia Huck; +Cc: KVM, linux-s390, Thomas Huth, Halil Pasic
FWIW, this is a kernel fallout of the valgrind related QEMU discussion.
On 11/21/2017 04:08 PM, 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@de.ibm.com>
> ---
> 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) {
> + /*
> + * 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) {
> + /* see above */
> + irq_state.flags = 0;
> + }
> r = kvm_s390_get_irq_state(vcpu,
> (__u8 __user *) irq_state.buf,
> irq_state.len);
>
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH 1/1] KVM: s390: mark irq_state.flags as non-usable
2017-11-21 15:08 [PATCH 1/1] KVM: s390: mark irq_state.flags as non-usable Christian Borntraeger
2017-11-21 15:08 ` Christian Borntraeger
@ 2017-11-21 15:18 ` David Hildenbrand
2017-11-21 15:32 ` Cornelia Huck
2017-11-21 17:42 ` Christian Borntraeger
1 sibling, 2 replies; 6+ messages in thread
From: David Hildenbrand @ 2017-11-21 15:18 UTC (permalink / raw)
To: Christian Borntraeger, Cornelia Huck
Cc: KVM, linux-s390, Thomas Huth, Halil Pasic
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@de.ibm.com>
> ---
> 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?).
> + /*
> + * 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() */
> + irq_state.flags = 0;
> + }
> r = kvm_s390_get_irq_state(vcpu,
> (__u8 __user *) irq_state.buf,
> irq_state.len);
>
--
Thanks,
David / dhildenb
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH 1/1] KVM: s390: mark irq_state.flags as non-usable
2017-11-21 15:18 ` David Hildenbrand
@ 2017-11-21 15:32 ` Cornelia Huck
2017-11-21 17:42 ` Christian Borntraeger
1 sibling, 0 replies; 6+ messages in thread
From: Cornelia Huck @ 2017-11-21 15:32 UTC (permalink / raw)
To: David Hildenbrand
Cc: Christian Borntraeger, KVM, linux-s390, Thomas Huth, Halil Pasic
On Tue, 21 Nov 2017 16:18:53 +0100
David Hildenbrand <david@redhat.com> 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@de.ibm.com>
> > ---
> > 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.)
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH 1/1] KVM: s390: mark irq_state.flags as non-usable
2017-11-21 15:18 ` David Hildenbrand
2017-11-21 15:32 ` Cornelia Huck
@ 2017-11-21 17:42 ` Christian Borntraeger
2017-11-21 18:27 ` Thomas Huth
1 sibling, 1 reply; 6+ messages in thread
From: Christian Borntraeger @ 2017-11-21 17:42 UTC (permalink / raw)
To: David Hildenbrand, Cornelia Huck
Cc: KVM, linux-s390, Thomas Huth, Halil Pasic
On 11/21/2017 04:18 PM, David Hildenbrand 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@de.ibm.com>
>> ---
>> 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?).
It is a dummy construct that matches other checks like "if flags return -EINVAL". But since
it is dummy we can do whatever we want (even just a comment) since nobody reads flags as of
today.
>
>> + /*
>> + * 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() */
>
>> + irq_state.flags = 0;
>> + }
>> r = kvm_s390_get_irq_state(vcpu,
>> (__u8 __user *) irq_state.buf,
>> irq_state.len);
>>
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH 1/1] KVM: s390: mark irq_state.flags as non-usable
2017-11-21 17:42 ` Christian Borntraeger
@ 2017-11-21 18:27 ` Thomas Huth
0 siblings, 0 replies; 6+ messages in thread
From: Thomas Huth @ 2017-11-21 18:27 UTC (permalink / raw)
To: Christian Borntraeger, David Hildenbrand, Cornelia Huck
Cc: KVM, linux-s390, Halil Pasic
On 21.11.2017 18:42, Christian Borntraeger wrote:
>
>
> On 11/21/2017 04:18 PM, David Hildenbrand 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@de.ibm.com>
>>> ---
>>> 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?).
>
> It is a dummy construct that matches other checks like "if flags return -EINVAL". But since
> it is dummy we can do whatever we want (even just a comment) since nobody reads flags as of
> today.
Not sure if changing the code here really makes sense ... I think I'd
rather prefer to add a comment to the header where the struct is
defined, and add some proper sentences about "flags" to the api.txt file.
Thomas
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-11-21 18:27 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-21 15:08 [PATCH 1/1] KVM: s390: mark irq_state.flags as non-usable Christian Borntraeger
2017-11-21 15:08 ` Christian Borntraeger
2017-11-21 15:18 ` David Hildenbrand
2017-11-21 15:32 ` Cornelia Huck
2017-11-21 17:42 ` Christian Borntraeger
2017-11-21 18:27 ` Thomas Huth
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox