Home Home > GIT Browse > SLE12-SP5-AZURE
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Thumshirn <jthumshirn@suse.de>2019-08-22 11:28:57 +0200
committerJohannes Thumshirn <jthumshirn@suse.de>2019-08-22 11:29:29 +0200
commit54ab0c20610c57f750b7a59dc5d503a4ff382d2c (patch)
tree3d1e5731b1c41c1e029eb14459f3b63c2efa62c3
parent79b0b2ea7f2370b63efaba3bdba4e1bc1723fc93 (diff)
parent5fc27f72bcaedb00dfae19bb7362cb5737a00186 (diff)
Merge remote-tracking branch 'origin/users/brogers/SLE12-SP5/for-next' into SLE12-SP5
Pull s/390 kvm fixes from Bruce Rogers.
-rw-r--r--patches.arch/kvm-add-machine-check-counter-to-kvm_stat.patch59
-rw-r--r--patches.arch/kvm-s390-abstract-adapter-interruption-word-generation-from-isc.patch55
-rw-r--r--patches.arch/kvm-s390-activate-gisa-for-emulated-interrupts.patch41
-rw-r--r--patches.arch/kvm-s390-add-debug-tracing-for-cpu-features-of-cpu-model.patch79
-rw-r--r--patches.arch/kvm-s390-add-exit-io-request-stats-and-simplify-code.patch81
-rw-r--r--patches.arch/kvm-s390-add-gisa-interrupts-to-flic-ioctl-interface.patch71
-rw-r--r--patches.arch/kvm-s390-clarify-kvm-related-kernel-message.patch47
-rw-r--r--patches.arch/kvm-s390-cleanup-struct-kvm_s390_float_interrupt.patch222
-rw-r--r--patches.arch/kvm-s390-define-gisa-format-0-data-structure.patch94
-rw-r--r--patches.arch/kvm-s390-do-not-set-intervention-requests-for-gisa-interrupts.patch51
-rw-r--r--patches.arch/kvm-s390-drop-use-of-spin-lock-in-_floating_irq_kick.patch41
-rw-r--r--patches.arch/kvm-s390-exploit-gisa-and-aiv-for-emulated-interrupts.patch269
-rw-r--r--patches.arch/kvm-s390-fix-fallthrough-annotation.patch60
-rw-r--r--patches.arch/kvm-s390-fix-kmsg-component-kvm-s390.patch44
-rw-r--r--patches.arch/kvm-s390-fix-potential-spectre-warnings.patch59
-rw-r--r--patches.arch/kvm-s390-generalize-kvm_s390_get_tod_clock_ext.patch74
-rw-r--r--patches.arch/kvm-s390-implement-gisa-ipm-related-primitives.patch62
-rw-r--r--patches.arch/kvm-s390-introduce-the-format-1-gisa.patch127
-rw-r--r--patches.arch/kvm-s390-make-kvm_s390_get_io_int-aware-of-gisa.patch124
-rw-r--r--patches.arch/kvm-s390-no-need-to-inititalize-kvm-arch-members-to-0.patch59
-rw-r--r--patches.arch/kvm-s390-provide-counters-for-all-interrupt-injects-delivery.patch301
-rw-r--r--patches.arch/kvm-s390-reverse-bit-ordering-of-irqs-in-pending-mask.patch143
-rw-r--r--patches.arch/kvm-s390-set-host-program-identifier.patch70
-rw-r--r--patches.arch/kvm-s390-tracing-apcb-changes.patch96
-rw-r--r--patches.arch/kvm-s390-unregister-debug-feature-on-failing-arch-init.patch63
-rw-r--r--patches.arch/kvm-s390-use-switch-vs-jump-table-in-intercept-c.patch113
-rw-r--r--patches.arch/kvm-s390-use-switch-vs-jump-table-in-interrupt-c.patch138
-rw-r--r--patches.arch/kvm-s390-use-switch-vs-jump-table-in-priv-c.patch254
-rw-r--r--patches.arch/kvm-s390-vsie-avoid-sparse-warning.patch32
-rw-r--r--patches.arch/kvm-s390-vsie-simplify-8k-address-checks.patch69
-rw-r--r--patches.arch/kvm-s390-vsie-store-guest-addresses-of-satellite-blocks-in-vsie_page.patch139
-rw-r--r--patches.arch/s390-bitops-add-test_and_clear_bit_inv.patch40
-rw-r--r--patches.arch/s390-css-indicate-the-availability-of-the-aiv-facility.patch40
-rw-r--r--patches.arch/s390-sclp-detect-dirq-facility6
-rw-r--r--patches.arch/s390-sclp-expose-the-gisa-format-facility.patch53
-rw-r--r--patches.arch/s390-setup-set-control-program-code-via-diag-3186
-rw-r--r--patches.arch/s390-sles15sp1-00-04-12-KVM-s390-Add-skey-emulation-fault-handling.patch60
-rw-r--r--patches.arch/s390-sles15sp1-00-07-03-KVM-s390-refactor-crypto-initialization.patch14
-rw-r--r--patches.fixes/kvm-s390-add-etoken-support-for-guests.patch18
-rw-r--r--series.conf34
40 files changed, 3375 insertions, 33 deletions
diff --git a/patches.arch/kvm-add-machine-check-counter-to-kvm_stat.patch b/patches.arch/kvm-add-machine-check-counter-to-kvm_stat.patch
new file mode 100644
index 0000000000..059fed57dc
--- /dev/null
+++ b/patches.arch/kvm-add-machine-check-counter-to-kvm_stat.patch
@@ -0,0 +1,59 @@
+From: QingFeng Hao <haoqf@linux.vnet.ibm.com>
+Date: Fri, 2 Mar 2018 11:56:47 +0100
+Subject: KVM: add machine check counter to kvm_stat
+Git-commit: 32de0749097ea5be5af7f06bc26cf4e06958ac0f
+Patch-mainline: v4.17-rc1
+References: jsc#SLE-6412
+
+This counter can be used for administration, debug or test purposes.
+
+Suggested-by: Vladislav Mironov <mironov@de.ibm.com>
+Signed-off-by: QingFeng Hao <haoqf@linux.vnet.ibm.com>
+Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
+Reviewed-by: Cornelia Huck <cohuck@redhat.com>
+Reviewed-by: David Hildenbrand <david@redhat.com>
+Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
+Signed-off-by: Bruce Rogers <brogers@suse.com>
+---
+ arch/s390/include/asm/kvm_host.h | 1 +
+ arch/s390/kvm/interrupt.c | 1 +
+ arch/s390/kvm/kvm-s390.c | 1 +
+ 3 files changed, 3 insertions(+)
+
+diff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_host.h
+index bca4e8d489ac..85f0013a47cd 100644
+--- a/arch/s390/include/asm/kvm_host.h
++++ b/arch/s390/include/asm/kvm_host.h
+@@ -329,6 +329,7 @@ struct kvm_vcpu_stat {
+ u64 deliver_restart_signal;
+ u64 deliver_program_int;
+ u64 deliver_io_int;
++ u64 deliver_machine_check;
+ u64 exit_wait_state;
+ u64 instruction_epsw;
+ u64 instruction_gs;
+diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c
+index 3d36c088a13d..aaf2a6839d0d 100644
+--- a/arch/s390/kvm/interrupt.c
++++ b/arch/s390/kvm/interrupt.c
+@@ -600,6 +600,7 @@ static int __must_check __deliver_machine_check(struct kvm_vcpu *vcpu)
+ trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id,
+ KVM_S390_MCHK,
+ mchk.cr14, mchk.mcic);
++ vcpu->stat.deliver_machine_check++;
+ rc = __write_machine_check(vcpu, &mchk);
+ }
+ return rc;
+diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
+index c235b45db308..242deaa6bb99 100644
+--- a/arch/s390/kvm/kvm-s390.c
++++ b/arch/s390/kvm/kvm-s390.c
+@@ -90,6 +90,7 @@ struct kvm_stats_debugfs_item debugfs_entries[] = {
+ { "deliver_restart_signal", VCPU_STAT(deliver_restart_signal) },
+ { "deliver_program_interruption", VCPU_STAT(deliver_program_int) },
+ { "deliver_io_interrupt", VCPU_STAT(deliver_io_int) },
++ { "deliver_machine_check", VCPU_STAT(deliver_machine_check) },
+ { "exit_wait_state", VCPU_STAT(exit_wait_state) },
+ { "instruction_epsw", VCPU_STAT(instruction_epsw) },
+ { "instruction_gs", VCPU_STAT(instruction_gs) },
+
diff --git a/patches.arch/kvm-s390-abstract-adapter-interruption-word-generation-from-isc.patch b/patches.arch/kvm-s390-abstract-adapter-interruption-word-generation-from-isc.patch
new file mode 100644
index 0000000000..4a8cd2f441
--- /dev/null
+++ b/patches.arch/kvm-s390-abstract-adapter-interruption-word-generation-from-isc.patch
@@ -0,0 +1,55 @@
+From: Michael Mueller <mimu@linux.vnet.ibm.com>
+Date: Thu, 31 Aug 2017 11:10:28 +0200
+Subject: KVM: s390: abstract adapter interruption word generation from ISC
+Git-commit: 2496c8e7fe9270bde5e125729c193120e7fa8c67
+Patch-mainline: v4.16-rc1
+References: jsc#SLE-6412
+
+The function isc_to_int_word() allows the generation of interruption
+words for adapter interrupts.
+
+Signed-off-by: Michael Mueller <mimu@linux.vnet.ibm.com>
+Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
+Reviewed-by: Cornelia Huck <cohuck@redhat.com>
+Reviewed-by: David Hildenbrand <david@redhat.com>
+Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
+Signed-off-by: Bruce Rogers <brogers@suse.com>
+---
+ arch/s390/kvm/interrupt.c | 9 +++++++--
+ 1 file changed, 7 insertions(+), 2 deletions(-)
+
+diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c
+index bad5a45c69f2..618b4465ca35 100644
+--- a/arch/s390/kvm/interrupt.c
++++ b/arch/s390/kvm/interrupt.c
+@@ -205,6 +205,11 @@ static uint64_t isc_to_isc_bits(int isc)
+ return (0x80 >> isc) << 24;
+ }
+
++static inline u32 isc_to_int_word(u8 isc)
++{
++ return ((u32)isc << 27) | 0x80000000;
++}
++
+ static inline u8 int_word_to_isc(u32 int_word)
+ {
+ return (int_word & 0x38000000) >> 27;
+@@ -1004,7 +1009,7 @@ static int __must_check __deliver_io(struct kvm_vcpu *vcpu,
+ */
+ VCPU_EVENT(vcpu, 4, "%s isc %u", "deliver: I/O (AI/gisa)", isc);
+ memset(&io, 0, sizeof(io));
+- io.io_int_word = (isc << 27) | 0x80000000;
++ io.io_int_word = isc_to_int_word(isc);
+ vcpu->stat.deliver_io_int++;
+ trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id,
+ KVM_S390_INT_IO(1, 0, 0, 0),
+@@ -2317,7 +2322,7 @@ static int kvm_s390_inject_airq(struct kvm *kvm,
+ struct kvm_s390_interrupt s390int = {
+ .type = KVM_S390_INT_IO(1, 0, 0, 0),
+ .parm = 0,
+- .parm64 = (adapter->isc << 27) | 0x80000000,
++ .parm64 = isc_to_int_word(adapter->isc),
+ };
+ int ret = 0;
+
+
diff --git a/patches.arch/kvm-s390-activate-gisa-for-emulated-interrupts.patch b/patches.arch/kvm-s390-activate-gisa-for-emulated-interrupts.patch
new file mode 100644
index 0000000000..618da6ecab
--- /dev/null
+++ b/patches.arch/kvm-s390-activate-gisa-for-emulated-interrupts.patch
@@ -0,0 +1,41 @@
+From: Michael Mueller <mimu@linux.vnet.ibm.com>
+Date: Fri, 23 Jun 2017 14:46:21 +0200
+Subject: KVM: s390: activate GISA for emulated interrupts
+Git-commit: f180bfdae024b34e71e89dcc82b037dd97f74c3a
+Patch-mainline: v4.16-rc1
+References: jsc#SLE-6412
+
+If the AIV facility is available, a GISA will be used to manage emulated
+adapter interrupts.
+
+Signed-off-by: Michael Mueller <mimu@linux.vnet.ibm.com>
+Reviewed-by: Halil Pasic <pasic@linux.vnet.ibm.com>
+Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
+Reviewed-by: David Hildenbrand <david@redhat.com>
+Reviewed-by: Cornelia Huck <cohuck@redhat.com>
+Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
+Signed-off-by: Bruce Rogers <brogers@suse.com>
+---
+ arch/s390/kvm/interrupt.c | 8 +++++++-
+ 1 file changed, 7 insertions(+), 1 deletion(-)
+
+diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c
+index 325ea87cd59d..b01be3c6b4fe 100644
+--- a/arch/s390/kvm/interrupt.c
++++ b/arch/s390/kvm/interrupt.c
+@@ -2860,7 +2860,13 @@ void kvm_s390_gisa_clear(struct kvm *kvm)
+
+ void kvm_s390_gisa_init(struct kvm *kvm)
+ {
+- /* not implemented yet */
++ if (!css_general_characteristics.aiv)
++ kvm->arch.gisa = NULL;
++ else {
++ kvm->arch.gisa = &kvm->arch.sie_page2->gisa;
++ VM_EVENT(kvm, 3, "gisa 0x%pK initialized", kvm->arch.gisa);
++ kvm_s390_gisa_clear(kvm);
++ }
+ }
+
+ void kvm_s390_gisa_destroy(struct kvm *kvm)
+
diff --git a/patches.arch/kvm-s390-add-debug-tracing-for-cpu-features-of-cpu-model.patch b/patches.arch/kvm-s390-add-debug-tracing-for-cpu-features-of-cpu-model.patch
new file mode 100644
index 0000000000..09774c7cce
--- /dev/null
+++ b/patches.arch/kvm-s390-add-debug-tracing-for-cpu-features-of-cpu-model.patch
@@ -0,0 +1,79 @@
+From: Christian Borntraeger <borntraeger@de.ibm.com>
+Date: Thu, 16 Nov 2017 12:30:15 +0100
+Subject: KVM: s390: add debug tracing for cpu features of CPU model
+Git-commit: 2f8311c912ab67084ce3657096df601c87f49a58
+Patch-mainline: v4.16-rc1
+References: jsc#SLE-6412
+
+The cpu model already traces the cpu facilities, the ibc and
+guest CPU ids. We should do the same for the cpu features (on
+success only).
+
+Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
+Reviewed-by: Halil Pasic <pasic@linux.vnet.ibm.com>
+Reviewed-by: Cornelia Huck <cohuck@redhat.com>
+Reviewed-by: David Hildenbrand <david@redhat.com>
+Signed-off-by: Bruce Rogers <brogers@suse.com>
+---
+ arch/s390/kvm/kvm-s390.c | 24 ++++++++++++++++++------
+ 1 file changed, 18 insertions(+), 6 deletions(-)
+
+diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
+index c21aed7f3c42..9597bd0259f4 100644
+--- a/arch/s390/kvm/kvm-s390.c
++++ b/arch/s390/kvm/kvm-s390.c
+@@ -1238,7 +1238,6 @@ static int kvm_s390_set_processor_feat(struct kvm *kvm,
+ struct kvm_device_attr *attr)
+ {
+ struct kvm_s390_vm_cpu_feat data;
+- int ret = -EBUSY;
+
+ if (copy_from_user(&data, (void __user *)attr->addr, sizeof(data)))
+ return -EFAULT;
+@@ -1248,13 +1247,18 @@ static int kvm_s390_set_processor_feat(struct kvm *kvm,
+ return -EINVAL;
+
+ mutex_lock(&kvm->lock);
+- if (!kvm->created_vcpus) {
+- bitmap_copy(kvm->arch.cpu_feat, (unsigned long *) data.feat,
+- KVM_S390_VM_CPU_FEAT_NR_BITS);
+- ret = 0;
++ if (kvm->created_vcpus) {
++ mutex_unlock(&kvm->lock);
++ return -EBUSY;
+ }
++ bitmap_copy(kvm->arch.cpu_feat, (unsigned long *) data.feat,
++ KVM_S390_VM_CPU_FEAT_NR_BITS);
+ mutex_unlock(&kvm->lock);
+- return ret;
++ VM_EVENT(kvm, 3, "SET: guest feat: 0x%16.16llx.0x%16.16llx.0x%16.16llx",
++ data.feat[0],
++ data.feat[1],
++ data.feat[2]);
++ return 0;
+ }
+
+ static int kvm_s390_set_processor_subfunc(struct kvm *kvm,
+@@ -1356,6 +1360,10 @@ static int kvm_s390_get_processor_feat(struct kvm *kvm,
+ KVM_S390_VM_CPU_FEAT_NR_BITS);
+ if (copy_to_user((void __user *)attr->addr, &data, sizeof(data)))
+ return -EFAULT;
++ VM_EVENT(kvm, 3, "GET: guest feat: 0x%16.16llx.0x%16.16llx.0x%16.16llx",
++ data.feat[0],
++ data.feat[1],
++ data.feat[2]);
+ return 0;
+ }
+
+@@ -1369,6 +1377,10 @@ static int kvm_s390_get_machine_feat(struct kvm *kvm,
+ KVM_S390_VM_CPU_FEAT_NR_BITS);
+ if (copy_to_user((void __user *)attr->addr, &data, sizeof(data)))
+ return -EFAULT;
++ VM_EVENT(kvm, 3, "GET: host feat: 0x%16.16llx.0x%16.16llx.0x%16.16llx",
++ data.feat[0],
++ data.feat[1],
++ data.feat[2]);
+ return 0;
+ }
+
+
diff --git a/patches.arch/kvm-s390-add-exit-io-request-stats-and-simplify-code.patch b/patches.arch/kvm-s390-add-exit-io-request-stats-and-simplify-code.patch
new file mode 100644
index 0000000000..e5d45630fe
--- /dev/null
+++ b/patches.arch/kvm-s390-add-exit-io-request-stats-and-simplify-code.patch
@@ -0,0 +1,81 @@
+From: Christian Borntraeger <borntraeger@de.ibm.com>
+Date: Fri, 23 Feb 2018 07:57:33 +0000
+Subject: KVM: s390: add exit io request stats and simplify code
+Git-commit: a5e0acea9ed644d622281a4a8fde94a2e24ec7e8
+Patch-mainline: v4.17-rc1
+References: jsc#SLE-6412
+
+We want to count IO exit requests in kvm_stat. At the same time
+we can get rid of the handle_noop function.
+
+Reviewed-by: David Hildenbrand <david@redhat.com>
+Reviewed-by: Cornelia Huck <cohuck@redhat.com>
+Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
+Signed-off-by: Bruce Rogers <brogers@suse.com>
+---
+ arch/s390/include/asm/kvm_host.h | 1 +
+ arch/s390/kvm/intercept.c | 17 ++++-------------
+ arch/s390/kvm/kvm-s390.c | 1 +
+ 3 files changed, 6 insertions(+), 13 deletions(-)
+
+diff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_host.h
+index 58587b1fae25..bca4e8d489ac 100644
+--- a/arch/s390/include/asm/kvm_host.h
++++ b/arch/s390/include/asm/kvm_host.h
+@@ -302,6 +302,7 @@ struct kvm_vcpu_stat {
+ u64 exit_userspace;
+ u64 exit_null;
+ u64 exit_external_request;
++ u64 exit_io_request;
+ u64 exit_external_interrupt;
+ u64 exit_stop_request;
+ u64 exit_validity;
+diff --git a/arch/s390/kvm/intercept.c b/arch/s390/kvm/intercept.c
+index 07c6e81163bf..a389fa85cca2 100644
+--- a/arch/s390/kvm/intercept.c
++++ b/arch/s390/kvm/intercept.c
+@@ -50,18 +50,6 @@ u8 kvm_s390_get_ilen(struct kvm_vcpu *vcpu)
+ return ilen;
+ }
+
+-static int handle_noop(struct kvm_vcpu *vcpu)
+-{
+- switch (vcpu->arch.sie_block->icptcode) {
+- case 0x10:
+- vcpu->stat.exit_external_request++;
+- break;
+- default:
+- break; /* nothing */
+- }
+- return 0;
+-}
+-
+ static int handle_stop(struct kvm_vcpu *vcpu)
+ {
+ struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
+@@ -465,8 +453,11 @@ int kvm_handle_sie_intercept(struct kvm_vcpu *vcpu)
+
+ switch (vcpu->arch.sie_block->icptcode) {
+ case ICPT_EXTREQ:
++ vcpu->stat.exit_external_request++;
++ return 0;
+ case ICPT_IOREQ:
+- return handle_noop(vcpu);
++ vcpu->stat.exit_io_request++;
++ return 0;
+ case ICPT_INST:
+ rc = handle_instruction(vcpu);
+ break;
+diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
+index 42b43dcde620..c235b45db308 100644
+--- a/arch/s390/kvm/kvm-s390.c
++++ b/arch/s390/kvm/kvm-s390.c
+@@ -65,6 +65,7 @@ struct kvm_stats_debugfs_item debugfs_entries[] = {
+ { "exit_validity", VCPU_STAT(exit_validity) },
+ { "exit_stop_request", VCPU_STAT(exit_stop_request) },
+ { "exit_external_request", VCPU_STAT(exit_external_request) },
++ { "exit_io_request", VCPU_STAT(exit_io_request) },
+ { "exit_external_interrupt", VCPU_STAT(exit_external_interrupt) },
+ { "exit_instruction", VCPU_STAT(exit_instruction) },
+ { "exit_pei", VCPU_STAT(exit_pei) },
+
diff --git a/patches.arch/kvm-s390-add-gisa-interrupts-to-flic-ioctl-interface.patch b/patches.arch/kvm-s390-add-gisa-interrupts-to-flic-ioctl-interface.patch
new file mode 100644
index 0000000000..4cb3c103ba
--- /dev/null
+++ b/patches.arch/kvm-s390-add-gisa-interrupts-to-flic-ioctl-interface.patch
@@ -0,0 +1,71 @@
+From: Michael Mueller <mimu@linux.vnet.ibm.com>
+Date: Wed, 14 Jun 2017 13:21:32 +0200
+Subject: KVM: s390: add GISA interrupts to FLIC ioctl interface
+Git-commit: 24160af6cb289ace9bde980b33d11713c8fc8192
+Patch-mainline: v4.16-rc1
+References: jsc#SLE-6412
+
+Pending interrupts marked in the GISA IPM are required to
+become part of the answer of ioctl KVM_DEV_FLIC_GET_ALL_IRQS.
+
+The ioctl KVM_DEV_FLIC_ENQUEUE is already capable to enqueue
+adapter interrupts when a GISA is present.
+
+With ioctl KVM_DEV_FLIC_CLEAR_IRQS the GISA IPM wil be cleared
+now as well.
+
+Signed-off-by: Michael Mueller <mimu@linux.vnet.ibm.com>
+Reviewed-by: Halil Pasic <pasic@linux.vnet.ibm.com>
+Reviewed-by: Pierre Morel <pmorel@linux.vnet.ibm.com>
+Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
+Reviewed-by: Cornelia Huck <cohuck@redhat.com>
+Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
+Signed-off-by: Bruce Rogers <brogers@suse.com>
+---
+ arch/s390/kvm/interrupt.c | 18 ++++++++++++++++++
+ 1 file changed, 18 insertions(+)
+
+diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c
+index 618b4465ca35..e804fd543e52 100644
+--- a/arch/s390/kvm/interrupt.c
++++ b/arch/s390/kvm/interrupt.c
+@@ -1897,6 +1897,7 @@ void kvm_s390_clear_float_irqs(struct kvm *kvm)
+ for (i = 0; i < FIRQ_MAX_COUNT; i++)
+ fi->counters[i] = 0;
+ spin_unlock(&fi->lock);
++ kvm_s390_gisa_clear(kvm);
+ };
+
+ static int get_all_floating_irqs(struct kvm *kvm, u8 __user *usrbuf, u64 len)
+@@ -1924,6 +1925,22 @@ static int get_all_floating_irqs(struct kvm *kvm, u8 __user *usrbuf, u64 len)
+
+ max_irqs = len / sizeof(struct kvm_s390_irq);
+
++ if (kvm->arch.gisa &&
++ kvm_s390_gisa_get_ipm(kvm->arch.gisa)) {
++ for (i = 0; i <= MAX_ISC; i++) {
++ if (n == max_irqs) {
++ /* signal userspace to try again */
++ ret = -ENOMEM;
++ goto out_nolock;
++ }
++ if (kvm_s390_gisa_tac_ipm_gisc(kvm->arch.gisa, i)) {
++ irq = (struct kvm_s390_irq *) &buf[n];
++ irq->type = KVM_S390_INT_IO(1, 0, 0, 0);
++ irq->u.io.io_int_word = isc_to_int_word(i);
++ n++;
++ }
++ }
++ }
+ fi = &kvm->arch.float_int;
+ spin_lock(&fi->lock);
+ for (i = 0; i < FIRQ_LIST_COUNT; i++) {
+@@ -1962,6 +1979,7 @@ static int get_all_floating_irqs(struct kvm *kvm, u8 __user *usrbuf, u64 len)
+
+ out:
+ spin_unlock(&fi->lock);
++out_nolock:
+ if (!ret && n > 0) {
+ if (copy_to_user(usrbuf, buf, sizeof(struct kvm_s390_irq) * n))
+ ret = -EFAULT;
+
diff --git a/patches.arch/kvm-s390-clarify-kvm-related-kernel-message.patch b/patches.arch/kvm-s390-clarify-kvm-related-kernel-message.patch
new file mode 100644
index 0000000000..ea1a849ecf
--- /dev/null
+++ b/patches.arch/kvm-s390-clarify-kvm-related-kernel-message.patch
@@ -0,0 +1,47 @@
+From: Michael Mueller <mimu@linux.ibm.com>
+Date: Mon, 10 Dec 2018 11:15:16 +0100
+Subject: KVM: s390: clarify kvm related kernel message
+Git-commit: 8d43d57036679a8635952c9ef54989a7b48e8c00
+Patch-mainline: v5.1-rc1
+References: jsc#SLE-6412
+
+As suggested by our ID dept. here are some kernel message
+updates.
+
+Signed-off-by: Michael Mueller <mimu@linux.ibm.com>
+Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
+Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
+Signed-off-by: Bruce Rogers <brogers@suse.com>
+---
+ arch/s390/kvm/kvm-s390.c | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
+index 56166b898f12..a736dd7c7ccc 100644
+--- a/arch/s390/kvm/kvm-s390.c
++++ b/arch/s390/kvm/kvm-s390.c
+@@ -438,7 +438,7 @@ int kvm_arch_init(void *opaque)
+ /* Register floating interrupt controller interface. */
+ rc = kvm_register_device_ops(&kvm_flic_ops, KVM_DEV_TYPE_FLIC);
+ if (rc) {
+- pr_err("Failed to register FLIC rc=%d\n", rc);
++ pr_err("A FLIC registration call failed with rc=%d\n", rc);
+ goto out_debug_unreg;
+ }
+ return 0;
+@@ -4211,12 +4211,12 @@ static int __init kvm_s390_init(void)
+ int i;
+
+ if (!sclp.has_sief2) {
+- pr_info("SIE not available\n");
++ pr_info("SIE is not available\n");
+ return -ENODEV;
+ }
+
+ if (nested && hpage) {
+- pr_info("nested (vSIE) and hpage (huge page backing) can currently not be activated concurrently");
++ pr_info("A KVM host that supports nesting cannot back its KVM guests with huge pages\n");
+ return -EINVAL;
+ }
+
+
diff --git a/patches.arch/kvm-s390-cleanup-struct-kvm_s390_float_interrupt.patch b/patches.arch/kvm-s390-cleanup-struct-kvm_s390_float_interrupt.patch
new file mode 100644
index 0000000000..475386f415
--- /dev/null
+++ b/patches.arch/kvm-s390-cleanup-struct-kvm_s390_float_interrupt.patch
@@ -0,0 +1,222 @@
+From: David Hildenbrand <david@redhat.com>
+Date: Mon, 8 Jan 2018 20:37:47 +0100
+Subject: KVM: s390: cleanup struct kvm_s390_float_interrupt
+Git-commit: a9f6c9a92f3771000493f6bbacbd7677b46d8706
+Patch-mainline: v4.16-rc1
+References: jsc#SLE-6412
+
+"wq" is not used at all. "cpuflags" can be access directly via the vcpu,
+just as "float_int" via vcpu->kvm.
+While at it, reuse _set_cpuflag() to make the code look nicer.
+
+Signed-off-by: David Hildenbrand <david@redhat.com>
+Message-Id: <20180108193747.10818-1-david@redhat.com>
+Reviewed-by: Cornelia Huck <cohuck@redhat.com>
+Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
+Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
+Signed-off-by: Bruce Rogers <brogers@suse.com>
+---
+ arch/s390/include/asm/kvm_host.h | 3 ---
+ arch/s390/kvm/interrupt.c | 25 +++++++++++--------------
+ arch/s390/kvm/kvm-s390.c | 3 ---
+ arch/s390/kvm/kvm-s390.h | 2 +-
+ arch/s390/kvm/sigp.c | 12 ++++--------
+ 5 files changed, 16 insertions(+), 29 deletions(-)
+
+diff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_host.h
+index dd32bc369050..8fb9df3964f6 100644
+--- a/arch/s390/include/asm/kvm_host.h
++++ b/arch/s390/include/asm/kvm_host.h
+@@ -538,9 +538,6 @@ struct kvm_s390_irq_payload {
+
+ struct kvm_s390_local_interrupt {
+ spinlock_t lock;
+- struct kvm_s390_float_interrupt *float_int;
+- struct swait_queue_head *wq;
+- atomic_t *cpuflags;
+ DECLARE_BITMAP(sigp_emerg_pending, KVM_MAX_VCPUS);
+ struct kvm_s390_irq_payload irq;
+ unsigned long pending_irqs;
+diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c
+index 98c67ca343a8..4a4079a98366 100644
+--- a/arch/s390/kvm/interrupt.c
++++ b/arch/s390/kvm/interrupt.c
+@@ -107,12 +107,11 @@ static int sca_inject_ext_call(struct kvm_vcpu *vcpu, int src_id)
+
+ static void sca_clear_ext_call(struct kvm_vcpu *vcpu)
+ {
+- struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
+ int rc, expect;
+
+ if (!kvm_s390_use_sca_entries())
+ return;
+- atomic_andnot(CPUSTAT_ECALL_PEND, li->cpuflags);
++ atomic_andnot(CPUSTAT_ECALL_PEND, &vcpu->arch.sie_block->cpuflags);
+ read_lock(&vcpu->kvm->arch.sca_lock);
+ if (vcpu->kvm->arch.use_esca) {
+ struct esca_block *sca = vcpu->kvm->arch.sca;
+@@ -286,13 +285,13 @@ static unsigned long deliverable_irqs(struct kvm_vcpu *vcpu)
+ static void __set_cpu_idle(struct kvm_vcpu *vcpu)
+ {
+ atomic_or(CPUSTAT_WAIT, &vcpu->arch.sie_block->cpuflags);
+- set_bit(vcpu->vcpu_id, vcpu->arch.local_int.float_int->idle_mask);
++ set_bit(vcpu->vcpu_id, vcpu->kvm->arch.float_int.idle_mask);
+ }
+
+ static void __unset_cpu_idle(struct kvm_vcpu *vcpu)
+ {
+ atomic_andnot(CPUSTAT_WAIT, &vcpu->arch.sie_block->cpuflags);
+- clear_bit(vcpu->vcpu_id, vcpu->arch.local_int.float_int->idle_mask);
++ clear_bit(vcpu->vcpu_id, vcpu->kvm->arch.float_int.idle_mask);
+ }
+
+ static void __reset_intercept_indicators(struct kvm_vcpu *vcpu)
+@@ -1241,7 +1240,7 @@ static int __inject_pfault_init(struct kvm_vcpu *vcpu, struct kvm_s390_irq *irq)
+
+ li->irq.ext = irq->u.ext;
+ set_bit(IRQ_PEND_PFAULT_INIT, &li->pending_irqs);
+- atomic_or(CPUSTAT_EXT_INT, li->cpuflags);
++ __set_cpuflag(vcpu, CPUSTAT_EXT_INT);
+ return 0;
+ }
+
+@@ -1266,7 +1265,7 @@ static int __inject_extcall(struct kvm_vcpu *vcpu, struct kvm_s390_irq *irq)
+ if (test_and_set_bit(IRQ_PEND_EXT_EXTERNAL, &li->pending_irqs))
+ return -EBUSY;
+ *extcall = irq->u.extcall;
+- atomic_or(CPUSTAT_EXT_INT, li->cpuflags);
++ __set_cpuflag(vcpu, CPUSTAT_EXT_INT);
+ return 0;
+ }
+
+@@ -1342,7 +1341,7 @@ static int __inject_sigp_emergency(struct kvm_vcpu *vcpu,
+
+ set_bit(irq->u.emerg.code, li->sigp_emerg_pending);
+ set_bit(IRQ_PEND_EXT_EMERGENCY, &li->pending_irqs);
+- atomic_or(CPUSTAT_EXT_INT, li->cpuflags);
++ __set_cpuflag(vcpu, CPUSTAT_EXT_INT);
+ return 0;
+ }
+
+@@ -1386,7 +1385,7 @@ static int __inject_ckc(struct kvm_vcpu *vcpu)
+ 0, 0);
+
+ set_bit(IRQ_PEND_EXT_CLOCK_COMP, &li->pending_irqs);
+- atomic_or(CPUSTAT_EXT_INT, li->cpuflags);
++ __set_cpuflag(vcpu, CPUSTAT_EXT_INT);
+ return 0;
+ }
+
+@@ -1399,7 +1398,7 @@ static int __inject_cpu_timer(struct kvm_vcpu *vcpu)
+ 0, 0);
+
+ set_bit(IRQ_PEND_EXT_CPU_TIMER, &li->pending_irqs);
+- atomic_or(CPUSTAT_EXT_INT, li->cpuflags);
++ __set_cpuflag(vcpu, CPUSTAT_EXT_INT);
+ return 0;
+ }
+
+@@ -1559,7 +1558,6 @@ static int __inject_io(struct kvm *kvm, struct kvm_s390_interrupt_info *inti)
+ static void __floating_irq_kick(struct kvm *kvm, u64 type)
+ {
+ struct kvm_s390_float_interrupt *fi = &kvm->arch.float_int;
+- struct kvm_s390_local_interrupt *li;
+ struct kvm_vcpu *dst_vcpu;
+ int sigcpu, online_vcpus, nr_tries = 0;
+
+@@ -1581,16 +1579,15 @@ static void __floating_irq_kick(struct kvm *kvm, u64 type)
+ dst_vcpu = kvm_get_vcpu(kvm, sigcpu);
+
+ /* make the VCPU drop out of the SIE, or wake it up if sleeping */
+- li = &dst_vcpu->arch.local_int;
+ switch (type) {
+ case KVM_S390_MCHK:
+- atomic_or(CPUSTAT_STOP_INT, li->cpuflags);
++ __set_cpuflag(dst_vcpu, CPUSTAT_STOP_INT);
+ break;
+ case KVM_S390_INT_IO_MIN...KVM_S390_INT_IO_MAX:
+- atomic_or(CPUSTAT_IO_INT, li->cpuflags);
++ __set_cpuflag(dst_vcpu, CPUSTAT_IO_INT);
+ break;
+ default:
+- atomic_or(CPUSTAT_EXT_INT, li->cpuflags);
++ __set_cpuflag(dst_vcpu, CPUSTAT_EXT_INT);
+ break;
+ }
+ kvm_s390_vcpu_wakeup(dst_vcpu);
+diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
+index 9597bd0259f4..0df009cb8850 100644
+--- a/arch/s390/kvm/kvm-s390.c
++++ b/arch/s390/kvm/kvm-s390.c
+@@ -2696,9 +2696,6 @@ struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm,
+
+ vcpu->arch.sie_block->icpua = id;
+ spin_lock_init(&vcpu->arch.local_int.lock);
+- vcpu->arch.local_int.float_int = &kvm->arch.float_int;
+- vcpu->arch.local_int.wq = &vcpu->wq;
+- vcpu->arch.local_int.cpuflags = &vcpu->arch.sie_block->cpuflags;
+ seqcount_init(&vcpu->arch.cputm_seqcount);
+
+ rc = kvm_vcpu_init(vcpu, kvm, id);
+diff --git a/arch/s390/kvm/kvm-s390.h b/arch/s390/kvm/kvm-s390.h
+index 654c0ea9f2ff..96a201158663 100644
+--- a/arch/s390/kvm/kvm-s390.h
++++ b/arch/s390/kvm/kvm-s390.h
+@@ -54,7 +54,7 @@ static inline int is_vcpu_stopped(struct kvm_vcpu *vcpu)
+
+ static inline int is_vcpu_idle(struct kvm_vcpu *vcpu)
+ {
+- return test_bit(vcpu->vcpu_id, vcpu->arch.local_int.float_int->idle_mask);
++ return test_bit(vcpu->vcpu_id, vcpu->kvm->arch.float_int.idle_mask);
+ }
+
+ static inline int kvm_is_ucontrol(struct kvm *kvm)
+diff --git a/arch/s390/kvm/sigp.c b/arch/s390/kvm/sigp.c
+index c1f5cde2c878..5cafd1e2651b 100644
+--- a/arch/s390/kvm/sigp.c
++++ b/arch/s390/kvm/sigp.c
+@@ -20,14 +20,11 @@
+ static int __sigp_sense(struct kvm_vcpu *vcpu, struct kvm_vcpu *dst_vcpu,
+ u64 *reg)
+ {
+- struct kvm_s390_local_interrupt *li;
+ int cpuflags;
+ int rc;
+ int ext_call_pending;
+
+- li = &dst_vcpu->arch.local_int;
+-
+- cpuflags = atomic_read(li->cpuflags);
++ cpuflags = atomic_read(&dst_vcpu->arch.sie_block->cpuflags);
+ ext_call_pending = kvm_s390_ext_call_pending(dst_vcpu);
+ if (!(cpuflags & CPUSTAT_STOPPED) && !ext_call_pending)
+ rc = SIGP_CC_ORDER_CODE_ACCEPTED;
+@@ -211,7 +208,7 @@ static int __sigp_store_status_at_addr(struct kvm_vcpu *vcpu,
+ int flags;
+ int rc;
+
+- flags = atomic_read(dst_vcpu->arch.local_int.cpuflags);
++ flags = atomic_read(&dst_vcpu->arch.sie_block->cpuflags);
+ if (!(flags & CPUSTAT_STOPPED)) {
+ *reg &= 0xffffffff00000000UL;
+ *reg |= SIGP_STATUS_INCORRECT_STATE;
+@@ -231,7 +228,6 @@ static int __sigp_store_status_at_addr(struct kvm_vcpu *vcpu,
+ static int __sigp_sense_running(struct kvm_vcpu *vcpu,
+ struct kvm_vcpu *dst_vcpu, u64 *reg)
+ {
+- struct kvm_s390_local_interrupt *li;
+ int rc;
+
+ if (!test_kvm_facility(vcpu->kvm, 9)) {
+@@ -240,8 +236,8 @@ static int __sigp_sense_running(struct kvm_vcpu *vcpu,
+ return SIGP_CC_STATUS_STORED;
+ }
+
+- li = &dst_vcpu->arch.local_int;
+- if (atomic_read(li->cpuflags) & CPUSTAT_RUNNING) {
++ if (atomic_read(&dst_vcpu->arch.sie_block->cpuflags) &
++ CPUSTAT_RUNNING) {
+ /* running */
+ rc = SIGP_CC_ORDER_CODE_ACCEPTED;
+ } else {
+
diff --git a/patches.arch/kvm-s390-define-gisa-format-0-data-structure.patch b/patches.arch/kvm-s390-define-gisa-format-0-data-structure.patch
new file mode 100644
index 0000000000..3a65cb7409
--- /dev/null
+++ b/patches.arch/kvm-s390-define-gisa-format-0-data-structure.patch
@@ -0,0 +1,94 @@
+From: Michael Mueller <mimu@linux.vnet.ibm.com>
+Date: Tue, 30 May 2017 14:26:02 +0200
+Subject: KVM: s390: define GISA format-0 data structure
+Git-commit: 19114beb73f774e466d9e39b8e8b961812c9f881
+Patch-mainline: v4.16-rc1
+References: jsc#SLE-6412
+
+In preperation to support pass-through adapter interrupts, the Guest
+Interruption State Area (GISA) and the Adapter Interruption Virtualization
+(AIV) features will be introduced here.
+
+This patch introduces format-0 GISA (that is defines the struct describing
+the GISA, allocates storage for it, and introduces fields for the
+GISA address in kvm_s390_sie_block and kvm_s390_vsie).
+
+As the GISA requires storage below 2GB, it is put in sie_page2, which is
+already allocated in ZONE_DMA. In addition, The GISA requires alignment to
+its integral boundary. This is already naturally aligned via the
+padding in the sie_page2.
+
+Signed-off-by: Michael Mueller <mimu@linux.vnet.ibm.com>
+Reviewed-by: Pierre Morel <pmorel@linux.vnet.ibm.com>
+Reviewed-by: Halil Pasic <pasic@linux.vnet.ibm.com>
+Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
+Reviewed-by: David Hildenbrand <david@redhat.com>
+Acked-by: Cornelia Huck <cohuck@redhat.com>
+Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
+Signed-off-by: Bruce Rogers <brogers@suse.com>
+---
+ arch/s390/include/asm/kvm_host.h | 23 +++++++++++++++++++----
+ arch/s390/kvm/kvm-s390.c | 1 +
+ 2 files changed, 20 insertions(+), 4 deletions(-)
+
+--- a/arch/s390/include/asm/kvm_host.h
++++ b/arch/s390/include/asm/kvm_host.h
+@@ -186,6 +186,7 @@ struct kvm_s390_sie_block {
+ #define ECA_IB 0x40000000
+ #define ECA_SIGPI 0x10000000
+ #define ECA_MVPGI 0x01000000
++#define ECA_AIV 0x00200000
+ #define ECA_VX 0x00020000
+ #define ECA_PROTEXCI 0x00002000
+ #define ECA_SII 0x00000001
+@@ -231,7 +232,8 @@ struct kvm_s390_sie_block {
+ __u8 epdx; /* 0x0069 */
+ __u8 reserved6a[2]; /* 0x006a */
+ __u32 todpr; /* 0x006c */
+- __u8 reserved70[16]; /* 0x0070 */
++ __u32 gd; /* 0x0070 */
++ __u8 reserved74[12]; /* 0x0074 */
+ __u64 mso; /* 0x0080 */
+ __u64 msl; /* 0x0088 */
+ psw_t gpsw; /* 0x0090 */
+@@ -720,14 +722,27 @@ struct kvm_s390_crypto_cb {
+ struct kvm_s390_apcb1 apcb1; /* 0x0080 */
+ };
+
++struct kvm_s390_gisa {
++ u32 next_alert;
++ u8 ipm;
++ u8 reserved01;
++ u8 : 6;
++ u8 g : 1;
++ u8 c : 1;
++ u8 iam;
++ u8 reserved02[4];
++ u32 airq_count;
++};
++
+ /*
+- * sie_page2 has to be allocated as DMA because fac_list and crycb need
+- * 31bit addresses in the sie control block.
++ * sie_page2 has to be allocated as DMA because fac_list, crycb and
++ * gisa need 31bit addresses in the sie control block.
+ */
+ struct sie_page2 {
+ __u64 fac_list[S390_ARCH_FAC_LIST_SIZE_U64]; /* 0x0000 */
+ struct kvm_s390_crypto_cb crycb; /* 0x0800 */
+- u8 reserved900[0x1000 - 0x900]; /* 0x0900 */
++ struct kvm_s390_gisa gisa; /* 0x0900 */
++ u8 reserved910[0x1000 - 0x910]; /* 0x0910 */
+ };
+
+ struct kvm_s390_vsie {
+--- a/arch/s390/kvm/kvm-s390.c
++++ b/arch/s390/kvm/kvm-s390.c
+@@ -1936,6 +1936,7 @@ int kvm_arch_init_vm(struct kvm *kvm, un
+ if (!kvm->arch.dbf)
+ goto out_err;
+
++ BUILD_BUG_ON(sizeof(struct sie_page2) != 4096);
+ kvm->arch.sie_page2 =
+ (struct sie_page2 *) get_zeroed_page(GFP_KERNEL | GFP_DMA);
+ if (!kvm->arch.sie_page2)
diff --git a/patches.arch/kvm-s390-do-not-set-intervention-requests-for-gisa-interrupts.patch b/patches.arch/kvm-s390-do-not-set-intervention-requests-for-gisa-interrupts.patch
new file mode 100644
index 0000000000..2ae0b264b1
--- /dev/null
+++ b/patches.arch/kvm-s390-do-not-set-intervention-requests-for-gisa-interrupts.patch
@@ -0,0 +1,51 @@
+From: Christian Borntraeger <borntraeger@de.ibm.com>
+Date: Mon, 12 Feb 2018 12:33:39 +0000
+Subject: KVM: s390: do not set intervention requests for GISA interrupts
+Git-commit: 8846f3175c6bf16382b06a4b9755e5296c0f921c
+Patch-mainline: v4.16-rc4
+References: jsc#SLE-6412
+
+If GISA is available, we do not have to kick CPUs out of SIE to deliver
+interrupts. The hardware can deliver such interrupts while running.
+
+Cc: Michael Mueller <mimu@linux.vnet.ibm.com>
+Reviewed-by: David Hildenbrand <david@redhat.com>
+Reviewed-by: Cornelia Huck <cohuck@redhat.com>
+Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
+Signed-off-by: Bruce Rogers <brogers@suse.com>
+---
+ arch/s390/kvm/interrupt.c | 11 ++++++++---
+ 1 file changed, 8 insertions(+), 3 deletions(-)
+
+diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c
+index 0aac3f5d6a81..9c1837d27d69 100644
+--- a/arch/s390/kvm/interrupt.c
++++ b/arch/s390/kvm/interrupt.c
+@@ -243,10 +243,15 @@ static inline int kvm_s390_gisa_tac_ipm_gisc(struct kvm_s390_gisa *gisa, u32 gis
+ return test_and_clear_bit_inv(IPM_BIT_OFFSET + gisc, (unsigned long *) gisa);
+ }
+
+-static inline unsigned long pending_irqs(struct kvm_vcpu *vcpu)
++static inline unsigned long pending_irqs_no_gisa(struct kvm_vcpu *vcpu)
+ {
+ return vcpu->kvm->arch.float_int.pending_irqs |
+- vcpu->arch.local_int.pending_irqs |
++ vcpu->arch.local_int.pending_irqs;
++}
++
++static inline unsigned long pending_irqs(struct kvm_vcpu *vcpu)
++{
++ return pending_irqs_no_gisa(vcpu) |
+ kvm_s390_gisa_get_ipm(vcpu->kvm->arch.gisa) << IRQ_PEND_IO_ISC_7;
+ }
+
+@@ -349,7 +354,7 @@ static void __set_cpuflag(struct kvm_vcpu *vcpu, u32 flag)
+
+ static void set_intercept_indicators_io(struct kvm_vcpu *vcpu)
+ {
+- if (!(pending_irqs(vcpu) & IRQ_PEND_IO_MASK))
++ if (!(pending_irqs_no_gisa(vcpu) & IRQ_PEND_IO_MASK))
+ return;
+ else if (psw_ioint_disabled(vcpu))
+ __set_cpuflag(vcpu, CPUSTAT_IO_INT);
+
diff --git a/patches.arch/kvm-s390-drop-use-of-spin-lock-in-_floating_irq_kick.patch b/patches.arch/kvm-s390-drop-use-of-spin-lock-in-_floating_irq_kick.patch
new file mode 100644
index 0000000000..0d62ef78d9
--- /dev/null
+++ b/patches.arch/kvm-s390-drop-use-of-spin-lock-in-_floating_irq_kick.patch
@@ -0,0 +1,41 @@
+From: Michael Mueller <mimu@linux.vnet.ibm.com>
+Date: Mon, 20 Nov 2017 10:37:30 +0100
+Subject: KVM: s390: drop use of spin lock in __floating_irq_kick
+Git-commit: 588629385c4b96c436cef55dff75eef7f90cd5f0
+Patch-mainline: v4.16-rc1
+References: jsc#SLE-6412
+
+It is not required to take to a lock to protect access to the cpuflags
+of the local interrupt structure of a vcpu as the performed operation
+is an atomic_or.
+
+Signed-off-by: Michael Mueller <mimu@linux.vnet.ibm.com>
+Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
+Reviewed-by: Cornelia Huck <cohuck@redhat.com>
+Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
+Signed-off-by: Bruce Rogers <brogers@suse.com>
+---
+ arch/s390/kvm/interrupt.c | 2 --
+ 1 file changed, 2 deletions(-)
+
+diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c
+index 5b8089b0d3ee..98c67ca343a8 100644
+--- a/arch/s390/kvm/interrupt.c
++++ b/arch/s390/kvm/interrupt.c
+@@ -1582,7 +1582,6 @@ static void __floating_irq_kick(struct kvm *kvm, u64 type)
+
+ /* make the VCPU drop out of the SIE, or wake it up if sleeping */
+ li = &dst_vcpu->arch.local_int;
+- spin_lock(&li->lock);
+ switch (type) {
+ case KVM_S390_MCHK:
+ atomic_or(CPUSTAT_STOP_INT, li->cpuflags);
+@@ -1594,7 +1593,6 @@ static void __floating_irq_kick(struct kvm *kvm, u64 type)
+ atomic_or(CPUSTAT_EXT_INT, li->cpuflags);
+ break;
+ }
+- spin_unlock(&li->lock);
+ kvm_s390_vcpu_wakeup(dst_vcpu);
+ }
+
+
diff --git a/patches.arch/kvm-s390-exploit-gisa-and-aiv-for-emulated-interrupts.patch b/patches.arch/kvm-s390-exploit-gisa-and-aiv-for-emulated-interrupts.patch
new file mode 100644
index 0000000000..59e8f4d7a7
--- /dev/null
+++ b/patches.arch/kvm-s390-exploit-gisa-and-aiv-for-emulated-interrupts.patch
@@ -0,0 +1,269 @@
+From: Michael Mueller <mimu@linux.vnet.ibm.com>
+Date: Mon, 12 Jun 2017 14:15:19 +0200
+Subject: KVM: s390: exploit GISA and AIV for emulated interrupts
+Git-commit: d7c5cb0105ddeff56694f4c6222ee7221824bad3
+Patch-mainline: v4.16-rc1
+References: jsc#SLE-6412
+
+The adapter interruption virtualization (AIV) facility is an
+optional facility that comes with functionality expected to increase
+the performance of adapter interrupt handling for both emulated and
+passed-through adapter interrupts. With AIV, adapter interrupts can be
+delivered to the guest without exiting SIE.
+
+This patch provides some preparations for using AIV for emulated adapter
+interrupts (including virtio) if it's available. When using AIV, the
+interrupts are delivered at the so called GISA by setting the bit
+corresponding to its Interruption Subclass (ISC) in the Interruption
+Pending Mask (IPM) instead of inserting a node into the floating interrupt
+list.
+
+To keep the change reasonably small, the handling of this new state is
+deferred in get_all_floating_irqs and handle_tpi. This patch concentrates
+on the code handling enqueuement of emulated adapter interrupts, and their
+delivery to the guest.
+
+Note that care is still required for adapter interrupts using AIV,
+because there is no guarantee that AIV is going to deliver the adapter
+interrupts pending at the GISA (consider all vcpus idle). When delivering
+GISA adapter interrupts by the host (usual mechanism) special attention
+is required to honor interrupt priorities.
+
+Empirical results show that the time window between making an interrupt
+pending at the GISA and doing kvm_s390_deliver_pending_interrupts is
+sufficient for a guest with at least moderate cpu activity to get adapter
+interrupts delivered within the SIE, and potentially save some SIE exits
+(if not other deliverable interrupts).
+
+The code will be activated with a follow-up patch.
+
+Signed-off-by: Michael Mueller <mimu@linux.vnet.ibm.com>
+Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
+Reviewed-by: David Hildenbrand <david@redhat.com>
+Reviewed-by: Cornelia Huck <cohuck@redhat.com>
+Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
+Signed-off-by: Bruce Rogers <brogers@suse.com>
+---
+ arch/s390/include/asm/kvm_host.h | 1 +
+ arch/s390/kvm/interrupt.c | 93 ++++++++++++++++++++++++++++++++--------
+ arch/s390/kvm/kvm-s390.c | 8 ++++
+ arch/s390/kvm/kvm-s390.h | 3 ++
+ 4 files changed, 87 insertions(+), 18 deletions(-)
+
+diff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_host.h
+index 45c91a0d9e26..10a0622cac01 100644
+--- a/arch/s390/include/asm/kvm_host.h
++++ b/arch/s390/include/asm/kvm_host.h
+@@ -798,6 +798,7 @@ struct kvm_arch{
+ struct kvm_s390_migration_state *migration_state;
+ /* subset of available cpu features enabled by user space */
+ DECLARE_BITMAP(cpu_feat, KVM_S390_VM_CPU_FEAT_NR_BITS);
++ struct kvm_s390_gisa *gisa;
+ };
+
+ #define KVM_HVA_ERR_BAD (-1UL)
+diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c
+index 37e8d450d2f7..bad5a45c69f2 100644
+--- a/arch/s390/kvm/interrupt.c
++++ b/arch/s390/kvm/interrupt.c
+@@ -241,7 +241,8 @@ static inline int kvm_s390_gisa_tac_ipm_gisc(struct kvm_s390_gisa *gisa, u32 gis
+ static inline unsigned long pending_irqs(struct kvm_vcpu *vcpu)
+ {
+ return vcpu->kvm->arch.float_int.pending_irqs |
+- vcpu->arch.local_int.pending_irqs;
++ vcpu->arch.local_int.pending_irqs |
++ kvm_s390_gisa_get_ipm(vcpu->kvm->arch.gisa) << IRQ_PEND_IO_ISC_7;
+ }
+
+ static inline int isc_to_irq_type(unsigned long isc)
+@@ -931,18 +932,38 @@ static int __must_check __deliver_virtio(struct kvm_vcpu *vcpu)
+ return rc ? -EFAULT : 0;
+ }
+
++static int __do_deliver_io(struct kvm_vcpu *vcpu, struct kvm_s390_io_info *io)
++{
++ int rc;
++
++ rc = put_guest_lc(vcpu, io->subchannel_id, (u16 *)__LC_SUBCHANNEL_ID);
++ rc |= put_guest_lc(vcpu, io->subchannel_nr, (u16 *)__LC_SUBCHANNEL_NR);
++ rc |= put_guest_lc(vcpu, io->io_int_parm, (u32 *)__LC_IO_INT_PARM);
++ rc |= put_guest_lc(vcpu, io->io_int_word, (u32 *)__LC_IO_INT_WORD);
++ rc |= write_guest_lc(vcpu, __LC_IO_OLD_PSW,
++ &vcpu->arch.sie_block->gpsw,
++ sizeof(psw_t));
++ rc |= read_guest_lc(vcpu, __LC_IO_NEW_PSW,
++ &vcpu->arch.sie_block->gpsw,
++ sizeof(psw_t));
++ return rc ? -EFAULT : 0;
++}
++
+ static int __must_check __deliver_io(struct kvm_vcpu *vcpu,
+ unsigned long irq_type)
+ {
+ struct list_head *isc_list;
+ struct kvm_s390_float_interrupt *fi;
+ struct kvm_s390_interrupt_info *inti = NULL;
++ struct kvm_s390_io_info io;
++ u32 isc;
+ int rc = 0;
+
+ fi = &vcpu->kvm->arch.float_int;
+
+ spin_lock(&fi->lock);
+- isc_list = &fi->lists[irq_type_to_isc(irq_type)];
++ isc = irq_type_to_isc(irq_type);
++ isc_list = &fi->lists[isc];
+ inti = list_first_entry_or_null(isc_list,
+ struct kvm_s390_interrupt_info,
+ list);
+@@ -970,24 +991,31 @@ static int __must_check __deliver_io(struct kvm_vcpu *vcpu,
+ spin_unlock(&fi->lock);
+
+ if (inti) {
+- rc = put_guest_lc(vcpu, inti->io.subchannel_id,
+- (u16 *)__LC_SUBCHANNEL_ID);
+- rc |= put_guest_lc(vcpu, inti->io.subchannel_nr,
+- (u16 *)__LC_SUBCHANNEL_NR);
+- rc |= put_guest_lc(vcpu, inti->io.io_int_parm,
+- (u32 *)__LC_IO_INT_PARM);
+- rc |= put_guest_lc(vcpu, inti->io.io_int_word,
+- (u32 *)__LC_IO_INT_WORD);
+- rc |= write_guest_lc(vcpu, __LC_IO_OLD_PSW,
+- &vcpu->arch.sie_block->gpsw,
+- sizeof(psw_t));
+- rc |= read_guest_lc(vcpu, __LC_IO_NEW_PSW,
+- &vcpu->arch.sie_block->gpsw,
+- sizeof(psw_t));
++ rc = __do_deliver_io(vcpu, &(inti->io));
+ kfree(inti);
++ goto out;
+ }
+
+- return rc ? -EFAULT : 0;
++ if (vcpu->kvm->arch.gisa &&
++ kvm_s390_gisa_tac_ipm_gisc(vcpu->kvm->arch.gisa, isc)) {
++ /*
++ * in case an adapter interrupt was not delivered
++ * in SIE context KVM will handle the delivery
++ */
++ VCPU_EVENT(vcpu, 4, "%s isc %u", "deliver: I/O (AI/gisa)", isc);
++ memset(&io, 0, sizeof(io));
++ io.io_int_word = (isc << 27) | 0x80000000;
++ vcpu->stat.deliver_io_int++;
++ trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id,
++ KVM_S390_INT_IO(1, 0, 0, 0),
++ ((__u32)io.subchannel_id << 16) |
++ io.subchannel_nr,
++ ((__u64)io.io_int_parm << 32) |
++ io.io_int_word);
++ rc = __do_deliver_io(vcpu, &io);
++ }
++out:
++ return rc;
+ }
+
+ typedef int (*deliver_irq_t)(struct kvm_vcpu *vcpu);
+@@ -1557,6 +1585,15 @@ static int __inject_io(struct kvm *kvm, struct kvm_s390_interrupt_info *inti)
+ struct list_head *list;
+ int isc;
+
++ isc = int_word_to_isc(inti->io.io_int_word);
++
++ if (kvm->arch.gisa && inti->type & KVM_S390_INT_IO_AI_MASK) {
++ VM_EVENT(kvm, 4, "%s isc %1u", "inject: I/O (AI/gisa)", isc);
++ kvm_s390_gisa_set_ipm_gisc(kvm->arch.gisa, isc);
++ kfree(inti);
++ return 0;
++ }
++
+ fi = &kvm->arch.float_int;
+ spin_lock(&fi->lock);
+ if (fi->counters[FIRQ_CNTR_IO] >= KVM_S390_MAX_FLOAT_IRQS) {
+@@ -1572,7 +1609,6 @@ static int __inject_io(struct kvm *kvm, struct kvm_s390_interrupt_info *inti)
+ inti->io.subchannel_id >> 8,
+ inti->io.subchannel_id >> 1 & 0x3,
+ inti->io.subchannel_nr);
+- isc = int_word_to_isc(inti->io.io_int_word);
+ list = &fi->lists[FIRQ_LIST_IO_ISC_0 + isc];
+ list_add_tail(&inti->list, list);
+ set_bit(isc_to_irq_type(isc), &fi->pending_irqs);
+@@ -2723,3 +2759,24 @@ int kvm_s390_get_irq_state(struct kvm_vcpu *vcpu, __u8 __user *buf, int len)
+
+ return n;
+ }
++
++void kvm_s390_gisa_clear(struct kvm *kvm)
++{
++ if (kvm->arch.gisa) {
++ memset(kvm->arch.gisa, 0, sizeof(struct kvm_s390_gisa));
++ kvm->arch.gisa->next_alert = (u32)(u64)kvm->arch.gisa;
++ VM_EVENT(kvm, 3, "gisa 0x%pK cleared", kvm->arch.gisa);
++ }
++}
++
++void kvm_s390_gisa_init(struct kvm *kvm)
++{
++ /* not implemented yet */
++}
++
++void kvm_s390_gisa_destroy(struct kvm *kvm)
++{
++ if (!kvm->arch.gisa)
++ return;
++ kvm->arch.gisa = NULL;
++}
+diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
+index b5c0ebe6550e..e05807bd2b4e 100644
+--- a/arch/s390/kvm/kvm-s390.c
++++ b/arch/s390/kvm/kvm-s390.c
+@@ -2159,6 +2159,7 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
+
+ spin_lock_init(&kvm->arch.start_stop_lock);
+ kvm_s390_vsie_init(kvm);
++ kvm_s390_gisa_init(kvm);
+ KVM_EVENT(3, "vm 0x%pK created by pid %u", kvm, current->pid);
+
+ return 0;
+@@ -2221,6 +2222,7 @@ void kvm_arch_destroy_vm(struct kvm *kvm)
+ kvm_free_vcpus(kvm);
+ sca_dispose(kvm);
+ debug_unregister(kvm->arch.dbf);
++ kvm_s390_gisa_destroy(kvm);
+ free_page((unsigned long)kvm->arch.sie_page2);
+ if (!kvm_is_ucontrol(kvm))
+ gmap_remove(kvm->arch.gmap);
+@@ -2644,6 +2646,11 @@ int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu)
+ if (test_kvm_facility(vcpu->kvm, 139))
+ vcpu->arch.sie_block->ecd |= ECD_MEF;
+
++ if (vcpu->arch.sie_block->gd) {
++ vcpu->arch.sie_block->eca |= ECA_AIV;
++ VCPU_EVENT(vcpu, 3, "AIV gisa format-%u enabled for cpu %03u",
++ vcpu->arch.sie_block->gd & 0x3, vcpu->vcpu_id);
++ }
+ vcpu->arch.sie_block->sdnxo = ((unsigned long) &vcpu->run->s.regs.sdnx)
+ | SDNXC;
+ vcpu->arch.sie_block->riccbd = (unsigned long) &vcpu->run->s.regs.riccb;
+@@ -2697,6 +2704,7 @@ struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm,
+
+ vcpu->arch.sie_block->icpua = id;
+ spin_lock_init(&vcpu->arch.local_int.lock);
++ vcpu->arch.sie_block->gd = (u32)(u64)kvm->arch.gisa;
+ seqcount_init(&vcpu->arch.cputm_seqcount);
+
+ rc = kvm_vcpu_init(vcpu, kvm, id);
+diff --git a/arch/s390/kvm/kvm-s390.h b/arch/s390/kvm/kvm-s390.h
+index 96a201158663..0dc992011f48 100644
+--- a/arch/s390/kvm/kvm-s390.h
++++ b/arch/s390/kvm/kvm-s390.h
+@@ -365,6 +365,9 @@ int kvm_s390_set_irq_state(struct kvm_vcpu *vcpu,
+ void __user *buf, int len);
+ int kvm_s390_get_irq_state(struct kvm_vcpu *vcpu,
+ __u8 __user *buf, int len);
++void kvm_s390_gisa_init(struct kvm *kvm);
++void kvm_s390_gisa_clear(struct kvm *kvm);
++void kvm_s390_gisa_destroy(struct kvm *kvm);
+
+ /* implemented in guestdbg.c */
+ void kvm_s390_backup_guest_per_regs(struct kvm_vcpu *vcpu);
+
diff --git a/patches.arch/kvm-s390-fix-fallthrough-annotation.patch b/patches.arch/kvm-s390-fix-fallthrough-annotation.patch
new file mode 100644
index 0000000000..ed3beb1ec5
--- /dev/null
+++ b/patches.arch/kvm-s390-fix-fallthrough-annotation.patch
@@ -0,0 +1,60 @@
+From: Sebastian Ott <sebott@linux.vnet.ibm.com>
+Date: Mon, 29 Jan 2018 16:12:30 +0100
+Subject: KVM: s390: fix fallthrough annotation
+Git-commit: 4ed8773b5055363f1666345dd5ae5af12c7c6268
+Patch-mainline: v4.17-rc1
+References: jsc#SLE-6412
+
+A case statement in kvm_s390_shadow_tables uses fallthrough annotations
+which are not recognized by gcc because they are hidden within a block.
+Move these annotations out of the block to fix (W=1) warnings like below:
+
+arch/s390/kvm/gaccess.c: In function 'kvm_s390_shadow_tables':
+arch/s390/kvm/gaccess.c:1029:26: warning: this statement may fall through [-Wimplicit-fallthrough=]
+ case ASCE_TYPE_REGION1: {
+ ^
+
+Signed-off-by: Sebastian Ott <sebott@linux.vnet.ibm.com>
+Reviewed-by: Cornelia Huck <cohuck@redhat.com>
+Reviewed-by: David Hildenbrand <david@redhat.com>
+Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
+Signed-off-by: Bruce Rogers <brogers@suse.com>
+---
+ arch/s390/kvm/gaccess.c | 9 +++------
+ 1 file changed, 3 insertions(+), 6 deletions(-)
+
+diff --git a/arch/s390/kvm/gaccess.c b/arch/s390/kvm/gaccess.c
+index 653cae5e1ee1..b47732a58124 100644
+--- a/arch/s390/kvm/gaccess.c
++++ b/arch/s390/kvm/gaccess.c
+@@ -1049,8 +1049,7 @@ static int kvm_s390_shadow_tables(struct gmap *sg, unsigned long saddr,
+ rc = gmap_shadow_r2t(sg, saddr, rfte.val, *fake);
+ if (rc)
+ return rc;
+- /* fallthrough */
+- }
++ } /* fallthrough */
+ case ASCE_TYPE_REGION2: {
+ union region2_table_entry rste;
+
+@@ -1076,8 +1075,7 @@ static int kvm_s390_shadow_tables(struct gmap *sg, unsigned long saddr,
+ rc = gmap_shadow_r3t(sg, saddr, rste.val, *fake);
+ if (rc)
+ return rc;
+- /* fallthrough */
+- }
++ } /* fallthrough */
+ case ASCE_TYPE_REGION3: {
+ union region3_table_entry rtte;
+
+@@ -1112,8 +1110,7 @@ static int kvm_s390_shadow_tables(struct gmap *sg, unsigned long saddr,
+ rc = gmap_shadow_sgt(sg, saddr, rtte.val, *fake);
+ if (rc)
+ return rc;
+- /* fallthrough */
+- }
++ } /* fallthrough */
+ case ASCE_TYPE_SEGMENT: {
+ union segment_table_entry ste;
+
+
diff --git a/patches.arch/kvm-s390-fix-kmsg-component-kvm-s390.patch b/patches.arch/kvm-s390-fix-kmsg-component-kvm-s390.patch
new file mode 100644
index 0000000000..4f9b40ed34
--- /dev/null
+++ b/patches.arch/kvm-s390-fix-kmsg-component-kvm-s390.patch
@@ -0,0 +1,44 @@
+From: Michael Mueller <mimu@linux.ibm.com>
+Date: Mon, 3 Dec 2018 10:20:22 +0100
+Subject: KVM: s390: fix kmsg component kvm-s390
+Git-commit: 7aedd9d48f2a8332c2c51a40d2dca8c097f0dcdb
+Patch-mainline: v5.0-rc1
+References: jsc#SLE-6412
+
+Relocate #define statement for kvm related kernel messages
+before the include of printk to become effective.
+
+Signed-off-by: Michael Mueller <mimu@linux.ibm.com>
+Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
+Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
+Signed-off-by: Bruce Rogers <brogers@suse.com>
+---
+ arch/s390/kvm/kvm-s390.c | 7 +++----
+ 1 file changed, 3 insertions(+), 4 deletions(-)
+
+diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
+index 72370a0229c0..56166b898f12 100644
+--- a/arch/s390/kvm/kvm-s390.c
++++ b/arch/s390/kvm/kvm-s390.c
+@@ -11,6 +11,9 @@
+ * Jason J. Herne <jjherne@us.ibm.com>
+ */
+
++#define KMSG_COMPONENT "kvm-s390"
++#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
++
+ #include <linux/compiler.h>
+ #include <linux/err.h>
+ #include <linux/fs.h>
+@@ -44,10 +47,6 @@
+ #include "kvm-s390.h"
+ #include "gaccess.h"
+
+-#define KMSG_COMPONENT "kvm-s390"
+-#undef pr_fmt
+-#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
+-
+ #define CREATE_TRACE_POINTS
+ #include "trace.h"
+ #include "trace-s390.h"
+
diff --git a/patches.arch/kvm-s390-fix-potential-spectre-warnings.patch b/patches.arch/kvm-s390-fix-potential-spectre-warnings.patch
new file mode 100644
index 0000000000..6c00fae80f
--- /dev/null
+++ b/patches.arch/kvm-s390-fix-potential-spectre-warnings.patch
@@ -0,0 +1,59 @@
+From: Eric Farman <farman@linux.ibm.com>
+Date: Wed, 17 Apr 2019 02:54:14 +0200
+Subject: KVM: s390: Fix potential spectre warnings
+Git-commit: 58616e6a37842740349b7a42dc442ec50fc1d457
+Patch-mainline: v5.2-rc1
+References: jsc#SLE-6412
+
+Fix some warnings from smatch:
+
+arch/s390/kvm/interrupt.c:2310 get_io_adapter() warn: potential spectre issue 'kvm->arch.adapters' [r] (local cap)
+arch/s390/kvm/interrupt.c:2341 register_io_adapter() warn: potential spectre issue 'dev->kvm->arch.adapters' [w]
+
+Signed-off-by: Eric Farman <farman@linux.ibm.com>
+Message-Id: <20190417005414.47801-1-farman@linux.ibm.com>
+Reviewed-by: David Hildenbrand <david@redhat.com>
+Reviewed-by: Cornelia Huck <cohuck@redhat.com>
+Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
+Signed-off-by: Bruce Rogers <brogers@suse.com>
+---
+ arch/s390/kvm/interrupt.c | 11 +++++++++--
+ 1 file changed, 9 insertions(+), 2 deletions(-)
+
+diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c
+index 2a270958a1dd..6d58180cb1e7 100644
+--- a/arch/s390/kvm/interrupt.c
++++ b/arch/s390/kvm/interrupt.c
+@@ -11,6 +11,7 @@
+ #include <linux/kvm_host.h>
+ #include <linux/hrtimer.h>
+ #include <linux/mmu_context.h>
++#include <linux/nospec.h>
+ #include <linux/signal.h>
+ #include <linux/slab.h>
+ #include <linux/bitmap.h>
+@@ -2213,6 +2214,7 @@ static struct s390_io_adapter *get_io_adapter(struct kvm *kvm, unsigned int id)
+ {
+ if (id >= MAX_S390_IO_ADAPTERS)
+ return NULL;
++ id = array_index_nospec(id, MAX_S390_IO_ADAPTERS);
+ return kvm->arch.adapters[id];
+ }
+
+@@ -2226,8 +2228,13 @@ static int register_io_adapter(struct kvm_device *dev,
+ (void __user *)attr->addr, sizeof(adapter_info)))
+ return -EFAULT;
+
+- if ((adapter_info.id >= MAX_S390_IO_ADAPTERS) ||
+- (dev->kvm->arch.adapters[adapter_info.id] != NULL))
++ if (adapter_info.id >= MAX_S390_IO_ADAPTERS)
++ return -EINVAL;
++
++ adapter_info.id = array_index_nospec(adapter_info.id,
++ MAX_S390_IO_ADAPTERS);
++
++ if (dev->kvm->arch.adapters[adapter_info.id] != NULL)
+ return -EINVAL;
+
+ adapter = kzalloc(sizeof(*adapter), GFP_KERNEL);
+
diff --git a/patches.arch/kvm-s390-generalize-kvm_s390_get_tod_clock_ext.patch b/patches.arch/kvm-s390-generalize-kvm_s390_get_tod_clock_ext.patch
new file mode 100644
index 0000000000..08164e6b89
--- /dev/null
+++ b/patches.arch/kvm-s390-generalize-kvm_s390_get_tod_clock_ext.patch
@@ -0,0 +1,74 @@
+From: David Hildenbrand <david@redhat.com>
+Date: Fri, 27 Apr 2018 14:36:13 +0200
+Subject: KVM: s390: generalize kvm_s390_get_tod_clock_ext()
+Git-commit: 33d1b2729e409e8327dec2d13a9144dfa76a947c
+Patch-mainline: v4.18-rc1
+References: jsc#SLE-6412
+
+Move the Multiple-epoch facility handling into it and rename it to
+kvm_s390_get_tod_clock().
+
+This leaves us with:
+- kvm_s390_set_tod_clock()
+- kvm_s390_get_tod_clock()
+- kvm_s390_get_tod_clock_fast()
+
+So all Multiple-epoch facility is hidden in these functions.
+
+Signed-off-by: David Hildenbrand <david@redhat.com>
+Reviewed-by: Collin Walling <walling@linux.ibm.com>
+Reviewed-by: Cornelia Huck <cohuck@redhat.com>
+Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
+Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
+Signed-off-by: Bruce Rogers <brogers@suse.com>
+---
+ arch/s390/kvm/kvm-s390.c | 21 +++++++++------------
+ 1 file changed, 9 insertions(+), 12 deletions(-)
+
+diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
+index 43d9bae8d4e0..53b4de7bb350 100644
+--- a/arch/s390/kvm/kvm-s390.c
++++ b/arch/s390/kvm/kvm-s390.c
+@@ -1133,8 +1133,8 @@ static int kvm_s390_set_tod(struct kvm *kvm, struct kvm_device_attr *attr)
+ return ret;
+ }
+
+-static void kvm_s390_get_tod_clock_ext(struct kvm *kvm,
+- struct kvm_s390_vm_tod_clock *gtod)
++static void kvm_s390_get_tod_clock(struct kvm *kvm,
++ struct kvm_s390_vm_tod_clock *gtod)
+ {
+ struct kvm_s390_tod_clock_ext htod;
+
+@@ -1143,10 +1143,12 @@ static void kvm_s390_get_tod_clock_ext(struct kvm *kvm,
+ get_tod_clock_ext((char *)&htod);
+
+ gtod->tod = htod.tod + kvm->arch.epoch;
+- gtod->epoch_idx = htod.epoch_idx + kvm->arch.epdx;
+-
+- if (gtod->tod < htod.tod)
+- gtod->epoch_idx += 1;
++ gtod->epoch_idx = 0;
++ if (test_kvm_facility(kvm, 139)) {
++ gtod->epoch_idx = htod.epoch_idx + kvm->arch.epdx;
++ if (gtod->tod < htod.tod)
++ gtod->epoch_idx += 1;
++ }
+
+ preempt_enable();
+ }
+@@ -1156,12 +1158,7 @@ static int kvm_s390_get_tod_ext(struct kvm *kvm, struct kvm_device_attr *attr)
+ struct kvm_s390_vm_tod_clock gtod;
+
+ memset(&gtod, 0, sizeof(gtod));
+-
+- if (test_kvm_facility(kvm, 139))
+- kvm_s390_get_tod_clock_ext(kvm, &gtod);
+- else
+- gtod.tod = kvm_s390_get_tod_clock_fast(kvm);
+-
++ kvm_s390_get_tod_clock(kvm, &gtod);
+ if (copy_to_user((void __user *)attr->addr, &gtod, sizeof(gtod)))
+ return -EFAULT;
+
+
diff --git a/patches.arch/kvm-s390-implement-gisa-ipm-related-primitives.patch b/patches.arch/kvm-s390-implement-gisa-ipm-related-primitives.patch
new file mode 100644
index 0000000000..556fe55a38
--- /dev/null
+++ b/patches.arch/kvm-s390-implement-gisa-ipm-related-primitives.patch
@@ -0,0 +1,62 @@
+From: Michael Mueller <mimu@linux.vnet.ibm.com>
+Date: Mon, 12 Jun 2017 12:37:57 +0200
+Subject: KVM: s390: implement GISA IPM related primitives
+Git-commit: d77e64141e322a3202de71a4afa7956c98d2a302
+Patch-mainline: v4.16-rc1
+References: jsc#SLE-6412
+
+The patch implements routines to access the GISA to test and modify
+its Interruption Pending Mask (IPM) from the host side.
+
+Signed-off-by: Michael Mueller <mimu@linux.vnet.ibm.com>
+Reviewed-by: Pierre Morel <pmorel@linux.vnet.ibm.com>
+Reviewed-by: Halil Pasic <pasic@linux.vnet.ibm.com>
+Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
+Reviewed-by: David Hildenbrand <david@redhat.com>
+Reviewed-by: Cornelia Huck <cohuck@redhat.com>
+Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
+Signed-off-by: Bruce Rogers <brogers@suse.com>
+---
+ arch/s390/kvm/interrupt.c | 28 ++++++++++++++++++++++++++++
+ 1 file changed, 28 insertions(+)
+
+diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c
+index ae11d893215a..37e8d450d2f7 100644
+--- a/arch/s390/kvm/interrupt.c
++++ b/arch/s390/kvm/interrupt.c
+@@ -210,6 +210,34 @@ static inline u8 int_word_to_isc(u32 int_word)
+ return (int_word & 0x38000000) >> 27;
+ }
+
++/*
++ * To use atomic bitmap functions, we have to provide a bitmap address
++ * that is u64 aligned. However, the ipm might be u32 aligned.
++ * Therefore, we logically start the bitmap at the very beginning of the
++ * struct and fixup the bit number.
++ */
++#define IPM_BIT_OFFSET (offsetof(struct kvm_s390_gisa, ipm) * BITS_PER_BYTE)
++
++static inline void kvm_s390_gisa_set_ipm_gisc(struct kvm_s390_gisa *gisa, u32 gisc)
++{
++ set_bit_inv(IPM_BIT_OFFSET + gisc, (unsigned long *) gisa);
++}
++
++static inline u8 kvm_s390_gisa_get_ipm(struct kvm_s390_gisa *gisa)
++{
++ return READ_ONCE(gisa->ipm);
++}
++
++static inline void kvm_s390_gisa_clear_ipm_gisc(struct kvm_s390_gisa *gisa, u32 gisc)
++{
++ clear_bit_inv(IPM_BIT_OFFSET + gisc, (unsigned long *) gisa);
++}
++
++static inline int kvm_s390_gisa_tac_ipm_gisc(struct kvm_s390_gisa *gisa, u32 gisc)
++{
++ return test_and_clear_bit_inv(IPM_BIT_OFFSET + gisc, (unsigned long *) gisa);
++}
++
+ static inline unsigned long pending_irqs(struct kvm_vcpu *vcpu)
+ {
+ return vcpu->kvm->arch.float_int.pending_irqs |
+
diff --git a/patches.arch/kvm-s390-introduce-the-format-1-gisa.patch b/patches.arch/kvm-s390-introduce-the-format-1-gisa.patch
new file mode 100644
index 0000000000..4c238bdcdd
--- /dev/null
+++ b/patches.arch/kvm-s390-introduce-the-format-1-gisa.patch
@@ -0,0 +1,127 @@
+From: Michael Mueller <mimu@linux.vnet.ibm.com>
+Date: Fri, 23 Jun 2017 13:51:25 +0200
+Subject: KVM: s390: introduce the format-1 GISA
+Git-commit: 4b9f952577fb40875a2a163d80515a8daa0d6bef
+Patch-mainline: v4.16-rc1
+References: jsc#SLE-6412
+
+The patch modifies the previously defined GISA data structure to be
+able to store two GISA formats, format-0 and format-1. Additionally,
+it verifies the availability of the GISA format facility and enables
+the use of a format-1 GISA in the SIE control block accordingly.
+
+A format-1 can do everything that format-0 can and we will need it
+for real HW passthrough. As there are systems with only format-0
+we keep both variants.
+
+Signed-off-by: Michael Mueller <mimu@linux.vnet.ibm.com>
+Reviewed-by: Pierre Morel <pmorel@linux.vnet.ibm.com>
+Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
+Reviewed-by: David Hildenbrand <david@redhat.com>
+Acked-by: Cornelia Huck <cohuck@redhat.com>
+Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
+Signed-off-by: Bruce Rogers <brogers@suse.com>
+---
+ arch/s390/include/asm/kvm_host.h | 44 +++++++++++++++++++++++++++++++---------
+ arch/s390/kvm/interrupt.c | 4 +---
+ arch/s390/kvm/kvm-s390.c | 2 ++
+ 3 files changed, 37 insertions(+), 13 deletions(-)
+
+diff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_host.h
+index 10a0622cac01..58587b1fae25 100644
+--- a/arch/s390/include/asm/kvm_host.h
++++ b/arch/s390/include/asm/kvm_host.h
+@@ -234,6 +234,7 @@ struct kvm_s390_sie_block {
+ __u8 epdx; /* 0x0069 */
+ __u8 reserved6a[2]; /* 0x006a */
+ __u32 todpr; /* 0x006c */
++#define GISA_FORMAT1 0x00000001
+ __u32 gd; /* 0x0070 */
+ __u8 reserved74[12]; /* 0x0074 */
+ __u64 mso; /* 0x0080 */
+@@ -730,15 +731,38 @@ struct kvm_s390_crypto_cb {
+ };
+
+ struct kvm_s390_gisa {
+- u32 next_alert;
+- u8 ipm;
+- u8 reserved01;
+- u8 : 6;
+- u8 g : 1;
+- u8 c : 1;
+- u8 iam;
+- u8 reserved02[4];
+- u32 airq_count;
++ union {
++ struct { /* common to all formats */
++ u32 next_alert;
++ u8 ipm;
++ u8 reserved01[2];
++ u8 iam;
++ };
++ struct { /* format 0 */
++ u32 next_alert;
++ u8 ipm;
++ u8 reserved01;
++ u8 : 6;
++ u8 g : 1;
++ u8 c : 1;
++ u8 iam;
++ u8 reserved02[4];
++ u32 airq_count;
++ } g0;
++ struct { /* format 1 */
++ u32 next_alert;
++ u8 ipm;
++ u8 simm;
++ u8 nimm;
++ u8 iam;
++ u8 aism[8];
++ u8 : 6;
++ u8 g : 1;
++ u8 c : 1;
++ u8 reserved03[11];
++ u32 airq_count;
++ } g1;
++ };
+ };
+
+ /*
+@@ -749,7 +773,7 @@ struct sie_page2 {
+ __u64 fac_list[S390_ARCH_FAC_LIST_SIZE_U64]; /* 0x0000 */
+ struct kvm_s390_crypto_cb crycb; /* 0x0800 */
+ struct kvm_s390_gisa gisa; /* 0x0900 */
+- u8 reserved910[0x1000 - 0x910]; /* 0x0910 */
++ u8 reserved920[0x1000 - 0x920]; /* 0x0920 */
+ };
+
+ struct kvm_s390_vsie {
+diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c
+index b01be3c6b4fe..0aac3f5d6a81 100644
+--- a/arch/s390/kvm/interrupt.c
++++ b/arch/s390/kvm/interrupt.c
+@@ -2860,9 +2860,7 @@ void kvm_s390_gisa_clear(struct kvm *kvm)
+
+ void kvm_s390_gisa_init(struct kvm *kvm)
+ {
+- if (!css_general_characteristics.aiv)
+- kvm->arch.gisa = NULL;
+- else {
++ if (css_general_characteristics.aiv) {
+ kvm->arch.gisa = &kvm->arch.sie_page2->gisa;
+ VM_EVENT(kvm, 3, "gisa 0x%pK initialized", kvm->arch.gisa);
+ kvm_s390_gisa_clear(kvm);
+diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
+index e05807bd2b4e..42b43dcde620 100644
+--- a/arch/s390/kvm/kvm-s390.c
++++ b/arch/s390/kvm/kvm-s390.c
+@@ -2705,6 +2705,8 @@ struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm,
+ vcpu->arch.sie_block->icpua = id;
+ spin_lock_init(&vcpu->arch.local_int.lock);
+ vcpu->arch.sie_block->gd = (u32)(u64)kvm->arch.gisa;
++ if (vcpu->arch.sie_block->gd && sclp.has_gisaf)
++ vcpu->arch.sie_block->gd |= GISA_FORMAT1;
+ seqcount_init(&vcpu->arch.cputm_seqcount);
+
+ rc = kvm_vcpu_init(vcpu, kvm, id);
+
diff --git a/patches.arch/kvm-s390-make-kvm_s390_get_io_int-aware-of-gisa.patch b/patches.arch/kvm-s390-make-kvm_s390_get_io_int-aware-of-gisa.patch
new file mode 100644
index 0000000000..818d969480
--- /dev/null
+++ b/patches.arch/kvm-s390-make-kvm_s390_get_io_int-aware-of-gisa.patch
@@ -0,0 +1,124 @@
+From: Michael Mueller <mimu@linux.vnet.ibm.com>
+Date: Fri, 7 Jul 2017 15:27:31 +0200
+Subject: KVM: s390: make kvm_s390_get_io_int() aware of GISA
+Git-commit: 4b35f65e67ee0e5bc4f394efa14a9fa3917cd2c1
+Patch-mainline: v4.16-rc1
+References: jsc#SLE-6412
+
+The function returns a pending I/O interrupt with the highest
+priority defined by its ISC.
+
+Together with AIV activation, pending adapter interrupts are
+managed by the GISA IPM. Thus kvm_s390_get_io_int() needs to
+inspect the IPM as well when the interrupt with the highest
+priority has to be identified.
+
+In case classic and adapter interrupts with the same ISC are
+pending, the classic interrupt will be returned first.
+
+Signed-off-by: Michael Mueller <mimu@linux.vnet.ibm.com>
+Reviewed-by: Halil Pasic <pasic@linux.vnet.ibm.com>
+Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
+Reviewed-by: Cornelia Huck <cohuck@redhat.com>
+Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
+Signed-off-by: Bruce Rogers <brogers@suse.com>
+---
+ arch/s390/kvm/interrupt.c | 74 ++++++++++++++++++++++++++++++++++++++++++++---
+ 1 file changed, 70 insertions(+), 4 deletions(-)
+
+diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c
+index e804fd543e52..325ea87cd59d 100644
+--- a/arch/s390/kvm/interrupt.c
++++ b/arch/s390/kvm/interrupt.c
+@@ -1489,20 +1489,86 @@ static struct kvm_s390_interrupt_info *get_io_int(struct kvm *kvm,
+ return NULL;
+ }
+
++static struct kvm_s390_interrupt_info *get_top_io_int(struct kvm *kvm,
++ u64 isc_mask, u32 schid)
++{
++ struct kvm_s390_interrupt_info *inti = NULL;
++ int isc;
++
++ for (isc = 0; isc <= MAX_ISC && !inti; isc++) {
++ if (isc_mask & isc_to_isc_bits(isc))
++ inti = get_io_int(kvm, isc, schid);
++ }
++ return inti;
++}
++
++static int get_top_gisa_isc(struct kvm *kvm, u64 isc_mask, u32 schid)
++{
++ unsigned long active_mask;
++ int isc;
++
++ if (schid)
++ goto out;
++ if (!kvm->arch.gisa)
++ goto out;
++
++ active_mask = (isc_mask & kvm_s390_gisa_get_ipm(kvm->arch.gisa) << 24) << 32;
++ while (active_mask) {
++ isc = __fls(active_mask) ^ (BITS_PER_LONG - 1);
++ if (kvm_s390_gisa_tac_ipm_gisc(kvm->arch.gisa, isc))
++ return isc;
++ clear_bit_inv(isc, &active_mask);
++ }
++out:
++ return -EINVAL;
++}
++
+ /*
+ * Dequeue and return an I/O interrupt matching any of the interruption
+ * subclasses as designated by the isc mask in cr6 and the schid (if != 0).
++ * Take into account the interrupts pending in the interrupt list and in GISA.
++ *
++ * Note that for a guest that does not enable I/O interrupts
++ * but relies on TPI, a flood of classic interrupts may starve
++ * out adapter interrupts on the same isc. Linux does not do
++ * that, and it is possible to work around the issue by configuring
++ * different iscs for classic and adapter interrupts in the guest,
++ * but we may want to revisit this in the future.
+ */
+ struct kvm_s390_interrupt_info *kvm_s390_get_io_int(struct kvm *kvm,
+ u64 isc_mask, u32 schid)
+ {
+- struct kvm_s390_interrupt_info *inti = NULL;
++ struct kvm_s390_interrupt_info *inti, *tmp_inti;
+ int isc;
+
+- for (isc = 0; isc <= MAX_ISC && !inti; isc++) {
+- if (isc_mask & isc_to_isc_bits(isc))
+- inti = get_io_int(kvm, isc, schid);
++ inti = get_top_io_int(kvm, isc_mask, schid);
++
++ isc = get_top_gisa_isc(kvm, isc_mask, schid);
++ if (isc < 0)
++ /* no AI in GISA */
++ goto out;
++
++ if (!inti)
++ /* AI in GISA but no classical IO int */
++ goto gisa_out;
++
++ /* both types of interrupts present */
++ if (int_word_to_isc(inti->io.io_int_word) <= isc) {
++ /* classical IO int with higher priority */
++ kvm_s390_gisa_set_ipm_gisc(kvm->arch.gisa, isc);
++ goto out;
+ }
++gisa_out:
++ tmp_inti = kzalloc(sizeof(*inti), GFP_KERNEL);
++ if (tmp_inti) {
++ tmp_inti->type = KVM_S390_INT_IO(1, 0, 0, 0);
++ tmp_inti->io.io_int_word = isc_to_int_word(isc);
++ if (inti)
++ kvm_s390_reinject_io_int(kvm, inti);
++ inti = tmp_inti;
++ } else
++ kvm_s390_gisa_set_ipm_gisc(kvm->arch.gisa, isc);
++out:
+ return inti;
+ }
+
+
diff --git a/patches.arch/kvm-s390-no-need-to-inititalize-kvm-arch-members-to-0.patch b/patches.arch/kvm-s390-no-need-to-inititalize-kvm-arch-members-to-0.patch
new file mode 100644
index 0000000000..3282b98ed1
--- /dev/null
+++ b/patches.arch/kvm-s390-no-need-to-inititalize-kvm-arch-members-to-0.patch
@@ -0,0 +1,59 @@
+From: David Hildenbrand <david@redhat.com>
+Date: Fri, 27 Apr 2018 14:36:12 +0200
+Subject: KVM: s390: no need to inititalize kvm->arch members to 0
+Git-commit: 9ac96d759fa2de2386a4fccab80880f99d1161d2
+Patch-mainline: v4.18-rc1
+References: jsc#SLE-6412
+
+KVM is allocated with kzalloc(), so these members are already 0.
+
+Signed-off-by: David Hildenbrand <david@redhat.com>
+Reviewed-by: Janosch Frank <frankja@linux.ibm.com>
+Reviewed-by: Collin Walling <walling@linux.ibm.com>
+Reviewed-by: Cornelia Huck <cohuck@redhat.com>
+Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
+Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
+Signed-off-by: Bruce Rogers <brogers@suse.com>
+---
+ arch/s390/kvm/kvm-s390.c | 8 +-------
+ 1 file changed, 1 insertion(+), 7 deletions(-)
+
+diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
+index a736dd7c7ccc..43d9bae8d4e0 100644
+--- a/arch/s390/kvm/kvm-s390.c
++++ b/arch/s390/kvm/kvm-s390.c
+@@ -2141,10 +2141,10 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
+
+ rc = -ENOMEM;
+
+- kvm->arch.use_esca = 0; /* start with basic SCA */
+ if (!sclp.has_64bscao)
+ alloc_flags |= GFP_DMA;
+ rwlock_init(&kvm->arch.sca_lock);
++ /* start with basic SCA */
+ kvm->arch.sca = (struct bsca_block *) get_zeroed_page(alloc_flags);
+ if (!kvm->arch.sca)
+ goto out_err;
+@@ -2195,8 +2195,6 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
+ kvm_s390_crypto_init(kvm);
+
+ mutex_init(&kvm->arch.float_int.ais_lock);
+- kvm->arch.float_int.simm = 0;
+- kvm->arch.float_int.nimm = 0;
+ spin_lock_init(&kvm->arch.float_int.lock);
+ for (i = 0; i < FIRQ_LIST_COUNT; i++)
+ INIT_LIST_HEAD(&kvm->arch.float_int.lists[i]);
+@@ -2222,12 +2220,8 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
+ kvm->arch.gmap->pfault_enabled = 0;
+ }
+
+- kvm->arch.css_support = 0;
+- kvm->arch.use_irqchip = 0;
+ kvm->arch.use_pfmfi = sclp.has_pfmfi;
+ kvm->arch.use_skf = sclp.has_skey;
+- kvm->arch.epoch = 0;
+-
+ spin_lock_init(&kvm->arch.start_stop_lock);
+ kvm_s390_vsie_init(kvm);
+ kvm_s390_gisa_init(kvm);
+
diff --git a/patches.arch/kvm-s390-provide-counters-for-all-interrupt-injects-delivery.patch b/patches.arch/kvm-s390-provide-counters-for-all-interrupt-injects-delivery.patch
new file mode 100644
index 0000000000..c066d2f6f5
--- /dev/null
+++ b/patches.arch/kvm-s390-provide-counters-for-all-interrupt-injects-delivery.patch
@@ -0,0 +1,301 @@
+From: Christian Borntraeger <borntraeger@de.ibm.com>
+Date: Thu, 8 Mar 2018 12:48:05 +0000
+Subject: KVM: s390: provide counters for all interrupt injects/delivery
+Git-commit: ccc40c53c07ba22cfe711cd625f9f0c77f272ae6
+Patch-mainline: v4.17-rc1
+References: jsc#SLE-6412
+
+For testing the exitless interrupt support it turned out useful to
+have separate counters for inject and delivery of I/O interrupt.
+While at it do the same for all interrupt types. For timer
+related interrupts (clock comparator and cpu timer) we even had
+no delivery counters. Fix this as well. On this way some counters
+are being renamed to have a similar name.
+
+Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
+Reviewed-by: Cornelia Huck <cohuck@redhat.com>
+Signed-off-by: Bruce Rogers <brogers@suse.com>
+---
+ arch/s390/include/asm/kvm_host.h | 25 +++++++++++++++++++++----
+ arch/s390/kvm/interrupt.c | 25 +++++++++++++++++++++----
+ arch/s390/kvm/kvm-s390.c | 24 +++++++++++++++++++++---
+ 3 files changed, 63 insertions(+), 11 deletions(-)
+
+diff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_host.h
+index 85f0013a47cd..40e9487b6896 100644
+--- a/arch/s390/include/asm/kvm_host.h
++++ b/arch/s390/include/asm/kvm_host.h
+@@ -320,17 +320,29 @@ struct kvm_vcpu_stat {
+ u64 exit_program_interruption;
+ u64 exit_instr_and_program;
+ u64 exit_operation_exception;
++ u64 deliver_ckc;
++ u64 deliver_cputm;
+ u64 deliver_external_call;
+ u64 deliver_emergency_signal;
+ u64 deliver_service_signal;
+- u64 deliver_virtio_interrupt;
++ u64 deliver_virtio;
+ u64 deliver_stop_signal;
+ u64 deliver_prefix_signal;
+ u64 deliver_restart_signal;
+- u64 deliver_program_int;
+- u64 deliver_io_int;
++ u64 deliver_program;
++ u64 deliver_io;
+ u64 deliver_machine_check;
+ u64 exit_wait_state;
++ u64 inject_ckc;
++ u64 inject_cputm;
++ u64 inject_external_call;
++ u64 inject_emergency_signal;
++ u64 inject_mchk;
++ u64 inject_pfault_init;
++ u64 inject_program;
++ u64 inject_restart;
++ u64 inject_set_prefix;
++ u64 inject_stop_signal;
+ u64 instruction_epsw;
+ u64 instruction_gs;
+ u64 instruction_io_other;
+@@ -655,7 +667,12 @@ struct kvm_vcpu_arch {
+ };
+
+ struct kvm_vm_stat {
+- ulong remote_tlb_flush;
++ u64 inject_io;
++ u64 inject_float_mchk;
++ u64 inject_pfault_done;
++ u64 inject_service_signal;
++ u64 inject_virtio;
++ u64 remote_tlb_flush;
+ };
+
+ struct kvm_arch_memory_slot {
+diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c
+index aaf2a6839d0d..2a270958a1dd 100644
+--- a/arch/s390/kvm/interrupt.c
++++ b/arch/s390/kvm/interrupt.c
+@@ -396,6 +396,7 @@ static int __must_check __deliver_cpu_timer(struct kvm_vcpu *vcpu)
+ struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
+ int rc;
+
++ vcpu->stat.deliver_cputm++;
+ trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id, KVM_S390_INT_CPU_TIMER,
+ 0, 0);
+
+@@ -415,6 +416,7 @@ static int __must_check __deliver_ckc(struct kvm_vcpu *vcpu)
+ struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
+ int rc;
+
++ vcpu->stat.deliver_ckc++;
+ trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id, KVM_S390_INT_CLOCK_COMP,
+ 0, 0);
+
+@@ -716,7 +718,7 @@ static int __must_check __deliver_prog(struct kvm_vcpu *vcpu)
+ ilen = pgm_info.flags & KVM_S390_PGM_FLAGS_ILC_MASK;
+ VCPU_EVENT(vcpu, 3, "deliver: program irq code 0x%x, ilen:%d",
+ pgm_info.code, ilen);
+- vcpu->stat.deliver_program_int++;
++ vcpu->stat.deliver_program++;
+ trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id, KVM_S390_PROGRAM_INT,
+ pgm_info.code, 0);
+
+@@ -905,7 +907,7 @@ static int __must_check __deliver_virtio(struct kvm_vcpu *vcpu)
+ VCPU_EVENT(vcpu, 4,
+ "deliver: virtio parm: 0x%x,parm64: 0x%llx",
+ inti->ext.ext_params, inti->ext.ext_params2);
+- vcpu->stat.deliver_virtio_interrupt++;
++ vcpu->stat.deliver_virtio++;
+ trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id,
+ inti->type,
+ inti->ext.ext_params,
+@@ -981,7 +983,7 @@ static int __must_check __deliver_io(struct kvm_vcpu *vcpu,
+ inti->io.subchannel_id >> 1 & 0x3,
+ inti->io.subchannel_nr);
+
+- vcpu->stat.deliver_io_int++;
++ vcpu->stat.deliver_io++;
+ trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id,
+ inti->type,
+ ((__u32)inti->io.subchannel_id << 16) |
+@@ -1010,7 +1012,7 @@ static int __must_check __deliver_io(struct kvm_vcpu *vcpu,
+ VCPU_EVENT(vcpu, 4, "%s isc %u", "deliver: I/O (AI/gisa)", isc);
+ memset(&io, 0, sizeof(io));
+ io.io_int_word = isc_to_int_word(isc);
+- vcpu->stat.deliver_io_int++;
++ vcpu->stat.deliver_io++;
+ trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id,
+ KVM_S390_INT_IO(1, 0, 0, 0),
+ ((__u32)io.subchannel_id << 16) |
+@@ -1274,6 +1276,7 @@ static int __inject_prog(struct kvm_vcpu *vcpu, struct kvm_s390_irq *irq)
+ {
+ struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
+
++ vcpu->stat.inject_program++;
+ VCPU_EVENT(vcpu, 3, "inject: program irq code 0x%x", irq->u.pgm.code);
+ trace_kvm_s390_inject_vcpu(vcpu->vcpu_id, KVM_S390_PROGRAM_INT,
+ irq->u.pgm.code, 0);
+@@ -1315,6 +1318,7 @@ static int __inject_pfault_init(struct kvm_vcpu *vcpu, struct kvm_s390_irq *irq)
+ {
+ struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
+
++ vcpu->stat.inject_pfault_init++;
+ VCPU_EVENT(vcpu, 4, "inject: pfault init parameter block at 0x%llx",
+ irq->u.ext.ext_params2);
+ trace_kvm_s390_inject_vcpu(vcpu->vcpu_id, KVM_S390_INT_PFAULT_INIT,
+@@ -1333,6 +1337,7 @@ static int __inject_extcall(struct kvm_vcpu *vcpu, struct kvm_s390_irq *irq)
+ struct kvm_s390_extcall_info *extcall = &li->irq.extcall;
+ uint16_t src_id = irq->u.extcall.code;
+
++ vcpu->stat.inject_external_call++;
+ VCPU_EVENT(vcpu, 4, "inject: external call source-cpu:%u",
+ src_id);
+ trace_kvm_s390_inject_vcpu(vcpu->vcpu_id, KVM_S390_INT_EXTERNAL_CALL,
+@@ -1357,6 +1362,7 @@ static int __inject_set_prefix(struct kvm_vcpu *vcpu, struct kvm_s390_irq *irq)
+ struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
+ struct kvm_s390_prefix_info *prefix = &li->irq.prefix;
+
++ vcpu->stat.inject_set_prefix++;
+ VCPU_EVENT(vcpu, 3, "inject: set prefix to %x",
+ irq->u.prefix.address);
+ trace_kvm_s390_inject_vcpu(vcpu->vcpu_id, KVM_S390_SIGP_SET_PREFIX,
+@@ -1377,6 +1383,7 @@ static int __inject_sigp_stop(struct kvm_vcpu *vcpu, struct kvm_s390_irq *irq)
+ struct kvm_s390_stop_info *stop = &li->irq.stop;
+ int rc = 0;
+
++ vcpu->stat.inject_stop_signal++;
+ trace_kvm_s390_inject_vcpu(vcpu->vcpu_id, KVM_S390_SIGP_STOP, 0, 0);
+
+ if (irq->u.stop.flags & ~KVM_S390_STOP_SUPP_FLAGS)
+@@ -1401,6 +1408,7 @@ static int __inject_sigp_restart(struct kvm_vcpu *vcpu,
+ {
+ struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
+
++ vcpu->stat.inject_restart++;
+ VCPU_EVENT(vcpu, 3, "%s", "inject: restart int");
+ trace_kvm_s390_inject_vcpu(vcpu->vcpu_id, KVM_S390_RESTART, 0, 0);
+
+@@ -1413,6 +1421,7 @@ static int __inject_sigp_emergency(struct kvm_vcpu *vcpu,
+ {
+ struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
+
++ vcpu->stat.inject_emergency_signal++;
+ VCPU_EVENT(vcpu, 4, "inject: emergency from cpu %u",
+ irq->u.emerg.code);
+ trace_kvm_s390_inject_vcpu(vcpu->vcpu_id, KVM_S390_INT_EMERGENCY,
+@@ -1433,6 +1442,7 @@ static int __inject_mchk(struct kvm_vcpu *vcpu, struct kvm_s390_irq *irq)
+ struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
+ struct kvm_s390_mchk_info *mchk = &li->irq.mchk;
+
++ vcpu->stat.inject_mchk++;
+ VCPU_EVENT(vcpu, 3, "inject: machine check mcic 0x%llx",
+ irq->u.mchk.mcic);
+ trace_kvm_s390_inject_vcpu(vcpu->vcpu_id, KVM_S390_MCHK, 0,
+@@ -1463,6 +1473,7 @@ static int __inject_ckc(struct kvm_vcpu *vcpu)
+ {
+ struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
+
++ vcpu->stat.inject_ckc++;
+ VCPU_EVENT(vcpu, 3, "%s", "inject: clock comparator external");
+ trace_kvm_s390_inject_vcpu(vcpu->vcpu_id, KVM_S390_INT_CLOCK_COMP,
+ 0, 0);
+@@ -1476,6 +1487,7 @@ static int __inject_cpu_timer(struct kvm_vcpu *vcpu)
+ {
+ struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
+
++ vcpu->stat.inject_cputm++;
+ VCPU_EVENT(vcpu, 3, "%s", "inject: cpu timer external");
+ trace_kvm_s390_inject_vcpu(vcpu->vcpu_id, KVM_S390_INT_CPU_TIMER,
+ 0, 0);
+@@ -1602,6 +1614,7 @@ static int __inject_service(struct kvm *kvm,
+ {
+ struct kvm_s390_float_interrupt *fi = &kvm->arch.float_int;
+
++ kvm->stat.inject_service_signal++;
+ spin_lock(&fi->lock);
+ fi->srv_signal.ext_params |= inti->ext.ext_params & SCCB_EVENT_PENDING;
+ /*
+@@ -1627,6 +1640,7 @@ static int __inject_virtio(struct kvm *kvm,
+ {
+ struct kvm_s390_float_interrupt *fi = &kvm->arch.float_int;
+
++ kvm->stat.inject_virtio++;
+ spin_lock(&fi->lock);
+ if (fi->counters[FIRQ_CNTR_VIRTIO] >= KVM_S390_MAX_VIRTIO_IRQS) {
+ spin_unlock(&fi->lock);
+@@ -1644,6 +1658,7 @@ static int __inject_pfault_done(struct kvm *kvm,
+ {
+ struct kvm_s390_float_interrupt *fi = &kvm->arch.float_int;
+
++ kvm->stat.inject_pfault_done++;
+ spin_lock(&fi->lock);
+ if (fi->counters[FIRQ_CNTR_PFAULT] >=
+ (ASYNC_PF_PER_VCPU * KVM_MAX_VCPUS)) {
+@@ -1663,6 +1678,7 @@ static int __inject_float_mchk(struct kvm *kvm,
+ {
+ struct kvm_s390_float_interrupt *fi = &kvm->arch.float_int;
+
++ kvm->stat.inject_float_mchk++;
+ spin_lock(&fi->lock);
+ fi->mchk.cr14 |= inti->mchk.cr14 & (1UL << CR_PENDING_SUBCLASS);
+ fi->mchk.mcic |= inti->mchk.mcic;
+@@ -1678,6 +1694,7 @@ static int __inject_io(struct kvm *kvm, struct kvm_s390_interrupt_info *inti)
+ struct list_head *list;
+ int isc;
+
++ kvm->stat.inject_io++;
+ isc = int_word_to_isc(inti->io.io_int_word);
+
+ if (kvm->arch.gisa && inti->type & KVM_S390_INT_IO_AI_MASK) {
+diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
+index 242deaa6bb99..701bb8dcfd4a 100644
+--- a/arch/s390/kvm/kvm-s390.c
++++ b/arch/s390/kvm/kvm-s390.c
+@@ -58,6 +58,7 @@
+ (KVM_MAX_VCPUS + LOCAL_IRQS))
+
+ #define VCPU_STAT(x) offsetof(struct kvm_vcpu, stat.x), KVM_STAT_VCPU
++#define VM_STAT(x) offsetof(struct kvm, stat.x), KVM_STAT_VM
+
+ struct kvm_stats_debugfs_item debugfs_entries[] = {
+ { "userspace_handled", VCPU_STAT(exit_userspace) },
+@@ -81,17 +82,34 @@ struct kvm_stats_debugfs_item debugfs_entries[] = {
+ { "instruction_lctl", VCPU_STAT(instruction_lctl) },
+ { "instruction_stctl", VCPU_STAT(instruction_stctl) },
+ { "instruction_stctg", VCPU_STAT(instruction_stctg) },
++ { "deliver_ckc", VCPU_STAT(deliver_ckc) },
++ { "deliver_cputm", VCPU_STAT(deliver_cputm) },
+ { "deliver_emergency_signal", VCPU_STAT(deliver_emergency_signal) },
+ { "deliver_external_call", VCPU_STAT(deliver_external_call) },
+ { "deliver_service_signal", VCPU_STAT(deliver_service_signal) },
+- { "deliver_virtio_interrupt", VCPU_STAT(deliver_virtio_interrupt) },
++ { "deliver_virtio", VCPU_STAT(deliver_virtio) },
+ { "deliver_stop_signal", VCPU_STAT(deliver_stop_signal) },
+ { "deliver_prefix_signal", VCPU_STAT(deliver_prefix_signal) },
+ { "deliver_restart_signal", VCPU_STAT(deliver_restart_signal) },
+- { "deliver_program_interruption", VCPU_STAT(deliver_program_int) },
+- { "deliver_io_interrupt", VCPU_STAT(deliver_io_int) },
++ { "deliver_program", VCPU_STAT(deliver_program) },
++ { "deliver_io", VCPU_STAT(deliver_io) },
+ { "deliver_machine_check", VCPU_STAT(deliver_machine_check) },
+ { "exit_wait_state", VCPU_STAT(exit_wait_state) },
++ { "inject_ckc", VCPU_STAT(inject_ckc) },
++ { "inject_cputm", VCPU_STAT(inject_cputm) },
++ { "inject_external_call", VCPU_STAT(inject_external_call) },
++ { "inject_float_mchk", VM_STAT(inject_float_mchk) },
++ { "inject_emergency_signal", VCPU_STAT(inject_emergency_signal) },
++ { "inject_io", VM_STAT(inject_io) },
++ { "inject_mchk", VCPU_STAT(inject_mchk) },
++ { "inject_pfault_done", VM_STAT(inject_pfault_done) },
++ { "inject_program", VCPU_STAT(inject_program) },
++ { "inject_restart", VCPU_STAT(inject_restart) },
++ { "inject_service_signal", VM_STAT(inject_service_signal) },
++ { "inject_set_prefix", VCPU_STAT(inject_set_prefix) },
++ { "inject_stop_signal", VCPU_STAT(inject_stop_signal) },
++ { "inject_pfault_init", VCPU_STAT(inject_pfault_init) },
++ { "inject_virtio", VM_STAT(inject_virtio) },
+ { "instruction_epsw", VCPU_STAT(instruction_epsw) },
+ { "instruction_gs", VCPU_STAT(instruction_gs) },
+ { "instruction_io_other", VCPU_STAT(instruction_io_other) },
+
diff --git a/patches.arch/kvm-s390-reverse-bit-ordering-of-irqs-in-pending-mask.patch b/patches.arch/kvm-s390-reverse-bit-ordering-of-irqs-in-pending-mask.patch
new file mode 100644
index 0000000000..1bc7ab0647
--- /dev/null
+++ b/patches.arch/kvm-s390-reverse-bit-ordering-of-irqs-in-pending-mask.patch
@@ -0,0 +1,143 @@
+From: Michael Mueller <mimu@linux.vnet.ibm.com>
+Date: Thu, 29 Jun 2017 18:39:27 +0200
+Subject: KVM: s390: reverse bit ordering of irqs in pending mask
+Git-commit: c7901a6ebee4b624971361bbd93f21ab0b359786
+Patch-mainline: v4.16-rc1
+References: jsc#SLE-6412
+
+This patch prepares a simplification of bit operations between the irq
+pending mask for emulated interrupts and the Interruption Pending Mask
+(IPM) which is part of the Guest Interruption State Area (GISA), a feature
+that allows interrupt delivery to guests by means of the SIE instruction.
+
+Without that change, a bit-wise *or* operation on parts of these two masks
+would either require a look-up table of size 256 bytes to map the IPM
+to the emulated irq pending mask bit orientation (all bits mirrored at half
+byte) or a sequence of up to 8 condidional branches to perform tests of
+single bit positions. Both options are to be rejected either by performance
+or space utilization reasons.
+
+Beyond that this change will be transparent.
+
+Signed-off-by: Michael Mueller <mimu@linux.vnet.ibm.com>
+Reviewed-by: Halil Pasic <pasic@linux.vnet.ibm.com>
+Reviewed-by: Pierre Morel <pmorel@linux.vnet.ibm.com>
+Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
+Reviewed-by: Cornelia Huck <cohuck@redhat.com>
+Reviewed-by: David Hildenbrand <david@redhat.com>
+Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
+Signed-off-by: Bruce Rogers <brogers@suse.com>
+---
+ arch/s390/include/asm/kvm_host.h | 54 ++++++++++++++++++++--------------------
+ arch/s390/kvm/interrupt.c | 12 ++++-----
+ 2 files changed, 33 insertions(+), 33 deletions(-)
+
+diff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_host.h
+index 8fb9df3964f6..eb65b828371e 100644
+--- a/arch/s390/include/asm/kvm_host.h
++++ b/arch/s390/include/asm/kvm_host.h
+@@ -432,35 +432,35 @@ struct kvm_vcpu_stat {
+ #define PGM_PER 0x80
+ #define PGM_CRYPTO_OPERATION 0x119
+
+-/* irq types in order of priority */
++/* irq types in ascend order of priorities */
+ enum irq_types {
+- IRQ_PEND_MCHK_EX = 0,
+- IRQ_PEND_SVC,
+- IRQ_PEND_PROG,
+- IRQ_PEND_MCHK_REP,
+- IRQ_PEND_EXT_IRQ_KEY,
+- IRQ_PEND_EXT_MALFUNC,
+- IRQ_PEND_EXT_EMERGENCY,
+- IRQ_PEND_EXT_EXTERNAL,
+- IRQ_PEND_EXT_CLOCK_COMP,
+- IRQ_PEND_EXT_CPU_TIMER,
+- IRQ_PEND_EXT_TIMING,
+- IRQ_PEND_EXT_SERVICE,
+- IRQ_PEND_EXT_HOST,
+- IRQ_PEND_PFAULT_INIT,
+- IRQ_PEND_PFAULT_DONE,
+- IRQ_PEND_VIRTIO,
+- IRQ_PEND_IO_ISC_0,
+- IRQ_PEND_IO_ISC_1,
+- IRQ_PEND_IO_ISC_2,
+- IRQ_PEND_IO_ISC_3,
+- IRQ_PEND_IO_ISC_4,
+- IRQ_PEND_IO_ISC_5,
+- IRQ_PEND_IO_ISC_6,
+- IRQ_PEND_IO_ISC_7,
+- IRQ_PEND_SIGP_STOP,
++ IRQ_PEND_SET_PREFIX = 0,
+ IRQ_PEND_RESTART,
+- IRQ_PEND_SET_PREFIX,
++ IRQ_PEND_SIGP_STOP,
++ IRQ_PEND_IO_ISC_7,
++ IRQ_PEND_IO_ISC_6,
++ IRQ_PEND_IO_ISC_5,
++ IRQ_PEND_IO_ISC_4,
++ IRQ_PEND_IO_ISC_3,
++ IRQ_PEND_IO_ISC_2,
++ IRQ_PEND_IO_ISC_1,
++ IRQ_PEND_IO_ISC_0,
++ IRQ_PEND_VIRTIO,
++ IRQ_PEND_PFAULT_DONE,
++ IRQ_PEND_PFAULT_INIT,
++ IRQ_PEND_EXT_HOST,
++ IRQ_PEND_EXT_SERVICE,
++ IRQ_PEND_EXT_TIMING,
++ IRQ_PEND_EXT_CPU_TIMER,
++ IRQ_PEND_EXT_CLOCK_COMP,
++ IRQ_PEND_EXT_EXTERNAL,
++ IRQ_PEND_EXT_EMERGENCY,
++ IRQ_PEND_EXT_MALFUNC,
++ IRQ_PEND_EXT_IRQ_KEY,
++ IRQ_PEND_MCHK_REP,
++ IRQ_PEND_PROG,
++ IRQ_PEND_SVC,
++ IRQ_PEND_MCHK_EX,
+ IRQ_PEND_COUNT
+ };
+
+diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c
+index 4a4079a98366..ae11d893215a 100644
+--- a/arch/s390/kvm/interrupt.c
++++ b/arch/s390/kvm/interrupt.c
+@@ -196,8 +196,8 @@ static int cpu_timer_irq_pending(struct kvm_vcpu *vcpu)
+
+ static inline int is_ioirq(unsigned long irq_type)
+ {
+- return ((irq_type >= IRQ_PEND_IO_ISC_0) &&
+- (irq_type <= IRQ_PEND_IO_ISC_7));
++ return ((irq_type >= IRQ_PEND_IO_ISC_7) &&
++ (irq_type <= IRQ_PEND_IO_ISC_0));
+ }
+
+ static uint64_t isc_to_isc_bits(int isc)
+@@ -218,12 +218,12 @@ static inline unsigned long pending_irqs(struct kvm_vcpu *vcpu)
+
+ static inline int isc_to_irq_type(unsigned long isc)
+ {
+- return IRQ_PEND_IO_ISC_0 + isc;
++ return IRQ_PEND_IO_ISC_0 - isc;
+ }
+
+ static inline int irq_type_to_isc(unsigned long irq_type)
+ {
+- return irq_type - IRQ_PEND_IO_ISC_0;
++ return IRQ_PEND_IO_ISC_0 - irq_type;
+ }
+
+ static unsigned long disable_iscs(struct kvm_vcpu *vcpu,
+@@ -1167,8 +1167,8 @@ int __must_check kvm_s390_deliver_pending_interrupts(struct kvm_vcpu *vcpu)
+ set_bit(IRQ_PEND_EXT_CPU_TIMER, &li->pending_irqs);
+
+ while ((irqs = deliverable_irqs(vcpu)) && !rc) {
+- /* bits are in the order of interrupt priority */
+- irq_type = find_first_bit(&irqs, IRQ_PEND_COUNT);
++ /* bits are in the reverse order of interrupt priority */
++ irq_type = find_last_bit(&irqs, IRQ_PEND_COUNT);
+ if (is_ioirq(irq_type)) {
+ rc = __deliver_io(vcpu, irq_type);
+ } else {
+
diff --git a/patches.arch/kvm-s390-set-host-program-identifier.patch b/patches.arch/kvm-s390-set-host-program-identifier.patch
new file mode 100644
index 0000000000..9869f39b2d
--- /dev/null
+++ b/patches.arch/kvm-s390-set-host-program-identifier.patch
@@ -0,0 +1,70 @@
+From: Collin Walling <walling@linux.ibm.com>
+Date: Fri, 31 Aug 2018 12:51:19 -0400
+Subject: KVM: s390: set host program identifier
+Git-commit: 67d49d52ae502eaea8858fbcb97e3c2891f78da9
+Patch-mainline: v4.20-rc1
+References: jsc#SLE-6412
+
+A host program identifier (HPID) provides information regarding the
+underlying host environment. A level-2 (VM) guest will have an HPID
+denoting Linux/KVM, which is set during VCPU setup. A level-3 (VM on a
+VM) and beyond guest will have an HPID denoting KVM vSIE, which is set
+for all shadow control blocks, overriding the original value of the
+HPID.
+
+Signed-off-by: Collin Walling <walling@linux.ibm.com>
+Reviewed-by: Janosch Frank <frankja@linux.ibm.com>
+Message-Id: <1535734279-10204-4-git-send-email-walling@linux.ibm.com>
+Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
+Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
+Signed-off-by: Bruce Rogers <brogers@suse.com>
+---
+ arch/s390/include/asm/kvm_host.h | 6 +++++-
+ arch/s390/kvm/kvm-s390.c | 2 ++
+ arch/s390/kvm/vsie.c | 2 ++
+ 3 files changed, 9 insertions(+), 1 deletion(-)
+
+diff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_host.h
+index 40e9487b6896..ecc3017d68b6 100644
+--- a/arch/s390/include/asm/kvm_host.h
++++ b/arch/s390/include/asm/kvm_host.h
+@@ -242,7 +242,11 @@ struct kvm_s390_sie_block {
+ psw_t gpsw; /* 0x0090 */
+ __u64 gg14; /* 0x00a0 */
+ __u64 gg15; /* 0x00a8 */
+- __u8 reservedb0[20]; /* 0x00b0 */
++ __u8 reservedb0[8]; /* 0x00b0 */
++#define HPID_KVM 0x4
++#define HPID_VSIE 0x5
++ __u8 hpid; /* 0x00b8 */
++ __u8 reservedb9[11]; /* 0x00b9 */
+ __u16 extcpuaddr; /* 0x00c4 */
+ __u16 eic; /* 0x00c6 */
+ __u32 reservedc8; /* 0x00c8 */
+diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
+index 701bb8dcfd4a..26d540b91e73 100644
+--- a/arch/s390/kvm/kvm-s390.c
++++ b/arch/s390/kvm/kvm-s390.c
+@@ -2689,6 +2689,8 @@ int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu)
+ hrtimer_init(&vcpu->arch.ckc_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
+ vcpu->arch.ckc_timer.function = kvm_s390_idle_wakeup;
+
++ vcpu->arch.sie_block->hpid = HPID_KVM;
++
+ kvm_s390_vcpu_crypto_setup(vcpu);
+
+ return rc;
+diff --git a/arch/s390/kvm/vsie.c b/arch/s390/kvm/vsie.c
+index 3c1f53e2d5c0..b3f135354d5e 100644
+--- a/arch/s390/kvm/vsie.c
++++ b/arch/s390/kvm/vsie.c
+@@ -542,6 +542,8 @@ static int shadow_scb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
+ if (test_kvm_facility(vcpu->kvm, 156))
+ scb_s->ecd |= scb_o->ecd & ECD_ETOKENF;
+
++ scb_s->hpid = HPID_VSIE;
++
+ prepare_ibc(vcpu, vsie_page);
+ rc = shadow_crycb(vcpu, vsie_page);
+ out:
+
diff --git a/patches.arch/kvm-s390-tracing-apcb-changes.patch b/patches.arch/kvm-s390-tracing-apcb-changes.patch
new file mode 100644
index 0000000000..6cdb1cf0a9
--- /dev/null
+++ b/patches.arch/kvm-s390-tracing-apcb-changes.patch
@@ -0,0 +1,96 @@
+From: Pierre Morel <pmorel@linux.ibm.com>
+Date: Fri, 5 Oct 2018 10:31:09 +0200
+Subject: KVM: s390: Tracing APCB changes
+Git-commit: 0e237e44699465139c07f969b051f83066a2ec1d
+Patch-mainline: v4.20-rc1
+References: jsc#SLE-6412
+
+kvm_arch_crypto_set_masks is a new function to centralize
+the setup the APCB masks inside the CRYCB SIE satellite.
+
+To trace APCB mask changes, we add KVM_EVENT() tracing to
+both kvm_arch_crypto_set_masks and kvm_arch_crypto_clear_masks.
+
+Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
+Message-Id: <1538728270-10340-2-git-send-email-pmorel@linux.ibm.com>
+Reviewed-by: Cornelia Huck <cohuck@redhat.com>
+Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
+Signed-off-by: Bruce Rogers <brogers@suse.com>
+---
+ arch/s390/include/asm/kvm_host.h | 2 ++
+ arch/s390/kvm/kvm-s390.c | 41 ++++++++++++++++++++++++++++++++++++++++
+ 2 files changed, 43 insertions(+)
+
+diff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_host.h
+index ecc3017d68b6..96816da2b8fd 100644
+--- a/arch/s390/include/asm/kvm_host.h
++++ b/arch/s390/include/asm/kvm_host.h
+@@ -873,6 +873,8 @@ void kvm_arch_async_page_present(struct kvm_vcpu *vcpu,
+ struct kvm_async_pf *work);
+
+ void kvm_arch_crypto_clear_masks(struct kvm *kvm);
++void kvm_arch_crypto_set_masks(struct kvm *kvm, unsigned long *apm,
++ unsigned long *aqm, unsigned long *adm);
+
+ extern int sie64a(struct kvm_s390_sie_block *, u64 *);
+ extern char sie_exit;
+diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
+index 26d540b91e73..d4d46154cd22 100644
+--- a/arch/s390/kvm/kvm-s390.c
++++ b/arch/s390/kvm/kvm-s390.c
+@@ -2014,6 +2014,46 @@ static void kvm_s390_set_crycb_format(struct kvm *kvm)
+ kvm->arch.crypto.crycbd |= CRYCB_FORMAT1;
+ }
+
++void kvm_arch_crypto_set_masks(struct kvm *kvm, unsigned long *apm,
++ unsigned long *aqm, unsigned long *adm)
++{
++ struct kvm_s390_crypto_cb *crycb = kvm->arch.crypto.crycb;
++
++ mutex_lock(&kvm->lock);
++ kvm_s390_vcpu_block_all(kvm);
++
++ switch (kvm->arch.crypto.crycbd & CRYCB_FORMAT_MASK) {
++ case CRYCB_FORMAT2: /* APCB1 use 256 bits */
++ memcpy(crycb->apcb1.apm, apm, 32);
++ VM_EVENT(kvm, 3, "SET CRYCB: apm %016lx %016lx %016lx %016lx",
++ apm[0], apm[1], apm[2], apm[3]);
++ memcpy(crycb->apcb1.aqm, aqm, 32);
++ VM_EVENT(kvm, 3, "SET CRYCB: aqm %016lx %016lx %016lx %016lx",
++ aqm[0], aqm[1], aqm[2], aqm[3]);
++ memcpy(crycb->apcb1.adm, adm, 32);
++ VM_EVENT(kvm, 3, "SET CRYCB: adm %016lx %016lx %016lx %016lx",
++ adm[0], adm[1], adm[2], adm[3]);
++ break;
++ case CRYCB_FORMAT1:
++ case CRYCB_FORMAT0: /* Fall through both use APCB0 */
++ memcpy(crycb->apcb0.apm, apm, 8);
++ memcpy(crycb->apcb0.aqm, aqm, 2);
++ memcpy(crycb->apcb0.adm, adm, 2);
++ VM_EVENT(kvm, 3, "SET CRYCB: apm %016lx aqm %04x adm %04x",
++ apm[0], *((unsigned short *)aqm),
++ *((unsigned short *)adm));
++ break;
++ default: /* Can not happen */
++ break;
++ }
++
++ /* recreate the shadow crycb for each vcpu */
++ kvm_s390_sync_request_broadcast(kvm, KVM_REQ_VSIE_RESTART);
++ kvm_s390_vcpu_unblock_all(kvm);
++ mutex_unlock(&kvm->lock);
++}
++EXPORT_SYMBOL_GPL(kvm_arch_crypto_set_masks);
++
+ void kvm_arch_crypto_clear_masks(struct kvm *kvm)
+ {
+ mutex_lock(&kvm->lock);
+@@ -2024,6 +2064,7 @@ void kvm_arch_crypto_clear_masks(struct kvm *kvm)
+ memset(&kvm->arch.crypto.crycb->apcb1, 0,
+ sizeof(kvm->arch.crypto.crycb->apcb1));
+
++ VM_EVENT(kvm, 3, "%s", "CLR CRYCB:");
+ /* recreate the shadow crycb for each vcpu */
+ kvm_s390_sync_request_broadcast(kvm, KVM_REQ_VSIE_RESTART);
+ kvm_s390_vcpu_unblock_all(kvm);
+
diff --git a/patches.arch/kvm-s390-unregister-debug-feature-on-failing-arch-init.patch b/patches.arch/kvm-s390-unregister-debug-feature-on-failing-arch-init.patch
new file mode 100644
index 0000000000..f4a2f0b8cc
--- /dev/null
+++ b/patches.arch/kvm-s390-unregister-debug-feature-on-failing-arch-init.patch
@@ -0,0 +1,63 @@
+From: Michael Mueller <mimu@linux.ibm.com>
+Date: Fri, 30 Nov 2018 15:32:06 +0100
+Subject: KVM: s390: unregister debug feature on failing arch init
+Git-commit: 308c3e6673b012beecb96ef04cc65f4a0e7cdd99
+Patch-mainline: v5.0-rc1
+References: jsc#SLE-6412
+
+Make sure the debug feature and its allocated resources get
+released upon unsuccessful architecture initialization.
+
+A related indication of the issue will be reported as kernel
+message.
+
+Signed-off-by: Michael Mueller <mimu@linux.ibm.com>
+Reviewed-by: Cornelia Huck <cohuck@redhat.com>
+Reviewed-by: Pierre Morel <pmorel@linux.ibm.com>
+Reviewed-by: David Hildenbrand <david@redhat.com>
+Message-Id: <20181130143215.69496-2-mimu@linux.ibm.com>
+Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
+Signed-off-by: Bruce Rogers <brogers@suse.com>
+---
+ arch/s390/kvm/kvm-s390.c | 17 ++++++++++++++---
+ 1 file changed, 14 insertions(+), 3 deletions(-)
+
+diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
+index d4d46154cd22..72370a0229c0 100644
+--- a/arch/s390/kvm/kvm-s390.c
++++ b/arch/s390/kvm/kvm-s390.c
+@@ -423,19 +423,30 @@ static void kvm_s390_cpu_feat_init(void)
+
+ int kvm_arch_init(void *opaque)
+ {
++ int rc;
++
+ kvm_s390_dbf = debug_register("kvm-trace", 32, 1, 7 * sizeof(long));
+ if (!kvm_s390_dbf)
+ return -ENOMEM;
+
+ if (debug_register_view(kvm_s390_dbf, &debug_sprintf_view)) {
+- debug_unregister(kvm_s390_dbf);
+- return -ENOMEM;
++ rc = -ENOMEM;
++ goto out_debug_unreg;
+ }
+
+ kvm_s390_cpu_feat_init();
+
+ /* Register floating interrupt controller interface. */
+- return kvm_register_device_ops(&kvm_flic_ops, KVM_DEV_TYPE_FLIC);
++ rc = kvm_register_device_ops(&kvm_flic_ops, KVM_DEV_TYPE_FLIC);
++ if (rc) {
++ pr_err("Failed to register FLIC rc=%d\n", rc);
++ goto out_debug_unreg;
++ }
++ return 0;
++
++out_debug_unreg:
++ debug_unregister(kvm_s390_dbf);
++ return rc;
+ }
+
+ void kvm_arch_exit(void)
+
diff --git a/patches.arch/kvm-s390-use-switch-vs-jump-table-in-intercept-c.patch b/patches.arch/kvm-s390-use-switch-vs-jump-table-in-intercept-c.patch
new file mode 100644
index 0000000000..84197cee23
--- /dev/null
+++ b/patches.arch/kvm-s390-use-switch-vs-jump-table-in-intercept-c.patch
@@ -0,0 +1,113 @@
+From: Christian Borntraeger <borntraeger@de.ibm.com>
+Date: Tue, 6 Feb 2018 10:19:28 +0000
+Subject: KVM: s390: use switch vs jump table in intercept.c
+Git-commit: cb7485da3ed1ac4ef6c71d4b2b715f8b87f118c8
+Patch-mainline: v4.16-rc4
+References: jsc#SLE-6412
+
+Instead of having huge jump tables for function selection,
+let's use normal switch/case statements for the instruction
+handlers in intercept.c We can now also get rid of
+intercept_handler_t.
+
+This allows the compiler to make the right decision depending
+on the situation (e.g. avoid jump-tables for thunks).
+
+Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
+Reviewed-by: Janosch Frank <frankja@linux.vnet.ibm.com>
+Reviewed-by: David Hildenbrand <david@redhat.com>
+Reviewed-by: Cornelia Huck <cohuck@redhat.com>
+Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
+Signed-off-by: Bruce Rogers <brogers@suse.com>
+---
+ arch/s390/kvm/intercept.c | 51 +++++++++++++++++++++++++++--------------------
+ arch/s390/kvm/kvm-s390.h | 2 --
+ 2 files changed, 29 insertions(+), 24 deletions(-)
+
+diff --git a/arch/s390/kvm/intercept.c b/arch/s390/kvm/intercept.c
+index 9c7d70715862..07c6e81163bf 100644
+--- a/arch/s390/kvm/intercept.c
++++ b/arch/s390/kvm/intercept.c
+@@ -22,22 +22,6 @@
+ #include "trace.h"
+ #include "trace-s390.h"
+
+-
+-static const intercept_handler_t instruction_handlers[256] = {
+- [0x01] = kvm_s390_handle_01,
+- [0x82] = kvm_s390_handle_lpsw,
+- [0x83] = kvm_s390_handle_diag,
+- [0xaa] = kvm_s390_handle_aa,
+- [0xae] = kvm_s390_handle_sigp,
+- [0xb2] = kvm_s390_handle_b2,
+- [0xb6] = kvm_s390_handle_stctl,
+- [0xb7] = kvm_s390_handle_lctl,
+- [0xb9] = kvm_s390_handle_b9,
+- [0xe3] = kvm_s390_handle_e3,
+- [0xe5] = kvm_s390_handle_e5,
+- [0xeb] = kvm_s390_handle_eb,
+-};
+-
+ u8 kvm_s390_get_ilen(struct kvm_vcpu *vcpu)
+ {
+ struct kvm_s390_sie_block *sie_block = vcpu->arch.sie_block;
+@@ -129,16 +113,39 @@ static int handle_validity(struct kvm_vcpu *vcpu)
+
+ static int handle_instruction(struct kvm_vcpu *vcpu)
+ {
+- intercept_handler_t handler;
+-
+ vcpu->stat.exit_instruction++;
+ trace_kvm_s390_intercept_instruction(vcpu,
+ vcpu->arch.sie_block->ipa,
+ vcpu->arch.sie_block->ipb);
+- handler = instruction_handlers[vcpu->arch.sie_block->ipa >> 8];
+- if (handler)
+- return handler(vcpu);
+- return -EOPNOTSUPP;
++
++ switch (vcpu->arch.sie_block->ipa >> 8) {
++ case 0x01:
++ return kvm_s390_handle_01(vcpu);
++ case 0x82:
++ return kvm_s390_handle_lpsw(vcpu);
++ case 0x83:
++ return kvm_s390_handle_diag(vcpu);
++ case 0xaa:
++ return kvm_s390_handle_aa(vcpu);
++ case 0xae:
++ return kvm_s390_handle_sigp(vcpu);
++ case 0xb2:
++ return kvm_s390_handle_b2(vcpu);
++ case 0xb6:
++ return kvm_s390_handle_stctl(vcpu);
++ case 0xb7:
++ return kvm_s390_handle_lctl(vcpu);
++ case 0xb9:
++ return kvm_s390_handle_b9(vcpu);
++ case 0xe3:
++ return kvm_s390_handle_e3(vcpu);
++ case 0xe5:
++ return kvm_s390_handle_e5(vcpu);
++ case 0xeb:
++ return kvm_s390_handle_eb(vcpu);
++ default:
++ return -EOPNOTSUPP;
++ }
+ }
+
+ static int inject_prog_on_prog_intercept(struct kvm_vcpu *vcpu)
+diff --git a/arch/s390/kvm/kvm-s390.h b/arch/s390/kvm/kvm-s390.h
+index 0dc992011f48..79b720887cb0 100644
+--- a/arch/s390/kvm/kvm-s390.h
++++ b/arch/s390/kvm/kvm-s390.h
+@@ -19,8 +19,6 @@
+ #include <asm/processor.h>
+ #include <asm/sclp.h>
+
+-typedef int (*intercept_handler_t)(struct kvm_vcpu *vcpu);
+-
+ /* Transactional Memory Execution related macros */
+ #define IS_TE_ENABLED(vcpu) ((vcpu->arch.sie_block->ecb & ECB_TE))
+ #define TDB_FORMAT1 1
+
diff --git a/patches.arch/kvm-s390-use-switch-vs-jump-table-in-interrupt-c.patch b/patches.arch/kvm-s390-use-switch-vs-jump-table-in-interrupt-c.patch
new file mode 100644
index 0000000000..92b4e277bc
--- /dev/null
+++ b/patches.arch/kvm-s390-use-switch-vs-jump-table-in-interrupt-c.patch
@@ -0,0 +1,138 @@
+From: David Hildenbrand <david@redhat.com>
+Date: Tue, 6 Feb 2018 15:17:43 +0100
+Subject: KVM: s390: use switch vs jump table in interrupt.c
+Git-commit: baabee67f4135e3de87bc874929ac50637aacb0d
+Patch-mainline: v4.16-rc4
+References: jsc#SLE-6412
+
+Just like for the interception handlers, let's also use a switch-case
+in our interrupt delivery code.
+
+Signed-off-by: David Hildenbrand <david@redhat.com>
+Message-Id: <20180206141743.24497-1-david@redhat.com>
+Reviewed-by: Cornelia Huck <cohuck@redhat.com>
+Reviewed-by: Janosch Frank <frankja@linux.vnet.ibm.com>
+Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
+Signed-off-by: Bruce Rogers <brogers@suse.com>
+---
+ arch/s390/kvm/interrupt.c | 84 ++++++++++++++++++++++++++++-------------------
+ 1 file changed, 50 insertions(+), 34 deletions(-)
+
+diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c
+index 9c1837d27d69..3d36c088a13d 100644
+--- a/arch/s390/kvm/interrupt.c
++++ b/arch/s390/kvm/interrupt.c
+@@ -194,12 +194,6 @@ static int cpu_timer_irq_pending(struct kvm_vcpu *vcpu)
+ return kvm_s390_get_cpu_timer(vcpu) >> 63;
+ }
+
+-static inline int is_ioirq(unsigned long irq_type)
+-{
+- return ((irq_type >= IRQ_PEND_IO_ISC_7) &&
+- (irq_type <= IRQ_PEND_IO_ISC_0));
+-}
+-
+ static uint64_t isc_to_isc_bits(int isc)
+ {
+ return (0x80 >> isc) << 24;
+@@ -1028,24 +1022,6 @@ static int __must_check __deliver_io(struct kvm_vcpu *vcpu,
+ return rc;
+ }
+
+-typedef int (*deliver_irq_t)(struct kvm_vcpu *vcpu);
+-
+-static const deliver_irq_t deliver_irq_funcs[] = {
+- [IRQ_PEND_MCHK_EX] = __deliver_machine_check,
+- [IRQ_PEND_MCHK_REP] = __deliver_machine_check,
+- [IRQ_PEND_PROG] = __deliver_prog,
+- [IRQ_PEND_EXT_EMERGENCY] = __deliver_emergency_signal,
+- [IRQ_PEND_EXT_EXTERNAL] = __deliver_external_call,
+- [IRQ_PEND_EXT_CLOCK_COMP] = __deliver_ckc,
+- [IRQ_PEND_EXT_CPU_TIMER] = __deliver_cpu_timer,
+- [IRQ_PEND_RESTART] = __deliver_restart,
+- [IRQ_PEND_SET_PREFIX] = __deliver_set_prefix,
+- [IRQ_PEND_PFAULT_INIT] = __deliver_pfault_init,
+- [IRQ_PEND_EXT_SERVICE] = __deliver_service,
+- [IRQ_PEND_PFAULT_DONE] = __deliver_pfault_done,
+- [IRQ_PEND_VIRTIO] = __deliver_virtio,
+-};
+-
+ /* Check whether an external call is pending (deliverable or not) */
+ int kvm_s390_ext_call_pending(struct kvm_vcpu *vcpu)
+ {
+@@ -1215,7 +1191,6 @@ void kvm_s390_clear_local_irqs(struct kvm_vcpu *vcpu)
+ int __must_check kvm_s390_deliver_pending_interrupts(struct kvm_vcpu *vcpu)
+ {
+ struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
+- deliver_irq_t func;
+ int rc = 0;
+ unsigned long irq_type;
+ unsigned long irqs;
+@@ -1235,16 +1210,57 @@ int __must_check kvm_s390_deliver_pending_interrupts(struct kvm_vcpu *vcpu)
+ while ((irqs = deliverable_irqs(vcpu)) && !rc) {
+ /* bits are in the reverse order of interrupt priority */
+ irq_type = find_last_bit(&irqs, IRQ_PEND_COUNT);
+- if (is_ioirq(irq_type)) {
++ switch (irq_type) {
++ case IRQ_PEND_IO_ISC_0:
++ case IRQ_PEND_IO_ISC_1:
++ case IRQ_PEND_IO_ISC_2:
++ case IRQ_PEND_IO_ISC_3:
++ case IRQ_PEND_IO_ISC_4:
++ case IRQ_PEND_IO_ISC_5:
++ case IRQ_PEND_IO_ISC_6:
++ case IRQ_PEND_IO_ISC_7:
+ rc = __deliver_io(vcpu, irq_type);
+- } else {
+- func = deliver_irq_funcs[irq_type];
+- if (!func) {
+- WARN_ON_ONCE(func == NULL);
+- clear_bit(irq_type, &li->pending_irqs);
+- continue;
+- }
+- rc = func(vcpu);
++ break;
++ case IRQ_PEND_MCHK_EX:
++ case IRQ_PEND_MCHK_REP:
++ rc = __deliver_machine_check(vcpu);
++ break;
++ case IRQ_PEND_PROG:
++ rc = __deliver_prog(vcpu);
++ break;
++ case IRQ_PEND_EXT_EMERGENCY:
++ rc = __deliver_emergency_signal(vcpu);
++ break;
++ case IRQ_PEND_EXT_EXTERNAL:
++ rc = __deliver_external_call(vcpu);
++ break;
++ case IRQ_PEND_EXT_CLOCK_COMP:
++ rc = __deliver_ckc(vcpu);
++ break;
++ case IRQ_PEND_EXT_CPU_TIMER:
++ rc = __deliver_cpu_timer(vcpu);
++ break;
++ case IRQ_PEND_RESTART:
++ rc = __deliver_restart(vcpu);
++ break;
++ case IRQ_PEND_SET_PREFIX:
++ rc = __deliver_set_prefix(vcpu);
++ break;
++ case IRQ_PEND_PFAULT_INIT:
++ rc = __deliver_pfault_init(vcpu);
++ break;
++ case IRQ_PEND_EXT_SERVICE:
++ rc = __deliver_service(vcpu);
++ break;
++ case IRQ_PEND_PFAULT_DONE:
++ rc = __deliver_pfault_done(vcpu);
++ break;
++ case IRQ_PEND_VIRTIO:
++ rc = __deliver_virtio(vcpu);
++ break;
++ default:
++ WARN_ONCE(1, "Unknown pending irq type %ld", irq_type);
++ clear_bit(irq_type, &li->pending_irqs);
+ }
+ }
+
+
diff --git a/patches.arch/kvm-s390-use-switch-vs-jump-table-in-priv-c.patch b/patches.arch/kvm-s390-use-switch-vs-jump-table-in-priv-c.patch
new file mode 100644
index 0000000000..3ca4d64b3f
--- /dev/null
+++ b/patches.arch/kvm-s390-use-switch-vs-jump-table-in-priv-c.patch
@@ -0,0 +1,254 @@
+From: Christian Borntraeger <borntraeger@de.ibm.com>
+Date: Fri, 8 Apr 2016 17:52:39 +0200
+Subject: KVM: s390: use switch vs jump table in priv.c
+Git-commit: 6db4263fec9e550e0cdaed732f4af77a44c10f5f
+Patch-mainline: v4.16-rc4
+References: jsc#SLE-6412
+
+Instead of having huge jump tables for function selection,
+let's use normal switch/case statements for the instruction
+handlers in priv.c
+
+This allows the compiler to make the right decision depending
+on the situation (e.g. avoid jump-tables for thunks).
+
+Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
+Reviewed-by: Cornelia Huck <cohuck@redhat.com>
+Reviewed-by: Janosch Frank <frankja@linux.vnet.ibm.com>
+Reviewed-by: David Hildenbrand <david@redhat.com>
+Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
+Signed-off-by: Bruce Rogers <brogers@suse.com>
+---
+ arch/s390/kvm/priv.c | 183 +++++++++++++++++++++++++--------------------------
+ 1 file changed, 91 insertions(+), 92 deletions(-)
+
+diff --git a/arch/s390/kvm/priv.c b/arch/s390/kvm/priv.c
+index 0af614773c57..c05c28a61de2 100644
+--- a/arch/s390/kvm/priv.c
++++ b/arch/s390/kvm/priv.c
+@@ -834,55 +834,60 @@ static int handle_stsi(struct kvm_vcpu *vcpu)
+ return rc;
+ }
+
+-static const intercept_handler_t b2_handlers[256] = {
+- [0x02] = handle_stidp,
+- [0x04] = handle_set_clock,
+- [0x10] = handle_set_prefix,
+- [0x11] = handle_store_prefix,
+- [0x12] = handle_store_cpu_address,
+- [0x14] = kvm_s390_handle_vsie,
+- [0x21] = handle_ipte_interlock,
+- [0x29] = handle_iske,
+- [0x2a] = handle_rrbe,
+- [0x2b] = handle_sske,
+- [0x2c] = handle_test_block,
+- [0x30] = handle_io_inst,
+- [0x31] = handle_io_inst,
+- [0x32] = handle_io_inst,
+- [0x33] = handle_io_inst,
+- [0x34] = handle_io_inst,
+- [0x35] = handle_io_inst,
+- [0x36] = handle_io_inst,
+- [0x37] = handle_io_inst,
+- [0x38] = handle_io_inst,
+- [0x39] = handle_io_inst,
+- [0x3a] = handle_io_inst,
+- [0x3b] = handle_io_inst,
+- [0x3c] = handle_io_inst,
+- [0x50] = handle_ipte_interlock,
+- [0x56] = handle_sthyi,
+- [0x5f] = handle_io_inst,
+- [0x74] = handle_io_inst,
+- [0x76] = handle_io_inst,
+- [0x7d] = handle_stsi,
+- [0xb1] = handle_stfl,
+- [0xb2] = handle_lpswe,
+-};
+-
+ int kvm_s390_handle_b2(struct kvm_vcpu *vcpu)
+ {
+- intercept_handler_t handler;
+-
+- /*
+- * A lot of B2 instructions are priviledged. Here we check for
+- * the privileged ones, that we can handle in the kernel.
+- * Anything else goes to userspace.
+- */
+- handler = b2_handlers[vcpu->arch.sie_block->ipa & 0x00ff];
+- if (handler)
+- return handler(vcpu);
+-
+- return -EOPNOTSUPP;
++ switch (vcpu->arch.sie_block->ipa & 0x00ff) {
++ case 0x02:
++ return handle_stidp(vcpu);
++ case 0x04:
++ return handle_set_clock(vcpu);
++ case 0x10:
++ return handle_set_prefix(vcpu);
++ case 0x11:
++ return handle_store_prefix(vcpu);
++ case 0x12:
++ return handle_store_cpu_address(vcpu);
++ case 0x14:
++ return kvm_s390_handle_vsie(vcpu);
++ case 0x21:
++ case 0x50:
++ return handle_ipte_interlock(vcpu);
++ case 0x29:
++ return handle_iske(vcpu);
++ case 0x2a:
++ return handle_rrbe(vcpu);
++ case 0x2b:
++ return handle_sske(vcpu);
++ case 0x2c:
++ return handle_test_block(vcpu);
++ case 0x30:
++ case 0x31:
++ case 0x32:
++ case 0x33:
++ case 0x34:
++ case 0x35:
++ case 0x36:
++ case 0x37:
++ case 0x38:
++ case 0x39:
++ case 0x3a:
++ case 0x3b:
++ case 0x3c:
++ case 0x5f:
++ case 0x74:
++ case 0x76:
++ return handle_io_inst(vcpu);
++ case 0x56:
++ return handle_sthyi(vcpu);
++ case 0x7d:
++ return handle_stsi(vcpu);
++ case 0xb1:
++ return handle_stfl(vcpu);
++ case 0xb2:
++ return handle_lpswe(vcpu);
++ default:
++ return -EOPNOTSUPP;
++ }
+ }
+
+ static int handle_epsw(struct kvm_vcpu *vcpu)
+@@ -1153,25 +1158,22 @@ static int handle_essa(struct kvm_vcpu *vcpu)
+ return 0;
+ }
+
+-static const intercept_handler_t b9_handlers[256] = {
+- [0x8a] = handle_ipte_interlock,
+- [0x8d] = handle_epsw,
+- [0x8e] = handle_ipte_interlock,
+- [0x8f] = handle_ipte_interlock,
+- [0xab] = handle_essa,
+- [0xaf] = handle_pfmf,
+-};
+-
+ int kvm_s390_handle_b9(struct kvm_vcpu *vcpu)
+ {
+- intercept_handler_t handler;
+-
+- /* This is handled just as for the B2 instructions. */
+- handler = b9_handlers[vcpu->arch.sie_block->ipa & 0x00ff];
+- if (handler)
+- return handler(vcpu);
+-
+- return -EOPNOTSUPP;
++ switch (vcpu->arch.sie_block->ipa & 0x00ff) {
++ case 0x8a:
++ case 0x8e:
++ case 0x8f:
++ return handle_ipte_interlock(vcpu);
++ case 0x8d:
++ return handle_epsw(vcpu);
++ case 0xab:
++ return handle_essa(vcpu);
++ case 0xaf:
++ return handle_pfmf(vcpu);
++ default:
++ return -EOPNOTSUPP;
++ }
+ }
+
+ int kvm_s390_handle_lctl(struct kvm_vcpu *vcpu)
+@@ -1319,22 +1321,20 @@ static int handle_stctg(struct kvm_vcpu *vcpu)
+ return rc ? kvm_s390_inject_prog_cond(vcpu, rc) : 0;
+ }
+
+-static const intercept_handler_t eb_handlers[256] = {
+- [0x2f] = handle_lctlg,
+- [0x25] = handle_stctg,
+- [0x60] = handle_ri,
+- [0x61] = handle_ri,
+- [0x62] = handle_ri,
+-};
+-
+ int kvm_s390_handle_eb(struct kvm_vcpu *vcpu)
+ {
+- intercept_handler_t handler;
+-
+- handler = eb_handlers[vcpu->arch.sie_block->ipb & 0xff];
+- if (handler)
+- return handler(vcpu);
+- return -EOPNOTSUPP;
++ switch (vcpu->arch.sie_block->ipb & 0x000000ff) {
++ case 0x25:
++ return handle_stctg(vcpu);
++ case 0x2f:
++ return handle_lctlg(vcpu);
++ case 0x60:
++ case 0x61:
++ case 0x62:
++ return handle_ri(vcpu);
++ default:
++ return -EOPNOTSUPP;
++ }
+ }
+
+ static int handle_tprot(struct kvm_vcpu *vcpu)
+@@ -1394,10 +1394,12 @@ static int handle_tprot(struct kvm_vcpu *vcpu)
+
+ int kvm_s390_handle_e5(struct kvm_vcpu *vcpu)
+ {
+- /* For e5xx... instructions we only handle TPROT */
+- if ((vcpu->arch.sie_block->ipa & 0x00ff) == 0x01)
++ switch (vcpu->arch.sie_block->ipa & 0x00ff) {
++ case 0x01:
+ return handle_tprot(vcpu);
+- return -EOPNOTSUPP;
++ default:
++ return -EOPNOTSUPP;
++ }
+ }
+
+ static int handle_sckpf(struct kvm_vcpu *vcpu)
+@@ -1428,17 +1430,14 @@ static int handle_ptff(struct kvm_vcpu *vcpu)
+ return 0;
+ }
+
+-static const intercept_handler_t x01_handlers[256] = {
+- [0x04] = handle_ptff,
+- [0x07] = handle_sckpf,
+-};
+-
+ int kvm_s390_handle_01(struct kvm_vcpu *vcpu)
+ {
+- intercept_handler_t handler;
+-
+- handler = x01_handlers[vcpu->arch.sie_block->ipa & 0x00ff];
+- if (handler)
+- return handler(vcpu);
+- return -EOPNOTSUPP;
++ switch (vcpu->arch.sie_block->ipa & 0x00ff) {
++ case 0x04:
++ return handle_ptff(vcpu);
++ case 0x07:
++ return handle_sckpf(vcpu);
++ default:
++ return -EOPNOTSUPP;
++ }
+ }
+
diff --git a/patches.arch/kvm-s390-vsie-avoid-sparse-warning.patch b/patches.arch/kvm-s390-vsie-avoid-sparse-warning.patch
new file mode 100644
index 0000000000..25be2fac88
--- /dev/null
+++ b/patches.arch/kvm-s390-vsie-avoid-sparse-warning.patch
@@ -0,0 +1,32 @@
+From: Christian Borntraeger <borntraeger@de.ibm.com>
+Date: Mon, 16 Jul 2018 10:34:28 +0200
+Subject: KVM: s390/vsie: avoid sparse warning
+Git-commit: 63747bf73cf329d4bce9087067042241c5330a4a
+Patch-mainline: v4.19-rc1
+References: jsc#SLE-6412
+
+This is a non-functional change that avoids
+arch/s390/kvm/vsie.c:839:25: warning: context imbalance in 'do_vsie_run' - unexpected unlock
+
+Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
+Reviewed-by: David Hildenbrand <david@redhat.com>
+Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
+Signed-off-by: Bruce Rogers <brogers@suse.com>
+---
+ arch/s390/kvm/vsie.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/arch/s390/kvm/vsie.c b/arch/s390/kvm/vsie.c
+index 16c05b39977e..901e0bc5ae23 100644
+--- a/arch/s390/kvm/vsie.c
++++ b/arch/s390/kvm/vsie.c
+@@ -985,6 +985,8 @@ static int handle_stfle(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
+ * - < 0 if an error occurred
+ */
+ static int do_vsie_run(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
++ __releases(vcpu->kvm->srcu)
++ __acquires(vcpu->kvm->srcu)
+ {
+ struct kvm_s390_sie_block *scb_s = &vsie_page->scb_s;
+ struct kvm_s390_sie_block *scb_o = vsie_page->scb_o;
+
diff --git a/patches.arch/kvm-s390-vsie-simplify-8k-address-checks.patch b/patches.arch/kvm-s390-vsie-simplify-8k-address-checks.patch
new file mode 100644
index 0000000000..447974432e
--- /dev/null
+++ b/patches.arch/kvm-s390-vsie-simplify-8k-address-checks.patch
@@ -0,0 +1,69 @@
+From: David Hildenbrand <david@redhat.com>
+Date: Wed, 9 May 2018 16:12:18 +0200
+Subject: KVM: s390: vsie: simplify < 8k address checks
+Git-commit: 2c8180e885c1b2844a24dcaf4a675972b8ce8edc
+Patch-mainline: v4.18-rc1
+References: jsc#SLE-6412
+
+This makes it certainly more readable.
+
+Signed-off-by: David Hildenbrand <david@redhat.com>
+Reviewed-by: Cornelia Huck <cohuck@redhat.com>
+Reviewed-by: Janosch Frank <frankja@linux.ibm.com>
+Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
+Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
+Signed-off-by: Bruce Rogers <brogers@suse.com>
+---
+ arch/s390/kvm/vsie.c | 10 +++++-----
+ 1 file changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/arch/s390/kvm/vsie.c b/arch/s390/kvm/vsie.c
+index b3f135354d5e..16c05b39977e 100644
+--- a/arch/s390/kvm/vsie.c
++++ b/arch/s390/kvm/vsie.c
+@@ -723,7 +723,7 @@ static int pin_blocks(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
+ if (test_kvm_cpu_feat(vcpu->kvm, KVM_S390_VM_CPU_FEAT_64BSCAO))
+ gpa |= (u64) READ_ONCE(scb_o->scaoh) << 32;
+ if (gpa) {
+- if (!(gpa & ~0x1fffUL))
++ if (gpa < 2 * PAGE_SIZE)
+ rc = set_validity_icpt(scb_s, 0x0038U);
+ else if ((gpa & ~0x1fffUL) == kvm_s390_get_prefix(vcpu))
+ rc = set_validity_icpt(scb_s, 0x0011U);
+@@ -744,7 +744,7 @@ static int pin_blocks(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
+
+ gpa = READ_ONCE(scb_o->itdba) & ~0xffUL;
+ if (gpa && (scb_s->ecb & ECB_TE)) {
+- if (!(gpa & ~0x1fffUL)) {
++ if (gpa < 2 * PAGE_SIZE) {
+ rc = set_validity_icpt(scb_s, 0x0080U);
+ goto unpin;
+ }
+@@ -760,7 +760,7 @@ static int pin_blocks(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
+
+ gpa = READ_ONCE(scb_o->gvrd) & ~0x1ffUL;
+ if (gpa && (scb_s->eca & ECA_VX) && !(scb_s->ecd & ECD_HOSTREGMGMT)) {
+- if (!(gpa & ~0x1fffUL)) {
++ if (gpa < 2 * PAGE_SIZE) {
+ rc = set_validity_icpt(scb_s, 0x1310U);
+ goto unpin;
+ }
+@@ -779,7 +779,7 @@ static int pin_blocks(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
+
+ gpa = READ_ONCE(scb_o->riccbd) & ~0x3fUL;
+ if (gpa && (scb_s->ecb3 & ECB3_RI)) {
+- if (!(gpa & ~0x1fffUL)) {
++ if (gpa < 2 * PAGE_SIZE) {
+ rc = set_validity_icpt(scb_s, 0x0043U);
+ goto unpin;
+ }
+@@ -799,7 +799,7 @@ static int pin_blocks(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
+
+ gpa = READ_ONCE(scb_o->sdnxo) & ~0xfUL;
+ sdnxc = READ_ONCE(scb_o->sdnxo) & 0xfUL;
+- if (!gpa || !(gpa & ~0x1fffUL)) {
++ if (!gpa || gpa < 2 * PAGE_SIZE) {
+ rc = set_validity_icpt(scb_s, 0x10b0U);
+ goto unpin;
+ }
+
diff --git a/patches.arch/kvm-s390-vsie-store-guest-addresses-of-satellite-blocks-in-vsie_page.patch b/patches.arch/kvm-s390-vsie-store-guest-addresses-of-satellite-blocks-in-vsie_page.patch
new file mode 100644
index 0000000000..d0be37ab5b
--- /dev/null
+++ b/patches.arch/kvm-s390-vsie-store-guest-addresses-of-satellite-blocks-in-vsie_page.patch
@@ -0,0 +1,139 @@
+From: David Hildenbrand <david@redhat.com>
+Date: Tue, 16 Jan 2018 18:15:26 +0100
+Subject: KVM: s390: vsie: store guest addresses of satellite blocks in
+ vsie_page
+Git-commit: 15e5020e575d0c1a4eddd99bf7ffdc1f34a3b17d
+Patch-mainline: v4.16-rc1
+References: jsc#SLE-6412
+
+This way, the values cannot change, even if another VCPU might try to
+mess with the nested SCB currently getting executed by another VCPU.
+
+We now always use the same gpa for pinning and unpinning a page (for
+unpinning, it is only relevant to mark the guest page dirty for
+migration).
+
+Signed-off-by: David Hildenbrand <david@redhat.com>
+Message-Id: <20180116171526.12343-3-david@redhat.com>
+Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
+Acked-by: Cornelia Huck <cohuck@redhat.com>
+Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
+Signed-off-by: Bruce Rogers <brogers@suse.com>
+---
+ arch/s390/kvm/vsie.c | 37 ++++++++++++++++++++++---------------
+ 1 file changed, 22 insertions(+), 15 deletions(-)
+
+--- a/arch/s390/kvm/vsie.c
++++ b/arch/s390/kvm/vsie.c
+@@ -38,7 +38,13 @@ struct vsie_page {
+ struct gmap *gmap; /* 0x0220 */
+ /* address of the last reported fault to guest2 */
+ unsigned long fault_addr; /* 0x0228 */
+- __u8 reserved[0x0700 - 0x0230]; /* 0x0230 */
++ /* calculated guest addresses of satellite control blocks */
++ gpa_t sca_gpa; /* 0x0230 */
++ gpa_t itdba_gpa; /* 0x0238 */
++ gpa_t gvrd_gpa; /* 0x0240 */
++ gpa_t riccbd_gpa; /* 0x0248 */
++ gpa_t sdnx_gpa; /* 0x0250 */
++ __u8 reserved[0x0700 - 0x0258]; /* 0x0258 */
+ struct kvm_s390_crypto_cb crycb; /* 0x0700 */
+ __u8 fac[S390_ARCH_FAC_LIST_SIZE_BYTE]; /* 0x0800 */
+ };
+@@ -485,46 +491,42 @@ static void unpin_guest_page(struct kvm
+ /* unpin all blocks previously pinned by pin_blocks(), marking them dirty */
+ static void unpin_blocks(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
+ {
+- struct kvm_s390_sie_block *scb_o = vsie_page->scb_o;
+ struct kvm_s390_sie_block *scb_s = &vsie_page->scb_s;
+ hpa_t hpa;
+- gpa_t gpa;
+
+ hpa = (u64) scb_s->scaoh << 32 | scb_s->scaol;
+ if (hpa) {
+- gpa = scb_o->scaol & ~0xfUL;
+- if (test_kvm_cpu_feat(vcpu->kvm, KVM_S390_VM_CPU_FEAT_64BSCAO))
+- gpa |= (u64) scb_o->scaoh << 32;
+- unpin_guest_page(vcpu->kvm, gpa, hpa);
++ unpin_guest_page(vcpu->kvm, vsie_page->sca_gpa, hpa);
++ vsie_page->sca_gpa = 0;
+ scb_s->scaol = 0;
+ scb_s->scaoh = 0;
+ }
+
+ hpa = scb_s->itdba;
+ if (hpa) {
+- gpa = scb_o->itdba & ~0xffUL;
+- unpin_guest_page(vcpu->kvm, gpa, hpa);
++ unpin_guest_page(vcpu->kvm, vsie_page->itdba_gpa, hpa);
++ vsie_page->itdba_gpa = 0;
+ scb_s->itdba = 0;
+ }
+
+ hpa = scb_s->gvrd;
+ if (hpa) {
+- gpa = scb_o->gvrd & ~0x1ffUL;
+- unpin_guest_page(vcpu->kvm, gpa, hpa);
++ unpin_guest_page(vcpu->kvm, vsie_page->gvrd_gpa, hpa);
++ vsie_page->gvrd_gpa = 0;
+ scb_s->gvrd = 0;
+ }
+
+ hpa = scb_s->riccbd;
+ if (hpa) {
+- gpa = scb_o->riccbd & ~0x3fUL;
+- unpin_guest_page(vcpu->kvm, gpa, hpa);
++ unpin_guest_page(vcpu->kvm, vsie_page->riccbd_gpa, hpa);
++ vsie_page->riccbd_gpa = 0;
+ scb_s->riccbd = 0;
+ }
+
+ hpa = scb_s->sdnxo;
+ if (hpa) {
+- gpa = scb_o->sdnxo;
+- unpin_guest_page(vcpu->kvm, gpa, hpa);
++ unpin_guest_page(vcpu->kvm, vsie_page->sdnx_gpa, hpa);
++ vsie_page->sdnx_gpa = 0;
+ scb_s->sdnxo = 0;
+ }
+ }
+@@ -569,6 +571,7 @@ static int pin_blocks(struct kvm_vcpu *v
+ }
+ if (rc)
+ goto unpin;
++ vsie_page->sca_gpa = gpa;
+ scb_s->scaoh = (u32)((u64)hpa >> 32);
+ scb_s->scaol = (u32)(u64)hpa;
+ }
+@@ -585,6 +588,7 @@ static int pin_blocks(struct kvm_vcpu *v
+ rc = set_validity_icpt(scb_s, 0x0080U);
+ goto unpin;
+ }
++ vsie_page->itdba_gpa = gpa;
+ scb_s->itdba = hpa;
+ }
+
+@@ -603,6 +607,7 @@ static int pin_blocks(struct kvm_vcpu *v
+ rc = set_validity_icpt(scb_s, 0x1310U);
+ goto unpin;
+ }
++ vsie_page->gvrd_gpa = gpa;
+ scb_s->gvrd = hpa;
+ }
+
+@@ -619,6 +624,7 @@ static int pin_blocks(struct kvm_vcpu *v
+ goto unpin;
+ }
+ /* Validity 0x0044 will be checked by SIE */
++ vsie_page->riccbd_gpa = gpa;
+ scb_s->riccbd = hpa;
+ }
+ if ((scb_s->ecb & ECB_GS) && !(scb_s->ecd & ECD_HOSTREGMGMT)) {
+@@ -646,6 +652,7 @@ static int pin_blocks(struct kvm_vcpu *v
+ rc = set_validity_icpt(scb_s, 0x10b0U);
+ goto unpin;
+ }
++ vsie_page->sdnx_gpa = gpa;
+ scb_s->sdnxo = hpa | sdnxc;
+ }
+ return 0;
diff --git a/patches.arch/s390-bitops-add-test_and_clear_bit_inv.patch b/patches.arch/s390-bitops-add-test_and_clear_bit_inv.patch
new file mode 100644
index 0000000000..4a2f3d3788
--- /dev/null
+++ b/patches.arch/s390-bitops-add-test_and_clear_bit_inv.patch
@@ -0,0 +1,40 @@
+From: Jens Freimann <jfrei@linux.vnet.ibm.com>
+Date: Thu, 16 Mar 2017 17:45:40 +0100
+Subject: s390/bitops: add test_and_clear_bit_inv()
+Git-commit: f3ec471a9832f8365836d70db4d52db9cc4dd6b1
+Patch-mainline: v4.16-rc1
+References: jsc#SLE-6412
+
+This patch adds a MSB0 bit numbering version of test_and_clear_bit().
+
+Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com>
+Signed-off-by: Michael Mueller <mimu@linux.vnet.ibm.com>
+Reviewed-by: Pierre Morel <pmorel@linux.vnet.ibm.com>
+Reviewed-by: Halil Pasic <pasic@linux.vnet.ibm.com>
+Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
+Reviewed-by: David Hildenbrand <david@redhat.com>
+Reviewed-by: Cornelia Huck <cohuck@redhat.com>
+Acked-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
+Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
+Signed-off-by: Bruce Rogers <brogers@suse.com>
+---
+ arch/s390/include/asm/bitops.h | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/arch/s390/include/asm/bitops.h b/arch/s390/include/asm/bitops.h
+index 99902b7b9f0c..66d7ac7dab49 100644
+--- a/arch/s390/include/asm/bitops.h
++++ b/arch/s390/include/asm/bitops.h
+@@ -260,6 +260,11 @@ static inline void clear_bit_inv(unsigned long nr, volatile unsigned long *ptr)
+ return clear_bit(nr ^ (BITS_PER_LONG - 1), ptr);
+ }
+
++static inline int test_and_clear_bit_inv(unsigned long nr, volatile unsigned long *ptr)
++{
++ return test_and_clear_bit(nr ^ (BITS_PER_LONG - 1), ptr);
++}
++
+ static inline void __set_bit_inv(unsigned long nr, volatile unsigned long *ptr)
+ {
+ return __set_bit(nr ^ (BITS_PER_LONG - 1), ptr);
+
diff --git a/patches.arch/s390-css-indicate-the-availability-of-the-aiv-facility.patch b/patches.arch/s390-css-indicate-the-availability-of-the-aiv-facility.patch
new file mode 100644
index 0000000000..128dcae6ce
--- /dev/null
+++ b/patches.arch/s390-css-indicate-the-availability-of-the-aiv-facility.patch
@@ -0,0 +1,40 @@
+From: Michael Mueller <mimu@linux.vnet.ibm.com>
+Date: Mon, 10 Jul 2017 11:03:42 +0200
+Subject: s390/css: indicate the availability of the AIV facility
+Git-commit: 72b523a30d9b9c7f749c3209e13de983aeb919c1
+Patch-mainline: v4.16-rc1
+References: jsc#SLE-6412
+
+The patch adds an indication for the presence Adapter Interruption
+Virtualization facility (AIV) of the general channel subsystem
+characteristics.
+
+Signed-off-by: Michael Mueller <mimu@linux.vnet.ibm.com>
+Reviewed-by: Halil Pasic <pasic@linux.vnet.ibm.com>
+Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
+Acked-by: Cornelia Huck <cohuck@redhat.com>
+Acked-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
+Reviewed-by: David Hildenbrand <david@redhat.com>
+Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
+[change wording]
+Signed-off-by: Bruce Rogers <brogers@suse.com>
+---
+ arch/s390/include/asm/css_chars.h | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/arch/s390/include/asm/css_chars.h b/arch/s390/include/asm/css_chars.h
+index fb331d8cda9b..8e3cabd61355 100644
+--- a/arch/s390/include/asm/css_chars.h
++++ b/arch/s390/include/asm/css_chars.h
+@@ -19,7 +19,9 @@ struct css_general_char {
+ u32 aif_tdd : 1; /* bit 56 */
+ u32 : 1;
+ u32 qebsm : 1; /* bit 58 */
+- u32 : 8;
++ u32 : 2;
++ u32 aiv : 1; /* bit 61 */
++ u32 : 5;
+ u32 aif_osa : 1; /* bit 67 */
+ u32 : 12;
+ u32 eadm_rf : 1; /* bit 80 */
+
diff --git a/patches.arch/s390-sclp-detect-dirq-facility b/patches.arch/s390-sclp-detect-dirq-facility
index 1d546e5c87..431cea6c05 100644
--- a/patches.arch/s390-sclp-detect-dirq-facility
+++ b/patches.arch/s390-sclp-detect-dirq-facility
@@ -17,9 +17,9 @@ Acked-by: Petr Tesarik <ptesarik@suse.com>
--- a/arch/s390/include/asm/sclp.h
+++ b/arch/s390/include/asm/sclp.h
-@@ -77,6 +77,7 @@ struct sclp_info {
- unsigned char has_skey : 1;
+@@ -78,6 +78,7 @@ struct sclp_info {
unsigned char has_kss : 1;
+ unsigned char has_gisaf : 1;
unsigned char has_diag318 : 1;
+ unsigned char has_dirq : 1;
unsigned int ibc;
@@ -37,7 +37,7 @@ Acked-by: Petr Tesarik <ptesarik@suse.com>
} __packed __aligned(PAGE_SIZE);
static struct sclp_ipl_info sclp_ipl_info;
-@@ -154,6 +155,7 @@ static void __init sclp_early_facilities
+@@ -155,6 +156,7 @@ static void __init sclp_early_facilities
sclp.mtid_prev = (sccb->fac42 & 0x80) ? (sccb->fac66 & 31) : 0;
sclp.hmfai = sccb->hmfai;
diff --git a/patches.arch/s390-sclp-expose-the-gisa-format-facility.patch b/patches.arch/s390-sclp-expose-the-gisa-format-facility.patch
new file mode 100644
index 0000000000..0e4a1b4cdb
--- /dev/null
+++ b/patches.arch/s390-sclp-expose-the-gisa-format-facility.patch
@@ -0,0 +1,53 @@
+From: Michael Mueller <mimu@linux.vnet.ibm.com>
+Date: Mon, 12 Jun 2017 13:49:28 +0200
+Subject: s390/sclp: expose the GISA format facility
+Git-commit: 9e73ea7056bd5f7e1b6e66e3d503478bb5160f07
+Patch-mainline: v4.16-rc1
+References: jsc#SLE-6412
+
+The GISA format facility is required by the host to be able to process
+a format-1 GISA. If not available, the used GISA format will be format-0.
+All format-1 related extension will not be available in this case.
+
+Signed-off-by: Michael Mueller <mimu@linux.vnet.ibm.com>
+Reviewed-by: Pierre Morel <pmorel@linux.vnet.ibm.com>
+Reviewed-by: Halil Pasic <pasic@linux.vnet.ibm.com>
+Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
+Acked-by: David Hildenbrand <david@redhat.com>
+Acked-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
+Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
+Signed-off-by: Bruce Rogers <brogers@suse.com>
+---
+ arch/s390/include/asm/sclp.h | 1 +
+ drivers/s390/char/sclp_early.c | 3 ++-
+ 2 files changed, 3 insertions(+), 1 deletion(-)
+
+--- a/arch/s390/include/asm/sclp.h
++++ b/arch/s390/include/asm/sclp.h
+@@ -76,6 +76,7 @@ struct sclp_info {
+ unsigned char has_ibs : 1;
+ unsigned char has_skey : 1;
+ unsigned char has_kss : 1;
++ unsigned char has_gisaf : 1;
+ unsigned int ibc;
+ unsigned int mtid;
+ unsigned int mtid_cp;
+--- a/drivers/s390/char/sclp_early.c
++++ b/drivers/s390/char/sclp_early.c
+@@ -48,7 +48,7 @@ struct read_info_sccb {
+ u8 _pad_112[116 - 112]; /* 112-115 */
+ u8 fac116; /* 116 */
+ u8 fac117; /* 117 */
+- u8 _pad_118; /* 118 */
++ u8 fac118; /* 118 */
+ u8 fac119; /* 119 */
+ u16 hcpua; /* 120-121 */
+ u8 _pad_122[124 - 122]; /* 122-123 */
+@@ -99,6 +99,7 @@ static void __init sclp_early_facilities
+ sclp.has_esca = !!(sccb->fac116 & 0x08);
+ sclp.has_pfmfi = !!(sccb->fac117 & 0x40);
+ sclp.has_ibs = !!(sccb->fac117 & 0x20);
++ sclp.has_gisaf = !!(sccb->fac118 & 0x08);
+ sclp.has_hvs = !!(sccb->fac119 & 0x80);
+ sclp.has_kss = !!(sccb->fac98 & 0x01);
+ if (sccb->fac85 & 0x02)
diff --git a/patches.arch/s390-setup-set-control-program-code-via-diag-318 b/patches.arch/s390-setup-set-control-program-code-via-diag-318
index f89c47aa38..6fe916c9a7 100644
--- a/patches.arch/s390-setup-set-control-program-code-via-diag-318
+++ b/patches.arch/s390-setup-set-control-program-code-via-diag-318
@@ -84,10 +84,10 @@ Acked-by: Petr Tesarik <ptesarik@suse.com>
int diag26c(void *req, void *resp, enum diag26c_sc subcode);
--- a/arch/s390/include/asm/sclp.h
+++ b/arch/s390/include/asm/sclp.h
-@@ -76,6 +76,7 @@ struct sclp_info {
- unsigned char has_ibs : 1;
+@@ -77,6 +77,7 @@ struct sclp_info {
unsigned char has_skey : 1;
unsigned char has_kss : 1;
+ unsigned char has_gisaf : 1;
+ unsigned char has_diag318 : 1;
unsigned int ibc;
unsigned int mtid;
@@ -151,7 +151,7 @@ Acked-by: Petr Tesarik <ptesarik@suse.com>
} __packed __aligned(PAGE_SIZE);
static struct sclp_ipl_info sclp_ipl_info;
-@@ -105,6 +107,8 @@ static void __init sclp_early_facilities
+@@ -106,6 +108,8 @@ static void __init sclp_early_facilities
S390_lowcore.machine_flags |= MACHINE_FLAG_ESOP;
if (sccb->fac91 & 0x40)
S390_lowcore.machine_flags |= MACHINE_FLAG_TLB_GUEST;
diff --git a/patches.arch/s390-sles15sp1-00-04-12-KVM-s390-Add-skey-emulation-fault-handling.patch b/patches.arch/s390-sles15sp1-00-04-12-KVM-s390-Add-skey-emulation-fault-handling.patch
index 714d062a5a..6b7fc143f9 100644
--- a/patches.arch/s390-sles15sp1-00-04-12-KVM-s390-Add-skey-emulation-fault-handling.patch
+++ b/patches.arch/s390-sles15sp1-00-04-12-KVM-s390-Add-skey-emulation-fault-handling.patch
@@ -27,7 +27,9 @@ Acked-by: Petr Tesarik <ptesarik@suse.com>
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
-@@ -1514,6 +1514,7 @@ static long kvm_s390_set_skeys(struct kv
+@@ -1549,10 +1549,11 @@ static long kvm_s390_get_skeys(struct kv
+ static long kvm_s390_set_skeys(struct kvm *kvm, struct kvm_s390_skeys *args)
+ {
uint8_t *keys;
uint64_t hva;
int srcu_idx, i, r = 0;
@@ -35,7 +37,11 @@ Acked-by: Petr Tesarik <ptesarik@suse.com>
if (args->flags != 0)
return -EINVAL;
-@@ -1538,9 +1539,11 @@ static long kvm_s390_set_skeys(struct kv
+
+ /* Enforce sane limit on memory allocation */
+@@ -1573,13 +1574,15 @@ static long kvm_s390_set_skeys(struct kv
+ /* Enable storage key handling for the guest */
+ r = s390_enable_skey();
if (r)
goto out;
@@ -48,7 +54,11 @@ Acked-by: Petr Tesarik <ptesarik@suse.com>
hva = gfn_to_hva(kvm, args->start_gfn + i);
if (kvm_is_error_hva(hva)) {
r = -EFAULT;
-@@ -1554,8 +1557,14 @@ static long kvm_s390_set_skeys(struct kv
+ break;
+ }
+@@ -1589,12 +1592,18 @@ static long kvm_s390_set_skeys(struct kv
+ r = -EINVAL;
+ break;
}
r = set_guest_storage_key(current->mm, hva, keys[i], 0);
@@ -65,9 +75,13 @@ Acked-by: Petr Tesarik <ptesarik@suse.com>
}
srcu_read_unlock(&kvm->srcu, srcu_idx);
up_read(&current->mm->mmap_sem);
+ out:
+ kvfree(keys);
--- a/arch/s390/kvm/priv.c
+++ b/arch/s390/kvm/priv.c
-@@ -247,9 +247,10 @@ static int try_handle_skey(struct kvm_vc
+@@ -245,13 +245,14 @@ static int try_handle_skey(struct kvm_vc
+ return 0;
+ }
static int handle_iske(struct kvm_vcpu *vcpu)
{
@@ -79,7 +93,11 @@ Acked-by: Petr Tesarik <ptesarik@suse.com>
int rc;
vcpu->stat.instruction_iske++;
-@@ -263,18 +264,28 @@ static int handle_iske(struct kvm_vcpu *
+
+ if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE)
+@@ -261,31 +262,42 @@ static int handle_iske(struct kvm_vcpu *
+ if (rc)
+ return rc != -EAGAIN ? rc : 0;
kvm_s390_get_regs_rre(vcpu, &reg1, &reg2);
@@ -116,7 +134,7 @@ Acked-by: Petr Tesarik <ptesarik@suse.com>
vcpu->run->s.regs.gprs[reg1] &= ~0xff;
vcpu->run->s.regs.gprs[reg1] |= key;
return 0;
-@@ -282,8 +293,9 @@ static int handle_iske(struct kvm_vcpu *
+ }
static int handle_rrbe(struct kvm_vcpu *vcpu)
{
@@ -127,7 +145,11 @@ Acked-by: Petr Tesarik <ptesarik@suse.com>
int rc;
vcpu->stat.instruction_rrbe++;
-@@ -297,19 +309,27 @@ static int handle_rrbe(struct kvm_vcpu *
+
+ if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE)
+@@ -295,23 +307,31 @@ static int handle_rrbe(struct kvm_vcpu *
+ if (rc)
+ return rc != -EAGAIN ? rc : 0;
kvm_s390_get_regs_rre(vcpu, &reg1, &reg2);
@@ -164,7 +186,11 @@ Acked-by: Petr Tesarik <ptesarik@suse.com>
kvm_s390_set_psw_cc(vcpu, rc);
return 0;
}
-@@ -324,6 +344,7 @@ static int handle_sske(struct kvm_vcpu *
+
+ #define SSKE_NQ 0x8
+@@ -322,10 +342,11 @@ static int handle_sske(struct kvm_vcpu *
+ {
+ unsigned char m3 = vcpu->arch.sie_block->ipb >> 28;
unsigned long start, end;
unsigned char key, oldkey;
int reg1, reg2;
@@ -172,7 +198,11 @@ Acked-by: Petr Tesarik <ptesarik@suse.com>
int rc;
vcpu->stat.instruction_sske++;
-@@ -356,19 +377,28 @@ static int handle_sske(struct kvm_vcpu *
+
+ if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE)
+@@ -354,23 +375,32 @@ static int handle_sske(struct kvm_vcpu *
+ start = kvm_s390_real_to_abs(vcpu, start);
+ end = start + PAGE_SIZE;
}
while (start != end) {
@@ -207,7 +237,11 @@ Acked-by: Petr Tesarik <ptesarik@suse.com>
}
if (m3 & (SSKE_MC | SSKE_MR)) {
-@@ -944,15 +974,16 @@ static int handle_pfmf(struct kvm_vcpu *
+ if (m3 & SSKE_MB) {
+ /* skey in reg1 is unpredictable */
+@@ -947,36 +977,43 @@ static int handle_pfmf(struct kvm_vcpu *
+ default:
+ return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION);
}
while (start != end) {
@@ -228,7 +262,9 @@ Acked-by: Petr Tesarik <ptesarik@suse.com>
return kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING);
}
-@@ -962,14 +993,20 @@ static int handle_pfmf(struct kvm_vcpu *
+ if (vcpu->run->s.regs.gprs[reg1] & PFMF_SK) {
+ int rc = kvm_s390_skey_check_enable(vcpu);
+
if (rc)
return rc;
down_read(&current->mm->mmap_sem);
@@ -254,3 +290,5 @@ Acked-by: Petr Tesarik <ptesarik@suse.com>
}
if (vcpu->run->s.regs.gprs[reg1] & PFMF_FSC) {
if (psw_bits(vcpu->arch.sie_block->gpsw).eaba == PSW_BITS_AMODE_64BIT) {
+ vcpu->run->s.regs.gprs[reg2] = end;
+ } else {
diff --git a/patches.arch/s390-sles15sp1-00-07-03-KVM-s390-refactor-crypto-initialization.patch b/patches.arch/s390-sles15sp1-00-07-03-KVM-s390-refactor-crypto-initialization.patch
index bb4c920b13..7ab49c9b98 100644
--- a/patches.arch/s390-sles15sp1-00-07-03-KVM-s390-refactor-crypto-initialization.patch
+++ b/patches.arch/s390-sles15sp1-00-07-03-KVM-s390-refactor-crypto-initialization.patch
@@ -43,15 +43,15 @@ Acked-by: Petr Tesarik <ptesarik@suse.com>
--- a/arch/s390/include/asm/kvm_host.h
+++ b/arch/s390/include/asm/kvm_host.h
-@@ -189,6 +189,7 @@ struct kvm_s390_sie_block {
- #define ECA_MVPGI 0x01000000
+@@ -190,6 +190,7 @@ struct kvm_s390_sie_block {
+ #define ECA_AIV 0x00200000
#define ECA_VX 0x00020000
#define ECA_PROTEXCI 0x00002000
+#define ECA_APIE 0x00000008
#define ECA_SII 0x00000001
__u32 eca; /* 0x004c */
#define ICPT_INST 0x04
-@@ -256,6 +257,7 @@ struct kvm_s390_sie_block {
+@@ -263,6 +264,7 @@ struct kvm_s390_sie_block {
__u8 reservede4[4]; /* 0x00e4 */
__u64 tecmc; /* 0x00e8 */
__u8 reservedf0[12]; /* 0x00f0 */
@@ -59,7 +59,7 @@ Acked-by: Petr Tesarik <ptesarik@suse.com>
#define CRYCB_FORMAT1 0x00000001
#define CRYCB_FORMAT2 0x00000003
__u32 crycbd; /* 0x00fc */
-@@ -699,6 +701,7 @@ struct kvm_s390_crypto {
+@@ -722,6 +724,7 @@ struct kvm_s390_crypto {
__u32 crycbd;
__u8 aes_kw;
__u8 dea_kw;
@@ -77,7 +77,7 @@ Acked-by: Petr Tesarik <ptesarik@suse.com>
#include "kvm-s390.h"
#include "gaccess.h"
-@@ -1903,49 +1904,37 @@ long kvm_arch_vm_ioctl(struct file *filp
+@@ -1936,49 +1937,37 @@ long kvm_arch_vm_ioctl(struct file *filp
return r;
}
@@ -146,7 +146,7 @@ Acked-by: Petr Tesarik <ptesarik@suse.com>
if (kvm_s390_apxa_installed())
kvm->arch.crypto.crycbd |= CRYCB_FORMAT2;
else
-@@ -1963,12 +1952,12 @@ static u64 kvm_s390_get_initial_cpuid(vo
+@@ -1996,12 +1985,12 @@ static u64 kvm_s390_get_initial_cpuid(vo
static void kvm_s390_crypto_init(struct kvm *kvm)
{
@@ -162,7 +162,7 @@ Acked-by: Petr Tesarik <ptesarik@suse.com>
/* Enable AES/DEA protected key functions by default */
kvm->arch.crypto.aes_kw = 1;
kvm->arch.crypto.dea_kw = 1;
-@@ -2496,17 +2485,24 @@ void kvm_arch_vcpu_postcreate(struct kvm
+@@ -2527,17 +2516,24 @@ void kvm_arch_vcpu_postcreate(struct kvm
static void kvm_s390_vcpu_crypto_setup(struct kvm_vcpu *vcpu)
{
diff --git a/patches.fixes/kvm-s390-add-etoken-support-for-guests.patch b/patches.fixes/kvm-s390-add-etoken-support-for-guests.patch
index ed7780857d..788db1536d 100644
--- a/patches.fixes/kvm-s390-add-etoken-support-for-guests.patch
+++ b/patches.fixes/kvm-s390-add-etoken-support-for-guests.patch
@@ -24,7 +24,7 @@ Acked-by: Johannes Thumshirn <jthumshirn@suse.de>
--- a/arch/s390/include/asm/kvm_host.h
+++ b/arch/s390/include/asm/kvm_host.h
-@@ -269,6 +269,7 @@ struct kvm_s390_sie_block {
+@@ -272,6 +272,7 @@ struct kvm_s390_sie_block {
__u8 reserved1c0[8]; /* 0x01c0 */
#define ECD_HOSTREGMGMT 0x20000000
#define ECD_MEF 0x08000000
@@ -62,7 +62,7 @@ Acked-by: Johannes Thumshirn <jthumshirn@suse.de>
};
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
-@@ -2261,6 +2261,8 @@ int kvm_arch_vcpu_init(struct kvm_vcpu *
+@@ -2353,6 +2353,8 @@ int kvm_arch_vcpu_init(struct kvm_vcpu *
vcpu->run->kvm_valid_regs |= KVM_SYNC_BPBC;
if (test_kvm_facility(vcpu->kvm, 133))
vcpu->run->kvm_valid_regs |= KVM_SYNC_GSCB;
@@ -71,7 +71,7 @@ Acked-by: Johannes Thumshirn <jthumshirn@suse.de>
/* fprs can be synchronized via vrs, even if the guest has no vx. With
* MACHINE_HAS_VX, (load|store)_fpu_regs() will work with vrs format.
*/
-@@ -2512,7 +2514,8 @@ int kvm_arch_vcpu_setup(struct kvm_vcpu
+@@ -2607,7 +2609,8 @@ int kvm_arch_vcpu_setup(struct kvm_vcpu
vcpu->arch.sie_block->sdnxo = ((unsigned long) &vcpu->run->s.regs.sdnx)
| SDNXC;
vcpu->arch.sie_block->riccbd = (unsigned long) &vcpu->run->s.regs.riccb;
@@ -81,7 +81,7 @@ Acked-by: Johannes Thumshirn <jthumshirn@suse.de>
if (sclp.has_kss)
atomic_or(CPUSTAT_KSS, &vcpu->arch.sie_block->cpuflags);
else
-@@ -3380,6 +3383,7 @@ static void sync_regs(struct kvm_vcpu *v
+@@ -3475,6 +3478,7 @@ static void sync_regs(struct kvm_vcpu *v
}
preempt_enable();
}
@@ -89,7 +89,7 @@ Acked-by: Johannes Thumshirn <jthumshirn@suse.de>
kvm_run->kvm_dirty_regs = 0;
}
-@@ -3419,7 +3423,7 @@ static void store_regs(struct kvm_vcpu *
+@@ -3514,7 +3518,7 @@ static void store_regs(struct kvm_vcpu *
__ctl_clear_bit(2, 4);
vcpu->arch.host_gscb = NULL;
}
@@ -109,7 +109,7 @@ Acked-by: Johannes Thumshirn <jthumshirn@suse.de>
*
* Author(s): David Hildenbrand <dahi@linux.vnet.ibm.com>
*/
-@@ -360,6 +360,10 @@ static int shadow_scb(struct kvm_vcpu *v
+@@ -378,6 +378,10 @@ static int shadow_scb(struct kvm_vcpu *v
if (test_kvm_facility(vcpu->kvm, 139))
scb_s->ecd |= scb_o->ecd & ECD_MEF;
@@ -120,8 +120,8 @@ Acked-by: Johannes Thumshirn <jthumshirn@suse.de>
prepare_ibc(vcpu, vsie_page);
rc = shadow_crycb(vcpu, vsie_page);
out:
-@@ -609,7 +613,8 @@ static int pin_blocks(struct kvm_vcpu *v
- /* Validity 0x0044 will be checked by SIE */
+@@ -627,7 +631,8 @@ static int pin_blocks(struct kvm_vcpu *v
+ vsie_page->riccbd_gpa = gpa;
scb_s->riccbd = hpa;
}
- if ((scb_s->ecb & ECB_GS) && !(scb_s->ecd & ECD_HOSTREGMGMT)) {
@@ -141,7 +141,7 @@ Acked-by: Johannes Thumshirn <jthumshirn@suse.de>
*
*/
-@@ -104,6 +104,7 @@ static struct facility_def facility_defs
+@@ -107,6 +107,7 @@ static struct facility_def facility_defs
.name = "FACILITIES_KVM_CPUMODEL",
.bits = (int[]){
diff --git a/series.conf b/series.conf
index b57c38e344..ba8f33373f 100644
--- a/series.conf
+++ b/series.conf
@@ -24104,9 +24104,25 @@
patches.arch/kvm-nvmx-fix-injection-to-l2-when-l1-don-t-intercept-external-interrupts
patches.arch/kvm-nvmx-fix-races-when-sending-nested-pi-while-dest-enters-leaves-l2
patches.fixes/KVM-s390-use-created_vcpus-in-more-places.patch
+ patches.arch/kvm-s390-add-debug-tracing-for-cpu-features-of-cpu-model.patch
+ patches.arch/kvm-s390-drop-use-of-spin-lock-in-_floating_irq_kick.patch
+ patches.arch/kvm-s390-cleanup-struct-kvm_s390_float_interrupt.patch
patches.arch/kvm-s390-vsie-use-read_once-to-access-some-scb-fields.patch
+ patches.arch/kvm-s390-vsie-store-guest-addresses-of-satellite-blocks-in-vsie_page.patch
patches.suse/KVM-s390-diagnoses-are-instructions-as-well.patch
patches.suse/KVM-s390-add-vcpu-stat-counters-for-many-instruction.patch
+ patches.arch/kvm-s390-reverse-bit-ordering-of-irqs-in-pending-mask.patch
+ patches.arch/kvm-s390-define-gisa-format-0-data-structure.patch
+ patches.arch/s390-bitops-add-test_and_clear_bit_inv.patch
+ patches.arch/kvm-s390-implement-gisa-ipm-related-primitives.patch
+ patches.arch/s390-css-indicate-the-availability-of-the-aiv-facility.patch
+ patches.arch/kvm-s390-exploit-gisa-and-aiv-for-emulated-interrupts.patch
+ patches.arch/kvm-s390-abstract-adapter-interruption-word-generation-from-isc.patch
+ patches.arch/kvm-s390-add-gisa-interrupts-to-flic-ioctl-interface.patch
+ patches.arch/kvm-s390-make-kvm_s390_get_io_int-aware-of-gisa.patch
+ patches.arch/kvm-s390-activate-gisa-for-emulated-interrupts.patch
+ patches.arch/s390-sclp-expose-the-gisa-format-facility.patch
+ patches.arch/kvm-s390-introduce-the-format-1-gisa.patch
patches.arch/KVM-arm-arm64-Handle-CPU_PM_ENTER_FAILED.patch
patches.fixes/x86-kvm-vmx-do-not-use-vm-exit-instruction-length-fo.patch
patches.suse/msft-hv-1588-x86-hyperv-Check-for-required-priviliges-in-hyperv_i.patch
@@ -24505,7 +24521,11 @@
patches.suse/msft-hv-1595-x86-headers-UAPI-Use-__u64-instead-of-u64-in-uapi-as.patch
patches.arch/x86-intel_rdt-fix-incorrect-returned-value-when-creating-rdgroup-sub-directory-in-resctrl-file-system
patches.arch/x86-topology-update-the-cpu-cores-field-in-proc-cpuinfo-correctly-across-cpu-hotplug-operations
+ patches.arch/kvm-s390-do-not-set-intervention-requests-for-gisa-interrupts.patch
patches.arch/kvm-s390-force-bp-isolation-for-vsie.patch
+ patches.arch/kvm-s390-use-switch-vs-jump-table-in-priv-c.patch
+ patches.arch/kvm-s390-use-switch-vs-jump-table-in-intercept-c.patch
+ patches.arch/kvm-s390-use-switch-vs-jump-table-in-interrupt-c.patch
patches.fixes/ARM-kvm-fix-building-with-gcc-8.patch
patches.arch/KVM-s390-take-care-of-clock-comparator-sign-control.patch
patches.arch/KVM-s390-consider-epoch-index-on-hotplugged-CPUs.patch
@@ -29033,6 +29053,10 @@
patches.suse/msft-hv-1633-x86-kvm-hyper-v-inject-GP-only-when-invalid-SINTx-ve.patch
patches.fixes/kvm-s390-implement-cpu-model-only-facilities.patch
patches.arch/s390-sles15sp1-00-04-01-KVM-s390-Refactor-host-cmma-and-pfmfi-interpretation.patch
+ patches.arch/kvm-s390-add-exit-io-request-stats-and-simplify-code.patch
+ patches.arch/kvm-s390-fix-fallthrough-annotation.patch
+ patches.arch/kvm-add-machine-check-counter-to-kvm_stat.patch
+ patches.arch/kvm-s390-provide-counters-for-all-interrupt-injects-delivery.patch
patches.arch/kvm-x86-define-svm-vmx-specific-kvm_arch__vm
patches.suse/msft-hv-1640-kvm-x86-hyperv-delete-dead-code-in-kvm_hv_hypercall.patch
patches.arch/arm64-KVM-Move-CPU-ID-reg-trap-setup-off-the-world-s.patch
@@ -34169,6 +34193,9 @@
patches.arch/KVM-arm-arm64-Set-dist-spis-to-NULL-after-kfree.patch
patches.arch/s390-sles15sp1-00-04-02-KVM-s390-Add-storage-key-facility-interpretation-con.patch
patches.arch/kvm-s390-reset-crypto-attributes-for-all-vcpus.patch
+ patches.arch/kvm-s390-no-need-to-inititalize-kvm-arch-members-to-0.patch
+ patches.arch/kvm-s390-generalize-kvm_s390_get_tod_clock_ext.patch
+ patches.arch/kvm-s390-vsie-simplify-8k-address-checks.patch
patches.arch/kvm-make-vm-ioctl-do-valloc-for-some-archs
patches.arch/kvm-nvmx-enforce-cpl-0-for-vmx-instructions
patches.arch/kvm-x86-introduce-linear_-read-write-system
@@ -39218,6 +39245,7 @@
patches.arch/KVM-PPC-Book3S-HV-Pack-VCORE-IDs-to-access-full-VCPU.patch
patches.arch/KVM-PPC-Book3S-HV-Allow-creating-max-number-of-VCPUs.patch
patches.arch/KVM-PPC-Book3S-HV-Read-kvm-arch.emul_smt_mode-under-.patch
+ patches.arch/kvm-s390-vsie-avoid-sparse-warning.patch
patches.fixes/kvm-s390-add-etoken-support-for-guests.patch
patches.suse/msft-hv-1746-KVM-x86-ensure-all-MSRs-can-always-be-KVM_GET-SET_MS.patch
patches.suse/msft-hv-1747-X86-Hyper-V-Add-flush-HvFlushGuestPhysicalAddressSpa.patch
@@ -41818,6 +41846,7 @@
patches.drivers/crypto-chelsio-Update-ntx-queue-received-from-cxgb4.patch
patches.fixes/printk-Fix-panic-caused-by-passing-log_buf_len-to-co.patch
patches.drivers/cgroup-netclassid-add-a-preemption-point-to-write_cl.patch
+ patches.arch/kvm-s390-set-host-program-identifier.patch
patches.arch/s390-sles15sp1-00-07-01-KVM-s390-vsie-simulate-VCPU-SIE-entry-exit.patch
patches.arch/s390-sles15sp1-00-07-02-KVM-s390-introduce-and-use-KVM_REQ_VSIE_RESTART.patch
patches.arch/s390-sles15sp1-00-07-03-KVM-s390-refactor-crypto-initialization.patch
@@ -41848,6 +41877,7 @@
patches.arch/KVM-PPC-Validate-TCEs-against-preregistered-memory-p.patch
patches.arch/KVM-PPC-Remove-redundand-permission-bits-removal.patch
patches.arch/kvm-s390-fix-locking-for-crypto-setting-error-path.patch
+ patches.arch/kvm-s390-tracing-apcb-changes.patch
patches.arch/kvm-nvmx-clear-reserved-bits-of-db-exit-qualification
patches.arch/kvm-nvmx-restore-host-state-in-nested_vmx_vmexit-for-vmfail
patches.suse/msft-hv-1786-KVM-x86-hyperv-enforce-vp_index-KVM_MAX_VCPUS.patch
@@ -43821,6 +43851,8 @@
patches.arch/kvm-x86-report-stibp-on-get_supported_cpuid.patch
patches.arch/KVM-arm-arm64-Fix-VMID-alloc-race-by-reverting-to-lo.patch
patches.fixes/arm-arm64-KVM-vgic-Force-VM-halt-when-changing-the-a.patch
+ patches.arch/kvm-s390-unregister-debug-feature-on-failing-arch-init.patch
+ patches.arch/kvm-s390-fix-kmsg-component-kvm-s390.patch
patches.arch/KVM-PPC-Book3S-HV-Fix-race-between-kvm_unmap_hva_ran.patch
patches.fixes/KVM-PPC-Book3S-PR-Set-hflag-to-indicate-that-POWER9-.patch
patches.arch/kvm-Disallow-wraparound-in-kvm_gfn_to_hva_cache_init.patch
@@ -46379,6 +46411,7 @@
patches.arch/kvm-x86-mmu-detect-mmio-generation-wrap-in-any-address-space
patches.arch/kvm-x86-mmu-do-not-cache-mmio-accesses-while-memslots-are-in-flux
patches.arch/KVM-PPC-Release-all-hardware-TCE-tables-attached-to-.patch
+ patches.arch/kvm-s390-clarify-kvm-related-kernel-message.patch
patches.suse/kvm-s390-implement-subfunction-processor-calls
patches.suse/kvm-s390-add-debug-logging-for-cpu-model-subfunctions
patches.arch/arm64-KVM-Fix-architecturally-invalid-reset-value-fo.patch
@@ -47933,6 +47966,7 @@
patches.fixes/nvme-fc-use-separate-work-queue-to-avoid-warning.patch
patches.fixes/nvme-multipath-avoid-crash-on-invalid-subsystem-cntl.patch
patches.arch/kvm-x86-skip-efer-vs-guest-cpuid-checks-for-host-initiated-writes
+ patches.arch/kvm-s390-fix-potential-spectre-warnings.patch
patches.suse/kvm-s390-add-vector-enhancements-facility-2-to-cpumodel
patches.suse/kvm-s390-add-vector-bcd-enhancements-facility-to-cpumodel
patches.suse/kvm-s390-add-msa9-to-cpumodel