Laurent Vivier wrote:
> Avi Kivity wrote:
>
>> 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.
>>
>
> I didn't do like that because I was afraid to miss some points to restore
> orig_eip.
>
This could be done using something like
emulate(ctxt)
{
decode_cache save = ctxt->decode_cache;
r = __emulate(ctxt);
if (r != success)
ctxt->decode_cache = save;
return r;
}
or in some similar way.
--
Any sufficiently difficult bug is indistinguishable from a feature.
-------------------------------------------------------------------------
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/
_______________________________________________
kvm-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/kvm-devel