KVM: s390: vsie: cleanup mcck reinjection
[sfrench/cifs-2.6.git] / arch / s390 / kvm / vsie.c
index 715c19c45d9adbf565c28839d6f9d45cdb627b15..fbe46dd0e55d4231e9935f46e0c6e5618b28fa16 100644 (file)
@@ -349,6 +349,9 @@ static int shadow_scb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
                scb_s->eca |= scb_o->eca & ECA_IB;
        if (test_kvm_cpu_feat(vcpu->kvm, KVM_S390_VM_CPU_FEAT_CEI))
                scb_s->eca |= scb_o->eca & ECA_CEI;
+       /* Epoch Extension */
+       if (test_kvm_facility(vcpu->kvm, 139))
+               scb_s->ecd |= scb_o->ecd & ECD_MEF;
 
        prepare_ibc(vcpu, vsie_page);
        rc = shadow_crycb(vcpu, vsie_page);
@@ -806,8 +809,6 @@ static int do_vsie_run(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
 {
        struct kvm_s390_sie_block *scb_s = &vsie_page->scb_s;
        struct kvm_s390_sie_block *scb_o = vsie_page->scb_o;
-       struct mcck_volatile_info *mcck_info;
-       struct sie_page *sie_page;
        int rc;
 
        handle_last_fault(vcpu, vsie_page);
@@ -831,9 +832,7 @@ static int do_vsie_run(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
 
        if (rc == -EINTR) {
                VCPU_EVENT(vcpu, 3, "%s", "machine check");
-               sie_page = container_of(scb_s, struct sie_page, sie_block);
-               mcck_info = &sie_page->mcck_info;
-               kvm_s390_reinject_machine_check(vcpu, mcck_info);
+               kvm_s390_reinject_machine_check(vcpu, &vsie_page->mcck_info);
                return 0;
        }
 
@@ -919,6 +918,13 @@ static void register_shadow_scb(struct kvm_vcpu *vcpu,
         */
        preempt_disable();
        scb_s->epoch += vcpu->kvm->arch.epoch;
+
+       if (scb_s->ecd & ECD_MEF) {
+               scb_s->epdx += vcpu->kvm->arch.epdx;
+               if (scb_s->epoch < vcpu->kvm->arch.epoch)
+                       scb_s->epdx += 1;
+       }
+
        preempt_enable();
 }