Guillaume Thouvenin wrote:
> On Mon, 18 Feb 2008 10:39:31 +0100
> Alexander Graf <[EMAIL PROTECTED]> wrote:
>
>
>   
>>> So if you want to see a VMentry failure, just remove the SS patching
>>> and you'll see one. My guess would be that you see a lot of problems
>>> with otherwise working code too then, though, as SS can be anything in
>>> that state.
>>>       
>
> So I made some tests and you were right, removing the SS patching
> showed VM entry failure but it also generated lots of problems. Thus I
> tried to modify a little bit the code and with the following patch (see
> the end of the email) I can detect VM Entry failures without generating
> other problems. It works when you use a distribution that is
> "big-real-mode free". I pasted the patch just to show the idea. 
>
> It's interesting because we can continue to use the virtual mode for the
> majority of distribution and we can detect when a VM entry failure is
> detected it means that we need to switch from virtual mode to full real
> mode emulation. Such failure is caught in handle_vmentry_failure() when
> patch applied. If it's doable, the next step is the modification of the
> SS segment selector to succeed the vm-entry and the switch from virtual
> mode to a real mode emulation that could be done in
> handle_vmentry_failure(). Does it make sense?
>
>   

Yes.  An alternative (useful if a failed vmentry corrupts the guest 
state) is to check all register state when switching modes.

> -
> +     fix_rmode_seg(VCPU_SREG_CS, &vcpu->arch.rmode.cs);
>       fix_rmode_seg(VCPU_SREG_ES, &vcpu->arch.rmode.es);
>       fix_rmode_seg(VCPU_SREG_DS, &vcpu->arch.rmode.ds);
>       fix_rmode_seg(VCPU_SREG_GS, &vcpu->arch.rmode.gs);
>       fix_rmode_seg(VCPU_SREG_FS, &vcpu->arch.rmode.fs);
> +     fix_rmode_seg(VCPU_SREG_SS, &vcpu->arch.rmode.ss);
>   

Ideally you wouldn't call fix_rmode_seg() at all.  The guest will 
emulate until such time as the segments are valid for v8086, for example 
when the guest reloads them itself.

> +     switch (basic_exit_reason) {
> +             case EXIT_REASON_INVALID_GUEST_STATE:
> +                     printk("caused by invalid guest state (%ld).\n", 
> exit_qualification);
> +                     /* At this point we need to modify SS selector to pass 
> vmentry test.
> +                      * This modification prevent the usage of virtual mode 
> to emulate real 
> +                      * mode so we need to pass in big real mode emulation
> +                      * with somehting like:
> +                      * vcpu->arch.rmode.emulate = 1
>   

Note you might need to emulate in protected mode as well, for a small 
part of the switch, for similar reasons.

-- 
error compiling committee.c: too many arguments to function


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel

Reply via email to