Commit bb64da9a authored by Christian Borntraeger's avatar Christian Borntraeger

KVM: s390: mark irq_state.flags as non-usable

Old kernels did not check for zero in the irq_state.flags field and old
QEMUs did not zero the flag/reserved fields when calling
KVM_S390_*_IRQ_STATE.  Let's add comments to prevent future uses of
these fields.
Signed-off-by: default avatarChristian Borntraeger <borntraeger@de.ibm.com>
Reviewed-by: default avatarThomas Huth <thuth@redhat.com>
Reviewed-by: default avatarCornelia Huck <cohuck@redhat.com>
Reviewed-by: default avatarDavid Hildenbrand <david@redhat.com>
Signed-off-by: default avatarChristian Borntraeger <borntraeger@de.ibm.com>
parent 940f89a5
...@@ -2901,14 +2901,19 @@ userspace buffer and its length: ...@@ -2901,14 +2901,19 @@ userspace buffer and its length:
struct kvm_s390_irq_state { struct kvm_s390_irq_state {
__u64 buf; __u64 buf;
__u32 flags; __u32 flags; /* will stay unused for compatibility reasons */
__u32 len; __u32 len;
__u32 reserved[4]; __u32 reserved[4]; /* will stay unused for compatibility reasons */
}; };
Userspace passes in the above struct and for each pending interrupt a Userspace passes in the above struct and for each pending interrupt a
struct kvm_s390_irq is copied to the provided buffer. struct kvm_s390_irq is copied to the provided buffer.
The structure contains a flags and a reserved field for future extensions. As
the kernel never checked for flags == 0 and QEMU never pre-zeroed flags and
reserved, these fields can not be used in the future without breaking
compatibility.
If -ENOBUFS is returned the buffer provided was too small and userspace If -ENOBUFS is returned the buffer provided was too small and userspace
may retry with a bigger buffer. may retry with a bigger buffer.
...@@ -2932,10 +2937,14 @@ containing a struct kvm_s390_irq_state: ...@@ -2932,10 +2937,14 @@ containing a struct kvm_s390_irq_state:
struct kvm_s390_irq_state { struct kvm_s390_irq_state {
__u64 buf; __u64 buf;
__u32 flags; /* will stay unused for compatibility reasons */
__u32 len; __u32 len;
__u32 pad; __u32 reserved[4]; /* will stay unused for compatibility reasons */
}; };
The restrictions for flags and reserved apply as well.
(see KVM_S390_GET_IRQ_STATE)
The userspace memory referenced by buf contains a struct kvm_s390_irq The userspace memory referenced by buf contains a struct kvm_s390_irq
for each interrupt to be injected into the guest. for each interrupt to be injected into the guest.
If one of the interrupts could not be injected for some reason the If one of the interrupts could not be injected for some reason the
......
// SPDX-License-Identifier: GPL-2.0 // SPDX-License-Identifier: GPL-2.0
/* /*
* hosting zSeries kernel virtual machines * hosting IBM Z kernel virtual machines (s390x)
* *
* Copyright IBM Corp. 2008, 2009 * Copyright IBM Corp. 2008, 2017
* *
* Author(s): Carsten Otte <cotte@de.ibm.com> * Author(s): Carsten Otte <cotte@de.ibm.com>
* Christian Borntraeger <borntraeger@de.ibm.com> * Christian Borntraeger <borntraeger@de.ibm.com>
...@@ -3808,6 +3808,7 @@ long kvm_arch_vcpu_ioctl(struct file *filp, ...@@ -3808,6 +3808,7 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
r = -EINVAL; r = -EINVAL;
break; break;
} }
/* do not use irq_state.flags, it will break old QEMUs */
r = kvm_s390_set_irq_state(vcpu, r = kvm_s390_set_irq_state(vcpu,
(void __user *) irq_state.buf, (void __user *) irq_state.buf,
irq_state.len); irq_state.len);
...@@ -3823,6 +3824,7 @@ long kvm_arch_vcpu_ioctl(struct file *filp, ...@@ -3823,6 +3824,7 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
r = -EINVAL; r = -EINVAL;
break; break;
} }
/* do not use irq_state.flags, it will break old QEMUs */
r = kvm_s390_get_irq_state(vcpu, r = kvm_s390_get_irq_state(vcpu,
(__u8 __user *) irq_state.buf, (__u8 __user *) irq_state.buf,
irq_state.len); irq_state.len);
......
...@@ -630,9 +630,9 @@ struct kvm_s390_irq { ...@@ -630,9 +630,9 @@ struct kvm_s390_irq {
struct kvm_s390_irq_state { struct kvm_s390_irq_state {
__u64 buf; __u64 buf;
__u32 flags; __u32 flags; /* will stay unused for compatibility reasons */
__u32 len; __u32 len;
__u32 reserved[4]; __u32 reserved[4]; /* will stay unused for compatibility reasons */
}; };
/* for KVM_SET_GUEST_DEBUG */ /* for KVM_SET_GUEST_DEBUG */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment