KVM: s390: protvirt: Mask PSW interrupt bits for interception 104 and 112
[sfrench/cifs-2.6.git] / arch / s390 / kvm / kvm-s390.c
index 028ce4e7439395f12e5e691332a4195b1998bc02..66ba6ca714fba99e1f89eb422e475a8e3f77a8a9 100644 (file)
@@ -4093,6 +4093,7 @@ static int vcpu_post_run(struct kvm_vcpu *vcpu, int exit_reason)
        return vcpu_post_run_fault_in_sie(vcpu);
 }
 
+#define PSW_INT_MASK (PSW_MASK_EXT | PSW_MASK_IO | PSW_MASK_MCHECK)
 static int __vcpu_run(struct kvm_vcpu *vcpu)
 {
        int rc, exit_reason;
@@ -4129,6 +4130,16 @@ static int __vcpu_run(struct kvm_vcpu *vcpu)
                        memcpy(vcpu->run->s.regs.gprs,
                               sie_page->pv_grregs,
                               sizeof(sie_page->pv_grregs));
+                       /*
+                        * We're not allowed to inject interrupts on intercepts
+                        * that leave the guest state in an "in-between" state
+                        * where the next SIE entry will do a continuation.
+                        * Fence interrupts in our "internal" PSW.
+                        */
+                       if (vcpu->arch.sie_block->icptcode == ICPT_PV_INSTR ||
+                           vcpu->arch.sie_block->icptcode == ICPT_PV_PREF) {
+                               vcpu->arch.sie_block->gpsw.mask &= ~PSW_INT_MASK;
+                       }
                }
                local_irq_disable();
                __enable_cpu_timer_accounting(vcpu);