public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* KVM: avoid unnecessary memcpy in kvm_emulate_pio
@ 2008-05-25  0:41 Marcelo Tosatti
  2008-05-25 11:39 ` Avi Kivity
  0 siblings, 1 reply; 2+ messages in thread
From: Marcelo Tosatti @ 2008-05-25  0:41 UTC (permalink / raw)
  To: Avi Kivity; +Cc: kvm-devel


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 <mtosatti@redhat.com>

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);
 

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-05-25 11:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-25  0:41 KVM: avoid unnecessary memcpy in kvm_emulate_pio Marcelo Tosatti
2008-05-25 11:39 ` Avi Kivity

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox