* KVM: x86: stop IO emulation cycle if instruction pointer is modified
@ 2013-07-05 19:16 Marcelo Tosatti
2013-07-06 7:41 ` Gleb Natapov
0 siblings, 1 reply; 3+ messages in thread
From: Marcelo Tosatti @ 2013-07-05 19:16 UTC (permalink / raw)
To: kvm-devel; +Cc: Gleb Natapov
MMIO/PIO emulation should be interrupted if the system is restarted.
Otherwise in progress IO emulation continues at the instruction pointer,
even after vcpus' IP has been modified by KVM_SET_REGS.
Use IP change as an indicator to reset MMIO/PIO emulation state.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index e8ba99c..9f7ce41 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -6144,6 +6144,10 @@ int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs)
kvm_register_write(vcpu, VCPU_REGS_R15, regs->r15);
#endif
+ /* stop IO emulation cycle if RIP changes */
+ if (kvm_rip_read(vcpu) != regs->rip)
+ vcpu->arch.complete_userspace_io = NULL;
+
kvm_rip_write(vcpu, regs->rip);
kvm_set_rflags(vcpu, regs->rflags);
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: KVM: x86: stop IO emulation cycle if instruction pointer is modified
2013-07-05 19:16 KVM: x86: stop IO emulation cycle if instruction pointer is modified Marcelo Tosatti
@ 2013-07-06 7:41 ` Gleb Natapov
2013-07-08 21:16 ` Marcelo Tosatti
0 siblings, 1 reply; 3+ messages in thread
From: Gleb Natapov @ 2013-07-06 7:41 UTC (permalink / raw)
To: Marcelo Tosatti; +Cc: kvm-devel
On Fri, Jul 05, 2013 at 04:16:55PM -0300, Marcelo Tosatti wrote:
>
> MMIO/PIO emulation should be interrupted if the system is restarted.
> Otherwise in progress IO emulation continues at the instruction pointer,
> even after vcpus' IP has been modified by KVM_SET_REGS.
>
> Use IP change as an indicator to reset MMIO/PIO emulation state.
>
Userspace has to return to the kernel to complete pending IO operation.
This is documented in Documentation/virtual/kvm/api.txt. If this is not
what program does it is a bug. What userspace you see the problem with?
> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
>
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index e8ba99c..9f7ce41 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -6144,6 +6144,10 @@ int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs)
> kvm_register_write(vcpu, VCPU_REGS_R15, regs->r15);
> #endif
>
> + /* stop IO emulation cycle if RIP changes */
> + if (kvm_rip_read(vcpu) != regs->rip)
> + vcpu->arch.complete_userspace_io = NULL;
> +
> kvm_rip_write(vcpu, regs->rip);
> kvm_set_rflags(vcpu, regs->rflags);
>
--
Gleb.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: KVM: x86: stop IO emulation cycle if instruction pointer is modified
2013-07-06 7:41 ` Gleb Natapov
@ 2013-07-08 21:16 ` Marcelo Tosatti
0 siblings, 0 replies; 3+ messages in thread
From: Marcelo Tosatti @ 2013-07-08 21:16 UTC (permalink / raw)
To: Gleb Natapov; +Cc: kvm-devel
On Sat, Jul 06, 2013 at 10:41:12AM +0300, Gleb Natapov wrote:
> On Fri, Jul 05, 2013 at 04:16:55PM -0300, Marcelo Tosatti wrote:
> >
> > MMIO/PIO emulation should be interrupted if the system is restarted.
> > Otherwise in progress IO emulation continues at the instruction pointer,
> > even after vcpus' IP has been modified by KVM_SET_REGS.
> >
> > Use IP change as an indicator to reset MMIO/PIO emulation state.
> >
> Userspace has to return to the kernel to complete pending IO operation.
> This is documented in Documentation/virtual/kvm/api.txt. If this is not
> what program does it is a bug. What userspace you see the problem with?
You're right, this patch should not be necessary.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-07-08 21:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-05 19:16 KVM: x86: stop IO emulation cycle if instruction pointer is modified Marcelo Tosatti
2013-07-06 7:41 ` Gleb Natapov
2013-07-08 21:16 ` Marcelo Tosatti
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox