Merge tag 'kvm-s390-master-4.15-1' of git://git.kernel.org/pub/scm/linux/kernel/git/kvms390/linux

KVM: s390: Fixes for 4.15

- SPDX tags
- Fence storage key accesses from problem state
- Make sure that irq_state.flags is not used in the future

+39 -57
+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.
+1 -4
arch/s390/kvm/Makefile
··· 1 # Makefile for kernel virtual machines on s390 2 # 3 # Copyright IBM Corp. 2008 4 - # 5 - # This program is free software; you can redistribute it and/or modify 6 - # it under the terms of the GNU General Public License (version 2 only) 7 - # as published by the Free Software Foundation. 8 9 KVM := ../../../virt/kvm 10 common-objs = $(KVM)/kvm_main.o $(KVM)/eventfd.o $(KVM)/async_pf.o $(KVM)/irqchip.o $(KVM)/vfio.o
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 # Makefile for kernel virtual machines on s390 3 # 4 # Copyright IBM Corp. 2008 5 6 KVM := ../../../virt/kvm 7 common-objs = $(KVM)/kvm_main.o $(KVM)/eventfd.o $(KVM)/async_pf.o $(KVM)/irqchip.o $(KVM)/vfio.o
+1 -4
arch/s390/kvm/diag.c
··· 1 /* 2 * handling diagnose instructions 3 * 4 * Copyright IBM Corp. 2008, 2011 5 - * 6 - * This program is free software; you can redistribute it and/or modify 7 - * it under the terms of the GNU General Public License (version 2 only) 8 - * as published by the Free Software Foundation. 9 * 10 * Author(s): Carsten Otte <cotte@de.ibm.com> 11 * Christian Borntraeger <borntraeger@de.ibm.com>
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 /* 3 * handling diagnose instructions 4 * 5 * Copyright IBM Corp. 2008, 2011 6 * 7 * Author(s): Carsten Otte <cotte@de.ibm.com> 8 * Christian Borntraeger <borntraeger@de.ibm.com>
+1 -4
arch/s390/kvm/gaccess.h
··· 1 /* 2 * access guest memory 3 * 4 * Copyright IBM Corp. 2008, 2014 5 - * 6 - * This program is free software; you can redistribute it and/or modify 7 - * it under the terms of the GNU General Public License (version 2 only) 8 - * as published by the Free Software Foundation. 9 * 10 * Author(s): Carsten Otte <cotte@de.ibm.com> 11 */
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * access guest memory 4 * 5 * Copyright IBM Corp. 2008, 2014 6 * 7 * Author(s): Carsten Otte <cotte@de.ibm.com> 8 */
+1 -4
arch/s390/kvm/guestdbg.c
··· 1 /* 2 * kvm guest debug support 3 * 4 * Copyright IBM Corp. 2014 5 - * 6 - * This program is free software; you can redistribute it and/or modify 7 - * it under the terms of the GNU General Public License (version 2 only) 8 - * as published by the Free Software Foundation. 9 * 10 * Author(s): David Hildenbrand <dahi@linux.vnet.ibm.com> 11 */
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 /* 3 * kvm guest debug support 4 * 5 * Copyright IBM Corp. 2014 6 * 7 * Author(s): David Hildenbrand <dahi@linux.vnet.ibm.com> 8 */
+1 -4
arch/s390/kvm/intercept.c
··· 1 /* 2 * in-kernel handling for sie intercepts 3 * 4 * Copyright IBM Corp. 2008, 2014 5 - * 6 - * This program is free software; you can redistribute it and/or modify 7 - * it under the terms of the GNU General Public License (version 2 only) 8 - * as published by the Free Software Foundation. 9 * 10 * Author(s): Carsten Otte <cotte@de.ibm.com> 11 * Christian Borntraeger <borntraeger@de.ibm.com>
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 /* 3 * in-kernel handling for sie intercepts 4 * 5 * Copyright IBM Corp. 2008, 2014 6 * 7 * Author(s): Carsten Otte <cotte@de.ibm.com> 8 * Christian Borntraeger <borntraeger@de.ibm.com>
+1 -4
arch/s390/kvm/interrupt.c
··· 1 /* 2 * handling kvm guest interrupts 3 * 4 * Copyright IBM Corp. 2008, 2015 5 - * 6 - * This program is free software; you can redistribute it and/or modify 7 - * it under the terms of the GNU General Public License (version 2 only) 8 - * as published by the Free Software Foundation. 9 * 10 * Author(s): Carsten Otte <cotte@de.ibm.com> 11 */
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 /* 3 * handling kvm guest interrupts 4 * 5 * Copyright IBM Corp. 2008, 2015 6 * 7 * Author(s): Carsten Otte <cotte@de.ibm.com> 8 */
+1 -4
arch/s390/kvm/irq.h
··· 1 /* 2 * s390 irqchip routines 3 * 4 * Copyright IBM Corp. 2014 5 - * 6 - * This program is free software; you can redistribute it and/or modify 7 - * it under the terms of the GNU General Public License (version 2 only) 8 - * as published by the Free Software Foundation. 9 * 10 * Author(s): Cornelia Huck <cornelia.huck@de.ibm.com> 11 */
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * s390 irqchip routines 4 * 5 * Copyright IBM Corp. 2014 6 * 7 * Author(s): Cornelia Huck <cornelia.huck@de.ibm.com> 8 */
+5 -6
arch/s390/kvm/kvm-s390.c
··· 1 /* 2 - * hosting zSeries kernel virtual machines 3 * 4 - * Copyright IBM Corp. 2008, 2009 5 - * 6 - * This program is free software; you can redistribute it and/or modify 7 - * it under the terms of the GNU General Public License (version 2 only) 8 - * as published by the Free Software Foundation. 9 * 10 * Author(s): Carsten Otte <cotte@de.ibm.com> 11 * Christian Borntraeger <borntraeger@de.ibm.com> ··· 3805 r = -EINVAL; 3806 break; 3807 } 3808 r = kvm_s390_set_irq_state(vcpu, 3809 (void __user *) irq_state.buf, 3810 irq_state.len); ··· 3821 r = -EINVAL; 3822 break; 3823 } 3824 r = kvm_s390_get_irq_state(vcpu, 3825 (__u8 __user *) irq_state.buf, 3826 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);
+1 -4
arch/s390/kvm/kvm-s390.h
··· 1 /* 2 * definition for kvm on s390 3 * 4 * Copyright IBM Corp. 2008, 2009 5 - * 6 - * This program is free software; you can redistribute it and/or modify 7 - * it under the terms of the GNU General Public License (version 2 only) 8 - * as published by the Free Software Foundation. 9 * 10 * Author(s): Carsten Otte <cotte@de.ibm.com> 11 * Christian Borntraeger <borntraeger@de.ibm.com>
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * definition for kvm on s390 4 * 5 * Copyright IBM Corp. 2008, 2009 6 * 7 * Author(s): Carsten Otte <cotte@de.ibm.com> 8 * Christian Borntraeger <borntraeger@de.ibm.com>
+10 -6
arch/s390/kvm/priv.c
··· 1 /* 2 * handling privileged instructions 3 * 4 * Copyright IBM Corp. 2008, 2013 5 - * 6 - * This program is free software; you can redistribute it and/or modify 7 - * it under the terms of the GNU General Public License (version 2 only) 8 - * as published by the Free Software Foundation. 9 * 10 * Author(s): Carsten Otte <cotte@de.ibm.com> 11 * Christian Borntraeger <borntraeger@de.ibm.com> ··· 232 VCPU_EVENT(vcpu, 4, "%s", "retrying storage key operation"); 233 return -EAGAIN; 234 } 235 - if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) 236 - return kvm_s390_inject_program_int(vcpu, PGM_PRIVILEGED_OP); 237 return 0; 238 } 239 ··· 241 unsigned char key; 242 int reg1, reg2; 243 int rc; 244 245 rc = try_handle_skey(vcpu); 246 if (rc) ··· 273 unsigned long addr; 274 int reg1, reg2; 275 int rc; 276 277 rc = try_handle_skey(vcpu); 278 if (rc) ··· 311 unsigned char key, oldkey; 312 int reg1, reg2; 313 int rc; 314 315 rc = try_handle_skey(vcpu); 316 if (rc)
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 /* 3 * handling privileged instructions 4 * 5 * Copyright IBM Corp. 2008, 2013 6 * 7 * Author(s): Carsten Otte <cotte@de.ibm.com> 8 * Christian Borntraeger <borntraeger@de.ibm.com> ··· 235 VCPU_EVENT(vcpu, 4, "%s", "retrying storage key operation"); 236 return -EAGAIN; 237 } 238 return 0; 239 } 240 ··· 246 unsigned char key; 247 int reg1, reg2; 248 int rc; 249 + 250 + if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) 251 + return kvm_s390_inject_program_int(vcpu, PGM_PRIVILEGED_OP); 252 253 rc = try_handle_skey(vcpu); 254 if (rc) ··· 275 unsigned long addr; 276 int reg1, reg2; 277 int rc; 278 + 279 + if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) 280 + return kvm_s390_inject_program_int(vcpu, PGM_PRIVILEGED_OP); 281 282 rc = try_handle_skey(vcpu); 283 if (rc) ··· 310 unsigned char key, oldkey; 311 int reg1, reg2; 312 int rc; 313 + 314 + if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) 315 + return kvm_s390_inject_program_int(vcpu, PGM_PRIVILEGED_OP); 316 317 rc = try_handle_skey(vcpu); 318 if (rc)
+1 -4
arch/s390/kvm/sigp.c
··· 1 /* 2 * handling interprocessor communication 3 * 4 * Copyright IBM Corp. 2008, 2013 5 - * 6 - * This program is free software; you can redistribute it and/or modify 7 - * it under the terms of the GNU General Public License (version 2 only) 8 - * as published by the Free Software Foundation. 9 * 10 * Author(s): Carsten Otte <cotte@de.ibm.com> 11 * Christian Borntraeger <borntraeger@de.ibm.com>
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 /* 3 * handling interprocessor communication 4 * 5 * Copyright IBM Corp. 2008, 2013 6 * 7 * Author(s): Carsten Otte <cotte@de.ibm.com> 8 * Christian Borntraeger <borntraeger@de.ibm.com>
+1 -4
arch/s390/kvm/vsie.c
··· 1 /* 2 * kvm nested virtualization support for s390x 3 * 4 * Copyright IBM Corp. 2016 5 - * 6 - * This program is free software; you can redistribute it and/or modify 7 - * it under the terms of the GNU General Public License (version 2 only) 8 - * as published by the Free Software Foundation. 9 * 10 * Author(s): David Hildenbrand <dahi@linux.vnet.ibm.com> 11 */
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 /* 3 * kvm nested virtualization support for s390x 4 * 5 * Copyright IBM Corp. 2016 6 * 7 * Author(s): David Hildenbrand <dahi@linux.vnet.ibm.com> 8 */
+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 */