]> git.baikalelectronics.ru Git - kernel.git/commitdiff
KVM: s390: pv: destroy the configuration before its memory
authorClaudio Imbrenda <imbrenda@linux.ibm.com>
Tue, 28 Jun 2022 13:56:13 +0000 (15:56 +0200)
committerJanosch Frank <frankja@linux.ibm.com>
Tue, 19 Jul 2022 12:06:56 +0000 (12:06 +0000)
Move the Destroy Secure Configuration UVC before the loop to destroy
the memory. If the protected VM has memory, it will be cleaned up and
made accessible by the Destroy Secure Configuration UVC. The struct
page for the relevant pages will still have the protected bit set, so
the loop is still needed to clean that up.

Switching the order of those two operations does not change the
outcome, but it is significantly faster.

Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Reviewed-by: Nico Boehr <nrb@linux.ibm.com>
Reviewed-by: Janosch Frank <frankja@linux.ibm.com>
Link: https://lore.kernel.org/r/20220628135619.32410-13-imbrenda@linux.ibm.com
Message-Id: <20220628135619.32410-13-imbrenda@linux.ibm.com>
Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
arch/s390/kvm/pv.c

index 4b64bf5bc3b0010699e5f5a42d3da7ade7b52138..7cb7799a0acb4000157554df8beec25634c6084b 100644 (file)
@@ -164,6 +164,9 @@ int kvm_s390_pv_deinit_vm(struct kvm *kvm, u16 *rc, u16 *rrc)
 {
        int cc;
 
+       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 the mm still has a mapping, make all its pages accessible
         * before destroying the guest
@@ -173,9 +176,6 @@ int kvm_s390_pv_deinit_vm(struct kvm *kvm, u16 *rc, u16 *rrc)
                mmput(kvm->mm);
        }
 
-       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_s390_pv_dealloc_vm(kvm);