Commit 7ee78855 authored by Alexander Graf's avatar Alexander Graf

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: default avatarAlexander Graf <agraf@suse.de>
parent 206c2ed7
...@@ -589,6 +589,7 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu, ...@@ -589,6 +589,7 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,
unsigned int exit_nr) unsigned int exit_nr)
{ {
int r = RESUME_HOST; int r = RESUME_HOST;
int s;
vcpu->stat.sum_exits++; vcpu->stat.sum_exits++;
...@@ -862,10 +863,10 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu, ...@@ -862,10 +863,10 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,
* again due to a host external interrupt. * again due to a host external interrupt.
*/ */
local_irq_disable(); local_irq_disable();
if (kvmppc_prepare_to_enter(vcpu)) { s = kvmppc_prepare_to_enter(vcpu);
if (s <= 0) {
local_irq_enable(); local_irq_enable();
run->exit_reason = KVM_EXIT_INTR; r = s;
r = -EINTR;
} else { } else {
kvmppc_lazy_ee_enable(); kvmppc_lazy_ee_enable();
} }
...@@ -1074,10 +1075,9 @@ int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu) ...@@ -1074,10 +1075,9 @@ int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)
* a host external interrupt. * a host external interrupt.
*/ */
local_irq_disable(); local_irq_disable();
if (kvmppc_prepare_to_enter(vcpu)) { ret = kvmppc_prepare_to_enter(vcpu);
if (ret <= 0) {
local_irq_enable(); local_irq_enable();
kvm_run->exit_reason = KVM_EXIT_INTR;
ret = -EINTR;
goto out; goto out;
} }
......
...@@ -467,7 +467,7 @@ void kvmppc_core_check_requests(struct kvm_vcpu *vcpu) ...@@ -467,7 +467,7 @@ void kvmppc_core_check_requests(struct kvm_vcpu *vcpu)
int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu) int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)
{ {
int ret; int ret, s;
#ifdef CONFIG_PPC_FPU #ifdef CONFIG_PPC_FPU
unsigned int fpscr; unsigned int fpscr;
int fpexc_mode; int fpexc_mode;
...@@ -480,10 +480,10 @@ int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu) ...@@ -480,10 +480,10 @@ int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)
} }
local_irq_disable(); local_irq_disable();
if (kvmppc_prepare_to_enter(vcpu)) { s = kvmppc_prepare_to_enter(vcpu);
if (s <= 0) {
local_irq_enable(); local_irq_enable();
kvm_run->exit_reason = KVM_EXIT_INTR; ret = s;
ret = -EINTR;
goto out; goto out;
} }
kvmppc_lazy_ee_enable(); kvmppc_lazy_ee_enable();
...@@ -642,6 +642,7 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu, ...@@ -642,6 +642,7 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,
unsigned int exit_nr) unsigned int exit_nr)
{ {
int r = RESUME_HOST; int r = RESUME_HOST;
int s;
/* update before a new last_exit_type is rewritten */ /* update before a new last_exit_type is rewritten */
kvmppc_update_timing_stats(vcpu); kvmppc_update_timing_stats(vcpu);
...@@ -948,11 +949,10 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu, ...@@ -948,11 +949,10 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,
*/ */
if (!(r & RESUME_HOST)) { if (!(r & RESUME_HOST)) {
local_irq_disable(); local_irq_disable();
if (kvmppc_prepare_to_enter(vcpu)) { s = kvmppc_prepare_to_enter(vcpu);
if (s <= 0) {
local_irq_enable(); local_irq_enable();
run->exit_reason = KVM_EXIT_INTR; r = (s << 2) | RESUME_HOST | (r & RESUME_FLAG_NV);
r = (-EINTR << 2) | RESUME_HOST | (r & RESUME_FLAG_NV);
kvmppc_account_exit(vcpu, SIGNAL_EXITS);
} else { } else {
kvmppc_lazy_ee_enable(); kvmppc_lazy_ee_enable();
} }
......
...@@ -53,11 +53,14 @@ int kvm_arch_vcpu_should_kick(struct kvm_vcpu *vcpu) ...@@ -53,11 +53,14 @@ int kvm_arch_vcpu_should_kick(struct kvm_vcpu *vcpu)
* Common checks before entering the guest world. Call with interrupts * Common checks before entering the guest world. Call with interrupts
* disabled. * disabled.
* *
* returns !0 if a signal is pending and check_signal is true * returns:
*
* == 1 if we're ready to go into guest state
* <= 0 if we need to go back to the host with return value
*/ */
int kvmppc_prepare_to_enter(struct kvm_vcpu *vcpu) int kvmppc_prepare_to_enter(struct kvm_vcpu *vcpu)
{ {
int r = 0; int r = 1;
WARN_ON_ONCE(!irqs_disabled()); WARN_ON_ONCE(!irqs_disabled());
while (true) { while (true) {
...@@ -69,7 +72,9 @@ int kvmppc_prepare_to_enter(struct kvm_vcpu *vcpu) ...@@ -69,7 +72,9 @@ int kvmppc_prepare_to_enter(struct kvm_vcpu *vcpu)
} }
if (signal_pending(current)) { if (signal_pending(current)) {
r = 1; kvmppc_account_exit(vcpu, SIGNAL_EXITS);
vcpu->run->exit_reason = KVM_EXIT_INTR;
r = -EINTR;
break; break;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment