KVM: s390: pv: Mark mm as protected after the set secure parameters and improve cleanup
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: 29b40f105e ("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>
This commit is contained in:
committed by
Christian Borntraeger
parent
6d6a18fdde
commit
1ed576a20c
@@ -2312,7 +2312,7 @@ static int kvm_s390_handle_pv(struct kvm *kvm, struct kvm_pv_cmd *cmd)
|
|||||||
struct kvm_s390_pv_unp unp = {};
|
struct kvm_s390_pv_unp unp = {};
|
||||||
|
|
||||||
r = -EINVAL;
|
r = -EINVAL;
|
||||||
if (!kvm_s390_pv_is_protected(kvm))
|
if (!kvm_s390_pv_is_protected(kvm) || !mm_is_protected(kvm->mm))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
r = -EFAULT;
|
r = -EFAULT;
|
||||||
|
|||||||
@@ -208,7 +208,6 @@ int kvm_s390_pv_init_vm(struct kvm *kvm, u16 *rc, u16 *rrc)
|
|||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
kvm->arch.gmap->guest_handle = uvcb.guest_handle;
|
kvm->arch.gmap->guest_handle = uvcb.guest_handle;
|
||||||
atomic_set(&kvm->mm->context.is_protected, 1);
|
|
||||||
return 0;
|
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;
|
*rrc = uvcb.header.rrc;
|
||||||
KVM_UV_EVENT(kvm, 3, "PROTVIRT VM SET PARMS: rc %x rrc %x",
|
KVM_UV_EVENT(kvm, 3, "PROTVIRT VM SET PARMS: rc %x rrc %x",
|
||||||
*rc, *rrc);
|
*rc, *rrc);
|
||||||
|
if (!cc)
|
||||||
|
atomic_set(&kvm->mm->context.is_protected, 1);
|
||||||
return cc ? -EINVAL : 0;
|
return cc ? -EINVAL : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2690,6 +2690,8 @@ static const struct mm_walk_ops reset_acc_walk_ops = {
|
|||||||
#include <linux/sched/mm.h>
|
#include <linux/sched/mm.h>
|
||||||
void s390_reset_acc(struct mm_struct *mm)
|
void s390_reset_acc(struct mm_struct *mm)
|
||||||
{
|
{
|
||||||
|
if (!mm_is_protected(mm))
|
||||||
|
return;
|
||||||
/*
|
/*
|
||||||
* we might be called during
|
* we might be called during
|
||||||
* reset: we walk the pages and clear
|
* reset: we walk the pages and clear
|
||||||
|
|||||||
Reference in New Issue
Block a user