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: Christian Borntraeger <borntraeger@de.ibm.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>

+18 -7
+12 -3
Documentation/virtual/kvm/api.txt
··· 2901 2902 struct kvm_s390_irq_state { 2903 __u64 buf; 2904 - __u32 flags; 2905 __u32 len; 2906 - __u32 reserved[4]; 2907 }; 2908 2909 Userspace passes in the above struct and for each pending interrupt a 2910 struct kvm_s390_irq is copied to the provided buffer. 2911 2912 If -ENOBUFS is returned the buffer provided was too small and userspace 2913 may retry with a bigger buffer. ··· 2937 2938 struct kvm_s390_irq_state { 2939 __u64 buf; 2940 __u32 len; 2941 - __u32 pad; 2942 }; 2943 2944 The userspace memory referenced by buf contains a struct kvm_s390_irq 2945 for each interrupt to be injected into the guest.
··· 2901 2902 struct kvm_s390_irq_state { 2903 __u64 buf; 2904 + __u32 flags; /* will stay unused for compatibility reasons */ 2905 __u32 len; 2906 + __u32 reserved[4]; /* will stay unused for compatibility reasons */ 2907 }; 2908 2909 Userspace passes in the above struct and for each pending interrupt a 2910 struct kvm_s390_irq is copied to the provided buffer. 2911 + 2912 + The structure contains a flags and a reserved field for future extensions. As 2913 + the kernel never checked for flags == 0 and QEMU never pre-zeroed flags and 2914 + reserved, these fields can not be used in the future without breaking 2915 + compatibility. 2916 2917 If -ENOBUFS is returned the buffer provided was too small and userspace 2918 may retry with a bigger buffer. ··· 2932 2933 struct kvm_s390_irq_state { 2934 __u64 buf; 2935 + __u32 flags; /* will stay unused for compatibility reasons */ 2936 __u32 len; 2937 + __u32 reserved[4]; /* will stay unused for compatibility reasons */ 2938 }; 2939 + 2940 + The restrictions for flags and reserved apply as well. 2941 + (see KVM_S390_GET_IRQ_STATE) 2942 2943 The userspace memory referenced by buf contains a struct kvm_s390_irq 2944 for each interrupt to be injected into the guest.
+4 -2
arch/s390/kvm/kvm-s390.c
··· 1 // SPDX-License-Identifier: GPL-2.0 2 /* 3 - * hosting zSeries kernel virtual machines 4 * 5 - * Copyright IBM Corp. 2008, 2009 6 * 7 * Author(s): Carsten Otte <cotte@de.ibm.com> 8 * Christian Borntraeger <borntraeger@de.ibm.com> ··· 3808 r = -EINVAL; 3809 break; 3810 } 3811 r = kvm_s390_set_irq_state(vcpu, 3812 (void __user *) irq_state.buf, 3813 irq_state.len); ··· 3824 r = -EINVAL; 3825 break; 3826 } 3827 r = kvm_s390_get_irq_state(vcpu, 3828 (__u8 __user *) irq_state.buf, 3829 irq_state.len);
··· 1 // SPDX-License-Identifier: GPL-2.0 2 /* 3 + * hosting IBM Z kernel virtual machines (s390x) 4 * 5 + * Copyright IBM Corp. 2008, 2017 6 * 7 * Author(s): Carsten Otte <cotte@de.ibm.com> 8 * Christian Borntraeger <borntraeger@de.ibm.com> ··· 3808 r = -EINVAL; 3809 break; 3810 } 3811 + /* do not use irq_state.flags, it will break old QEMUs */ 3812 r = kvm_s390_set_irq_state(vcpu, 3813 (void __user *) irq_state.buf, 3814 irq_state.len); ··· 3823 r = -EINVAL; 3824 break; 3825 } 3826 + /* do not use irq_state.flags, it will break old QEMUs */ 3827 r = kvm_s390_get_irq_state(vcpu, 3828 (__u8 __user *) irq_state.buf, 3829 irq_state.len);
+2 -2
include/uapi/linux/kvm.h
··· 630 631 struct kvm_s390_irq_state { 632 __u64 buf; 633 - __u32 flags; 634 __u32 len; 635 - __u32 reserved[4]; 636 }; 637 638 /* for KVM_SET_GUEST_DEBUG */
··· 630 631 struct kvm_s390_irq_state { 632 __u64 buf; 633 + __u32 flags; /* will stay unused for compatibility reasons */ 634 __u32 len; 635 + __u32 reserved[4]; /* will stay unused for compatibility reasons */ 636 }; 637 638 /* for KVM_SET_GUEST_DEBUG */