From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gleb Natapov Subject: Re: [PATCH 2/2] Provide fast path for "rep ins" emulation if possible. Date: Tue, 5 Jun 2012 20:19:19 +0300 Message-ID: <20120605171919.GH20236@redhat.com> References: <1337782095-32287-1-git-send-email-gleb@redhat.com> <1337782095-32287-3-git-send-email-gleb@redhat.com> <4FCE2ECB.8080103@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvm@vger.kernel.org, mtosatti@redhat.com To: Avi Kivity Return-path: Received: from mx1.redhat.com ([209.132.183.28]:57385 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755023Ab2FERTU (ORCPT ); Tue, 5 Jun 2012 13:19:20 -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 q55HJKGn012753 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 5 Jun 2012 13:19:20 -0400 Content-Disposition: inline In-Reply-To: <4FCE2ECB.8080103@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Tue, Jun 05, 2012 at 07:07:39PM +0300, Avi Kivity wrote: > > + > > + count = (PAGE_SIZE - offset_in_page(linear_addr))/size; > > + > > + if (count == 0) /* 'in' crosses page boundry */ > > + return EMULATE_FAIL; > > + > > + count = min(count, rcx); > > + > > + r = __kvm_fast_string_pio_in(vcpu, size, port, linear_addr, count); > > + > > + if (r != EMULATE_DO_MMIO) > > + return r; > > + > > + vcpu->arch.fast_string_pio_ctxt.linear_addr = linear_addr; > > + vcpu->arch.complete_userspace_io = complete_fast_string_pio; > > + return EMULATE_DO_MMIO; > > +} > > +EXPORT_SYMBOL_GPL(kvm_fast_string_pio_in); > > Perhaps a better way to do it is to move the code into the emulator, > which already handles all the checks and masks, and just avoid > x86_decode_insn()/x86_emulate_insn(). > I do not see how it would be better. Emulator works on different data structures that should be prepared and the only functions that we can reuse (as far as I see) are register_address_increment() and ad_mask() anyway. -- Gleb.