diff options
author | Alexander Graf <agraf@suse.de> | 2012-08-12 06:42:30 -0400 |
---|---|---|
committer | Alexander Graf <agraf@suse.de> | 2012-10-05 17:38:45 -0400 |
commit | 24afa37b9c8f035d2fe2028e4824bc4e49bafe73 (patch) | |
tree | b295955b1b74bcdd404f8bb29d5a21d6ae708419 | |
parent | 0652eaaebea0995b3236e51dec727d62264f4248 (diff) |
KVM: PPC: Consistentify vcpu exit path
When getting out of __vcpu_run, let's be consistent about the state we
return in. We want to always
* have IRQs enabled
* have called kvm_guest_exit before
Signed-off-by: Alexander Graf <agraf@suse.de>
-rw-r--r-- | arch/powerpc/kvm/book3s_pr.c | 8 | ||||
-rw-r--r-- | arch/powerpc/kvm/booke.c | 13 |
2 files changed, 14 insertions, 7 deletions
diff --git a/arch/powerpc/kvm/book3s_pr.c b/arch/powerpc/kvm/book3s_pr.c index 9430a362e5a3..3dec346c4b93 100644 --- a/arch/powerpc/kvm/book3s_pr.c +++ b/arch/powerpc/kvm/book3s_pr.c | |||
@@ -868,12 +868,15 @@ program_interrupt: | |||
868 | */ | 868 | */ |
869 | __hard_irq_disable(); | 869 | __hard_irq_disable(); |
870 | if (kvmppc_prepare_to_enter(vcpu)) { | 870 | if (kvmppc_prepare_to_enter(vcpu)) { |
871 | /* local_irq_enable(); */ | ||
871 | run->exit_reason = KVM_EXIT_INTR; | 872 | run->exit_reason = KVM_EXIT_INTR; |
872 | r = -EINTR; | 873 | r = -EINTR; |
874 | } else { | ||
875 | /* Going back to guest */ | ||
876 | kvm_guest_enter(); | ||
873 | } | 877 | } |
874 | } | 878 | } |
875 | 879 | ||
876 | kvm_guest_enter(); | ||
877 | trace_kvm_book3s_reenter(r, vcpu); | 880 | trace_kvm_book3s_reenter(r, vcpu); |
878 | 881 | ||
879 | return r; | 882 | return r; |
@@ -1123,7 +1126,8 @@ int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu) | |||
1123 | 1126 | ||
1124 | ret = __kvmppc_vcpu_run(kvm_run, vcpu); | 1127 | ret = __kvmppc_vcpu_run(kvm_run, vcpu); |
1125 | 1128 | ||
1126 | kvm_guest_exit(); | 1129 | /* No need for kvm_guest_exit. It's done in handle_exit. |
1130 | We also get here with interrupts enabled. */ | ||
1127 | 1131 | ||
1128 | current->thread.regs->msr = ext_msr; | 1132 | current->thread.regs->msr = ext_msr; |
1129 | 1133 | ||
diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c index 887c7cc02146..aae535f6d9de 100644 --- a/arch/powerpc/kvm/booke.c +++ b/arch/powerpc/kvm/booke.c | |||
@@ -481,6 +481,7 @@ int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu) | |||
481 | 481 | ||
482 | local_irq_disable(); | 482 | local_irq_disable(); |
483 | if (kvmppc_prepare_to_enter(vcpu)) { | 483 | if (kvmppc_prepare_to_enter(vcpu)) { |
484 | local_irq_enable(); | ||
484 | kvm_run->exit_reason = KVM_EXIT_INTR; | 485 | kvm_run->exit_reason = KVM_EXIT_INTR; |
485 | ret = -EINTR; | 486 | ret = -EINTR; |
486 | goto out; | 487 | goto out; |
@@ -512,6 +513,9 @@ int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu) | |||
512 | 513 | ||
513 | ret = __kvmppc_vcpu_run(kvm_run, vcpu); | 514 | ret = __kvmppc_vcpu_run(kvm_run, vcpu); |
514 | 515 | ||
516 | /* No need for kvm_guest_exit. It's done in handle_exit. | ||
517 | We also get here with interrupts enabled. */ | ||
518 | |||
515 | #ifdef CONFIG_PPC_FPU | 519 | #ifdef CONFIG_PPC_FPU |
516 | kvmppc_save_guest_fp(vcpu); | 520 | kvmppc_save_guest_fp(vcpu); |
517 | 521 | ||
@@ -527,12 +531,9 @@ int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu) | |||
527 | current->thread.fpexc_mode = fpexc_mode; | 531 | current->thread.fpexc_mode = fpexc_mode; |
528 | #endif | 532 | #endif |
529 | 533 | ||
530 | kvm_guest_exit(); | ||
531 | |||
532 | out: | 534 | out: |
533 | vcpu->mode = OUTSIDE_GUEST_MODE; | 535 | vcpu->mode = OUTSIDE_GUEST_MODE; |
534 | smp_wmb(); | 536 | smp_wmb(); |
535 | local_irq_enable(); | ||
536 | return ret; | 537 | return ret; |
537 | } | 538 | } |
538 | 539 | ||
@@ -947,14 +948,16 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu, | |||
947 | if (!(r & RESUME_HOST)) { | 948 | if (!(r & RESUME_HOST)) { |
948 | local_irq_disable(); | 949 | local_irq_disable(); |
949 | if (kvmppc_prepare_to_enter(vcpu)) { | 950 | if (kvmppc_prepare_to_enter(vcpu)) { |
951 | local_irq_enable(); | ||
950 | run->exit_reason = KVM_EXIT_INTR; | 952 | run->exit_reason = KVM_EXIT_INTR; |
951 | r = (-EINTR << 2) | RESUME_HOST | (r & RESUME_FLAG_NV); | 953 | r = (-EINTR << 2) | RESUME_HOST | (r & RESUME_FLAG_NV); |
952 | kvmppc_account_exit(vcpu, SIGNAL_EXITS); | 954 | kvmppc_account_exit(vcpu, SIGNAL_EXITS); |
955 | } else { | ||
956 | /* Going back to guest */ | ||
957 | kvm_guest_enter(); | ||
953 | } | 958 | } |
954 | } | 959 | } |
955 | 960 | ||
956 | kvm_guest_enter(); | ||
957 | |||
958 | return r; | 961 | return r; |
959 | } | 962 | } |
960 | 963 | ||