From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH] Correct management of REP prefix Date: Sun, 30 Sep 2007 11:06:10 +0200 Message-ID: <46FF6702.2060203@qumranet.com> References: <1190928863669-git-send-email-Laurent.Vivier@bull.net> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org To: Laurent Vivier Return-path: In-Reply-To: <1190928863669-git-send-email-Laurent.Vivier-6ktuUTfB/bM@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: kvm-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org Errors-To: kvm-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org List-Id: kvm.vger.kernel.org Laurent Vivier wrote: > This patch corrects some errors appearing when we have an emulation failure > on an operation using REP prefix. > > When x86_emulate_insn() fails, saving EIP and ECX is not enough as emulation > should have modified other registers like RSI or RDI. Moreover, the emulation > can fail on the writeback, and in this case we are not able to restore > registers. > > This patch takes another approach: at the beginning of x86_emulate_insn() we > restore state we have at end of x86_decode_insn(). To do that, we store EIP in > a new field in decode_cache, decode_eip. This field store the EIP as it is at > the end of x86_decode_insn(); and at beginning of x86_emulate_insn(), we restore > all registers as they are in vcpu. We can do that, because the x86_decode_insn() > doesn't modify registers (except EIP). > How about doing it slightly differently: keep c->eip at its current meaning, and add c->eip_orig to revert to? That will make the patch smaller and reduce the changes of something being missed. -- error compiling committee.c: too many arguments to function ------------------------------------------------------------------------- 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/