public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi@qumranet.com>
To: Guillaume Thouvenin <guillaume.thouvenin@ext.bull.net>
Cc: kvm-devel <kvm-devel@lists.sourceforge.net>,
	Alexander Graf <alex@csgraf.de>
Subject: Re: catch vmentry failure (was enable gfxboot on VMX)
Date: Sun, 02 Mar 2008 19:15:32 +0200	[thread overview]
Message-ID: <47CAE0B4.3000400@qumranet.com> (raw)
In-Reply-To: <20080229153446.1fdead94@frecb000711.frec.bull.fr>

Guillaume Thouvenin wrote:
> On Mon, 18 Feb 2008 10:39:31 +0100
> Alexander Graf <alex@csgraf.de> 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/

  reply	other threads:[~2008-03-02 17:15 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-15  7:13 [PATCH] enable gfxboot on VMX Alexander Graf
2008-02-15 13:47 ` Avi Kivity
2008-02-15 13:58   ` Alexander Graf
2008-02-16  9:06     ` Avi Kivity
2008-02-16 13:34       ` Alexander Graf
2008-02-17  8:15         ` Avi Kivity
2008-02-18  9:17         ` Guillaume Thouvenin
2008-02-18  9:34           ` Alexander Graf
2008-02-18  9:39             ` Alexander Graf
2008-02-29 14:34               ` catch vmentry failure (was enable gfxboot on VMX) Guillaume Thouvenin
2008-03-02 17:15                 ` Avi Kivity [this message]
2008-02-19  3:37             ` [PATCH] enable gfxboot on VMX Anthony Liguori
2008-02-19  8:26               ` Avi Kivity
2008-02-15 14:56 ` Anthony Liguori
2008-02-15 15:13   ` Alexander Graf
2008-02-15 15:46     ` Steffen Winterfeldt
2008-02-18 11:46 ` Andi Kleen
2008-02-18 12:04   ` Alexander Graf

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=47CAE0B4.3000400@qumranet.com \
    --to=avi@qumranet.com \
    --cc=alex@csgraf.de \
    --cc=guillaume.thouvenin@ext.bull.net \
    --cc=kvm-devel@lists.sourceforge.net \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox