Skip to content

Commit 1ed576a

Browse files
frankjaaborntraeger
authored andcommitted
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: 29b40f1 ("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>
1 parent 6d6a18f commit 1ed576a

3 files changed

Lines changed: 5 additions & 2 deletions

File tree

arch/s390/kvm/kvm-s390.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2312,7 +2312,7 @@ static int kvm_s390_handle_pv(struct kvm *kvm, struct kvm_pv_cmd *cmd)
23122312
struct kvm_s390_pv_unp unp = {};
23132313

23142314
r = -EINVAL;
2315-
if (!kvm_s390_pv_is_protected(kvm))
2315+
if (!kvm_s390_pv_is_protected(kvm) || !mm_is_protected(kvm->mm))
23162316
break;
23172317

23182318
r = -EFAULT;

arch/s390/kvm/pv.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,6 @@ int kvm_s390_pv_init_vm(struct kvm *kvm, u16 *rc, u16 *rrc)
208208
return -EIO;
209209
}
210210
kvm->arch.gmap->guest_handle = uvcb.guest_handle;
211-
atomic_set(&kvm->mm->context.is_protected, 1);
212211
return 0;
213212
}
214213

@@ -228,6 +227,8 @@ int kvm_s390_pv_set_sec_parms(struct kvm *kvm, void *hdr, u64 length, u16 *rc,
228227
*rrc = uvcb.header.rrc;
229228
KVM_UV_EVENT(kvm, 3, "PROTVIRT VM SET PARMS: rc %x rrc %x",
230229
*rc, *rrc);
230+
if (!cc)
231+
atomic_set(&kvm->mm->context.is_protected, 1);
231232
return cc ? -EINVAL : 0;
232233
}
233234

arch/s390/mm/gmap.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2690,6 +2690,8 @@ static const struct mm_walk_ops reset_acc_walk_ops = {
26902690
#include <linux/sched/mm.h>
26912691
void s390_reset_acc(struct mm_struct *mm)
26922692
{
2693+
if (!mm_is_protected(mm))
2694+
return;
26932695
/*
26942696
* we might be called during
26952697
* reset: we walk the pages and clear

0 commit comments

Comments
 (0)