From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo Tosatti Subject: Re: [PATCH] KVM: x86 emulator: access GPRs on demand Date: Tue, 7 Aug 2012 18:24:15 -0300 Message-ID: <20120807212415.GB6689@amt.cnet> References: <1342700078-23534-1-git-send-email-avi@redhat.com> <20120807212301.GA6689@amt.cnet> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Gleb Natapov , kvm@vger.kernel.org To: Avi Kivity Return-path: Received: from mx1.redhat.com ([209.132.183.28]:32633 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753093Ab2HGVYS (ORCPT ); Tue, 7 Aug 2012 17:24:18 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q77LOI35026791 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 7 Aug 2012 17:24:18 -0400 Content-Disposition: inline In-Reply-To: <20120807212301.GA6689@amt.cnet> Sender: kvm-owner@vger.kernel.org List-ID: On Tue, Aug 07, 2012 at 06:23:01PM -0300, Marcelo Tosatti wrote: > On Thu, Jul 19, 2012 at 03:14:38PM +0300, Avi Kivity wrote: > > Instead of populating the the entire register file, read in registers > > as they are accessed, and write back only the modified ones. This > > saves a VMREAD and VMWRITE on Intel (for rsp, since it is not usually > > used during emulation), and a two 128-byte copies for the registers. > > > > Signed-off-by: Avi Kivity > > --- > > arch/x86/include/asm/kvm_emulate.h | 17 ++- > > arch/x86/kvm/emulate.c | 268 +++++++++++++++++++++---------------- > > arch/x86/kvm/x86.c | 50 ++++--- > > 3 files changed, 192 insertions(+), 143 deletions(-) > > > > diff --git a/arch/x86/include/asm/kvm_emulate.h b/arch/x86/include/asm/kvm_emulate.h > > index c764f43..2f1da16 100644 > > --- a/arch/x86/include/asm/kvm_emulate.h > > +++ b/arch/x86/include/asm/kvm_emulate.h > > @@ -86,6 +86,19 @@ struct x86_instruction_info { > > > > struct x86_emulate_ops { > > /* > > + * read_gpr: read a general purpose register (rax - r15) > > + * > > + * @reg: gpr number. > > + */ > > + ulong (*read_gpr)(struct x86_emulate_ctxt *ctxt, unsigned reg); > > + /* > > + * write_gpr: write a general purpose register (rax - r15) > > + * > > + * @reg: gpr number. > > + * @val: value to write. > > + */ > > + void (*write_gpr)(struct x86_emulate_ctxt *ctxt, unsigned reg, ulong val); > > + /* > > * read_std: Read bytes of standard (non-emulated/special) memory. > > * Used for descriptor reading. > > * @addr: [IN ] Linear address from which to read. > > @@ -281,8 +294,10 @@ struct x86_emulate_ctxt { > > bool rip_relative; > > unsigned long _eip; > > struct operand memop; > > + u32 regs_valid; /* bitmaps of registers in _regs[] that can be read */ > > + u32 regs_dirty; /* bitmaps of registers in _regs[] that have been written */ > > emul_regs_dirty (to avoid with the other regs_dirty). avoid confusion.