From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Nadav Har'El" Subject: Re: [PATCH 8/24] Hold a vmcs02 for each vmcs12 Date: Mon, 2 Aug 2010 16:38:45 +0300 Message-ID: <20100802133845.GB3779@fermat.math.technion.ac.il> References: <1276431753-nyh@il.ibm.com> <201006131226.o5DCQebV012952@rice.haifa.ibm.com> <1A42CE6F5F474C41B63392A5F80372B21F67B76C@shsmsx501.ccr.corp.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: "avi@redhat.com" , "kvm@vger.kernel.org" To: "Dong, Eddie" Return-path: Received: from mailgw13.technion.ac.il ([132.68.225.13]:8091 "EHLO mailgw13.technion.ac.il" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752325Ab0HBNit (ORCPT ); Mon, 2 Aug 2010 09:38:49 -0400 Content-Disposition: inline In-Reply-To: <1A42CE6F5F474C41B63392A5F80372B21F67B76C@shsmsx501.ccr.corp.intel.com> Sender: kvm-owner@vger.kernel.org List-ID: On Tue, Jul 06, 2010, Dong, Eddie wrote about "RE: [PATCH 8/24] Hold a vmcs02 for each vmcs12": > > +/* Allocate an L0 VMCS (vmcs02) for the current L1 VMCS (vmcs12), if > > one + * does not already exist. The allocation is done in L0 memory, >... > > +static int nested_create_current_vmcs(struct kvm_vcpu *vcpu) > > +{ > > + struct vmcs_list *new_l2_guest; > > + struct vmcs *l2_vmcs; > > + > > + if (nested_get_current_vmcs(vcpu)) > > + return 0; /* nothing to do - we already have a VMCS */ > > + > > + if (to_vmx(vcpu)->nested.l2_vmcs_num >= NESTED_MAX_VMCS) > > + return -ENOMEM; > > + > > + new_l2_guest = (struct vmcs_list *) > > + kmalloc(sizeof(struct vmcs_list), GFP_KERNEL); > > + if (!new_l2_guest) > > + return -ENOMEM; > > + > > + l2_vmcs = alloc_vmcs(); > > I didn't see where it was used. Hints on the usage? Hi, I'm afraid I didn't understand the question. Where is what used? What nested_create_current_vmcs does (as the comment above it explains) is to allocate a vmcs02 for the current vmcs12, or return one that has been previously allocated (and saved in a list we hold of these mappings). The alloc_vmcs() call you pointed to happens when there isn't yet a vmcs02 for this vmcs12, and we need to allocate a new one. A few lines down this new mapping between a vmcs12 address to vmcs02 is put in new_l2_guest and that is inserted into the list of mappings. Does this answer your question? By the way, in my latest version of the code, l2_vmcs is now better named, "vmcs02" :-) > > + if (!l2_vmcs) { > > + kfree(new_l2_guest); > > + return -ENOMEM; > > + } > > + > > + new_l2_guest->vmcs_addr = to_vmx(vcpu)->nested.current_vmptr; > > + new_l2_guest->l2_vmcs = l2_vmcs; > > + list_add(&(new_l2_guest->list), > > &(to_vmx(vcpu)->nested.l2_vmcs_list)); > > + to_vmx(vcpu)->nested.l2_vmcs_num++; + return 0; > > +} -- Nadav Har'El | Monday, Aug 2 2010, 22 Av 5770 nyh@math.technion.ac.il |----------------------------------------- Phone +972-523-790466, ICQ 13349191 |A computer program does what you tell it http://nadav.harel.org.il |to do, not what you want it to do.