提交 24afa37b 编写于 作者: A Alexander Graf

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: NAlexander Graf <agraf@suse.de>
上级 0652eaae
...@@ -868,12 +868,15 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu, ...@@ -868,12 +868,15 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,
*/ */
__hard_irq_disable(); __hard_irq_disable();
if (kvmppc_prepare_to_enter(vcpu)) { if (kvmppc_prepare_to_enter(vcpu)) {
/* local_irq_enable(); */
run->exit_reason = KVM_EXIT_INTR; run->exit_reason = KVM_EXIT_INTR;
r = -EINTR; r = -EINTR;
} else {
/* Going back to guest */
kvm_guest_enter();
} }
} }
kvm_guest_enter();
trace_kvm_book3s_reenter(r, vcpu); trace_kvm_book3s_reenter(r, vcpu);
return r; return r;
...@@ -1123,7 +1126,8 @@ int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu) ...@@ -1123,7 +1126,8 @@ int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)
ret = __kvmppc_vcpu_run(kvm_run, vcpu); ret = __kvmppc_vcpu_run(kvm_run, vcpu);
kvm_guest_exit(); /* No need for kvm_guest_exit. It's done in handle_exit.
We also get here with interrupts enabled. */
current->thread.regs->msr = ext_msr; current->thread.regs->msr = ext_msr;
......
...@@ -481,6 +481,7 @@ int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu) ...@@ -481,6 +481,7 @@ 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)) { if (kvmppc_prepare_to_enter(vcpu)) {
local_irq_enable();
kvm_run->exit_reason = KVM_EXIT_INTR; kvm_run->exit_reason = KVM_EXIT_INTR;
ret = -EINTR; ret = -EINTR;
goto out; goto out;
...@@ -512,6 +513,9 @@ int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu) ...@@ -512,6 +513,9 @@ int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)
ret = __kvmppc_vcpu_run(kvm_run, vcpu); ret = __kvmppc_vcpu_run(kvm_run, vcpu);
/* No need for kvm_guest_exit. It's done in handle_exit.
We also get here with interrupts enabled. */
#ifdef CONFIG_PPC_FPU #ifdef CONFIG_PPC_FPU
kvmppc_save_guest_fp(vcpu); kvmppc_save_guest_fp(vcpu);
...@@ -527,12 +531,9 @@ int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu) ...@@ -527,12 +531,9 @@ int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)
current->thread.fpexc_mode = fpexc_mode; current->thread.fpexc_mode = fpexc_mode;
#endif #endif
kvm_guest_exit();
out: out:
vcpu->mode = OUTSIDE_GUEST_MODE; vcpu->mode = OUTSIDE_GUEST_MODE;
smp_wmb(); smp_wmb();
local_irq_enable();
return ret; return ret;
} }
...@@ -947,14 +948,16 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu, ...@@ -947,14 +948,16 @@ 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)) { if (kvmppc_prepare_to_enter(vcpu)) {
local_irq_enable();
run->exit_reason = KVM_EXIT_INTR; run->exit_reason = KVM_EXIT_INTR;
r = (-EINTR << 2) | RESUME_HOST | (r & RESUME_FLAG_NV); r = (-EINTR << 2) | RESUME_HOST | (r & RESUME_FLAG_NV);
kvmppc_account_exit(vcpu, SIGNAL_EXITS); kvmppc_account_exit(vcpu, SIGNAL_EXITS);
} else {
/* Going back to guest */
kvm_guest_enter();
} }
} }
kvm_guest_enter();
return r; return r;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册