]> git.baikalelectronics.ru Git - kernel.git/commitdiff
KVM: s390: pv: Mark mm as protected after the set secure parameters and improve cleanup
authorJanosch Frank <frankja@linux.ibm.com>
Tue, 20 Oct 2020 10:12:07 +0000 (06:12 -0400)
committerChristian Borntraeger <borntraeger@de.ibm.com>
Wed, 11 Nov 2020 08:31:48 +0000 (09:31 +0100)
We can only have protected guest pages after a successful set secure
parameters call as only then the UV allows imports and unpacks.

By moving the test we can now also check for it in s390_reset_acc()
and do an early return if it is 0.

Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
Fixes: 395ccddc452f ("KVM: s390: protvirt: Add initial vm and cpu lifecycle handling")
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
arch/s390/kvm/kvm-s390.c
arch/s390/kvm/pv.c
arch/s390/mm/gmap.c

index 6b74b92c1a586abc73c46c7a31a975f95d325b23..08ea6c4735cdc6a0f55b8435768923e6692385c6 100644 (file)
@@ -2312,7 +2312,7 @@ static int kvm_s390_handle_pv(struct kvm *kvm, struct kvm_pv_cmd *cmd)
                struct kvm_s390_pv_unp unp = {};
 
                r = -EINVAL;
-               if (!kvm_s390_pv_is_protected(kvm))
+               if (!kvm_s390_pv_is_protected(kvm) || !mm_is_protected(kvm->mm))
                        break;
 
                r = -EFAULT;
index eb99e2f95ebed41679db4dc7ca172f4d76696fae..f5847f9dec7c9e6bf90c2165b2d5eaefc09ccfe0 100644 (file)
@@ -208,7 +208,6 @@ int kvm_s390_pv_init_vm(struct kvm *kvm, u16 *rc, u16 *rrc)
                return -EIO;
        }
        kvm->arch.gmap->guest_handle = uvcb.guest_handle;
-       atomic_set(&kvm->mm->context.is_protected, 1);
        return 0;
 }
 
@@ -228,6 +227,8 @@ int kvm_s390_pv_set_sec_parms(struct kvm *kvm, void *hdr, u64 length, u16 *rc,
        *rrc = uvcb.header.rrc;
        KVM_UV_EVENT(kvm, 3, "PROTVIRT VM SET PARMS: rc %x rrc %x",
                     *rc, *rrc);
+       if (!cc)
+               atomic_set(&kvm->mm->context.is_protected, 1);
        return cc ? -EINVAL : 0;
 }
 
index cfb0017f33a70444b6d8d0a636d35937489725b2..64795d03492632b629aaef4b88907ef8adb12677 100644 (file)
@@ -2690,6 +2690,8 @@ static const struct mm_walk_ops reset_acc_walk_ops = {
 #include <linux/sched/mm.h>
 void s390_reset_acc(struct mm_struct *mm)
 {
+       if (!mm_is_protected(mm))
+               return;
        /*
         * we might be called during
         * reset:                             we walk the pages and clear