From: Marcelo Tosatti <mtosatti@redhat.com>
To: Avi Kivity <avi@redhat.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH v3] KVM: x86 emulator: access GPRs on demand
Date: Sun, 26 Aug 2012 14:04:14 -0300 [thread overview]
Message-ID: <20120826170414.GA21928@amt.cnet> (raw)
In-Reply-To: <20120823081427.GA27248@amt.cnet>
On Thu, Aug 23, 2012 at 05:14:27AM -0300, Marcelo Tosatti wrote:
> On Sun, Aug 19, 2012 at 12:32:36PM +0300, Avi Kivity wrote:
> > On 08/17/2012 08:29 PM, Marcelo Tosatti wrote:
> > > On Thu, Aug 16, 2012 at 05:54:49PM +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.
> > >>
> > >
> > >> @@ -2715,14 +2764,17 @@ int emulator_task_switch(struct x86_emulate_ctxt *ctxt,
> > >> {
> > >> int rc;
> > >>
> > >> + invalidate_registers(ctxt);
> > >> ctxt->_eip = ctxt->eip;
> > >> ctxt->dst.type = OP_NONE;
> > >>
> > >> rc = emulator_do_task_switch(ctxt, tss_selector, idt_index, reason,
> > >> has_error_code, error_code);
> > >>
> > >> - if (rc == X86EMUL_CONTINUE)
> > >> + if (rc == X86EMUL_CONTINUE) {
> > >> ctxt->eip = ctxt->_eip;
> > >> + writeback_registers(ctxt);
> > >> + }
> > >>
> > >> return (rc == X86EMUL_UNHANDLEABLE) ? EMULATION_FAILED : EMULATION_OK;
> > >> }
> > >
> > >
> > > No clear point when emulator register cache is active, when it is
> > > not (AFAICS this patch does not invalidate registers on emulation start
> > > (the above being one of the exceptions) does not clear valid bit on
> > > writeback-to-vcpu-cache on emulation exit).
> >
> > It is cleared when emulation starts. For the non-insn-emulation entry
> > points, there is an explicit invalidate. For the emulation entry point,
> > there is a memset() that clears everything up to _regs, which includes
> > the cache. This discrepancy isn't nice, but it preexists. I don't know
> > whether we should decompose the memset() or not, it is rather efficient.
> >
> > >
> > > Concern is that emulator can start with cached registers marked as valid
> > > but in fact are invalid from previous emulation round.
> > >
> > > Maybe move invalidate() to init_emulate_ctxt?
> > >
> >
> > See the memset() in init_decode_cache().
>
> Right. Applied, thanks.
Actually, had to revert because autotest was failing.
Now it rejects:
4 out of 49 hunks FAILED -- saving rejects to file
arch/x86/kvm/emulate.c.rej
Please regenerate.
next prev parent reply other threads:[~2012-08-26 18:21 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-16 14:54 [PATCH v3] KVM: x86 emulator: access GPRs on demand Avi Kivity
2012-08-17 17:29 ` Marcelo Tosatti
2012-08-19 9:32 ` Avi Kivity
2012-08-23 8:14 ` Marcelo Tosatti
2012-08-26 17:04 ` Marcelo Tosatti [this message]
2012-08-27 20:22 ` Avi Kivity
2012-08-27 20:24 ` Avi Kivity
2012-08-27 20:53 ` Marcelo Tosatti
2012-08-27 20:54 ` Marcelo Tosatti
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120826170414.GA21928@amt.cnet \
--to=mtosatti@redhat.com \
--cc=avi@redhat.com \
--cc=kvm@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.