diff options
author | Dominik Dingel <dingel@linux.vnet.ibm.com> | 2013-07-26 09:04:00 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-08-29 12:47:28 -0400 |
commit | 6904756d54d4f98a9f835ed9cbc3f149ef7ac678 (patch) | |
tree | 9584fe646c735d09b666c62497a0cabe98561642 /arch | |
parent | 0a4b6d4ff200a553951f77f765971cb3e4c91ec0 (diff) |
KVM: s390: move kvm_guest_enter,exit closer to sie
commit 2b29a9fdcb92bfc6b6f4c412d71505869de61a56 upstream.
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 <dingel@linux.vnet.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/s390/kvm/kvm-s390.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c index c1c7c683fa26..698fb826e149 100644 --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c | |||
@@ -622,14 +622,25 @@ static int __vcpu_run(struct kvm_vcpu *vcpu) | |||
622 | kvm_s390_deliver_pending_interrupts(vcpu); | 622 | kvm_s390_deliver_pending_interrupts(vcpu); |
623 | 623 | ||
624 | vcpu->arch.sie_block->icptcode = 0; | 624 | vcpu->arch.sie_block->icptcode = 0; |
625 | preempt_disable(); | ||
626 | kvm_guest_enter(); | ||
627 | preempt_enable(); | ||
628 | VCPU_EVENT(vcpu, 6, "entering sie flags %x", | 625 | VCPU_EVENT(vcpu, 6, "entering sie flags %x", |
629 | atomic_read(&vcpu->arch.sie_block->cpuflags)); | 626 | atomic_read(&vcpu->arch.sie_block->cpuflags)); |
630 | trace_kvm_s390_sie_enter(vcpu, | 627 | trace_kvm_s390_sie_enter(vcpu, |
631 | atomic_read(&vcpu->arch.sie_block->cpuflags)); | 628 | atomic_read(&vcpu->arch.sie_block->cpuflags)); |
629 | |||
630 | /* | ||
631 | * As PF_VCPU will be used in fault handler, between guest_enter | ||
632 | * and guest_exit should be no uaccess. | ||
633 | */ | ||
634 | preempt_disable(); | ||
635 | kvm_guest_enter(); | ||
636 | preempt_enable(); | ||
632 | rc = sie64a(vcpu->arch.sie_block, vcpu->run->s.regs.gprs); | 637 | rc = sie64a(vcpu->arch.sie_block, vcpu->run->s.regs.gprs); |
638 | kvm_guest_exit(); | ||
639 | |||
640 | VCPU_EVENT(vcpu, 6, "exit sie icptcode %d", | ||
641 | vcpu->arch.sie_block->icptcode); | ||
642 | trace_kvm_s390_sie_exit(vcpu, vcpu->arch.sie_block->icptcode); | ||
643 | |||
633 | if (rc) { | 644 | if (rc) { |
634 | if (kvm_is_ucontrol(vcpu->kvm)) { | 645 | if (kvm_is_ucontrol(vcpu->kvm)) { |
635 | rc = SIE_INTERCEPT_UCONTROL; | 646 | rc = SIE_INTERCEPT_UCONTROL; |
@@ -639,10 +650,6 @@ static int __vcpu_run(struct kvm_vcpu *vcpu) | |||
639 | rc = kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING); | 650 | rc = kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING); |
640 | } | 651 | } |
641 | } | 652 | } |
642 | VCPU_EVENT(vcpu, 6, "exit sie icptcode %d", | ||
643 | vcpu->arch.sie_block->icptcode); | ||
644 | trace_kvm_s390_sie_exit(vcpu, vcpu->arch.sie_block->icptcode); | ||
645 | kvm_guest_exit(); | ||
646 | 653 | ||
647 | memcpy(&vcpu->run->s.regs.gprs[14], &vcpu->arch.sie_block->gg14, 16); | 654 | memcpy(&vcpu->run->s.regs.gprs[14], &vcpu->arch.sie_block->gg14, 16); |
648 | return rc; | 655 | return rc; |