All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Vivier <Laurent.Vivier-6ktuUTfB/bM@public.gmane.org>
To: "Kamble,
	Nitin A" <nitin.a.kamble-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Cc: kvm-devel
	<kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>,
	Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
Subject: Re: use of saved_eip
Date: Wed, 26 Sep 2007 23:51:59 +0200	[thread overview]
Message-ID: <46FAD47F.2040701@bull.net> (raw)
In-Reply-To: <5461330FA59EDB46BE9AB8AAF2C431AD054D2CAC-1a9uaKK1+wJcIJlls4ac1rfspsVTdybXVpNB7YpNyf8@public.gmane.org>

Kamble, Nitin A wrote:
> Hi Vivier, Avi,

Hi Nitin,
(BTW, my first name is Laurent)

>   In order to debug faulures in my tree, I was looking at the saved_eip 
> changes coming from your commit. I did not understand the use of 
> saved_eip properly. like why is it used in the emulation of the pop 
> instruction. Can you please help me understand it's usage?

in emulate_instruction(), we decode instructions and copy vcpu registers 
to ctxt (in x86_decode_insn()), then we really emulate the instruction 
(in x86_emulate_insn()).

In x86_emulate_insn(), if we have a REP prefix, we decrement ECX and set 
EIP to next instruction, then we try to emulate the instruction.
If the emulation fails (because this is a MMIO for instance) we have to 
restore the initial values of ECX and EIP because we will re-enter in 
x86_emulate_insn() once the IO has been managed by Qemu and thus ECX is 
decremented again and EIP set to next instruction again.

And you are right: _we_don't_have_to_do_that_for_the_pop_instruction_, 
it's a mistake because the REP prefix hasn't been processed at this 
level, it is managed (ECX and EIP are modified) later.

So, you can remove from pop_instruction:

1383                         if (c->rep_prefix) {
1384                                 c->regs[VCPU_REGS_RCX] = saved_rcx;
1385                                 c->eip = saved_eip;
1386                         }

Sorry for the inconvenience,

Laurent



-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

  parent reply	other threads:[~2007-09-26 21:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-26 19:52 use of saved_eip Kamble, Nitin A
     [not found] ` <5461330FA59EDB46BE9AB8AAF2C431AD054D2CAC-1a9uaKK1+wJcIJlls4ac1rfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-09-26 21:51   ` Laurent Vivier [this message]
     [not found]     ` <46FAD47F.2040701-6ktuUTfB/bM@public.gmane.org>
2007-09-27  1:47       ` Nitin A Kamble
     [not found]         ` <1190857675.13519.6.camel-mpPvwfgnXtFHIUuj5cj4Omt3HXsI98Cx0E9HWUfgJXw@public.gmane.org>
2007-09-27  7:27           ` Laurent Vivier
2007-09-27  8:45       ` [PATCH] On a pop instruction, don't restore ECX and EIP on error Laurent Vivier
     [not found]         ` <11908827342885-git-send-email-Laurent.Vivier-6ktuUTfB/bM@public.gmane.org>
2007-09-27  9:06           ` Avi Kivity

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=46FAD47F.2040701@bull.net \
    --to=laurent.vivier-6ktuutfb/bm@public.gmane.org \
    --cc=avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org \
    --cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    --cc=nitin.a.kamble-ral2JQCrhuEAvxtiuMwx3w@public.gmane.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.