From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Tian, Kevin" Subject: RE: [PATCH 18/31] nVMX: Implement VMLAUNCH and VMRESUME Date: Wed, 25 May 2011 16:00:54 +0800 Message-ID: <625BA99ED14B2D499DC4E29D8138F1505C9BFA39F8@shsmsx502.ccr.corp.intel.com> References: <1305575004-nyh@il.ibm.com> <201105161953.p4GJr8Jo001858@rice.haifa.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT Cc: "gleb@redhat.com" , "avi@redhat.com" To: Nadav Har'El , "kvm@vger.kernel.org" Return-path: Received: from mga02.intel.com ([134.134.136.20]:6984 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752705Ab1EYIBk convert rfc822-to-8bit (ORCPT ); Wed, 25 May 2011 04:01:40 -0400 In-Reply-To: <201105161953.p4GJr8Jo001858@rice.haifa.ibm.com> Content-Language: en-US Sender: kvm-owner@vger.kernel.org List-ID: > From: Nadav Har'El > Sent: Tuesday, May 17, 2011 3:53 AM > > Implement the VMLAUNCH and VMRESUME instructions, allowing a guest > hypervisor to run its own guests. > > This patch does not include some of the necessary validity checks on > vmcs12 fields before the entry. These will appear in a separate patch > below. > > Signed-off-by: Nadav Har'El > --- [...] > +static int nested_vmx_run(struct kvm_vcpu *vcpu, bool launch) > +{ > + struct vmcs12 *vmcs12; > + struct vcpu_vmx *vmx = to_vmx(vcpu); > + int cpu; > + struct saved_vmcs *saved_vmcs02; > + > + if (!nested_vmx_check_permission(vcpu)) > + return 1; > + skip_emulated_instruction(vcpu); > + > + vmcs12 = get_vmcs12(vcpu); > + > + enter_guest_mode(vcpu); > + > + vmx->nested.vmcs01_tsc_offset = vmcs_read64(TSC_OFFSET); > + > + /* > + * Switch from L1's VMCS (vmcs01), to L2's VMCS (vmcs02). Remember > + * vmcs01, on which CPU it was last loaded, and whether it was launched > + * (we need all these values next time we will use L1). Then recall > + * these values from the last time vmcs02 was used. > + */ > + saved_vmcs02 = nested_get_current_vmcs02(vmx); > + if (!saved_vmcs02) > + return -ENOMEM; > + we shouldn't return error after the guest mode is updated. Or else move enter_guest_mode to a later place... Thanks Kevin