Commit 2b8250ae authored by Jan Kiszka's avatar Jan Kiszka

x86/ipipe: kvm: Only put vcpu if it is active

We may leave kvm_arch_vcpu_put with the ipipe notifier still registered
in case shared MSRs are still active. If a VM preemption will hit us
after that point but before the user return notifier fired, we may run
kvm_arch_vcpu_put again from __ipipe_handle_vm_preemption. Do not rely
on this being harmless and rather use a flag to decide if the run is
needed.
Signed-off-by: Jan Kiszka's avatarJan Kiszka <jan.kiszka@siemens.com>
parent 22b8cb0d
......@@ -2787,8 +2787,11 @@ void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu)
*/
set_debugreg(0, 6);
#ifdef CONFIG_IPIPE
vcpu->ipipe_put_vcpu = false;
if (!smsr->dirty)
__ipipe_exit_vm();
#endif
hard_cond_local_irq_restore(flags);
}
......@@ -2802,7 +2805,8 @@ void __ipipe_handle_vm_preemption(struct ipipe_vm_notifier *nfy)
struct kvm_vcpu *vcpu;
vcpu = container_of(nfy, struct kvm_vcpu, ipipe_notifier);
kvm_arch_vcpu_put(vcpu);
if (vcpu->ipipe_put_vcpu)
kvm_arch_vcpu_put(vcpu);
kvm_restore_shared_msrs(smsr);
__ipipe_exit_vm();
}
......@@ -6621,7 +6625,10 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
local_irq_disable();
hard_cond_local_irq_disable();
#ifdef CONFIG_IPIPE
__ipipe_enter_vm(&vcpu->ipipe_notifier);
vcpu->ipipe_put_vcpu = true;
#endif
kvm_x86_ops->prepare_guest_switch(vcpu);
if (vcpu->fpu_active)
......
......@@ -229,6 +229,7 @@ struct kvm_vcpu {
#endif
#ifdef CONFIG_IPIPE
struct ipipe_vm_notifier ipipe_notifier;
bool ipipe_put_vcpu;
#endif
int cpu;
int vcpu_id;
......
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