Skip to content

Commit 2b29a9f

Browse files
Dominik Dingelbonzini
authored andcommitted
KVM: s390: move kvm_guest_enter,exit closer to sie
Any uaccess between guest_enter and guest_exit could trigger a page fault, the page fault handler would handle it as a guest fault and translate a user address as guest address. Signed-off-by: Dominik Dingel <[email protected]> Signed-off-by: Christian Borntraeger <[email protected]> CC: [email protected] Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 90db76e commit 2b29a9f

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

arch/s390/kvm/kvm-s390.c

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -702,14 +702,25 @@ static int __vcpu_run(struct kvm_vcpu *vcpu)
702702
return rc;
703703

704704
vcpu->arch.sie_block->icptcode = 0;
705-
preempt_disable();
706-
kvm_guest_enter();
707-
preempt_enable();
708705
VCPU_EVENT(vcpu, 6, "entering sie flags %x",
709706
atomic_read(&vcpu->arch.sie_block->cpuflags));
710707
trace_kvm_s390_sie_enter(vcpu,
711708
atomic_read(&vcpu->arch.sie_block->cpuflags));
709+
710+
/*
711+
* As PF_VCPU will be used in fault handler, between guest_enter
712+
* and guest_exit should be no uaccess.
713+
*/
714+
preempt_disable();
715+
kvm_guest_enter();
716+
preempt_enable();
712717
rc = sie64a(vcpu->arch.sie_block, vcpu->run->s.regs.gprs);
718+
kvm_guest_exit();
719+
720+
VCPU_EVENT(vcpu, 6, "exit sie icptcode %d",
721+
vcpu->arch.sie_block->icptcode);
722+
trace_kvm_s390_sie_exit(vcpu, vcpu->arch.sie_block->icptcode);
723+
713724
if (rc > 0)
714725
rc = 0;
715726
if (rc < 0) {
@@ -721,10 +732,6 @@ static int __vcpu_run(struct kvm_vcpu *vcpu)
721732
rc = kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING);
722733
}
723734
}
724-
VCPU_EVENT(vcpu, 6, "exit sie icptcode %d",
725-
vcpu->arch.sie_block->icptcode);
726-
trace_kvm_s390_sie_exit(vcpu, vcpu->arch.sie_block->icptcode);
727-
kvm_guest_exit();
728735

729736
memcpy(&vcpu->run->s.regs.gprs[14], &vcpu->arch.sie_block->gg14, 16);
730737
return rc;

0 commit comments

Comments
 (0)