diff options
author | Alexander Graf <agraf@suse.de> | 2012-08-13 06:44:41 -0400 |
---|---|---|
committer | Alexander Graf <agraf@suse.de> | 2012-10-05 17:38:46 -0400 |
commit | 7ee788556bf395a8ef413bea33494df29a3409e0 (patch) | |
tree | dfc85c7287cb634cb0c6d3e367c8139fef01cf78 | |
parent | 206c2ed7f1ea55222bde2954ee3d65c2e9cfb750 (diff) |
KVM: PPC: Add return value in prepare_to_enter
Our prepare_to_enter helper wants to be able to return in more circumstances
to the host than only when an interrupt is pending. Broaden the interface a
bit and move even more generic code to the generic helper.
Signed-off-by: Alexander Graf <agraf@suse.de>
-rw-r--r-- | arch/powerpc/kvm/book3s_pr.c | 12 | ||||
-rw-r--r-- | arch/powerpc/kvm/booke.c | 16 | ||||
-rw-r--r-- | arch/powerpc/kvm/powerpc.c | 11 |
3 files changed, 22 insertions, 17 deletions
diff --git a/arch/powerpc/kvm/book3s_pr.c b/arch/powerpc/kvm/book3s_pr.c index 1ff0d6ccc589..71fa0f1873b3 100644 --- a/arch/powerpc/kvm/book3s_pr.c +++ b/arch/powerpc/kvm/book3s_pr.c | |||
@@ -589,6 +589,7 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu, | |||
589 | unsigned int exit_nr) | 589 | unsigned int exit_nr) |
590 | { | 590 | { |
591 | int r = RESUME_HOST; | 591 | int r = RESUME_HOST; |
592 | int s; | ||
592 | 593 | ||
593 | vcpu->stat.sum_exits++; | 594 | vcpu->stat.sum_exits++; |
594 | 595 | ||
@@ -862,10 +863,10 @@ program_interrupt: | |||
862 | * again due to a host external interrupt. | 863 | * again due to a host external interrupt. |
863 | */ | 864 | */ |
864 | local_irq_disable(); | 865 | local_irq_disable(); |
865 | if (kvmppc_prepare_to_enter(vcpu)) { | 866 | s = kvmppc_prepare_to_enter(vcpu); |
867 | if (s <= 0) { | ||
866 | local_irq_enable(); | 868 | local_irq_enable(); |
867 | run->exit_reason = KVM_EXIT_INTR; | 869 | r = s; |
868 | r = -EINTR; | ||
869 | } else { | 870 | } else { |
870 | kvmppc_lazy_ee_enable(); | 871 | kvmppc_lazy_ee_enable(); |
871 | } | 872 | } |
@@ -1074,10 +1075,9 @@ int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu) | |||
1074 | * a host external interrupt. | 1075 | * a host external interrupt. |
1075 | */ | 1076 | */ |
1076 | local_irq_disable(); | 1077 | local_irq_disable(); |
1077 | if (kvmppc_prepare_to_enter(vcpu)) { | 1078 | ret = kvmppc_prepare_to_enter(vcpu); |
1079 | if (ret <= 0) { | ||
1078 | local_irq_enable(); | 1080 | local_irq_enable(); |
1079 | kvm_run->exit_reason = KVM_EXIT_INTR; | ||
1080 | ret = -EINTR; | ||
1081 | goto out; | 1081 | goto out; |
1082 | } | 1082 | } |
1083 | 1083 | ||
diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c index 5e8dc1909130..1917802463f5 100644 --- a/arch/powerpc/kvm/booke.c +++ b/arch/powerpc/kvm/booke.c | |||
@@ -467,7 +467,7 @@ void kvmppc_core_check_requests(struct kvm_vcpu *vcpu) | |||
467 | 467 | ||
468 | int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu) | 468 | int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu) |
469 | { | 469 | { |
470 | int ret; | 470 | int ret, s; |
471 | #ifdef CONFIG_PPC_FPU | 471 | #ifdef CONFIG_PPC_FPU |
472 | unsigned int fpscr; | 472 | unsigned int fpscr; |
473 | int fpexc_mode; | 473 | int fpexc_mode; |
@@ -480,10 +480,10 @@ int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu) | |||
480 | } | 480 | } |
481 | 481 | ||
482 | local_irq_disable(); | 482 | local_irq_disable(); |
483 | if (kvmppc_prepare_to_enter(vcpu)) { | 483 | s = kvmppc_prepare_to_enter(vcpu); |
484 | if (s <= 0) { | ||
484 | local_irq_enable(); | 485 | local_irq_enable(); |
485 | kvm_run->exit_reason = KVM_EXIT_INTR; | 486 | ret = s; |
486 | ret = -EINTR; | ||
487 | goto out; | 487 | goto out; |
488 | } | 488 | } |
489 | kvmppc_lazy_ee_enable(); | 489 | kvmppc_lazy_ee_enable(); |
@@ -642,6 +642,7 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu, | |||
642 | unsigned int exit_nr) | 642 | unsigned int exit_nr) |
643 | { | 643 | { |
644 | int r = RESUME_HOST; | 644 | int r = RESUME_HOST; |
645 | int s; | ||
645 | 646 | ||
646 | /* update before a new last_exit_type is rewritten */ | 647 | /* update before a new last_exit_type is rewritten */ |
647 | kvmppc_update_timing_stats(vcpu); | 648 | kvmppc_update_timing_stats(vcpu); |
@@ -948,11 +949,10 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu, | |||
948 | */ | 949 | */ |
949 | if (!(r & RESUME_HOST)) { | 950 | if (!(r & RESUME_HOST)) { |
950 | local_irq_disable(); | 951 | local_irq_disable(); |
951 | if (kvmppc_prepare_to_enter(vcpu)) { | 952 | s = kvmppc_prepare_to_enter(vcpu); |
953 | if (s <= 0) { | ||
952 | local_irq_enable(); | 954 | local_irq_enable(); |
953 | run->exit_reason = KVM_EXIT_INTR; | 955 | r = (s << 2) | RESUME_HOST | (r & RESUME_FLAG_NV); |
954 | r = (-EINTR << 2) | RESUME_HOST | (r & RESUME_FLAG_NV); | ||
955 | kvmppc_account_exit(vcpu, SIGNAL_EXITS); | ||
956 | } else { | 956 | } else { |
957 | kvmppc_lazy_ee_enable(); | 957 | kvmppc_lazy_ee_enable(); |
958 | } | 958 | } |
diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c index dc86371b9953..0e2a98ab6a77 100644 --- a/arch/powerpc/kvm/powerpc.c +++ b/arch/powerpc/kvm/powerpc.c | |||
@@ -53,11 +53,14 @@ int kvm_arch_vcpu_should_kick(struct kvm_vcpu *vcpu) | |||
53 | * Common checks before entering the guest world. Call with interrupts | 53 | * Common checks before entering the guest world. Call with interrupts |
54 | * disabled. | 54 | * disabled. |
55 | * | 55 | * |
56 | * returns !0 if a signal is pending and check_signal is true | 56 | * returns: |
57 | * | ||
58 | * == 1 if we're ready to go into guest state | ||
59 | * <= 0 if we need to go back to the host with return value | ||
57 | */ | 60 | */ |
58 | int kvmppc_prepare_to_enter(struct kvm_vcpu *vcpu) | 61 | int kvmppc_prepare_to_enter(struct kvm_vcpu *vcpu) |
59 | { | 62 | { |
60 | int r = 0; | 63 | int r = 1; |
61 | 64 | ||
62 | WARN_ON_ONCE(!irqs_disabled()); | 65 | WARN_ON_ONCE(!irqs_disabled()); |
63 | while (true) { | 66 | while (true) { |
@@ -69,7 +72,9 @@ int kvmppc_prepare_to_enter(struct kvm_vcpu *vcpu) | |||
69 | } | 72 | } |
70 | 73 | ||
71 | if (signal_pending(current)) { | 74 | if (signal_pending(current)) { |
72 | r = 1; | 75 | kvmppc_account_exit(vcpu, SIGNAL_EXITS); |
76 | vcpu->run->exit_reason = KVM_EXIT_INTR; | ||
77 | r = -EINTR; | ||
73 | break; | 78 | break; |
74 | } | 79 | } |
75 | 80 | ||