From mboxrd@z Thu Jan 1 00:00:00 1970 From: Greg KH Subject: [patch 24/60] KVM: Skip pio instruction when it is emulated, not executed Date: Wed, 12 Dec 2007 22:52:09 -0800 Message-ID: <20071213065209.GY6867@kroah.com> References: <20071213064518.328162328@mini.kroah.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: Theodore Ts'o , Zwane Mwaikambo , kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org, Justin Forbes , Domenico Andreoli , Chris Wedgwood , Randy Dunlap , Michael Krufky , Avi Kivity , Chuck Ebbert , Dave Jones , Chuck Wolber , akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org, torvalds-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org, alan-qBU/x9rampVanCEyBjwyrvXRex20P6io@public.gmane.org To: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, stable-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org Return-path: Content-Disposition: inline; filename="kvm-skip-pio-instruction-when-it-is-emulated-not-executed.patch" In-Reply-To: <20071213065039.GA6867-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: kvm-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org Errors-To: kvm-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org List-Id: kvm.vger.kernel.org 2.6.23-stable review patch. If anyone has any objections, please let us know. ------------------ From: Avi Kivity patch 0967b7bf1c22b55777aba46ff616547feed0b141 in mainline. If we defer updating rip until pio instructions are executed, we have a problem with reset: a pio reset updates rip, and when the instruction completes we skip the emulated instruction, pointing rip somewhere completely unrelated. Fix by updating rip when we see decode the instruction, not after emulation. Signed-off-by: Avi Kivity Signed-off-by: Greg Kroah-Hartman --- drivers/kvm/kvm_main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/drivers/kvm/kvm_main.c +++ b/drivers/kvm/kvm_main.c @@ -1757,8 +1757,6 @@ static int complete_pio(struct kvm_vcpu io->count -= io->cur_count; io->cur_count = 0; - if (!io->count) - kvm_arch_ops->skip_emulated_instruction(vcpu); return 0; } @@ -1804,6 +1802,7 @@ int kvm_setup_pio(struct kvm_vcpu *vcpu, pio_dev = vcpu_find_pio_dev(vcpu, port); if (!string) { + kvm_arch_ops->skip_emulated_instruction(vcpu); kvm_arch_ops->cache_regs(vcpu); memcpy(vcpu->pio_data, &vcpu->regs[VCPU_REGS_RAX], 4); kvm_arch_ops->decache_regs(vcpu); @@ -1850,6 +1849,9 @@ int kvm_setup_pio(struct kvm_vcpu *vcpu, vcpu->run->io.count = now; vcpu->pio.cur_count = now; + if (now == count) + kvm_arch_ops->skip_emulated_instruction(vcpu); + for (i = 0; i < nr_pages; ++i) { spin_lock(&vcpu->kvm->lock); page = gva_to_page(vcpu, address + i * PAGE_SIZE); -- ------------------------------------------------------------------------- SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace