All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marcelo Tosatti <mtosatti@redhat.com>
To: Mohammed Gamal <m.gamal005@gmail.com>
Cc: avi@redhat.com, kvm@vger.kernel.org
Subject: Re: [PATCHv3] VMX: Enhance invalid guest state emulation
Date: Tue, 1 Sep 2009 10:29:38 -0300	[thread overview]
Message-ID: <20090901132938.GA19864@amt.cnet> (raw)
In-Reply-To: <52d4a3890909010608h1f406b42j98d403493859d6b6@mail.gmail.com>

On Tue, Sep 01, 2009 at 03:08:55PM +0200, Mohammed Gamal wrote:
> On Tue, Sep 1, 2009 at 2:18 PM, Marcelo Tosatti<mtosatti@redhat.com> wrote:
> > On Tue, Sep 01, 2009 at 02:14:17PM +0200, Mohammed Gamal wrote:
> >> On Tue, Sep 1, 2009 at 1:48 PM, Marcelo Tosatti<mtosatti@redhat.com> wrote:
> >> > On Tue, Sep 01, 2009 at 12:48:18PM +0200, Mohammed Gamal wrote:
> >> >> - Change returned handle_invalid_guest_state() to return relevant exit codes
> >> >> - Move triggering the emulation from vmx_vcpu_run() to vmx_handle_exit()
> >> >> - Return to userspace instead of repeatedly trying to emulate instructions that have already failed
> >> >>
> >> >> Signed-off-by: Mohammed Gamal <m.gamal005@gmail.com>
> >> >
> >> > Mohammed,
> >> >
> >> > The handle_invalid_guest_state loop is potentially problematic. It would
> >> > be more appropriate to use the __vcpu_run loop.
> >> >
> >> > Can't you set vmx->emulation_required depending on the result
> >> > of one call to emulate_instruction and get rid of the while
> >> > (!guest_state_valid(vcpu)) loop?
> >> >
> >>
> >> Invalid state emulation is VMX-specfic, while the __vcpu_run loop is
> >> independent of the virtualization extension (defined in x86.c), no?
> >> AMD SVM can comforably run hosts in big-real mode and thus it doesn't
> >> have the notion of a guest going to an invalid state because of mode
> >> switching, so I don't think it'd be a good idea to move emulation into
> >> a generic layer. Please correct me if I am wrong
> >
> > Right. But all i am asking is to emulate one instruction at a
> > time in handle_invalid_guest_state, instead of looping until
> > guest_state_valid(vcpu).
> >
> > So you get rid of schedule(), the check for signal_pending, etc.
> 
> But we'll still need to enter the guest when it's in a valid state, so
> we need to move that loop somewhere, 

Sure, just set vmx->emulation_required = guest_state_valid(vcpu). When
the state is good, the entry handler will vmentry.

> and now that we still have a loop
> we'll also still need to do the pending signals and scheduling checks,
> no?

Point is you can use the __vcpu_run loop.

In the latest patch you do:

+       /* Don't enter VMX if guest state is invalid, let the exit handler
+          start emulation until we arrive back to a valid state */
+       if (vmx->emulation_required && emulate_invalid_guest_state)
               	return;

And then emulate in the exit handler.

> I'd appreciate any suggestions you have to alleviate this.

I fail to see why you need an internal loop if you can use the external
(__vcpu_run) one.


  reply	other threads:[~2009-09-01 13:29 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-01 10:48 [PATCHv3] VMX: Enhance invalid guest state emulation Mohammed Gamal
2009-09-01 11:48 ` Marcelo Tosatti
2009-09-01 12:14   ` Mohammed Gamal
2009-09-01 12:18     ` Marcelo Tosatti
2009-09-01 13:08       ` Mohammed Gamal
2009-09-01 13:29         ` Marcelo Tosatti [this message]
2009-09-01 13:32           ` Mohammed Gamal
2009-09-01 15:55             ` Marcelo Tosatti
2009-09-01 16:23             ` 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=20090901132938.GA19864@amt.cnet \
    --to=mtosatti@redhat.com \
    --cc=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=m.gamal005@gmail.com \
    /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.