From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo Tosatti Subject: Re: [PATCHv3] VMX: Enhance invalid guest state emulation Date: Tue, 1 Sep 2009 09:18:04 -0300 Message-ID: <20090901121804.GA19145@amt.cnet> References: <1251802098-23819-1-git-send-email-m.gamal005@gmail.com> <20090901114806.GA18778@amt.cnet> <52d4a3890909010514n20ceef87i4767e277c550a581@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: avi@redhat.com, kvm@vger.kernel.org To: Mohammed Gamal Return-path: Received: from mx1.redhat.com ([209.132.183.28]:22980 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753799AbZIAMSf (ORCPT ); Tue, 1 Sep 2009 08:18:35 -0400 Content-Disposition: inline In-Reply-To: <52d4a3890909010514n20ceef87i4767e277c550a581@mail.gmail.com> Sender: kvm-owner@vger.kernel.org List-ID: On Tue, Sep 01, 2009 at 02:14:17PM +0200, Mohammed Gamal wrote: > On Tue, Sep 1, 2009 at 1:48 PM, Marcelo Tosatti 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 > > > > 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.