From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo Tosatti Subject: KVM: x86: stop IO emulation cycle if instruction pointer is modified Date: Fri, 5 Jul 2013 16:16:55 -0300 Message-ID: <20130705191654.GA18788@amt.cnet> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Gleb Natapov To: kvm-devel Return-path: Received: from mx1.redhat.com ([209.132.183.28]:37274 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752256Ab3GETjX (ORCPT ); Fri, 5 Jul 2013 15:39:23 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r65JdNGx006350 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 5 Jul 2013 15:39:23 -0400 Content-Disposition: inline Sender: kvm-owner@vger.kernel.org List-ID: 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 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);