]> git.baikalelectronics.ru Git - kernel.git/commitdiff
KVM: s390: pv: refactoring of kvm_s390_pv_deinit_vm
authorClaudio Imbrenda <imbrenda@linux.ibm.com>
Tue, 28 Jun 2022 13:56:12 +0000 (15:56 +0200)
committerJanosch Frank <frankja@linux.ibm.com>
Tue, 19 Jul 2022 12:06:56 +0000 (12:06 +0000)
Refactor kvm_s390_pv_deinit_vm to improve readability and simplify the
improvements that are coming in subsequent patches.

No functional change intended.

Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Reviewed-by: Janosch Frank <frankja@linux.ibm.com>
Link: https://lore.kernel.org/r/20220628135619.32410-12-imbrenda@linux.ibm.com
Message-Id: <20220628135619.32410-12-imbrenda@linux.ibm.com>
[frankja@linux.ibm.com: Dropped commit message line regarding review]
Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
arch/s390/kvm/pv.c

index c063d1a9cf04e66361076b3f2f47c5c2cd667ef0..4b64bf5bc3b0010699e5f5a42d3da7ade7b52138 100644 (file)
@@ -176,17 +176,17 @@ int kvm_s390_pv_deinit_vm(struct kvm *kvm, u16 *rc, u16 *rrc)
        cc = uv_cmd_nodata(kvm_s390_pv_get_handle(kvm),
                           UVC_CMD_DESTROY_SEC_CONF, rc, rrc);
        WRITE_ONCE(kvm->arch.gmap->guest_handle, 0);
-       if (!cc)
-               atomic_dec(&kvm->mm->context.protected_count);
-       KVM_UV_EVENT(kvm, 3, "PROTVIRT DESTROY VM: rc %x rrc %x", *rc, *rrc);
-       WARN_ONCE(cc, "protvirt destroy vm failed rc %x rrc %x", *rc, *rrc);
-       /* Intended memory leak on "impossible" error */
        if (!cc) {
+               atomic_dec(&kvm->mm->context.protected_count);
                kvm_s390_pv_dealloc_vm(kvm);
-               return 0;
+       } else {
+               /* Intended memory leak on "impossible" error */
+               s390_replace_asce(kvm->arch.gmap);
        }
-       s390_replace_asce(kvm->arch.gmap);
-       return -EIO;
+       KVM_UV_EVENT(kvm, 3, "PROTVIRT DESTROY VM: rc %x rrc %x", *rc, *rrc);
+       WARN_ONCE(cc, "protvirt destroy vm failed rc %x rrc %x", *rc, *rrc);
+
+       return cc ? -EIO : 0;
 }
 
 static void kvm_s390_pv_mmu_notifier_release(struct mmu_notifier *subscription,