From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo Tosatti Subject: KVM: avoid unnecessary memcpy in kvm_emulate_pio Date: Sat, 24 May 2008 21:41:33 -0300 Message-ID: <20080525004133.GA14165@dmt> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvm-devel To: Avi Kivity Return-path: Received: from mx1.redhat.com ([66.187.233.31]:42452 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754449AbYEYAlv (ORCPT ); Sat, 24 May 2008 20:41:51 -0400 Content-Disposition: inline Sender: kvm-owner@vger.kernel.org List-ID: When emulating in instructions there's no point in copying the destination register contents to vcpu->arch.pio_data since it will be overwritten by the ioport handler. Also remove the ->decache_regs() call, since as you mentioned there is no register change to writeback. Signed-off-by: Marcelo Tosatti diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index e537005..f43f770 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -2254,8 +2254,8 @@ int kvm_emulate_pio(struct kvm_vcpu *vcpu, struct kvm_run *run, int in, handler); kvm_x86_ops->cache_regs(vcpu); - memcpy(vcpu->arch.pio_data, &vcpu->arch.regs[VCPU_REGS_RAX], 4); - kvm_x86_ops->decache_regs(vcpu); + if (!in) + memcpy(vcpu->arch.pio_data, &vcpu->arch.regs[VCPU_REGS_RAX], 4); kvm_x86_ops->skip_emulated_instruction(vcpu);